Remove redundant callback, simplify API

This commit is contained in:
Zeev Suraski 2003-10-05 07:52:28 +00:00
parent 05152d3845
commit 3f5acc73a5
4 changed files with 29 additions and 27 deletions

View File

@ -150,10 +150,9 @@ static inline zval **_get_zval_ptr_ptr(znode *node, temp_variable *Ts TSRMLS_DC)
} }
} }
static inline zval **zend_fetch_property_address_inner(zval *object, znode *op2, temp_variable *Ts, int type TSRMLS_DC) static inline void zend_fetch_property_address_inner(zval *object, znode *op2, znode *result, temp_variable *Ts, int type TSRMLS_DC)
{ {
zval *prop_ptr = get_zval_ptr(op2, Ts, &EG(free_op2), BP_VAR_R); zval *prop_ptr = get_zval_ptr(op2, Ts, &EG(free_op2), BP_VAR_R);
zval **retval = NULL;
zval tmp; zval tmp;
@ -172,20 +171,20 @@ static inline zval **zend_fetch_property_address_inner(zval *object, znode *op2,
break; break;
} }
if (Z_OBJ_HT_P(object)->get_property_ptr != NULL) { if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) {
retval = Z_OBJ_HT_P(object)->get_property_ptr(object, prop_ptr TSRMLS_CC); T(result->u.var).var.ptr_ptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, prop_ptr TSRMLS_CC);
} } else if (Z_OBJ_HT_P(object)->read_property) {
T(result->u.var).var.ptr = Z_OBJ_HT_P(object)->read_property(object, prop_ptr, 0 TSRMLS_CC);
if (retval == NULL) { T(result->u.var).var.ptr_ptr = &T(result->u.var).var.ptr;
} else {
zend_error(E_WARNING, "This object doesn't support property references"); zend_error(E_WARNING, "This object doesn't support property references");
retval = &EG(error_zval_ptr); T(result->u.var).var.ptr_ptr = &EG(error_zval_ptr);
} }
if (prop_ptr == &tmp) { if (prop_ptr == &tmp) {
zval_dtor(prop_ptr); zval_dtor(prop_ptr);
} }
FREE_OP(Ts, op2, EG(free_op2)); FREE_OP(Ts, op2, EG(free_op2));
return retval;
} }
@ -1014,7 +1013,7 @@ static void zend_fetch_property_address(znode *result, znode *op1, znode *op2, t
SEPARATE_ZVAL(container_ptr); SEPARATE_ZVAL(container_ptr);
container = *container_ptr; container = *container_ptr;
} }
*retval = zend_fetch_property_address_inner(container, op2, Ts, type TSRMLS_CC); zend_fetch_property_address_inner(container, op2, result, Ts, type TSRMLS_CC);
SELECTIVE_PZVAL_LOCK(**retval, result); SELECTIVE_PZVAL_LOCK(**retval, result);
} }
@ -1097,8 +1096,8 @@ static void zend_pre_incdec_property(znode *result, znode *op1, znode *op2, temp
/* here we are sure we are dealing with an object */ /* here we are sure we are dealing with an object */
if (Z_OBJ_HT_P(object)->get_property_zval_ptr) { if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) {
zval **zptr = Z_OBJ_HT_P(object)->get_property_zval_ptr(object, property TSRMLS_CC); zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property TSRMLS_CC);
if (zptr != NULL) { /* NULL means no success in getting PTR */ if (zptr != NULL) { /* NULL means no success in getting PTR */
SEPARATE_ZVAL_IF_NOT_REF(zptr); SEPARATE_ZVAL_IF_NOT_REF(zptr);
@ -1142,8 +1141,8 @@ static void zend_post_incdec_property(znode *result, znode *op1, znode *op2, tem
/* here we are sure we are dealing with an object */ /* here we are sure we are dealing with an object */
if (Z_OBJ_HT_P(object)->get_property_zval_ptr) { if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) {
zval **zptr = Z_OBJ_HT_P(object)->get_property_zval_ptr(object, property TSRMLS_CC); zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property TSRMLS_CC);
if (zptr != NULL) { /* NULL means no success in getting PTR */ if (zptr != NULL) { /* NULL means no success in getting PTR */
have_get_ptr = 1; have_get_ptr = 1;
SEPARATE_ZVAL_IF_NOT_REF(zptr); SEPARATE_ZVAL_IF_NOT_REF(zptr);
@ -1534,8 +1533,8 @@ static inline int zend_binary_assign_op_obj_helper(int (*binary_op)(zval *result
/* here property is a string */ /* here property is a string */
if (EX(opline)->extended_value == ZEND_ASSIGN_OBJ if (EX(opline)->extended_value == ZEND_ASSIGN_OBJ
&& Z_OBJ_HT_P(object)->get_property_zval_ptr) { && Z_OBJ_HT_P(object)->get_property_ptr_ptr) {
zval **zptr = Z_OBJ_HT_P(object)->get_property_zval_ptr(object, property TSRMLS_CC); zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property TSRMLS_CC);
if (zptr != NULL) { /* NULL means no success in getting PTR */ if (zptr != NULL) { /* NULL means no success in getting PTR */
SEPARATE_ZVAL_IF_NOT_REF(zptr); SEPARATE_ZVAL_IF_NOT_REF(zptr);

View File

@ -386,7 +386,7 @@ static void zend_std_write_dimension(zval *object, zval *offset, zval *value TSR
} }
static zval **zend_std_get_property_ptr(zval *object, zval *member TSRMLS_DC) static zval **zend_std_get_property_ptr_ptr(zval *object, zval *member TSRMLS_DC)
{ {
zend_object *zobj; zend_object *zobj;
zval tmp_member; zval tmp_member;
@ -429,6 +429,15 @@ static zval **zend_std_get_property_ptr(zval *object, zval *member TSRMLS_DC)
return retval; return retval;
} }
static zval *zend_std_get_property_ptr(zval *object, zval *member TSRMLS_DC)
{
zval **rv = zend_std_get_property_ptr_ptr(object, member TSRMLS_CC);
return *rv;
}
static void zend_std_unset_property(zval *object, zval *member TSRMLS_DC) static void zend_std_unset_property(zval *object, zval *member TSRMLS_DC)
{ {
zend_object *zobj; zend_object *zobj;
@ -892,8 +901,7 @@ zend_object_handlers std_object_handlers = {
zend_std_write_property, /* write_property */ zend_std_write_property, /* write_property */
zend_std_read_dimension, /* read_dimension */ zend_std_read_dimension, /* read_dimension */
zend_std_write_dimension, /* write_dimension */ zend_std_write_dimension, /* write_dimension */
zend_std_get_property_ptr, /* get_property_ptr */ zend_std_get_property_ptr_ptr, /* get_property_ptr_ptr */
zend_std_get_property_ptr, /* get_property_zval_ptr */
NULL, /* get */ NULL, /* get */
NULL, /* set */ NULL, /* set */
zend_std_has_property, /* has_property */ zend_std_has_property, /* has_property */

View File

@ -36,11 +36,8 @@ typedef void (*zend_object_write_property_t)(zval *object, zval *member, zval *v
/* Used to set dimension of the object */ /* Used to set dimension of the object */
typedef void (*zend_object_write_dimension_t)(zval *object, zval *offset, zval *value TSRMLS_DC); typedef void (*zend_object_write_dimension_t)(zval *object, zval *offset, zval *value TSRMLS_DC);
/* Used to create pointer to the property of the object, for future r/w access via get/set */
typedef zval **(*zend_object_get_property_ptr_t)(zval *object, zval *member TSRMLS_DC);
/* Used to create pointer to the property of the object, for future direct r/w access */ /* Used to create pointer to the property of the object, for future direct r/w access */
typedef zval **(*zend_object_get_property_zval_ptr_t)(zval *object, zval *member TSRMLS_DC); typedef zval **(*zend_object_get_property_ptr_ptr_t)(zval *object, zval *member TSRMLS_DC);
/* Used to set object value (most probably used in combination with /* Used to set object value (most probably used in combination with
* typedef the result of the get_property_ptr) * typedef the result of the get_property_ptr)
@ -96,8 +93,7 @@ typedef struct _zend_object_handlers {
zend_object_write_property_t write_property; zend_object_write_property_t write_property;
zend_object_read_dimension_t read_dimension; zend_object_read_dimension_t read_dimension;
zend_object_write_dimension_t write_dimension; zend_object_write_dimension_t write_dimension;
zend_object_get_property_ptr_t get_property_ptr; zend_object_get_property_ptr_ptr_t get_property_ptr_ptr;
zend_object_get_property_zval_ptr_t get_property_zval_ptr;
zend_object_get_t get; zend_object_get_t get;
zend_object_set_t set; zend_object_set_t set;
zend_object_has_property_t has_property; zend_object_has_property_t has_property;

View File

@ -275,8 +275,7 @@ static zend_object_handlers zend_object_proxy_handlers = {
NULL, /* write_property */ NULL, /* write_property */
NULL, /* read dimension */ NULL, /* read dimension */
NULL, /* write_dimension */ NULL, /* write_dimension */
NULL, /* get_property_ptr */ NULL, /* get_property_ptr_ptr */
NULL, /* get_property_zval_ptr */
zend_object_proxy_get, /* get */ zend_object_proxy_get, /* get */
zend_object_proxy_set, /* set */ zend_object_proxy_set, /* set */
NULL, /* has_property */ NULL, /* has_property */