cvs: ZendEngine2 / zend_reflection_api.c

From: Date: Sun, 27 Feb 2005 22:21:17 +0000
Subject: cvs: ZendEngine2 / zend_reflection_api.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-3444@lists.php.net to get a copy of this message
helly Sun Feb 27 17:21:17 2005 EDT Modified files: /ZendEngine2 zend_reflection_api.c Log: - Add two new methods - Fix signature, no need to cast it http://cvs.php.net/diff.php/ZendEngine2/zend_reflection_api.c?r1=1.148&r2=1.149&ty=u Index: ZendEngine2/zend_reflection_api.c diff -u ZendEngine2/zend_reflection_api.c:1.148 ZendEngine2/zend_reflection_api.c:1.149 --- ZendEngine2/zend_reflection_api.c:1.148 Wed Feb 23 07:20:04 2005 +++ ZendEngine2/zend_reflection_api.c Sun Feb 27 17:21:17 2005 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_reflection_api.c,v 1.148 2005/02/23 12:20:04 derick Exp $ */ +/* $Id: zend_reflection_api.c,v 1.149 2005/02/27 22:21:17 helly Exp $ */ #include "zend.h" #include "zend_API.h" #include "zend_exceptions.h" @@ -182,7 +182,7 @@ class_entry->interfaces[num_interfaces - 1] = interface_entry; } -static void reflection_free_objects_storage(zend_object *object TSRMLS_DC) +static void reflection_free_objects_storage(void *object TSRMLS_DC) { reflection_object *intern = (reflection_object *) object; @@ -2309,6 +2309,67 @@ } /* }}} */ +/* {{{ proto public mixed ReflectionClass::getStaticPropertyValue(string name [, mixed default]) + Returns the value of a tsstic property */ +ZEND_METHOD(reflection_class, getStaticPropertyValue) +{ + reflection_object *intern; + zend_class_entry *ce; + char *name; + int name_len; + zval **prop, *def_value = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &name, &name_len, &def_value) == FAILURE) { + return; + } + + GET_REFLECTION_OBJECT_PTR(ce); + + zend_update_class_constants(ce TSRMLS_CC); + prop = zend_std_get_static_property(ce, name, name_len, 1 TSRMLS_CC); + if (!prop) { + if (def_value) { + RETURN_ZVAL(def_value, 1, 0); + } else { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + "Class %s does not have a property named %s", ce->name, name); + } + return; + } else { + RETURN_ZVAL(*prop, 1, 0); + } +} +/* }}} */ + +/* {{{ proto public void ReflectionClass::setStaticPropertyValue($name, $value) + Sets the value of a static property */ +ZEND_METHOD(reflection_class, setStaticPropertyValue) +{ + reflection_object *intern; + zend_class_entry *ce; + char *name; + int name_len; + zval **variable_ptr, *value; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &name, &name_len, &value) == FAILURE) { + return; + } + + GET_REFLECTION_OBJECT_PTR(ce); + + zend_update_class_constants(ce TSRMLS_CC); + variable_ptr = zend_std_get_static_property(ce, name, name_len, 1 TSRMLS_CC); + if (!variable_ptr) { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + "Class %s does not have a property named %s", ce->name, name); + return; + } + zval_dtor(*variable_ptr); + **variable_ptr = *value; + zval_copy_ctor(*variable_ptr); +} +/* }}} */ + /* {{{ proto public array ReflectionClass::getDefaultProperties() Returns an associative array containing copies of all default property values of the class */ ZEND_METHOD(reflection_class, getDefaultProperties) @@ -3721,6 +3782,8 @@ ZEND_ME(reflection_class, getParentClass, NULL, 0) ZEND_ME(reflection_class, isSubclassOf, NULL, 0) ZEND_ME(reflection_class, getStaticProperties, NULL, 0) + ZEND_ME(reflection_class, getStaticPropertyValue, NULL, 0) + ZEND_ME(reflection_class, setStaticPropertyValue, NULL, 0) ZEND_ME(reflection_class, getDefaultProperties, NULL, 0) ZEND_ME(reflection_class, isIterateable, NULL, 0) ZEND_ME(reflection_class, implementsInterface, NULL, 0)

« previous php.zend-engine.cvs (#3444) next »