Browse Source

add zend_u_read_property() and zend_u_update_property()

experimental/first_unicode_implementation
Antony Dovgal 18 years ago
parent
commit
182de3e907
  1. 57
      Zend/zend_API.c
  2. 2
      Zend/zend_API.h

57
Zend/zend_API.c

@ -3836,6 +3836,34 @@ ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, char *
}
/* }}} */
ZEND_API void zend_u_update_property(zend_class_entry *scope, zval *object, zend_uchar type, zstr name, int name_length, zval *value TSRMLS_DC) /* {{{ */
{
zval *property;
zend_class_entry *old_scope = EG(scope);
EG(scope) = scope;
if (!Z_OBJ_HT_P(object)->write_property) {
zstr class_name;
zend_uint class_name_len;
zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);
zend_error(E_CORE_ERROR, "Property %v of class %v cannot be updated", name.v, class_name.v);
}
MAKE_STD_ZVAL(property);
if (type == IS_UNICODE) {
ZVAL_UNICODEL(property, name.u, name_length, 1);
} else {
ZVAL_ASCII_STRINGL(property, name.s, name_length, 1);
}
Z_OBJ_HT_P(object)->write_property(object, property, value TSRMLS_CC);
zval_ptr_dtor(&property);
EG(scope) = old_scope;
}
/* }}} */
ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, char *name, int name_length TSRMLS_DC) /* {{{ */
{
zval *tmp;
@ -4184,6 +4212,35 @@ ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, char *n
}
/* }}} */
ZEND_API zval *zend_u_read_property(zend_class_entry *scope, zval *object, zend_uchar type, zstr name, int name_length, zend_bool silent TSRMLS_DC) /* {{{ */
{
zval *property, *value;
zend_class_entry *old_scope = EG(scope);
EG(scope) = scope;
if (!Z_OBJ_HT_P(object)->read_property) {
zstr class_name;
zend_uint class_name_len;
zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);
zend_error(E_CORE_ERROR, "Property %v of class %v cannot be read", name.v, class_name.v);
}
MAKE_STD_ZVAL(property);
if (type == IS_UNICODE) {
ZVAL_UNICODEL(property, name.u, name_length, 1);
} else {
ZVAL_ASCII_STRINGL(property, name.s, name_length, 1);
}
value = Z_OBJ_HT_P(object)->read_property(object, property, silent?BP_VAR_IS:BP_VAR_R TSRMLS_CC);
zval_ptr_dtor(&property);
EG(scope) = old_scope;
return value;
}
/* }}} */
ZEND_API zval *zend_read_static_property(zend_class_entry *scope, char *name, int name_length, zend_bool silent TSRMLS_DC) /* {{{ */
{
zval **property;

2
Zend/zend_API.h

@ -311,6 +311,7 @@ ZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, char *name
ZEND_API void zend_update_class_constants(zend_class_entry *class_type TSRMLS_DC);
ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, char *name, int name_length, zval *value TSRMLS_DC);
ZEND_API void zend_u_update_property(zend_class_entry *scope, zval *object, zend_uchar type, zstr name, int name_length, zval *value TSRMLS_DC);
ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, char *name, int name_length TSRMLS_DC);
ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, char *name, int name_length, long value TSRMLS_DC);
ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, char *name, int name_length, long value TSRMLS_DC);
@ -354,6 +355,7 @@ ZEND_API int zend_update_static_property_unicode(zend_class_entry *scope, char *
ZEND_API int zend_update_static_property_unicodel(zend_class_entry *scope, char *name, int name_length, UChar *value, int value_length TSRMLS_DC);
ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, char *name, int name_length, zend_bool silent TSRMLS_DC);
ZEND_API zval *zend_u_read_property(zend_class_entry *scope, zval *object, zend_uchar type, zstr name, int name_length, zend_bool silent TSRMLS_DC);
ZEND_API zval *zend_read_static_property(zend_class_entry *scope, char *name, int name_length, zend_bool silent TSRMLS_DC);

Loading…
Cancel
Save