- Move Reflection into its own extension

This commit is contained in:
Marcus Boerger 2005-11-17 22:59:39 +00:00
parent 0be9760a60
commit a40a48fbd4
9 changed files with 99 additions and 4329 deletions

View file

@ -15,7 +15,7 @@ libZend_la_SOURCES=\
zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \ zend_list.c zend_indent.c zend_builtin_functions.c zend_sprintf.c \
zend_ini.c zend_qsort.c zend_objects.c zend_object_handlers.c \ zend_ini.c zend_qsort.c zend_objects.c zend_object_handlers.c \
zend_objects_API.c zend_ts_hash.c zend_stream.c zend_mm.c \ zend_objects_API.c zend_ts_hash.c zend_stream.c zend_mm.c \
zend_default_classes.c zend_reflection_api.c \ zend_default_classes.c \
zend_iterators.c zend_interfaces.c zend_exceptions.c \ zend_iterators.c zend_interfaces.c zend_exceptions.c \
zend_strtod.c zend_strtod.c zend_strtol.c zend_strtod.c zend_strtod.c zend_strtol.c

View file

@ -30,7 +30,6 @@
#include "zend_ini.h" #include "zend_ini.h"
#include "zend_unicode.h" #include "zend_unicode.h"
#include "zend_interfaces.h" #include "zend_interfaces.h"
#include "zend_reflection_api.h"
#if defined(ZEND_WIN32) && ZEND_DEBUG #if defined(ZEND_WIN32) && ZEND_DEBUG
BOOL WINAPI IsDebuggerPresent(VOID); BOOL WINAPI IsDebuggerPresent(VOID);

View file

@ -21,7 +21,6 @@
#include "zend.h" #include "zend.h"
#include "zend_API.h" #include "zend_API.h"
#include "zend_reflection_api.h"
#include "zend_builtin_functions.h" #include "zend_builtin_functions.h"
#include "zend_interfaces.h" #include "zend_interfaces.h"
#include "zend_exceptions.h" #include "zend_exceptions.h"
@ -31,7 +30,6 @@ ZEND_API void zend_register_default_classes(TSRMLS_D)
{ {
zend_register_interfaces(TSRMLS_C); zend_register_interfaces(TSRMLS_C);
zend_register_default_exception(TSRMLS_C); zend_register_default_exception(TSRMLS_C);
zend_register_reflection_api(TSRMLS_C);
zend_register_iterator_wrapper(TSRMLS_C); zend_register_iterator_wrapper(TSRMLS_C);
} }

View file

@ -23,7 +23,6 @@
#include "zend.h" #include "zend.h"
#include "zend_API.h" #include "zend_API.h"
#include "zend_reflection_api.h"
#include "zend_builtin_functions.h" #include "zend_builtin_functions.h"
#include "zend_interfaces.h" #include "zend_interfaces.h"
#include "zend_exceptions.h" #include "zend_exceptions.h"

File diff suppressed because it is too large Load diff

View file

@ -1,51 +0,0 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) 1998-2005 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: George Schlossnagle <george@omniti.com> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef ZEND_REFLECTION_API_H
#define ZEND_REFLECTION_API_H
BEGIN_EXTERN_C()
/* Class entry pointers */
extern ZEND_API zend_class_entry *reflector_ptr;
extern ZEND_API zend_class_entry *reflection_exception_ptr;
extern ZEND_API zend_class_entry *reflection_ptr;
extern ZEND_API zend_class_entry *reflection_function_ptr;
extern ZEND_API zend_class_entry *reflection_parameter_ptr;
extern ZEND_API zend_class_entry *reflection_class_ptr;
extern ZEND_API zend_class_entry *reflection_object_ptr;
extern ZEND_API zend_class_entry *reflection_method_ptr;
extern ZEND_API zend_class_entry *reflection_property_ptr;
extern ZEND_API zend_class_entry *reflection_extension_ptr;
ZEND_API void zend_register_reflection_api(TSRMLS_D);
ZEND_API void zend_reflection_class_factory(zend_class_entry *ce, zval *object TSRMLS_DC);
END_EXTERN_C()
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* indent-tabs-mode: t
* End:
*/

View file

