cvs: ZendEngine2 / zend_API.c zend_API.h
"Antony Dovgal" <[email protected]>
| Newsgroups | gmane.comp.php.cvs.zend |
|---|---|
| Message-ID | <cvstony20011217321241@cvsserver> |
tony2001 Tue Jul 29 08:47:21 2008 UTC
Modified files:
/ZendEngine2 zend_API.c zend_API.h
Log:
add zend_u_read_property() and zend_u_update_property()
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.479&r2=1.480&diff_format=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.479 ZendEngine2/zend_API.c:1.480
--- ZendEngine2/zend_API.c:1.479 Sat Jul 26 18:32:39 2008
+++ ZendEngine2/zend_API.c Tue Jul 29 08:47:21 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.479 2008/07/26 18:32:39 dmitry Exp $ */
+/* $Id: zend_API.c,v 1.480 2008/07/29 08:47:21 tony2001 Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -3836,6 +3836,34 @@
}
/* }}} */
+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_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;
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.h?r1=1.304&r2=1.305&diff_format=u
Index: ZendEngine2/zend_API.h
diff -u ZendEngine2/zend_API.h:1.304 ZendEngine2/zend_API.h:1.305
--- ZendEngine2/zend_API.h:1.304 Sat Jul 26 13:14:55 2008
+++ ZendEngine2/zend_API.h Tue Jul 29 08:47:21 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.h,v 1.304 2008/07/26 13:14:55 dmitry Exp $ */
+/* $Id: zend_API.h,v 1.305 2008/07/29 08:47:21 tony2001 Exp $ */
#ifndef ZEND_API_H
#define ZEND_API_H
@@ -311,6 +311,7 @@
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_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);
--
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php