From: Zeev Suraski Date: Mon, 7 Jul 2003 10:53:27 +0000 (+0000) Subject: Add get_dim callback X-Git-Tag: BEFORE_ARG_INFO~349 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3cfa6a68f43a3d35dab133f2a3acbe45cc886fd6;p=php Add get_dim callback --- diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 4053c5fca0..44161b18b8 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -920,6 +920,17 @@ static void zend_fetch_dimension_address(znode *result, znode *op1, znode *op2, return; } break; + case IS_OBJECT: + if (type == BP_VAR_R) { + zval *dim = get_zval_ptr(op2, Ts, &EG(free_op2), BP_VAR_R); + zval *overloaded_result = Z_OBJ_HT_P(container)->read_dimension(container, dim TSRMLS_CC); + + *retval = &overloaded_result; + AI_USE_PTR(T(result->u.var).var); + FREE_OP(Ts, op2, EG(free_op2)); + SELECTIVE_PZVAL_LOCK(**retval, result); + } + break; default: { zval *offset; diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 2bee3d75a7..78aa8af692 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -335,11 +335,28 @@ static void zend_std_write_property(zval *object, zval *member, zval *value TSRM } } +zval *zend_std_read_dimension(zval *object, zval *offset TSRMLS_DC) +{ +#if 1 + zend_error(E_ERROR, "Cannot use object as array"); +#else + zend_printf("Fetching from object: "); + zend_print_zval(object, 0); + + zend_printf("\n the offset: "); + zend_print_zval(offset, 0); + + zend_printf("\n"); +#endif + return EG(uninitialized_zval_ptr); +} + static void zend_std_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC) { +#if 1 zend_error(E_ERROR, "Cannot use object as array"); -#if 0 +#else zend_printf("Assigning to object: "); zend_print_zval(object, 0); @@ -348,9 +365,9 @@ static void zend_std_write_dimension(zval *object, zval *offset, zval *value TSR zend_printf("\n the value: "); zend_print_zval(value, 0); -#endif zend_printf("\n"); +#endif } @@ -835,6 +852,7 @@ zend_object_handlers std_object_handlers = { zend_std_read_property, /* read_property */ zend_std_write_property, /* write_property */ + zend_std_read_dimension, /* read_dimension */ zend_std_write_dimension, /* write_dimension */ zend_std_get_property_ptr, /* get_property_ptr */ zend_std_get_property_ptr, /* get_property_zval_ptr */ diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h index b8f877d3a7..760b37a745 100644 --- a/Zend/zend_object_handlers.h +++ b/Zend/zend_object_handlers.h @@ -27,6 +27,9 @@ union _zend_function; /* Used to fetch property from the object, read-only */ typedef zval *(*zend_object_read_property_t)(zval *object, zval *member TSRMLS_DC); +/* Used to fetch dimension from the object, read-only */ +typedef zval *(*zend_object_read_dimension_t)(zval *object, zval *offset TSRMLS_DC); + /* Used to set property of the object */ typedef void (*zend_object_write_property_t)(zval *object, zval *member, zval *value TSRMLS_DC); @@ -88,6 +91,7 @@ typedef struct _zend_object_handlers { /* individual object functions */ zend_object_read_property_t read_property; zend_object_write_property_t write_property; + zend_object_read_dimension_t read_dimension; zend_object_write_dimension_t write_dimension; zend_object_get_property_ptr_t get_property_ptr; zend_object_get_property_zval_ptr_t get_property_zval_ptr; diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c index 8867080647..e162193229 100644 --- a/Zend/zend_objects_API.c +++ b/Zend/zend_objects_API.c @@ -273,6 +273,7 @@ static zend_object_handlers zend_object_proxy_handlers = { NULL, /* read_property */ NULL, /* write_property */ + NULL, /* read dimension */ NULL, /* write_dimension */ NULL, /* get_property_ptr */ NULL, /* get_property_zval_ptr */