From: Marcus Boerger Date: Sat, 16 Aug 2003 20:46:22 +0000 (+0000) Subject: Simplify abstract method declaration X-Git-Tag: RELEASE_0_7~622 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fe1a086d19a9635ee9e7acb4466217345902834e;p=php Simplify abstract method declaration --- diff --git a/Zend/zend_API.c b/Zend/zend_API.c index fc35227541..9255ade0ac 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -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; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 41fd8ab32b..99ff104a4a 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -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 }, diff --git a/Zend/zend_reflection_api.c b/Zend/zend_reflection_api.c index 2a9a4e5292..1277fca145 100644 --- a/Zend/zend_reflection_api.c +++ b/Zend/zend_reflection_api.c @@ -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); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 2a9a4e5292..1277fca145 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -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);