From: Michael Wallner Date: Wed, 30 Sep 2015 10:40:19 +0000 (+0200) Subject: Merge branch 'v1.0.x' X-Git-Tag: release-2.0.0RC1~5 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=82a22c5890659bb20931c76b94198a949447f1ea;p=m6w6%2Fext-propro Merge branch 'v1.0.x' --- 82a22c5890659bb20931c76b94198a949447f1ea diff --cc src/php_propro_api.h index d82055f,e22c239..2c03c0f --- a/src/php_propro_api.h +++ b/src/php_propro_api.h @@@ -35,39 -37,53 +35,39 @@@ typedef struct php_property_proxy php_p * member accessible by reference from PHP userland. * * Example: - * ~~~~~~~~~~{.c} + * \code{.c} - * static zval *my_read_prop(zval *object, zval *member, int type, zend_literal *key TSRMLS_DC) + * static zval *my_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *tmp) * { - * my_object_t *obj = zend_object_store_get_object(object TSRMLS_CC); - * my_prophandler_t *handler; - * zval *return_value, *copy = my_cast(IS_STRING, member); + * zval *return_value; + * zend_string *member_name = zval_get_string(member); + * my_prophandler_t *handler = my_get_prophandler(member_name); * - * if (SUCCESS == my_get_prophandler(Z_STRVAL_P(copy), Z_STRLEN_P(copy), &handler)) { - * ALLOC_ZVAL(return_value); - * Z_SET_REFCOUNT_P(return_value, 0); - * Z_UNSET_ISREF_P(return_value); + * if (!handler || type == BP_VAR_R || type == BP_VAR_IS) { + * return_value = zend_get_std_object_handlers()->read_property(object, member, type, cache_slot, tmp); * - * if (type == BP_VAR_R) { - * handler->read(obj, return_value TSRMLS_CC); - * } else { - * // - * // This is the interesting part - * // - * php_property_proxy_t *proxy; - * zend_object_value proxy_ov; - * zend_class_entry *proxy_ce; + * if (handler) { + * handler->read(object, tmp); * - * proxy = php_property_proxy_init(object, Z_STRVAL_P(copy), Z_STRLEN_P(copy) TSRMLS_CC); - * proxy_ce = php_property_proxy_get_class_entry(); - * proxy_ov = php_property_proxy_object_new_ex(proxy_ce, proxy, NULL TSRMLS_CC); - * RETVAL_OBJVAL(proxy_ov, 0); - * } - * } else { - * zend_object_handlers *oh = zend_get_std_object_handlers(); - * return_value = oh->read_property(object, member, type, key TSRMLS_CC); - * } + * zval_ptr_dtor(return_value); + * ZVAL_COPY_VALUE(return_value, tmp); + * } + * } else { + * return_value = php_property_proxy_zval(object, member_name); + * } * - * zval_ptr_dtor(©); + * zend_string_release(member_name); * - * return return_value; + * return return_value; * } - * ~~~~~~~~~~ + * \endcode */ struct php_property_proxy_object { - /** The std zend_object */ - zend_object zo; - /** The object value for easy zval creation */ - zend_object_value zv; /** The actual property proxy */ php_property_proxy_t *proxy; - /** A reference to any parent property proxy object */ - struct php_property_proxy_object *parent; + /** Any parent property proxy object */ + zval parent; + /** The std zend_object */ + zend_object zo; }; typedef struct php_property_proxy_object php_property_proxy_object_t;