Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22103 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61553 invoked by uid 1010); 3 Mar 2006 22:30:36 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 61538 invoked from network); 3 Mar 2006 22:30:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Mar 2006 22:30:36 -0000 X-Host-Fingerprint: 212.227.48.61 mayflowerholding.com Linux 2.5 (sometimes 2.4) (4) Received: from ([212.227.48.61:55730] helo=s15175637.rootmaster.info) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id B1/E1-35203-A83C8044 for ; Fri, 03 Mar 2006 17:30:34 -0500 Received: (qmail 5816 invoked by uid 2520); 3 Mar 2006 23:30:30 +0100 Received: from 82.135.93.14 by s15175637 (envelope-from , uid 2020) with qmail-scanner-1.25st (uvscan: v4.4.00/v4705. spamassassin: 3.0.3. perlscan: 1.25st. Clear:RC:0(82.135.93.14):SA:0(-0.6/7.0):. Processed in 2.304816 secs); 03 Mar 2006 22:30:30 -0000 X-Spam-Status: No, hits=-0.6 required=7.0 Received: from ppp-82-135-93-14.mnet-online.de (HELO ?192.168.1.102?) (82.135.93.14) by mayflowerholding.com with (DHE-RSA-AES256-SHA encrypted) SMTP; 3 Mar 2006 23:30:28 +0100 To: internals@lists.php.net Date: Fri, 3 Mar 2006 23:30:00 +0100 User-Agent: KMail/1.9.1 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_oNMCEVWEER4th8q" Message-ID: <200603032330.00973.johannes@php.net> Subject: [patch] Separating ZEND_METHOD and ZEND_FUNCTION From: johannes@php.net (Johannes Schlueter) --Boundary-00=_oNMCEVWEER4th8q Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, following a recent discussion on IRC I'd like to propose a little patch separating ZEND_FUNCTION and ZEND_METHOD. Currently functions declared as ZEND_FUNCTION are named zif_exported_name. Class methods are exported as zif_class_method. If you try to create a PHP function called foo_bar but already have some class foo with a method bar this leads to a "redefinition of `zif_foo_bar`". The attached patch solves this kind of issues by prefixing methods with zim_ (with m like in method) instead of zif_. Additionally it might help a bit while debugging since you can see wether you're in some class/object or a function context. As always the patch is also available at my repository on http://svn.schlueters.de/phpatches/HEAD/zend_separate_zend_method.diff johannes --Boundary-00=_oNMCEVWEER4th8q Content-Type: text/x-diff; charset="us-ascii"; name="zend_separate_zend_method.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="zend_separate_zend_method.diff" Index: Zend/zend_API.h =================================================================== RCS file: /repository/ZendEngine2/zend_API.h,v retrieving revision 1.236 diff -u -p -r1.236 zend_API.h --- Zend/zend_API.h 26 Feb 2006 11:57:14 -0000 1.236 +++ Zend/zend_API.h 3 Mar 2006 22:15:24 -0000 @@ -42,9 +42,10 @@ typedef struct _zend_function_entry { } zend_function_entry; #define ZEND_FN(name) zif_##name +#define ZEND_MN(name) zim_##name #define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS) #define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(ZEND_FN(name)) -#define ZEND_METHOD(classname, name) ZEND_NAMED_FUNCTION(ZEND_FN(classname##_##name)) +#define ZEND_METHOD(classname, name) ZEND_NAMED_FUNCTION(ZEND_MN(classname##_##name)) #define ZEND_FENTRY(zend_name, name, arg_info, flags) { #zend_name, name, arg_info, (zend_uint) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags }, @@ -53,10 +54,10 @@ typedef struct _zend_function_entry { #define ZEND_DEP_FE(name, arg_info) ZEND_FENTRY(name, ZEND_FN(name), arg_info, ZEND_ACC_DEPRECATED) #define ZEND_FALIAS(name, alias, arg_info) ZEND_FENTRY(name, ZEND_FN(alias), arg_info, 0) #define ZEND_DEP_FALIAS(name, alias, arg_info) ZEND_FENTRY(name, ZEND_FN(alias), arg_info, ZEND_ACC_DEPRECATED) -#define ZEND_ME(classname, name, arg_info, flags) ZEND_FENTRY(name, ZEND_FN(classname##_##name), arg_info, flags) +#define ZEND_ME(classname, name, arg_info, flags) ZEND_FENTRY(name, ZEND_MN(classname##_##name), arg_info, flags) #define ZEND_ABSTRACT_ME(classname, name, arg_info) ZEND_FENTRY(name, NULL, arg_info, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT) #define ZEND_MALIAS(classname, name, alias, arg_info, flags) \ - ZEND_FENTRY(name, ZEND_FN(classname##_##alias), arg_info, flags) + ZEND_FENTRY(name, ZEND_MN(classname##_##alias), arg_info, flags) #define ZEND_ME_MAPPING(name, func_name, arg_types) ZEND_NAMED_FE(name, ZEND_FN(func_name), arg_types) #define ZEND_ARG_INFO(pass_by_ref, name) { {#name}, sizeof(#name)-1, {NULL}, 0, 0, 0, pass_by_ref, 0, 0 }, --Boundary-00=_oNMCEVWEER4th8q--