On Mon, 24 Mar 2003, Tal Peer wrote:
Ok, attached is a revised patch that also compiles in zts :)
> Hello,
> I've changed get_declared_classes behaviour a bit in order to add
> namespaces support (NS::class format). See attached patch.
>
> Currently, due to what seems to me as a bug, it outputs every user-defined
> class (inside a namespace, that is) twice. I checked, and EG(class_table)
> seems to contain each namespace entry twice. This can be workedaround with
> a little hack, but i guess it should be fixed.
>
> --
> Tal Peer
> [EMAIL PROTECTED]
--
Tal Peer
[EMAIL PROTECTED]
Index: zend_builtin_functions.c
===================================================================
RCS file: /repository/ZendEngine2/zend_builtin_functions.c,v
retrieving revision 1.175
diff -u -r1.175 zend_builtin_functions.c
--- zend_builtin_functions.c 5 Mar 2003 11:14:41 -0000 1.175
+++ zend_builtin_functions.c 25 Mar 2003 13:15:57 -0000
@@ -1044,15 +1044,31 @@
}
/* }}} */
+static int copy_class_name_from_namespace(zend_class_entry **pce, zval *array
TSRMLS_DC)
+{
+ zend_class_entry *ce = *pce;
+ char *fullname = do_alloca(ce->ns->name_length + ce->name_length + 3);
+
+ zend_sprintf(fullname, "%s::%s", ce->ns->name, ce->name);
+ add_next_index_stringl(array, fullname, ce->ns->name_length + ce->name_length
+ 3, 1);
+ free_alloca(fullname);
+
+ return 0;
+}
-static int copy_class_name(zend_class_entry **pce, int num_args, va_list args,
zend_hash_key *hash_key)
+static int copy_class_name(zend_class_entry **pce, int num_args, va_list args,
zend_hash_key *hash_key TSRMLS_DC)
{
zval *array = va_arg(args, zval *);
zend_class_entry *ce = *pce;
if (hash_key->nKeyLength==0 || hash_key->arKey[0]!=0) {
- add_next_index_stringl(array, ce->name, ce->name_length, 1);
+ if (ce->type == ZEND_NAMESPACE) {
+ zend_hash_apply_with_argument(&ce->class_table,
(apply_func_arg_t) copy_class_name_from_namespace, array TSRMLS_CC);
+ } else {
+ add_next_index_stringl(array, ce->name, ce->name_length+1, 1);
+ }
}
+
return 0;
}
@@ -1066,7 +1082,7 @@
}
array_init(return_value);
- zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)
copy_class_name, 1, return_value);
+ zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t)
copy_class_name, 1, return_value TSRMLS_CC);
}
/* }}} */
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php