cvs: ZendEngine2 / zend_API.c zend_compile.c zend_compile.h zend_object_handlers.c zend_reflection_api.c
| From: | Marcus Boerger | Date: | Tue, 30 Aug 2005 18:27:19 +0000 |
| Subject: | cvs: ZendEngine2 / zend_API.c zend_compile.c zend_compile.h zend_object_handlers.c zend_reflection_api.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-4084@lists.php.net to get a copy of this message | ||
helly Tue Aug 30 14:27:19 2005 EDT
Modified files:
/ZendEngine2 zend_API.c zend_compile.c zend_compile.h
zend_object_handlers.c zend_reflection_api.c
Log:
- Adds module registering a function to struct zend_internal_function.
(Johannes)
# This information is by reflection API and error messages.
http://cvs.php.net/diff.php/ZendEngine2/zend_API.c?r1=1.313&r2=1.314&ty=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.313 ZendEngine2/zend_API.c:1.314
--- ZendEngine2/zend_API.c:1.313 Tue Aug 23 08:53:19 2005
+++ ZendEngine2/zend_API.c Tue Aug 30 14:27:17 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.313 2005/08/23 12:53:19 dmitry Exp $ */
+/* $Id: zend_API.c,v 1.314 2005/08/30 18:27:17 helly Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -1914,12 +1914,15 @@
}
efree(lcname);
module = module_ptr;
+ EG(current_module) = module;
if (module->functions && zend_register_functions(NULL, module->functions, NULL,
module->type TSRMLS_CC)==FAILURE) {
+ EG(current_module) = NULL;
zend_error(E_CORE_WARNING,"%s: Unable to register functions, unable to load",
module->name);
return NULL;
}
+ EG(current_module) = NULL;
return module;
}
@@ -1996,7 +1999,8 @@
target_function_table = CG(function_table);
}
internal_function->type = ZEND_INTERNAL_FUNCTION;
-
+ internal_function->module = EG(current_module);
+
if (scope) {
class_name_len = scope->name_length;
lc_class_name = zend_str_tolower_dup(scope->name, class_name_len);
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.658&r2=1.659&ty=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.658 ZendEngine2/zend_compile.c:1.659
--- ZendEngine2/zend_compile.c:1.658 Wed Aug 24 16:42:05 2005
+++ ZendEngine2/zend_compile.c Tue Aug 30 14:27:17 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.658 2005/08/24 20:42:05 andrei Exp $ */
+/* $Id: zend_compile.c,v 1.659 2005/08/30 18:27:17 helly Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -2277,6 +2277,10 @@
Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant),
((zend_op_array *) function)->filename,
((zend_op_array *) function)->opcodes[0].lineno);
+ } else if (((zend_internal_function *)function)->module) {
+ zend_error(error_level, "Cannot redeclare %R() (internal function exists in module
%s)",
+ Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant),
+ ((zend_internal_function *)function)->module->name);
} else {
zend_error(error_level, "Cannot redeclare %R()", Z_TYPE(opline->op2.u.constant),
Z_UNIVAL(opline->op2.u.constant));
}
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.321&r2=1.322&ty=u
Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.321 ZendEngine2/zend_compile.h:1.322
--- ZendEngine2/zend_compile.h:1.321 Wed Aug 24 16:42:06 2005
+++ ZendEngine2/zend_compile.h Tue Aug 30 14:27:17 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.h,v 1.321 2005/08/24 20:42:06 andrei Exp $ */
+/* $Id: zend_compile.h,v 1.322 2005/08/30 18:27:17 helly Exp $ */
#ifndef ZEND_COMPILE_H
#define ZEND_COMPILE_H
@@ -238,6 +238,7 @@
/* END of common elements */
void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
+ struct _zend_module_entry *module;
} zend_internal_function;
#define ZEND_FN_SCOPE_NAME(function) ((function) && (function)->common.scope ?
(function)->common.scope->name : EMPTY_STR)
http://cvs.php.net/diff.php/ZendEngine2/zend_object_handlers.c?r1=1.144&r2=1.145&ty=u
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.144 ZendEngine2/zend_object_handlers.c:1.145
--- ZendEngine2/zend_object_handlers.c:1.144 Fri Aug 19 18:33:39 2005
+++ ZendEngine2/zend_object_handlers.c Tue Aug 30 14:27:17 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_object_handlers.c,v 1.144 2005/08/19 22:33:39 andrei Exp $ */
+/* $Id: zend_object_handlers.c,v 1.145 2005/08/30 18:27:17 helly Exp $ */
#include "zend.h"
#include "zend_globals.h"
@@ -716,6 +716,7 @@
if (zobj->ce->__call) {
zend_internal_function *call_user_call = emalloc(sizeof(zend_internal_function));
call_user_call->type = ZEND_INTERNAL_FUNCTION;
+ call_user_call->module = zobj->ce->module;
call_user_call->handler = zend_std_call_user_call;
call_user_call->arg_info = NULL;
call_user_call->num_args = 0;
http://cvs.php.net/diff.php/ZendEngine2/zend_reflection_api.c?r1=1.175&r2=1.176&ty=u
Index: ZendEngine2/zend_reflection_api.c
diff -u ZendEngine2/zend_reflection_api.c:1.175 ZendEngine2/zend_reflection_api.c:1.176
--- ZendEngine2/zend_reflection_api.c:1.175 Tue Aug 30 03:27:06 2005
+++ ZendEngine2/zend_reflection_api.c Tue Aug 30 14:27:17 2005
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_reflection_api.c,v 1.175 2005/08/30 07:27:06 helly Exp $ */
+/* $Id: zend_reflection_api.c,v 1.176 2005/08/30 18:27:17 helly Exp $ */
#include "zend.h"
#include "zend_API.h"
#include "zend_exceptions.h"
@@ -648,7 +648,13 @@
}
string_printf(str, fptr->common.scope ? "%sMethod [ " : "%sFunction [ ",
indent);
- string_printf(str, (fptr->type == ZEND_USER_FUNCTION) ? "<user> " :
"<internal> ");
+ string_printf(str, (fptr->type == ZEND_USER_FUNCTION) ? "<user" :
"<internal");
+ if (fptr->type == ZEND_INTERNAL_FUNCTION && ((zend_internal_function*)fptr)->module)
{
+ string_printf(str, ":%s", ((zend_internal_function*)fptr)->module->name);
+ }
+ string_printf(str, "> ");
+
+
if (fptr->common.fn_flags & ZEND_ACC_CTOR) {
string_printf(str, "<ctor> ");
}
@@ -1552,7 +1558,7 @@
}
/* }}} */
-/* {{{ proto public ReflectionParameter[] Reflection_Function::getParameters()
+/* {{{ proto public ReflectionParameter[] ReflectionFunction::getParameters()
Returns an array of parameter objects for this function */
ZEND_METHOD(reflection_function, getParameters)
{
@@ -1579,6 +1585,54 @@
}
/* }}} */
+/* {{{ proto public ReflectionExtension|NULL ReflectionFunction::getExtension()
+ Returns NULL or the extension the function belongs to */
+ZEND_METHOD(reflection_function, getExtension)
+{
+ reflection_object *intern;
+ zend_function *fptr;
+ zend_internal_function *internal;
+
+ METHOD_NOTSTATIC;
+ GET_REFLECTION_OBJECT_PTR(fptr);
+
+ if (fptr->type != ZEND_INTERNAL_FUNCTION) {
+ RETURN_NULL();
+ }
+
+ internal = (zend_internal_function *)fptr;
+ if (internal->module) {
+ reflection_extension_factory(return_value, internal->module->name TSRMLS_CC);
+ } else {
+ RETURN_NULL();
+ }
+}
+/* }}} */
+
+/* {{{ proto public string|false ReflectionFunction::getExtensionName()
+ Returns false or the name of the extension the function belongs to */
+ZEND_METHOD(reflection_function, getExtensionName)
+{
+ reflection_object *intern;
+ zend_function *fptr;
+ zend_internal_function *internal;
+
+ METHOD_NOTSTATIC;
+ GET_REFLECTION_OBJECT_PTR(fptr);
+
+ if (fptr->type != ZEND_INTERNAL_FUNCTION) {
+ RETURN_FALSE;
+ }
+
+ internal = (zend_internal_function *)fptr;
+ if (internal->module) {
+ RETURN_STRING(internal->module->name, 1);
+ } else {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
/* {{{ proto public static mixed ReflectionParameter::export(mixed function, mixed parameter [,
bool return]) throws ReflectionException
Exports a reflection object. Returns the output if TRUE is specified for return, printing it
otherwise. */
ZEND_METHOD(reflection_parameter, export)
@@ -3850,6 +3904,8 @@
ZEND_ME(reflection_function, getParameters, NULL, 0)
ZEND_ME(reflection_function, getNumberOfParameters, NULL, 0)
ZEND_ME(reflection_function, getNumberOfRequiredParameters, NULL, 0)
+ ZEND_ME(reflection_function, getExtension, NULL, 0)
+ ZEND_ME(reflection_function, getExtensionName, NULL, 0)
{NULL, NULL, NULL}
};