Simplify abstract method declaration

This commit is contained in:
Marcus Boerger 2003-08-16 20:46:22 +00:00
parent c346aad91a
commit fe1a086d19
4 changed files with 4 additions and 15 deletions

View 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;

View 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 },

View 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);

View 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);