[PHP-CVS] cvs: php-src /ext/reflection php_reflection.c php_reflection.h

2006-06-09 Thread Hannes Magnusson
bjori   Sat Jun 10 00:28:28 2006 UTC

  Modified files:  
/php-src/ext/reflection php_reflection.c php_reflection.h 
  Log:
  Fixed bug #37764
  - Created new abstract class, ReflectionFunctionAbstract implementing 
Reflector
  - Moved all methods from ReflectionFunction (except export, invoke  
invokeArgs)
  - ReflectionFunction now inherits everything from ReflectionFunctionAbstract
  and implements its own export, invoke  invokeArgs methods
  - ReflectionMethod now extends ReflectionFunctionAbstract and implements
  its own export, invoke  invokeArgs methods.
  - Removed stdClass typehint from ReflectionClass::isInstance
  - Removed stdClass typehint from ReflectionClass::set/getValue
  
  
  http://cvs.php.net/viewcvs.cgi/php-src/ext/reflection/php_reflection.c?r1=1.234r2=1.235diff_format=u
Index: php-src/ext/reflection/php_reflection.c
diff -u php-src/ext/reflection/php_reflection.c:1.234 
php-src/ext/reflection/php_reflection.c:1.235
--- php-src/ext/reflection/php_reflection.c:1.234   Wed Jun  7 22:39:00 2006
+++ php-src/ext/reflection/php_reflection.c Sat Jun 10 00:28:28 2006
@@ -20,7 +20,7 @@
+--+
 */
 
-/* $Id: php_reflection.c,v 1.234 2006/06/07 22:39:00 helly Exp $ */
+/* $Id: php_reflection.c,v 1.235 2006/06/10 00:28:28 bjori Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -43,6 +43,7 @@
 PHPAPI zend_class_entry *reflector_ptr;
 PHPAPI zend_class_entry *reflection_exception_ptr;
 PHPAPI zend_class_entry *reflection_ptr;
+PHPAPI zend_class_entry *reflection_function_abstract_ptr;
 PHPAPI zend_class_entry *reflection_function_ptr;
 PHPAPI zend_class_entry *reflection_parameter_ptr;
 PHPAPI zend_class_entry *reflection_class_ptr;
@@ -1381,7 +1382,7 @@
zend_function *fptr;
string str;
 
-   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0);
+   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0);
GET_REFLECTION_OBJECT_PTR(fptr);
string_init(str);
_function_string(str, fptr, intern-ce,  TSRMLS_CC);
@@ -1393,7 +1394,7 @@
Returns this function's name */
 ZEND_METHOD(reflection, function_getName)
 {
-   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0);
+   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0);
_default_get_entry(getThis(), name, sizeof(name), return_value 
TSRMLS_CC);
 }
 /* }}} */
@@ -1405,7 +1406,7 @@
reflection_object *intern;
zend_function *fptr;
 
-   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0);
+   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0);
GET_REFLECTION_OBJECT_PTR(fptr);
RETURN_BOOL(fptr-type == ZEND_INTERNAL_FUNCTION);
 }
@@ -1418,7 +1419,7 @@
reflection_object *intern;
zend_function *fptr;
 
-   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0);
+   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0);
GET_REFLECTION_OBJECT_PTR(fptr);
RETURN_BOOL(fptr-type == ZEND_USER_FUNCTION);
 }
@@ -1431,7 +1432,7 @@
reflection_object *intern;
zend_function *fptr;
 
-   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0);
+   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0);
GET_REFLECTION_OBJECT_PTR(fptr);
if (fptr-type == ZEND_USER_FUNCTION) {
RETURN_STRING(fptr-op_array.filename, 1);
@@ -1447,7 +1448,7 @@
reflection_object *intern;
zend_function *fptr;
 
-   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0);
+   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0);
GET_REFLECTION_OBJECT_PTR(fptr);
if (fptr-type == ZEND_USER_FUNCTION) {
RETURN_LONG(fptr-op_array.line_start);
@@ -1463,7 +1464,7 @@
reflection_object *intern;
zend_function *fptr;
 
-   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0);
+   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0);
GET_REFLECTION_OBJECT_PTR(fptr);
if (fptr-type == ZEND_USER_FUNCTION) {
RETURN_LONG(fptr-op_array.line_end);
@@ -1479,7 +1480,7 @@
reflection_object *intern;
zend_function *fptr;
 
-   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0);
+   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0);
GET_REFLECTION_OBJECT_PTR(fptr);
if (fptr-type == ZEND_USER_FUNCTION  fptr-op_array.doc_comment) {
RETURN_STRINGL(fptr-op_array.doc_comment, 
fptr-op_array.doc_comment_len, 1);
@@ -1496,7 +1497,7 @@
reflection_object *intern;
zend_function *fptr;

-   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0);
+   METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0);
GET_REFLECTION_OBJECT_PTR(fptr);
 
/* Return an empty array in case no static variables exist 

[PHP-CVS] cvs: php-src /ext/reflection php_reflection.c php_reflection.h

2005-11-17 Thread Marcus Boerger
helly   Thu Nov 17 17:59:41 2005 EDT

  Modified files:  
/php-src/ext/reflection php_reflection.c php_reflection.h 
  Log:
  - Move Reflection into its own extension
  
http://cvs.php.net/diff.php/php-src/ext/reflection/php_reflection.c?r1=1.189r2=1.190ty=u
Index: php-src/ext/reflection/php_reflection.c
diff -u php-src/ext/reflection/php_reflection.c:1.189 
php-src/ext/reflection/php_reflection.c:1.190
--- php-src/ext/reflection/php_reflection.c:1.189   Tue Nov 15 10:20:19 2005
+++ php-src/ext/reflection/php_reflection.c Thu Nov 17 17:59:38 2005
@@ -19,7 +19,17 @@
+--+
 */
 
-/* $Id: php_reflection.c,v 1.189 2005/11/15 15:20:19 dmitry Exp $ */
+/* $Id: php_reflection.c,v 1.190 2005/11/17 22:59:38 helly Exp $ */
+
+#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_API.h
 #include zend_exceptions.h
@@ -29,16 +39,34 @@
 #include zend_interfaces.h
 
 /* Class entry pointers */
-ZEND_API zend_class_entry *reflector_ptr;
-ZEND_API zend_class_entry *reflection_exception_ptr;
-ZEND_API zend_class_entry *reflection_ptr;
-ZEND_API zend_class_entry *reflection_function_ptr;
-ZEND_API zend_class_entry *reflection_parameter_ptr;
-ZEND_API zend_class_entry *reflection_class_ptr;
-ZEND_API zend_class_entry *reflection_object_ptr;
-ZEND_API zend_class_entry *reflection_method_ptr;
-ZEND_API zend_class_entry *reflection_property_ptr;
-ZEND_API zend_class_entry *reflection_extension_ptr;
+PHPAPI zend_class_entry *reflector_ptr;
+PHPAPI zend_class_entry *reflection_exception_ptr;
+PHPAPI zend_class_entry *reflection_ptr;
+PHPAPI zend_class_entry *reflection_function_ptr;
+PHPAPI zend_class_entry *reflection_parameter_ptr;
+PHPAPI zend_class_entry *reflection_class_ptr;
+PHPAPI zend_class_entry *reflection_object_ptr;
+PHPAPI zend_class_entry *reflection_method_ptr;
+PHPAPI zend_class_entry *reflection_property_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 */
 
@@ -921,7 +949,7 @@
 /* }}} */
 
 /* {{{ 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;
zval *name;
@@ -4132,6 +4160,10 @@
 };
 /* }}} */
 
+function_entry reflection_ext_functions[] = { /* {{{ */
+   {NULL, NULL, NULL}
+}; /* }}} */
+
 static zend_object_handlers *zend_std_obj_handlers;
 
 /* {{{ _reflection_write_property */
@@ -4152,10 +4184,17 @@
 }
 /* }}} */
 
