swig wraps C++ objects as zend overloaded objects, the property getters and setters fall back to storing things in the Z_OBJPROP_P(property_reference->object) hash but I'm not doing it properly and I can't work out what I'm doing wrong.
The propget functions are generated like this: static pval _wrap_propget_ArrayStruct(zend_property_reference *property_referenc e) { pval result; pval **_result; zend_llist_element *element = property_reference->elements_list->head; zend_overloaded_element *property=(zend_overloaded_element *)element->data; /* Parent class hierachy dispatcher */ if (_propget_ArrayStruct(property_reference, &result)==SUCCESS) return result; /* Nope? return it ourselves from property hash*/ if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(proper ty->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) ret urn **_result; result.type = IS_NULL; return result; } No the trouble is I don't get reference counting/copying/whatever right, and, if for example I store a string in the hash, then later, if I read the string back a few times I find it's value changes, so I'm sure I'm passing around a free'd zval. The set function is generated like this: static int _wrap_propset_ArrayStruct(zend_property_reference *property_reference , pval *value) { zend_llist_element *element = property_reference->elements_list->head; zend_overloaded_element *property=(zend_overloaded_element *)element->data; /* Parent class hierachy dispatcher */ if (_propset_ArrayStruct(property_reference, value)==SUCCESS) return SUCCESS; /* nope? set it ourselves */ return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property-> element)),1+Z_STRLEN_P(&(property->element)),value); } I've tried zval_copy_ctor, SEPERATE_ZVAL and the like both before storing and after reading but I can't get any joy: This sort of php script: <?php // Sample test file require "arrays.php"; $ss=new simplestruct(); $ss->array_c="ab"; var_dump($ss); var_dump($ss->array_c); $x=$ss->array_c; print "1 $x\n"; $x=$ss->array_c; print "2 $x\n"; $x=$ss->array_c; print "3 $x\n"; var_dump($x); ?> outputs this: X-Powered-By: PHP/4.2.1 Content-type: text/html object(simplestruct)(2) { ["_cPtr"]=> resource(1) of type (_p_SimpleStruct) ["array_c"]=> &string(2) "ab" } string(2) "ab" 1 1 2 2 3 3 string(2) "T" instead of string(2) "ab" 1 ab 2 ab 3 ab string(2) "ab" -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php