]> granicus.if.org Git - php/commitdiff
Add get_dim callback
authorZeev Suraski <zeev@php.net>
Mon, 7 Jul 2003 10:53:27 +0000 (10:53 +0000)
committerZeev Suraski <zeev@php.net>
Mon, 7 Jul 2003 10:53:27 +0000 (10:53 +0000)
Zend/zend_execute.c
Zend/zend_object_handlers.c
Zend/zend_object_handlers.h
Zend/zend_objects_API.c

index 4053c5fca0f0dc055503e2123459d3f289fc82e6..44161b18b8f6a43c6e07e9b1e4ebb54c3aa3b94c 100644 (file)
@@ -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;
 
index 2bee3d75a7b8e4330304d9c128362bccfc07979c..78aa8af692ca87e369ba0daa674653b7cee39904 100644 (file)
@@ -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 */
index b8f877d3a76f66dc13c4c711dcf46bd2ea095bf9..760b37a74562aa5c179e34560fee0ea5f83509f9 100644 (file)
@@ -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;
index 8867080647e0472a3eb70fdcc3dd3f4d427fc700..e162193229929872a763277859037c20e2e42671 100644 (file)
@@ -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 */