X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-propro;a=blobdiff_plain;f=php_propro.c;h=c92d6d4a3f7754da92505947919ca129ee9d3073;hp=d0a69c6e422a0f84e43f01270ef55aaeeac91626;hb=18896658482f619ab050506ffea3d5379dba40c1;hpb=ca4c8e0bc0fb8f799815325cb4724275bddc9b28 diff --git a/php_propro.c b/php_propro.c index d0a69c6..c92d6d4 100644 --- a/php_propro.c +++ b/php_propro.c @@ -18,7 +18,7 @@ #include #include -#include "php_propro.h" +#include "php_propro_api.h" #define DEBUG_PROPRO 0 @@ -43,26 +43,13 @@ php_property_proxy_t *php_property_proxy_init(zval *container, zend_string *memb void php_property_proxy_free(php_property_proxy_t **proxy) { if (*proxy) { - zval_ptr_dtor( &(*proxy)->container); + zval_ptr_dtor(&(*proxy)->container); zend_string_release((*proxy)->member); efree(*proxy); *proxy = NULL; } } -zval *php_property_proxy_zval(zval *container, zend_string *member) -{ - php_property_proxy_t *proxy; - php_property_proxy_object_t *proxy_obj; - - proxy = php_property_proxy_init(container, member); - proxy_obj = php_property_proxy_object_new_ex(NULL, proxy); - - ZVAL_OBJ(&proxy_obj->myself, &proxy_obj->zo); - Z_ADDREF(proxy_obj->myself); - return &proxy_obj->myself; -} - static zend_class_entry *php_property_proxy_class_entry; static zend_object_handlers php_property_proxy_object_handlers; @@ -247,7 +234,7 @@ static zval *get_parent_proxied_value(zval *object, zval *return_value) static zval *get_proxied_value(zval *object, zval *return_value) { - zval *hash_value, *ref; + zval *hash_value, *ref, prop_tmp; php_property_proxy_object_t *obj; obj = get_propro(object); @@ -271,7 +258,7 @@ static zval *get_proxied_value(zval *object, zval *return_value) switch (Z_TYPE_P(ref)) { case IS_OBJECT: RETVAL_ZVAL(zend_read_property(Z_OBJCE_P(ref), ref, - obj->proxy->member->val, obj->proxy->member->len, 0), + obj->proxy->member->val, obj->proxy->member->len, 0, &prop_tmp), 0, 0); break; @@ -355,7 +342,7 @@ static void set_proxied_value(zval *object, zval *value) static zval *read_dimension(zval *object, zval *offset, int type, zval *return_value) { zval proxied_value; - zval *o = offset; + zend_string *member = offset ? zval_get_string(offset) : NULL; debug_propro(1, type == BP_VAR_R ? "dim_read" : "dim_read_ref", get_propro(object), offset, NULL); @@ -363,21 +350,16 @@ static zval *read_dimension(zval *object, zval *offset, int type, zval *return_v ZVAL_UNDEF(&proxied_value); get_proxied_value(object, &proxied_value); - if (o) { - convert_to_string_ex(o); - } - - if (BP_VAR_R == type && o && !Z_ISUNDEF(proxied_value)) { + if (BP_VAR_R == type && member && !Z_ISUNDEF(proxied_value)) { if (Z_TYPE(proxied_value) == IS_ARRAY) { zval *hash_value = zend_symtable_find(Z_ARRVAL(proxied_value), - Z_STR_P(o)); + member); if (hash_value) { RETVAL_ZVAL(hash_value, 1, 0); } } } else { - zend_string *member; php_property_proxy_t *proxy; php_property_proxy_object_t *proxy_obj; @@ -389,9 +371,7 @@ static zval *read_dimension(zval *object, zval *offset, int type, zval *return_v set_proxied_value(object, &proxied_value); } - if (o) { - member = Z_STR_P(o); - } else { + if (!member) { member = zend_long_to_str(zend_hash_next_free_element( Z_ARRVAL(proxied_value))); } @@ -399,17 +379,13 @@ static zval *read_dimension(zval *object, zval *offset, int type, zval *return_v proxy = php_property_proxy_init(&proxied_value, member); zval_ptr_dtor(&proxied_value); - if (!o) { - zend_string_release(member); - } - proxy_obj = php_property_proxy_object_new_ex(NULL, proxy); ZVAL_COPY(&proxy_obj->parent, object); RETVAL_OBJ(&proxy_obj->zo); } - if (o && o != offset) { - zval_ptr_dtor(o); + if (member) { + zend_string_release(member); } debug_propro(-1, type == BP_VAR_R ? "dim_read" : "dim_read_ref",