cvs: ZendEngine2 / zend_API.c
| From: | Andrei Zmievski | Date: | Fri, 10 Jan 2003 14:41:53 +0000 |
| Subject: | cvs: ZendEngine2 / zend_API.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-787@lists.php.net to get a copy of this message | ||
andrei Fri Jan 10 09:41:53 2003 EDT
Modified files:
/ZendEngine2 zend_API.c
Log:
Automatically register constructor, destructor, and clone function when
class methods are registered.
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.141 ZendEngine2/zend_API.c:1.142
--- ZendEngine2/zend_API.c:1.141 Wed Jan 1 07:38:54 2003
+++ ZendEngine2/zend_API.c Fri Jan 10 09:41:53 2003
@@ -1042,11 +1042,12 @@
int zend_register_functions(zend_class_entry *scope, zend_function_entry *functions, HashTable
*function_table, int type TSRMLS_DC)
{
zend_function_entry *ptr = functions;
- zend_function function;
+ zend_function function, *reg_function;
zend_internal_function *internal_function = (zend_internal_function *)&function;
int count=0, unload=0;
HashTable *target_function_table = function_table;
int error_type;
+ zend_function *ctor = NULL, *dtor = NULL, *clone = NULL;
if (type==MODULE_PERSISTENT) {
error_type = E_CORE_WARNING;
@@ -1070,10 +1071,25 @@
zend_unregister_functions(functions, count, target_function_table TSRMLS_CC);
return FAILURE;
}
- if (zend_hash_add(target_function_table, ptr->fname, strlen(ptr->fname)+1, &function,
sizeof(zend_function), NULL) == FAILURE) {
+ if (zend_hash_add(target_function_table, ptr->fname, strlen(ptr->fname)+1, &function,
sizeof(zend_function), (void**)®_function) == FAILURE) {
unload=1;
break;
}
+ if (scope) {
+ /*
+ * If it's an old-style constructor, store it only if we don't have
+ * a constructor already.
+ */
+ if (!strcmp(ptr->fname, scope->name) && !ctor) {
+ ctor = reg_function;
+ } else if (!strcmp(ptr->fname, ZEND_CONSTRUCTOR_FUNC_NAME)) {
+ ctor = reg_function;
+ } else if (!strcmp(ptr->fname, ZEND_DESTRUCTOR_FUNC_NAME)) {
+ dtor = reg_function;
+ } else if (!strcmp(ptr->fname, ZEND_CLONE_FUNC_NAME)) {
+ clone = reg_function;
+ }
+ }
ptr++;
count++;
}
@@ -1086,6 +1102,11 @@
}
zend_unregister_functions(functions, count, target_function_table TSRMLS_CC);
return FAILURE;
+ }
+ if (scope) {
+ scope->constructor = ctor;
+ scope->destructor = dtor;
+ scope->clone = clone;
}
return SUCCESS;
}