cvs: ZendEngine2 / zend_API.c zend_API.h
| From: | Andrei Zmievski | Date: | Wed, 02 Apr 2003 20:27:45 +0000 |
| Subject: | cvs: ZendEngine2 / zend_API.c zend_API.h | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-1105@lists.php.net to get a copy of this message | ||
andrei Wed Apr 2 15:27:45 2003 EDT
Modified files:
/ZendEngine2 zend_API.c zend_API.h
Log:
- Add zend_register_internal_namespace() API function.
- Add zend_register_internal_class_in_ns() API function.
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.162 ZendEngine2/zend_API.c:1.163
--- ZendEngine2/zend_API.c:1.162 Sat Mar 29 06:19:37 2003
+++ ZendEngine2/zend_API.c Wed Apr 2 15:27:44 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.162 2003/03/29 11:19:37 zeev Exp $ */
+/* $Id: zend_API.c,v 1.163 2003/04/02 20:27:44 andrei Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -1165,7 +1165,11 @@
internal_function->function_name = ptr->fname;
internal_function->scope = scope;
internal_function->fn_flags = ZEND_ACC_PUBLIC;
- internal_function->ns = EG(active_namespace);
+ if (!scope) {
+ internal_function->ns = EG(active_namespace);
+ } else {
+ internal_function->ns = NULL;
+ }
internal_function->prototype = NULL;
if (!internal_function->handler) {
zend_error(error_type, "Null function defined as active function");
@@ -1381,6 +1385,54 @@
return class_entry;
}
+ZEND_API zend_class_entry *zend_register_internal_class_in_ns(zend_class_entry *class_entry,
zend_class_entry *parent_ce, zend_namespace *ns, char *ns_name TSRMLS_DC)
+{
+ zend_class_entry *register_class;
+ zend_namespace *orig_namespace = NULL;
+
+ if (!ns && ns_name) {
+ zend_namespace **pns;
+ size_t ns_name_length = strlen(ns_name);
+ char *lowercase_name = zend_strndup(ns_name, ns_name_length);
+ zend_str_tolower(lowercase_name, ns_name_length);
+ if (zend_hash_find(&CG(global_namespace).class_table, lowercase_name, ns_name_length+1, (void
**)&pns) == FAILURE) {
+ free(lowercase_name);
+ return NULL;
+ } else {
+ ns = *pns;
+ }
+ free(lowercase_name);
+ }
+
+ if (EG(active_namespace) != ns) {
+ orig_namespace = EG(active_namespace);
+ EG(active_namespace) = ns;
+ CG(class_table) = &ns->class_table;
+ }
+ register_class = zend_register_internal_class_ex(class_entry, parent_ce, NULL TSRMLS_CC);
+ if (orig_namespace) {
+ EG(active_namespace) = orig_namespace;
+ CG(class_table) = &orig_namespace->class_table;
+ }
+
+ return register_class;
+}
+
+ZEND_API zend_namespace *zend_register_internal_namespace(zend_namespace *orig_ns TSRMLS_DC)
+{
+ zend_namespace *ns = malloc(sizeof(zend_namespace));
+ char *lowercase_name = zend_strndup(orig_ns->name, orig_ns->name_length);
+ *ns = *orig_ns;
+
+ ns->type = ZEND_INTERNAL_NAMESPACE;
+ zend_init_namespace(ns TSRMLS_CC);
+
+ zend_str_tolower(lowercase_name, ns->name_length);
+ zend_hash_update(&CG(global_namespace).class_table, lowercase_name, ns->name_length+1,
&ns, sizeof(zend_namespace *), NULL);
+ free(lowercase_name);
+
+ return ns;
+}
ZEND_API int zend_set_hash_symbol(zval *symbol, char *name, int name_length,
zend_bool is_ref, int num_symbol_tables, ...)
Index: ZendEngine2/zend_API.h
diff -u ZendEngine2/zend_API.h:1.132 ZendEngine2/zend_API.h:1.133
--- ZendEngine2/zend_API.h:1.132 Wed Mar 26 02:44:09 2003
+++ ZendEngine2/zend_API.h Wed Apr 2 15:27:44 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.h,v 1.132 2003/03/26 07:44:09 sebastian Exp $ */
+/* $Id: zend_API.h,v 1.133 2003/04/02 20:27:44 andrei Exp $ */
#ifndef ZEND_API_H
#define ZEND_API_H
@@ -101,6 +101,8 @@
class_container.__set = handle_propset; \
}
+#define INIT_NAMESPACE(ns_container, ns_name) INIT_CLASS_ENTRY(ns_container, ns_name, NULL)
+
int zend_next_free_module(void);
@@ -134,6 +136,8 @@
ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry TSRMLS_DC);
ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry,
zend_class_entry *parent_ce, char *parent_name TSRMLS_DC);
+ZEND_API zend_class_entry *zend_register_internal_class_in_ns(zend_class_entry *class_entry,
zend_class_entry *parent_ce, zend_namespace *ns, char *ns_name TSRMLS_DC);
+ZEND_API zend_namespace *zend_register_internal_namespace(zend_namespace *ns TSRMLS_DC);
ZEND_API int zend_disable_function(char *function_name, uint function_name_length TSRMLS_DC);
ZEND_API int zend_disable_class(char *class_name, uint class_name_length TSRMLS_DC);