cvs: ZendEngine2 / zend_reflection_api.c
| From: | George Schlossnagle | Date: | Tue, 01 Jul 2003 04:10:57 +0000 |
| Subject: | cvs: ZendEngine2 / zend_reflection_api.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-1416@lists.php.net to get a copy of this message | ||
gschlossnagle Tue Jul 1 00:10:57 2003 EDT
Modified files:
/ZendEngine2 zend_reflection_api.c
Log:
more incremental changes. add anything that needs a class factory.
Index: ZendEngine2/zend_reflection_api.c
diff -u ZendEngine2/zend_reflection_api.c:1.4 ZendEngine2/zend_reflection_api.c:1.5
--- ZendEngine2/zend_reflection_api.c:1.4 Mon Jun 30 22:31:21 2003
+++ ZendEngine2/zend_reflection_api.c Tue Jul 1 00:10:57 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_reflection_api.c,v 1.4 2003/07/01 02:31:21 gschlossnagle Exp $ */
+/* $Id: zend_reflection_api.c,v 1.5 2003/07/01 04:10:57 gschlossnagle Exp $ */
#include <assert.h>
#include "zend.h"
@@ -82,6 +82,18 @@
return retval;
}
+static zval * reflection_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC)
+{
+ if (!object) {
+ ALLOC_ZVAL(object);
+ }
+ Z_TYPE_P(object) = IS_OBJECT;
+ object_init_ex(object, pce);
+ object->refcount = 1;
+ object->is_ref = 1;
+ return object;
+}
+
ZEND_FUNCTION(reflection_function)
{
zval **name;
@@ -320,6 +332,18 @@
efree(params);
}
+void reflection_class_factory(zend_class_entry *ce, zval *object)
+{
+ reflection_object *intern;
+ zval *name;
+ ALLOC_ZVAL(name);
+ ZVAL_STRINGL(name, ce->name, ce->name_length, 1);
+ reflection_instanciate(reflection_class_ptr, object);
+ intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
+ intern->ptr = ce;
+ zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **)
&name, sizeof(zval *), NULL);
+}
+
ZEND_FUNCTION(reflection_class)
{
zval **name;
@@ -527,7 +551,7 @@
if (intern == NULL || (ce = intern->ptr) == NULL) {
RETURN_FALSE;
}
- if(zend_hash_find(&ce->constants_table, Z_STRVAL_PP(name), Z_STRLEN_PP(name) + 1, (void **)
&value) == FAILURE) {
+ if (zend_hash_find(&ce->constants_table, Z_STRVAL_PP(name), Z_STRLEN_PP(name) + 1, (void
**) &value) == FAILURE) {
RETURN_FALSE;
}
*return_value = **value;
@@ -551,6 +575,51 @@
RETURN_BOOL(ce->type & ZEND_ACC_INTERFACE);
}
+ZEND_FUNCTION(reflection_class_getinterfaces)
+{
+ zval *object;
+ reflection_object *intern;
+ zend_class_entry *ce;
+
+ if (ZEND_NUM_ARGS() > 0) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
+ object = getThis();
+ intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
+ if (intern == NULL || (ce = intern->ptr) == NULL) {
+ RETURN_FALSE;
+ }
+ if (ce->num_interfaces) {
+ int i;
+ array_init(return_value);
+ for(i=0; i < ce->num_interfaces; i++) {
+ zval *interface;
+ ALLOC_ZVAL(interface);
+ reflection_class_factory(ce->interfaces[i], interface);
+ add_next_index_zval(return_value, interface);
+ }
+ }
+}
+
+ZEND_FUNCTION(reflection_class_getparentclass)
+{
+ zval *object;
+ reflection_object *intern;
+ zend_class_entry *ce;
+
+ if (ZEND_NUM_ARGS() > 0) {
+ ZEND_WRONG_PARAM_COUNT();
+ }
+ object = getThis();
+ intern = (reflection_object *) zend_object_store_get_object(object TSRMLS_CC);
+ if (intern && (ce = intern->ptr) && ce->parent) {
+ reflection_class_factory(ce->parent, return_value);
+ }
+ else {
+ RETURN_FALSE;
+ }
+}
+
static zend_function_entry reflection_function_functions[] = {
ZEND_FE(reflection_function, NULL)
ZEND_NAMED_FE(isinternal, ZEND_FN(reflection_function_isinternal), NULL)
@@ -576,7 +645,9 @@
ZEND_NAMED_FE(getdoccomment, ZEND_FN(reflection_class_getdoccomment), NULL)
ZEND_NAMED_FE(getconstants, ZEND_FN(reflection_class_getconstants), NULL)
ZEND_NAMED_FE(getconstant, ZEND_FN(reflection_class_getconstant), NULL)
+ ZEND_NAMED_FE(getinterfaces, ZEND_FN(reflection_class_getinterfaces), NULL)
ZEND_NAMED_FE(isinterface, ZEND_FN(reflection_class_isinterface), NULL)
+ ZEND_NAMED_FE(getparentclass, ZEND_FN(reflection_class_getparentclass), NULL)
{NULL, NULL, NULL}
};