X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_property_proxy.c;h=5be7ebbc0ab2de91254cfadf9b8912ec4ca493af;hp=43ec7095c56f1054959122dc923e1da9013a0449;hb=bfa5d473bdfb59fd39f04c2b8fb77ea4a7e9421b;hpb=c5da027b7eca8eae5304e536539c2be05e716009 diff --git a/php_http_property_proxy.c b/php_http_property_proxy.c index 43ec709..5be7ebb 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) @@ -128,6 +135,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 +152,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 */ @@ -253,7 +261,7 @@ PHP_METHOD(HttpPropertyProxy, __construct) PHP_MINIT_FUNCTION(http_property_proxy) { - PHP_HTTP_REGISTER_CLASS(http\\Object, PropertyProxy, http_property_proxy, NULL, ZEND_ACC_FINAL); + PHP_HTTP_REGISTER_CLASS(http\\Object, PropertyProxy, http_property_proxy, NULL, ZEND_ACC_FINAL_CLASS); php_http_property_proxy_class_entry->create_object = php_http_property_proxy_object_new; memcpy(&php_http_property_proxy_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); php_http_property_proxy_object_handlers.set = php_http_property_proxy_object_set;