-/* {{{ zend_register_reflection_api */
-ZEND_API void zend_register_reflection_api(TSRMLS_D) {
+static void reflection_init_globals(zend_reflection_globals *globals) /* {{{ */
+{
+   /* Initialize your global struct */
+} /* }}} */
+
+PHP_MINIT_FUNCTION(reflection) /* {{{ */
+{
zend_class_entry _reflection_entry;
 
+   ZEND_INIT_MODULE_GLOBALS(reflection, reflection_init_globals, NULL);
+
zend_std_obj_handlers = zend_get_std_object_handlers();
memcpy(reflection_object_handlers, zend_get_std_object_handlers(), 
sizeof(zend_object_handlers));
reflection_object_handlers.clone_obj = NULL;
@@ -4230,8 +4269,32 @@
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_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_reflection.c,v 1.190 
2005/11/17 22:59:38 helly Exp $);
+
+   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:
http://cvs.php.net/diff.php/php-src/ext/reflection/php_reflection.h?r1=1.7r2=1.8ty=u
Index: 

Re: [PHP-CVS] cvs: php-src /ext/reflection php_reflection.c php_reflection.h

2005-11-17 Thread Jani Taskinen


You propably should not add this if you think this extension
can't be compiled as shared:

+#ifdef COMPILE_DL_REFLECTION
+ZEND_GET_MODULE(reflection)
+#endif


On Thu, 17 Nov 2005, Marcus Boerger wrote:



helly   Thu Nov 17 17:59:41 2005 EDT

 Modified files:
   /php-src/ext/reflection  php_reflection.c php_reflection.h
 Log:
 - Move Reflection into its own extension

http://cvs.php.net/diff.php/php-src/ext/reflection/php_reflection.c?r1=1.189r2=1.190ty=u
Index: php-src/ext/reflection/php_reflection.c
diff -u php-src/ext/reflection/php_reflection.c:1.189 
php-src/ext/reflection/php_reflection.c:1.190
--- php-src/ext/reflection/php_reflection.c:1.189   Tue Nov 15 10:20:19 2005
+++ php-src/ext/reflection/php_reflection.c Thu Nov 17 17:59:38 2005
@@ -19,7 +19,17 @@
   +--+
*/

-/* $Id: php_reflection.c,v 1.189 2005/11/15 15:20:19 dmitry Exp $ */
+/* $Id: php_reflection.c,v 1.190 2005/11/17 22:59:38 helly Exp $ */
+
+#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_API.h
#include zend_exceptions.h
@@ -29,16 +39,34 @@
#include zend_interfaces.h

/* Class entry pointers */
-ZEND_API zend_class_entry *reflector_ptr;
-ZEND_API zend_class_entry *reflection_exception_ptr;
-ZEND_API zend_class_entry *reflection_ptr;
-ZEND_API zend_class_entry *reflection_function_ptr;
-ZEND_API zend_class_entry *reflection_parameter_ptr;
-ZEND_API zend_class_entry *reflection_class_ptr;
-ZEND_API zend_class_entry *reflection_object_ptr;
-ZEND_API zend_class_entry *reflection_method_ptr;
-ZEND_API zend_class_entry *reflection_property_ptr;
-ZEND_API zend_class_entry *reflection_extension_ptr;
+PHPAPI zend_class_entry *reflector_ptr;
+PHPAPI zend_class_entry *reflection_exception_ptr;
+PHPAPI zend_class_entry *reflection_ptr;
+PHPAPI zend_class_entry *reflection_function_ptr;
+PHPAPI zend_class_entry *reflection_parameter_ptr;
+PHPAPI zend_class_entry *reflection_class_ptr;
+PHPAPI zend_class_entry *reflection_object_ptr;
+PHPAPI zend_class_entry *reflection_method_ptr;
+PHPAPI zend_class_entry *reflection_property_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 */

@@ -921,7 +949,7 @@
/* }}} */

/* {{{ 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;
zval *name;
@@ -4132,6 +4160,10 @@
};
/* }}} */

+function_entry reflection_ext_functions[] = { /* {{{ */
+   {NULL, NULL, NULL}
+}; /* }}} */
+
static zend_object_handlers *zend_std_obj_handlers;

/* {{{ _reflection_write_property */
@@ -4152,10 +4184,17 @@
}
/* }}} */

-/* {{{ zend_register_reflection_api */
-ZEND_API void zend_register_reflection_api(TSRMLS_D) {
+static void reflection_init_globals(zend_reflection_globals *globals) /* {{{ */
+{
+   /* Initialize your global struct */
+} /* }}} */
+
+PHP_MINIT_FUNCTION(reflection) /* {{{ */
+{
zend_class_entry _reflection_entry;

+   ZEND_INIT_MODULE_GLOBALS(reflection, reflection_init_globals, NULL);
+
zend_std_obj_handlers = zend_get_std_object_handlers();
memcpy(reflection_object_handlers, zend_get_std_object_handlers(), 
sizeof(zend_object_handlers));
reflection_object_handlers.clone_obj = NULL;
@@ -4230,8 +4269,32 @@
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_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_reflection.c,v 1.190 
2005/11/17 22:59:38 helly Exp $);
+
+   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