a quick question about the new serialization callbacks. is it necessary only
to serialize the state specific to the given object, or

do we also have to explicitly serialize the properties hash ?

Assuming my classes are set up as below, will the serialization mechanism
take care of subclasses for me
(calling __sleep etc). if not what more do i need to accomodate userland
subclasses ?


typedef struct php_locale_object {
  zend_object std;
  void *ptr;
} php_locale_object;


/* {{{ Locale serialization support **/

static int locale_serialize(zval *object, unsigned char **buffer, zend_uint
*buf_len, zend_serialize_data *data TSRMLS_DC)
{
 Locale *loc = I18N_FETCH_OBJ(object, Locale *);
 char *name, *result;
 int len;

 name = (char *)loc->getName();
 len = strlen(name);
 result = (len > 0) ? estrndup(name, len) : NULL;
 *buffer = (unsigned char*)result;
 *buf_len = (zend_uint)len;

 return SUCCESS;
}



static int locale_unserialize(zval **object, zend_class_entry *ce, const
unsigned char *buf,
   zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC)
{
 Locale *loc;

 if (buf_len) {
  Locale temp = Locale::createFromName((char *)buf);

  loc = new Locale(temp);
 } else {
  loc = new Locale();
 }

 *object = php_locale_new(loc TSRMLS_CC);

 return SUCCESS;
}

/* }}} */


l0t3k

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to