@ -1295,7 +1295,7 @@ PHP_ADD_SOURCES(Zend, \
if test -r "$abs_srcdir/Zend/zend_objects.c"; then if test -r "$abs_srcdir/Zend/zend_objects.c"; then
PHP_ADD_SOURCES(Zend, zend_objects.c zend_object_handlers.c zend_objects_API.c zend_mm.c \ PHP_ADD_SOURCES(Zend, zend_objects.c zend_object_handlers.c zend_objects_API.c zend_mm.c \
zend_default_classes.c zend_reflection_api.c) zend_default_classes.c)
fi fi
dnl Selectively disable optimization due to high RAM usage during dnl Selectively disable optimization due to high RAM usage during

View file

@ -20,6 +20,16 @@
*/ */
/* $Id$ */ /* $Id$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "php_reflection.h"
#include "ext/standard/info.h"
#include "zend.h" #include "zend.h"
#include "zend_API.h" #include "zend_API.h"
#include "zend_exceptions.h" #include "zend_exceptions.h"
@ -29,16 +39,34 @@
#include "zend_interfaces.h" #include "zend_interfaces.h"
/* Class entry pointers */ /* Class entry pointers */
ZEND_API zend_class_entry *reflector_ptr; PHPAPI zend_class_entry *reflector_ptr;
ZEND_API zend_class_entry *reflection_exception_ptr; PHPAPI zend_class_entry *reflection_exception_ptr;
ZEND_API zend_class_entry *reflection_ptr; PHPAPI zend_class_entry *reflection_ptr;
ZEND_API zend_class_entry *reflection_function_ptr; PHPAPI zend_class_entry *reflection_function_ptr;
ZEND_API zend_class_entry *reflection_parameter_ptr; PHPAPI zend_class_entry *reflection_parameter_ptr;
ZEND_API zend_class_entry *reflection_class_ptr; PHPAPI zend_class_entry *reflection_class_ptr;
ZEND_API zend_class_entry *reflection_object_ptr; PHPAPI zend_class_entry *reflection_object_ptr;
ZEND_API zend_class_entry *reflection_method_ptr; PHPAPI zend_class_entry *reflection_method_ptr;
ZEND_API zend_class_entry *reflection_property_ptr; PHPAPI zend_class_entry *reflection_property_ptr;
ZEND_API zend_class_entry *reflection_extension_ptr; PHPAPI zend_class_entry *reflection_extension_ptr;
ZEND_BEGIN_MODULE_GLOBALS(reflection)
ZEND_END_MODULE_GLOBALS(reflection)
#ifdef ZTS
# define REFLECTION_G(v) \
TSRMG(reflection_globals_id, zend_reflection_globals*, v)
extern int reflection_globals_id;
#else
# define REFLECTION_G(v) (reflection_globals.v)
extern zend_reflection_globals reflectionglobals;
#endif
#ifdef COMPILE_DL_REFLECTION
ZEND_GET_MODULE(reflection)
#endif
ZEND_DECLARE_MODULE_GLOBALS(reflection)
/* Method macros */ /* Method macros */
@ -921,7 +949,7 @@ static void _function_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask)
/* }}} */ /* }}} */
/* {{{ zend_reflection_class_factory */ /* {{{ zend_reflection_class_factory */
ZEND_API void zend_reflection_class_factory(zend_class_entry *ce, zval *object TSRMLS_DC) PHPAPI void zend_reflection_class_factory(zend_class_entry *ce, zval *object TSRMLS_DC)
{ {
reflection_object *intern; reflection_object *intern;
zval *name; zval *name;
@ -4132,6 +4160,10 @@ static zend_function_entry reflection_extension_functions[] = {
}; };
/* }}} */ /* }}} */
function_entry reflection_ext_functions[] = { /* {{{ */
{NULL, NULL, NULL}
}; /* }}} */
static zend_object_handlers *zend_std_obj_handlers; static zend_object_handlers *zend_std_obj_handlers;
/* {{{ _reflection_write_property */ /* {{{ _reflection_write_property */
@ -4152,10 +4184,17 @@ static void _reflection_write_property(zval *object, zval *member, zval *value T
} }
/* }}} */ /* }}} */
/* {{{ zend_register_reflection_api */ static void reflection_init_globals(zend_reflection_globals *globals) /* {{{ */
ZEND_API void zend_register_reflection_api(TSRMLS_D) { {
/* Initialize your global struct */
} /* }}} */
PHP_MINIT_FUNCTION(reflection) /* {{{ */
{
zend_class_entry _reflection_entry; zend_class_entry _reflection_entry;
ZEND_INIT_MODULE_GLOBALS(reflection, reflection_init_globals, NULL);
zend_std_obj_handlers = zend_get_std_object_handlers(); zend_std_obj_handlers = zend_get_std_object_handlers();
memcpy(&reflection_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); memcpy(&reflection_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
reflection_object_handlers.clone_obj = NULL; reflection_object_handlers.clone_obj = NULL;
@ -4230,8 +4269,32 @@ ZEND_API void zend_register_reflection_api(TSRMLS_D) {
REGISTER_MAIN_LONG_CONSTANT("C_IMPLICIT_ABSTRACT", ZEND_ACC_IMPLICIT_ABSTRACT_CLASS, CONST_PERSISTENT|CONST_CS); REGISTER_MAIN_LONG_CONSTANT("C_IMPLICIT_ABSTRACT", ZEND_ACC_IMPLICIT_ABSTRACT_CLASS, CONST_PERSISTENT|CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("C_EXPLICIT_ABSTRACT", ZEND_ACC_EXPLICIT_ABSTRACT_CLASS, CONST_PERSISTENT|CONST_CS); REGISTER_MAIN_LONG_CONSTANT("C_EXPLICIT_ABSTRACT", ZEND_ACC_EXPLICIT_ABSTRACT_CLASS, CONST_PERSISTENT|CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("C_FINAL", ZEND_ACC_FINAL_CLASS, CONST_PERSISTENT|CONST_CS); REGISTER_MAIN_LONG_CONSTANT("C_FINAL", ZEND_ACC_FINAL_CLASS, CONST_PERSISTENT|CONST_CS);
}
/* }}} */ return SUCCESS;
} /* }}} */
PHP_MINFO_FUNCTION(reflection) /* {{{ */
{
php_info_print_table_start();
php_info_print_table_header(2, "Reflection", "enabled");
php_info_print_table_row(2, "Version", "$Id$");
php_info_print_table_end();
} /* }}} */
zend_module_entry reflection_module_entry = { /* {{{ */
STANDARD_MODULE_HEADER,
"Reflection",
reflection_ext_functions,
PHP_MINIT(reflection),
NULL,
NULL,
NULL,
PHP_MINFO(reflection),
"0.1",
STANDARD_MODULE_PROPERTIES
}; /* }}} */
/* /*
* Local variables: * Local variables:

View file

@ -18,29 +18,33 @@
/* $Id$ */ /* $Id$ */
#ifndef ZEND_REFLECTION_API_H #ifndef PHP_REFLECTION_H
#define ZEND_REFLECTION_API_H #define PHP_REFLECTION_H
#include "php.h"
extern zend_module_entry reflection_module_entry;
#define phpext_reflection_ptr &reflection_module_entry
BEGIN_EXTERN_C() BEGIN_EXTERN_C()
/* Class entry pointers */ /* Class entry pointers */
extern ZEND_API zend_class_entry *reflector_ptr; extern PHPAPI zend_class_entry *reflector_ptr;
extern ZEND_API zend_class_entry *reflection_exception_ptr; extern PHPAPI zend_class_entry *reflection_exception_ptr;
extern ZEND_API zend_class_entry *reflection_ptr; extern PHPAPI zend_class_entry *reflection_ptr;
extern ZEND_API zend_class_entry *reflection_function_ptr; extern PHPAPI zend_class_entry *reflection_function_ptr;
extern ZEND_API zend_class_entry *reflection_parameter_ptr; extern PHPAPI zend_class_entry *reflection_parameter_ptr;
extern ZEND_API zend_class_entry *reflection_class_ptr; extern PHPAPI zend_class_entry *reflection_class_ptr;
extern ZEND_API zend_class_entry *reflection_object_ptr; extern PHPAPI zend_class_entry *reflection_object_ptr;
extern ZEND_API zend_class_entry *reflection_method_ptr; extern PHPAPI zend_class_entry *reflection_method_ptr;
extern ZEND_API zend_class_entry *reflection_property_ptr; extern PHPAPI zend_class_entry *reflection_property_ptr;
extern ZEND_API zend_class_entry *reflection_extension_ptr; extern PHPAPI zend_class_entry *reflection_extension_ptr;
ZEND_API void zend_register_reflection_api(TSRMLS_D); PHPAPI void zend_reflection_class_factory(zend_class_entry *ce, zval *object TSRMLS_DC);
ZEND_API void zend_reflection_class_factory(zend_class_entry *ce, zval *object TSRMLS_DC);
END_EXTERN_C() END_EXTERN_C()
#endif #endif /* PHP_REFLECTION_H */
/* /*
* Local variables: * Local variables: