X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_client_datashare.c;h=c339c2084bf4e4168b56ee55ba7a4ea6e82036a9;hp=5f7a90a26ab13406fd511b0256b85587fabec4d5;hb=8191c55421fb6ecc86185608a8b0510da1525e1e;hpb=ffc0b7e324486790e283b6b39353c5a9990b56f6 diff --git a/php_http_client_datashare.c b/php_http_client_datashare.c index 5f7a90a..c339c20 100644 --- a/php_http_client_datashare.c +++ b/php_http_client_datashare.c @@ -15,21 +15,21 @@ static int php_http_client_datashare_compare_handles(void *h1, void *h2); -PHP_HTTP_API php_http_client_datashare_t *php_http_client_datashare_init(php_http_client_datashare_t *h, php_http_client_datashare_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC) +PHP_HTTP_API php_http_client_datashare_t *php_http_client_datashare_init(php_http_client_datashare_t *h, php_http_client_datashare_ops_t *ops, php_resource_factory_t *rf, void *init_arg TSRMLS_DC) { php_http_client_datashare_t *free_h = NULL; if (!h) { free_h = h = emalloc(sizeof(*h)); } - memset(h, sizeof(*h), 0); + memset(h, 0, sizeof(*h)); zend_llist_init(&h->clients, sizeof(zval *), ZVAL_PTR_DTOR, 0); h->ops = ops; if (rf) { h->rf = rf; } else if (ops->rsrc) { - h->rf = php_http_resource_factory_init(NULL, h->ops->rsrc, h, NULL); + h->rf = php_resource_factory_init(NULL, h->ops->rsrc, h, NULL); } TSRMLS_SET_CTX(h->ts); @@ -59,7 +59,7 @@ PHP_HTTP_API void php_http_client_datashare_dtor(php_http_client_datashare_t *h) h->ops->dtor(h); } zend_llist_destroy(&h->clients); - php_http_resource_factory_free(&h->rf); + php_resource_factory_free(&h->rf); } PHP_HTTP_API void php_http_client_datashare_free(php_http_client_datashare_t **h) @@ -147,11 +147,7 @@ PHP_HTTP_BEGIN_ARGS(detach, 1) PHP_HTTP_ARG_OBJ(http\\Client, client, 0) PHP_HTTP_END_ARGS; -static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value -#if PHP_VERSION_ID >= 50400 -, const zend_literal *literal_key -#endif -TSRMLS_DC); +static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC); static zend_class_entry *php_http_client_datashare_class_entry; @@ -205,11 +201,7 @@ zend_object_value php_http_client_datashare_object_new_ex(zend_class_entry *ce, 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 ov.handle = zend_objects_store_put(o, NULL, php_http_client_datashare_object_free, NULL TSRMLS_CC); ov.handlers = &php_http_client_datashare_object_handlers; @@ -234,11 +226,31 @@ void php_http_client_datashare_object_free(void *object TSRMLS_DC) efree(o); } -static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value -#if PHP_VERSION_ID >= 50400 -, const zend_literal *literal_key +static zval *php_http_client_datashare_object_read_prop(zval *object, zval *member, int type PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC) +{ + zend_property_info *pi; + + if ((pi = zend_get_property_info(php_http_client_datashare_class_entry, member, 1 TSRMLS_CC))) { + if (type != BP_VAR_R) { + zval *zproxy; + php_property_proxy_t *proxy; + + proxy = php_property_proxy_init(object, pi->name, pi->name_length TSRMLS_CC); + + MAKE_STD_ZVAL(zproxy); +#ifdef Z_SET_REFCOUNT_P + Z_SET_REFCOUNT_P(zproxy, 0); +#else + zproxy->refcount = 0; #endif -TSRMLS_DC) + ZVAL_OBJVAL(zproxy, php_property_proxy_object_new_ex(php_property_proxy_get_class_entry(), proxy, NULL TSRMLS_CC), 0); + return zproxy; + } + } + return zend_get_std_object_handlers()->read_property(object, member, type PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC); +} + +static void php_http_client_datashare_object_write_prop(zval *object, zval *member, zval *value PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC) { zend_property_info *pi; @@ -262,33 +274,9 @@ TSRMLS_DC) } } - zend_get_std_object_handlers()->write_property(object, member, value -#if PHP_VERSION_ID >= 50400 - , literal_key -#endif - TSRMLS_CC); + zend_get_std_object_handlers()->write_property(object, member, value PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC); } -static zval **php_http_client_datashare_object_get_prop_ptr(zval *object, zval *member -#if PHP_VERSION_ID >= 50400 -, const zend_literal *literal_key -#endif -TSRMLS_DC) -{ - zend_property_info *pi; - - if ((pi = zend_get_property_info(php_http_client_datashare_class_entry, member, 1 TSRMLS_CC))) { - return &php_http_property_proxy_init(NULL, object, member, NULL TSRMLS_CC)->myself; - } - - return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member -#if PHP_VERSION_ID >= 50400 - , literal_key -#endif - TSRMLS_CC); -} - - PHP_METHOD(HttpClientDataShare, __destruct) { php_http_client_datashare_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); @@ -358,8 +346,9 @@ PHP_MINIT_FUNCTION(http_client_datashare) php_http_client_datashare_class_entry->create_object = php_http_client_datashare_object_new; memcpy(&php_http_client_datashare_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); php_http_client_datashare_object_handlers.clone_obj = NULL; + php_http_client_datashare_object_handlers.read_property = php_http_client_datashare_object_read_prop; php_http_client_datashare_object_handlers.write_property = php_http_client_datashare_object_write_prop; - php_http_client_datashare_object_handlers.get_property_ptr_ptr = php_http_client_datashare_object_get_prop_ptr; + php_http_client_datashare_object_handlers.get_property_ptr_ptr = NULL; zend_class_implements(php_http_client_datashare_class_entry TSRMLS_CC, 1, spl_ce_Countable);