Re: Bison 3 support for PHP 5.5
| From: | Jakub Zelenka | Date: | Fri, 23 May 2014 18:48:14 +0000 |
| Subject: | Re: Bison 3 support for PHP 5.5 | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-74469@lists.php.net to get a copy of this message | ||
On Fri, May 23, 2014 at 6:46 AM, Stas Malyshev <smalyshev@sugarcrm.com>wrote:
> Hi!
>
> > So instead, I created the TSRMLS_DN and TSRMLS_CN macros which, in
> > the ZTS case, work like TSRMLS_D/TSRMLS_C, but when ZTS is off, still
> > resolve to a parameter (that must always be present), which is passed
> > NULL.
>
> I don't think it is a very good idea to add extra parameter that does
> nothing to every function. There should be a better solution to this.
>
>
I agree with Stas that the way how it's done at the moment is pretty ugly.
I was dealing with similar problem in jsond parser (
https://github.com/bukka/php-jsond/blob/master/jsond_parser.y
) where I
decided to use a structure (php_json_parser) for general parser info as
well as scanner data and TSRMLS if ZTS defined. It means that data from the
scanner are passed to the parser through that structure instead of using
global variable (that's the way how it's done in PHP). tsrm_ls can be set
using TSRMLS_SET_CTX fetched from that structure TSRMLS_FETCH_FROM_CTX.
So to sum it up... I think that a better solution would be using a
structure that would contain scanner data (_zend_php_scanner_globals ) and
TSRMLS if ZTS defined. It would be a cleaner solution IMHO. It could also
allow some optimization for the compiler as local variables might be saved
in registers (not sure about this one... :) ).
However this is probaly more something for phpng as it requires a bit more
changes... :)
Jakub