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
Hello l0t3k,
Sunday, March 20, 2005, 5:29:57 PM, you wrote:
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 ?
You have to do all your own (.) answers all further question
(snip)
marcus
Marcus,
i just read through var.c (specifically php_var_serialize_intern) and it
seems as if the properties hash is handled correctly if the user specifies
__sleep and __wakeup.
IOW, the custom callback is called, then _sleep is called to determine how
to further handle properties.
l0t3k
"Marcus Boerger" mail@marcus-boerger.de wrote in message
news:1245669636.20050320203441@marcus-boerger.de...
You have to do all your own (.) answers all further question
(snip)
marcus
Hello l0t3k,
Monday, March 21, 2005, 12:14:03 PM, you wrote:
Marcus,
i just read through var.c (specifically php_var_serialize_intern) and it
seems as if the properties hash is handled correctly if the user specifies
__sleep and __wakeup.
IOW, the custom callback is called, then _sleep is called to determine how
to further handle properties.
Thanks for checking that, i didn't new and imho it is absolutley wrong.
Instead the user should call that funcs his own in an overloaded class
of the c code should enforce calling it otherwise. I think so becuase
the whole idea of being able to overload serializing at c level is that
there might be classes that do not have standard properties implemented
and hence a call to __sleep/__wakeup does not make sense.
regards
marcus
"Marcus Boerger" mail@marcus-boerger.de wrote in message
news:1245669636.20050320203441@marcus-boerger.de...
You have to do all your own (.) answers all further question
(snip)
marcus
--
Best regards,
Marcus mailto:mail@marcus-boerger.de