]> granicus.if.org Git - php/commitdiff
Simplify abstract method declaration
authorMarcus Boerger <helly@php.net>
Sat, 16 Aug 2003 20:46:22 +0000 (20:46 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 16 Aug 2003 20:46:22 +0000 (20:46 +0000)
Zend/zend_API.c
Zend/zend_API.h
Zend/zend_reflection_api.c
ext/reflection/php_reflection.c

index fc352275416a8ad4f545c20b6e61f176cfec8707..9255ade0ac68190814de0d337842df2589a0bd2a 100644 (file)
@@ -1185,7 +1185,7 @@ int zend_register_functions(zend_class_entry *scope, zend_function_entry *functi
                } else {
                        internal_function->fn_flags = ZEND_ACC_PUBLIC;
                }
-               if (!internal_function->handler) {
+               if (!internal_function->handler && !(ptr->flags&ZEND_ACC_ABSTRACT)) {
                        zend_error(error_type, "Null function defined as active function");
                        zend_unregister_functions(functions, count, target_function_table TSRMLS_CC);
                        return FAILURE;
index 41fd8ab32ba69427e2c92b9bce2f7592f2aa44e4..99ff104a4ad32bda11a893e312c2f2bea40f21b4 100644 (file)
@@ -50,6 +50,7 @@ typedef struct _zend_function_entry {
 #define ZEND_FE(name, arg_info)                                                ZEND_NAMED_FE(name, ZEND_FN(name), arg_info)
 #define ZEND_FALIAS(name, alias, arg_info)                     ZEND_NAMED_FE(name, ZEND_FN(alias), arg_info)
 #define ZEND_ME(classname, name, arg_info, flags)      { #name, ZEND_FN(classname##_##name), arg_info, sizeof(arg_info)/sizeof(struct _zend_arg_info)-1, flags },
+#define ZEND_ABSTRACT_ME(classname, name, arg_info)    { #name, NULL, arg_info, sizeof(arg_info)/sizeof(struct _zend_arg_info)-1, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT },
 
 #define ZEND_ARG_INFO(pass_by_ref, name)                                                       { #name, sizeof(#name)-1, NULL, 0, 0, pass_by_ref },
 #define ZEND_ARG_PASS_INFO(pass_by_ref)                                                                { NULL, 0, NULL, 0, 0, pass_by_ref },
index 2a9a4e529292f6f5f486e461d3ab5324636aa899..1277fca14588b9847de7a3022685b6c550652edb 100644 (file)
@@ -2171,7 +2171,7 @@ static zend_function_entry reflection_functions[] = {
 };
 
 static zend_function_entry reflector_functions[] = {
-       ZEND_NAMED_FE(tostring, ZEND_FN(reflector_tostring), NULL)
+       ZEND_ABSTRACT_ME(reflector, tostring, NULL)
        {NULL, NULL, NULL}
 };
 
@@ -2266,7 +2266,6 @@ static zend_function_entry reflection_extension_functions[] = {
 
 ZEND_API void zend_register_reflection_api(TSRMLS_D) {
        zend_class_entry _reflection_entry;
-       zend_function *mptr;
 
        memcpy(&reflection_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
 
@@ -2277,11 +2276,6 @@ ZEND_API void zend_register_reflection_api(TSRMLS_D) {
        reflector_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC);
        reflector_ptr->ce_flags = ZEND_ACC_ABSTRACT | ZEND_ACC_INTERFACE;
 
-       /* Ugly... is there a better way to introduce an abstract method to a class? */
-       if (zend_hash_find(&reflector_ptr->function_table, "tostring", sizeof("tostring"), (void **) &mptr) == SUCCESS) {
-               mptr->common.fn_flags = ZEND_ACC_ABSTRACT | ZEND_ACC_PUBLIC;
-       }
-
        INIT_CLASS_ENTRY(_reflection_entry, "reflection_function", reflection_function_functions);
        _reflection_entry.create_object = reflection_objects_new;
        reflection_function_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC);
index 2a9a4e529292f6f5f486e461d3ab5324636aa899..1277fca14588b9847de7a3022685b6c550652edb 100644 (file)
@@ -2171,7 +2171,7 @@ static zend_function_entry reflection_functions[] = {
 };
 
 static zend_function_entry reflector_functions[] = {
-       ZEND_NAMED_FE(tostring, ZEND_FN(reflector_tostring), NULL)
+       ZEND_ABSTRACT_ME(reflector, tostring, NULL)
        {NULL, NULL, NULL}
 };
 
@@ -2266,7 +2266,6 @@ static zend_function_entry reflection_extension_functions[] = {
 
 ZEND_API void zend_register_reflection_api(TSRMLS_D) {
        zend_class_entry _reflection_entry;
-       zend_function *mptr;
 
        memcpy(&reflection_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
 
@@ -2277,11 +2276,6 @@ ZEND_API void zend_register_reflection_api(TSRMLS_D) {
        reflector_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC);
        reflector_ptr->ce_flags = ZEND_ACC_ABSTRACT | ZEND_ACC_INTERFACE;
 
-       /* Ugly... is there a better way to introduce an abstract method to a class? */
-       if (zend_hash_find(&reflector_ptr->function_table, "tostring", sizeof("tostring"), (void **) &mptr) == SUCCESS) {
-               mptr->common.fn_flags = ZEND_ACC_ABSTRACT | ZEND_ACC_PUBLIC;
-       }
-
        INIT_CLASS_ENTRY(_reflection_entry, "reflection_function", reflection_function_functions);
        _reflection_entry.create_object = reflection_objects_new;
        reflection_function_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC);