X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_property_proxy.c;h=781c0c0ccc5c60e67ed8d579bc93d7406b46efbd;hp=43ec7095c56f1054959122dc923e1da9013a0449;hb=305ac2f007710b684d96b05f33964b4f6a4e3e4d;hpb=c5da027b7eca8eae5304e536539c2be05e716009 diff --git a/php_http_property_proxy.c b/php_http_property_proxy.c index 43ec709..781c0c0 100644 --- a/php_http_property_proxy.c +++ b/php_http_property_proxy.c @@ -16,7 +16,7 @@ # define PHP_HTTP_PPDBG 0 #endif -php_http_property_proxy_t *php_http_property_proxy_init(php_http_property_proxy_t *proxy, zval *object, zval *member, zval *parent TSRMLS_DC) +PHP_HTTP_API php_http_property_proxy_t *php_http_property_proxy_init(php_http_property_proxy_t *proxy, zval *object, zval *member, zval *parent TSRMLS_DC) { if (!proxy) { proxy = emalloc(sizeof(*proxy)); @@ -24,7 +24,7 @@ php_http_property_proxy_t *php_http_property_proxy_init(php_http_property_proxy_ memset(proxy, 0, sizeof(*proxy)); MAKE_STD_ZVAL(proxy->myself); - ZVAL_OBJVAL(proxy->myself, php_http_property_proxy_object_new_ex(php_http_property_proxy_class_entry, proxy, NULL TSRMLS_CC), 0); + ZVAL_OBJVAL(proxy->myself, php_http_property_proxy_object_new_ex(php_http_property_proxy_get_class_entry(), proxy, NULL TSRMLS_CC), 0); Z_ADDREF_P(object); proxy->object = object; proxy->member = php_http_ztyp(IS_STRING, member); @@ -39,7 +39,7 @@ php_http_property_proxy_t *php_http_property_proxy_init(php_http_property_proxy_ return proxy; } -void php_http_property_proxy_dtor(php_http_property_proxy_t *proxy) +PHP_HTTP_API void php_http_property_proxy_dtor(php_http_property_proxy_t *proxy) { zval_ptr_dtor(&proxy->object); zval_ptr_dtor(&proxy->member); @@ -49,7 +49,7 @@ void php_http_property_proxy_dtor(php_http_property_proxy_t *proxy) } } -void php_http_property_proxy_free(php_http_property_proxy_t **proxy) +PHP_HTTP_API void php_http_property_proxy_free(php_http_property_proxy_t **proxy) { if (*proxy) { php_http_property_proxy_dtor(*proxy); @@ -65,11 +65,18 @@ void php_http_property_proxy_free(php_http_property_proxy_t **proxy) PHP_HTTP_EMPTY_ARGS(__construct); -zend_class_entry *php_http_property_proxy_class_entry; -zend_function_entry php_http_property_proxy_method_entry[] = { +static zend_class_entry *php_http_property_proxy_class_entry; + +zend_class_entry *php_http_property_proxy_get_class_entry(void) +{ + return php_http_property_proxy_class_entry; +} + +static zend_function_entry php_http_property_proxy_method_entry[] = { PHP_HTTP_PP_ME(__construct, ZEND_ACC_FINAL|ZEND_ACC_PRIVATE) EMPTY_FUNCTION_ENTRY }; + static zend_object_handlers php_http_property_proxy_object_handlers; zend_object_value php_http_property_proxy_object_new(zend_class_entry *ce TSRMLS_DC) @@ -84,7 +91,11 @@ zend_object_value php_http_property_proxy_object_new_ex(zend_class_entry *ce, ph o = ecalloc(1, sizeof(*o)); zend_object_std_init((zend_object *) o, ce TSRMLS_CC); +#if PHP_VERSION_ID < 50339 + zend_hash_copy(((zend_object *) o)->properties, &(ce->default_properties), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval*)); +#else object_properties_init((zend_object *) o, ce); +#endif if (ptr) { *ptr = o; @@ -128,6 +139,7 @@ static zval *php_http_property_proxy_object_get(zval *object TSRMLS_DC) MAKE_STD_ZVAL(unset); ZVAL_NULL(unset); zend_symtable_update(Z_ARRVAL_P(obj->proxy->object), Z_STRVAL_P(obj->proxy->member), Z_STRLEN_P(obj->proxy->member)+1, (void *) &unset, sizeof(zval *), (void *) &data); + Z_ADDREF_PP(data); } return *data; @@ -144,10 +156,10 @@ static void php_http_property_proxy_object_set(zval **object, zval *value TSRMLS #if PHP_HTTP_PPDBG fprintf(stderr, "proxy_set: %s\n", Z_STRVAL_P(obj->proxy->member)); #endif + Z_ADDREF_P(value); if (Z_TYPE_P(target) == IS_OBJECT) { zend_update_property(Z_OBJCE_P(target), target, Z_STRVAL_P(obj->proxy->member), Z_STRLEN_P(obj->proxy->member), value TSRMLS_CC); } else { - Z_ADDREF_P(value); zend_symtable_update(Z_ARRVAL_P(target), Z_STRVAL_P(obj->proxy->member), Z_STRLEN_P(obj->proxy->member)+1, (void *) &value, sizeof(zval *), NULL); } /* propagate */