return ++module_count;
}
+/* If parent_ce is not NULL then it inherits from parent_ce
+ * If parent_ce is NULL and parent_name isn't then it looks for the parent and inherits from it
+ * If both parent_ce and parent_name are NULL it does a regular class registration
+ * If parent_name is specified but not found NULL is returned
+ */
+ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce, char *parent_name)
+{
+ zend_class_entry *register_class;
+ CLS_FETCH();
+
+ if (!parent_ce && parent_name) {
+ if (zend_hash_find(CG(class_table), parent_name, strlen(parent_name)+1, (void **) &parent_ce)==FAILURE) {
+ return NULL;
+ }
+ }
+
+ register_class = zend_register_internal_class(class_entry);
+
+ if (parent_ce) {
+ do_inheritance(register_class, parent_ce);
+ }
+ return register_class;
+}
ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry)
{
int zend_register_functions(zend_function_entry *functions, HashTable *function_table);
void zend_unregister_functions(zend_function_entry *functions, int count, HashTable *function_table);
ZEND_API int zend_register_module(zend_module_entry *module_entry);
+
ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry);
+ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce, char *parent_name);
+
ZEND_API zend_module_entry *zend_get_module(int module_number);
ZEND_API int zend_disable_function(char *function_name, uint function_name_length);
}
}
+void do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce)
+{
+ zend_function tmp_zend_function;
+ zval *tmp;
+
+ /* Perform inheritance */
+ zend_hash_merge(&ce->default_properties, &parent_ce->default_properties, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0);
+ zend_hash_merge(&ce->function_table, &parent_ce->function_table, (void (*)(void *)) function_add_ref, &tmp_zend_function, sizeof(zend_function), 0);
+ ce->parent = parent_ce;
+ do_inherit_parent_constructor(ce);
+}
+
ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_table, HashTable *class_table, int compile_time)
{
case ZEND_DECLARE_INHERITED_CLASS: {
zend_class_entry *ce, *parent_ce;
char *class_name, *parent_name;
- zend_function tmp_zend_function;
- zval *tmp;
int found_ce;
return FAILURE;
}
- /* Perform inheritance */
- zend_hash_merge(&ce->default_properties, &parent_ce->default_properties, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0);
- zend_hash_merge(&ce->function_table, &parent_ce->function_table, (void (*)(void *)) function_add_ref, &tmp_zend_function, sizeof(zend_function), 0);
- ce->parent = parent_ce;
- do_inherit_parent_constructor(ce);
-
+ do_inheritance(ce, parent_ce);
/* Register the derived class */
if (zend_hash_add(class_table, class_name, strlen(class_name)+1, ce, sizeof(zend_class_entry), NULL)==FAILURE) {
void do_end_function_call(znode *function_name, znode *result, znode *argument_list, int is_method, int is_dynamic_fcall CLS_DC);
void do_return(znode *expr, int do_end_vparse CLS_DC);
ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_table, HashTable *class_table, int compile_time);
+void do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce);
void do_early_binding(CLS_D);
void do_pass_param(znode *param, int op, int offset CLS_DC);