cvs: ZendEngine2 / zend_reflection_api.c
| From: | Marcus Boerger | Date: | Sat, 20 Sep 2003 14:22:48 +0000 |
| Subject: | cvs: ZendEngine2 / zend_reflection_api.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-1856@lists.php.net to get a copy of this message | ||
helly Sat Sep 20 10:22:48 2003 EDT
Modified files:
/ZendEngine2 zend_reflection_api.c
Log:
Add public array Reflection_Class::getDefaultProperties()
Index: ZendEngine2/zend_reflection_api.c
diff -u ZendEngine2/zend_reflection_api.c:1.67 ZendEngine2/zend_reflection_api.c:1.68
--- ZendEngine2/zend_reflection_api.c:1.67 Thu Sep 18 08:09:55 2003
+++ ZendEngine2/zend_reflection_api.c Sat Sep 20 10:22:48 2003
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_reflection_api.c,v 1.67 2003/09/18 12:09:55 helly Exp $ */
+/* $Id: zend_reflection_api.c,v 1.68 2003/09/20 14:22:48 helly Exp $ */
#include "zend.h"
#include "zend_API.h"
#include "zend_default_classes.h"
@@ -1819,6 +1819,50 @@
}
/* }}} */
+/* {{{ proto public array Reflection_Class::getDefaultProperties()
+ Returns an associative array containing copies of all default property values of the class */
+ZEND_METHOD(reflection_class, getDefaultProperties)
+{
+ reflection_object *intern;
+ zend_class_entry *ce;
+ int count;
+
+ METHOD_NOTSTATIC_NUMPARAMS(0);
+ GET_REFLECTION_OBJECT_PTR(ce);
+ array_init(return_value);
+
+ count = zend_hash_num_elements(&ce->default_properties);
+ if (count > 0) {
+ HashPosition pos;
+ zval **prop;
+
+ zend_hash_internal_pointer_reset_ex(&ce->default_properties, &pos);
+ while (zend_hash_get_current_data_ex(&ce->default_properties, (void **) &prop,
&pos) == SUCCESS) {
+ char *key, *class_name, *prop_name;
+ uint key_len;
+ ulong num_index;
+ zval *prop_copy;
+
+ zend_hash_get_current_key_ex(&ce->default_properties, &key, &key_len,
&num_index, 0, &pos);
+ zend_hash_move_forward_ex(&ce->default_properties, &pos);
+ unmangle_property_name(key, &class_name, &prop_name);
+ if (class_name && class_name[0] != '*' && strcmp(class_name,
ce->name)) {
+ /* filter privates from base classes */
+ continue;
+ }
+
+ /* copy: enforce read only access */
+ ALLOC_ZVAL(prop_copy);
+ *prop_copy = **prop;
+ zval_copy_ctor(prop_copy);
+ INIT_PZVAL(prop_copy);
+
+ add_assoc_zval(return_value, prop_name, prop_copy);
+ }
+ }
+}
+/* }}} */
+
/* {{{ proto public string Reflection_Class::__toString()
Returns a string representation */
ZEND_METHOD(reflection_class, __toString)
@@ -2904,6 +2948,7 @@
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, getDefaultProperties, NULL, 0)
{NULL, NULL, NULL}
};