Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33692 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15087 invoked by uid 1010); 4 Dec 2007 21:05:22 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 14949 invoked from network); 4 Dec 2007 21:05:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Dec 2007 21:05:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=sam@sambarrow.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sam@sambarrow.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain sambarrow.com from 205.234.132.11 cause and error) X-PHP-List-Original-Sender: sam@sambarrow.com X-Host-Fingerprint: 205.234.132.11 scottsdale.servershost.net Received: from [205.234.132.11] ([205.234.132.11:51717] helo=scottsdale.servershost.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 21/E8-47601-F6AB5574 for ; Tue, 04 Dec 2007 15:37:04 -0500 Received: from [65.207.49.92] (port=46925) by scottsdale.servershost.net with esmtpsa (SSLv3:RC4-MD5:128) (Exim 4.68) (envelope-from ) id 1IzeVs-0001Bi-1u; Tue, 04 Dec 2007 14:37:04 -0600 To: Gregory Beaver Cc: internals Mailing List In-Reply-To: <47559876.3060803@chiaraquartet.net> References: <47559876.3060803@chiaraquartet.net> Content-Type: text/plain Date: Tue, 04 Dec 2007 15:32:44 -0500 Message-ID: <1196800364.4360.2.camel@sbarrow-desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-Antivirus-Scanner: Clean mail though you should still use an Antivirus X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - scottsdale.servershost.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - sambarrow.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] multiple namespace per file patch From: sam@sambarrow.com (Sam Barrow) I support this patch 100%. I have a large application I'm rewriting to include namespaces, however now I can no longer use my script caching functionality (which improved performance literally about 500%) that compiled all of my includes into one file, because many of the files have namespaces. On Tue, 2007-12-04 at 12:12 -0600, Gregory Beaver wrote: > Hi, > > There's been enough confusion, here's the patch again, this time against > 5.3, no tests for clarity > > http://pear.php.net/~greg/multi.5.3.patch.txt > > This patch allows: > > namespace A; > class a {} > namespace B; > class a {} > namespace A; > import B::a as b; > class c extends b; > ?> > > It doesn't allow: > $anycode = 1; > namespace A; > ?> > > so all code must have a namespace declaration. The sole purpose is to > combine files containing namespace declarations. > > Greg > plain text document attachment (multi.5.3.patch.txt) > Index: Zend/zend_compile.c > =================================================================== > RCS file: /repository/ZendEngine2/zend_compile.c,v > retrieving revision 1.647.2.27.2.41.2.28 > diff -u -r1.647.2.27.2.41.2.28 zend_compile.c > --- Zend/zend_compile.c 4 Dec 2007 12:38:42 -0000 1.647.2.27.2.41.2.28 > +++ Zend/zend_compile.c 4 Dec 2007 17:24:34 -0000 > @@ -4722,13 +4722,10 @@ > CG(active_op_array)->opcodes[num-1].opcode == ZEND_TICKS)) { > --num; > } > - if (num > 0) { > + if (!CG(current_namespace) && num > 0) { > zend_error(E_COMPILE_ERROR, "Namespace declaration statement has to be the very first statement in the script"); > } > } > - if (CG(current_namespace)) { > - zend_error(E_COMPILE_ERROR, "Namespace cannot be declared twice"); > - } > lcname = zend_str_tolower_dup(Z_STRVAL(name->u.constant), Z_STRLEN(name->u.constant)); > if (((Z_STRLEN(name->u.constant) == sizeof("self")-1) && > !memcmp(lcname, "self", sizeof("self")-1)) || > @@ -4738,6 +4735,16 @@ > } > efree(lcname); > > + if (CG(current_namespace)) { > + zval_dtor(CG(current_namespace)); > + efree(CG(current_namespace)); > + } > + if (CG(current_import)) { > + zend_hash_destroy(CG(current_import)); > + efree(CG(current_import)); > + } > + CG(current_import) = NULL; > + > ALLOC_ZVAL(CG(current_namespace)); > *CG(current_namespace) = name->u.constant; > } > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php