Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_closures.c zend_closures.h /tests closure_022.phpt
[email protected] (Dmitry Stogov)
| Newsgroups | php.zend-engine.cvs |
|---|---|
| Message-ID | <[email protected]> |
Must be fixed now.
Thanks. Dmitry.
Felipe Pena wrote:
> Hi Dmitry, Marcus,
>
> I think that we need keep the E_ERROR here. See that:
>
>
> function foo($errno, $errstr, $errfile, $errline) { }
> set_error_handler('foo');
>
> $x = function() {};
> print $x->a;
>
>
> 2008/8/11 Marcus Boerger <[email protected]>:
>> Hello Dmitry,
>>
>> oh shit, you were faster than I :-)
>>
>> I am still working on fixing the Reflection leaks of the 2nd part of this
>> and will be submitting somewhen today. Thanks for submitting this part
>> already anyway.
>>
>> marcus
>>
>> Monday, August 11, 2008, 10:49:14 AM, you wrote:
>>
>>> dmitry Mon Aug 11 08:49:14 2008 UTC
>>> Modified files:
>>> /ZendEngine2 zend_closures.c zend_closures.h
>>> /ZendEngine2/tests closure_022.phpt
>>> Log:
>>> - Made closures implementation reflection friendly (Christian)
>>> - Changed E_ERROR(s) into E_RECOVERABLE_ERROR(s) (Marcus)
>>>
>>>
>>> http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_closures.c?r1=1.11&r2=1.12&diff_format=u
>>> Index: ZendEngine2/zend_closures.c
>>> diff -u ZendEngine2/zend_closures.c:1.11 ZendEngine2/zend_closures.c:1.12
>>> --- ZendEngine2/zend_closures.c:1.11 Thu Aug 7 13:36:13 2008
>>> +++ ZendEngine2/zend_closures.c Mon Aug 11 08:49:14 2008
>>> @@ -17,7 +17,7 @@
>>>
>>> +----------------------------------------------------------------------+
>>> */
>>>
>>> -/* $Id: zend_closures.c,v 1.11 2008/08/07 13:36:13 dmitry Exp $ */
>>> +/* $Id: zend_closures.c,v 1.12 2008/08/11 08:49:14 dmitry Exp $ */
>>>
>>> #include "zend.h"
>>> #include "zend_API.h"
>>> @@ -26,11 +26,10 @@
>>> #include "zend_objects_API.h"
>>> #include "zend_globals.h"
>>>
>>> -#define ZEND_INVOKE_FUNC_NAME "__invoke"
>>> #define ZEND_CLOSURE_PRINT_NAME "Closure object"
>>>
>>> #define ZEND_CLOSURE_PROPERTY_ERROR() \
>>> - zend_error(E_ERROR, "Closure object cannot have properties")
>>> + zend_error(E_RECOVERABLE_ERROR, "Closure object cannot have properties")
>>>
>>> typedef struct _zend_closure {
>>> zend_object std;
>>> @@ -38,7 +37,7 @@
>>> zval *this_ptr;
>>> } zend_closure;
>>>
>>> -static zend_class_entry *zend_ce_closure;
>>> +ZEND_API zend_class_entry *zend_ce_closure;
>>> static zend_object_handlers closure_handlers;
>>>
>>> ZEND_METHOD(Closure, __invoke) /* {{{ */
>>> @@ -50,7 +49,7 @@
>>> arguments = emalloc(sizeof(zval**) * ZEND_NUM_ARGS());
>>> if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), arguments) == FAILURE) {
>>> efree(arguments);
>>> - zend_error(E_ERROR, "Cannot get arguments for calling closure");
>>> + zend_error(E_RECOVERABLE_ERROR, "Cannot get arguments for calling closure");
>>> RETVAL_FALSE;
>>> } else if (call_user_function_ex(CG(function_table), NULL,
>>> this_ptr, &closure_result_ptr, ZEND_NUM_ARGS(), arguments, 1, NULL TSRMLS_CC) == FAILURE) {
>>> RETVAL_FALSE;
>>> @@ -74,21 +73,21 @@
>>>
>>> static zend_function *zend_closure_get_constructor(zval *object TSRMLS_DC) /* {{{ */
>>> {
>>> - zend_error(E_ERROR, "Instantiation of 'Closure' is not allowed");
>>> + zend_error(E_RECOVERABLE_ERROR, "Instantiation of 'Closure' is not allowed");
>>> return NULL;
>>> }
>>> /* }}} */
>>>
>>> static int zend_closure_serialize(zval *object, int *type, zstr
>>> *buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC) /* {{{ */
>>> {
>>> - zend_error(E_ERROR, "Serialization of 'Closure' is not allowed");
>>> + zend_error(E_RECOVERABLE_ERROR, "Serialization of 'Closure' is not allowed");
>>> return FAILURE;
>>> }
>>> /* }}} */
>>>
>>> static int zend_closure_unserialize(zval **object, zend_class_entry
>>> *ce, int type, const zstr buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC) /* {{{ */
>>> {
>>> - zend_error(E_ERROR, "Unserialization of 'Closure' is not allowed");
>>> + zend_error(E_RECOVERABLE_ERROR, "Unserialization of 'Closure' is not allowed");
>>> return FAILURE;
>>> }
>>> /* }}} */
>>> @@ -99,6 +98,26 @@
>>> }
>>> /* }}} */
>>>
>>> +ZEND_API zend_function *zend_get_closure_invoke_method(zval *obj TSRMLS_DC) /* {{{ */
>>> +{
>>> + zend_closure *closure = (zend_closure
>>> *)zend_object_store_get_object(obj TSRMLS_CC);
>>> + zend_function *invoke =
>>> (zend_function*)emalloc(sizeof(zend_function));
>>> +
>>> + invoke->common = closure->func.common;
>>> + invoke->type = ZEND_INTERNAL_FUNCTION;
>>> + invoke->internal_function.fn_flags = ZEND_ACC_PUBLIC | ZEND_ACC_CALL_VIA_HANDLER;
>>> + invoke->internal_function.handler = ZEND_MN(Closure___invoke);
>>> + invoke->internal_function.module = 0;
>>> + invoke->internal_function.scope = zend_ce_closure;
>>> + if (UG(unicode)) {
>>> + invoke->internal_function.function_name.u = USTR_MAKE(ZEND_INVOKE_FUNC_NAME);
>>> + } else {
>>> + invoke->internal_function.function_name.s =
>>> estrndup(ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1);
>>> + }
>>> + return invoke;
>>> +}
>>> +/* }}} */
>>> +
>>> static zend_function *zend_closure_get_method(zval **object_ptr, zstr
>>> method_name, int method_len TSRMLS_DC) /* {{{ */
>>> {
>>> unsigned int lc_name_len;
>>> @@ -110,22 +129,8 @@
>>> if ((lc_name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) &&
>>> (ZEND_U_EQUAL(type, lc_name, lc_name_len,
>>> ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1))
>>> ) {
>>> - zend_closure *closure = (zend_closure
>>> *)zend_object_store_get_object(*object_ptr TSRMLS_CC);
>>> - zend_function *invoke =
>>> (zend_function*)emalloc(sizeof(zend_function));
>>> -
>>> - invoke->common = closure->func.common;
>>> - invoke->type = ZEND_INTERNAL_FUNCTION;
>>> - invoke->internal_function.fn_flags = ZEND_ACC_CALL_VIA_HANDLER;
>>> - invoke->internal_function.handler = ZEND_MN(Closure___invoke);
>>> - invoke->internal_function.module = 0;
>>> - invoke->internal_function.scope = zend_ce_closure;
>>> - if (UG(unicode)) {
>>> - invoke->internal_function.function_name.u = USTR_MAKE(ZEND_INVOKE_FUNC_NAME);
>>> - } else {
>>> - invoke->internal_function.function_name.s =
>>> estrndup(ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1);
>>> - }
>>> efree(lc_name.v);
>>> - return invoke;
>>> + return zend_get_closure_invoke_method(*object_ptr TSRMLS_CC);
>>> }
>>> efree(lc_name.v);
>>> return NULL;
>>> http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_closures.h?r1=1.1&r2=1.2&diff_format=u
>>> Index: ZendEngine2/zend_closures.h
>>> diff -u ZendEngine2/zend_closures.h:1.1 ZendEngine2/zend_closures.h:1.2
>>> --- ZendEngine2/zend_closures.h:1.1 Tue Jul 8 07:05:03 2008
>>> +++ ZendEngine2/zend_closures.h Mon Aug 11 08:49:14 2008
>>> @@ -17,17 +17,22 @@
>>>
>>> +----------------------------------------------------------------------+
>>> */
>>>
>>> -/* $Id: zend_closures.h,v 1.1 2008/07/08 07:05:03 dmitry Exp $ */
>>> +/* $Id: zend_closures.h,v 1.2 2008/08/11 08:49:14 dmitry Exp $ */
>>>
>>> #ifndef ZEND_CLOSURES_H
>>> #define ZEND_CLOSURES_H
>>>
>>> BEGIN_EXTERN_C()
>>>
>>> +#define ZEND_INVOKE_FUNC_NAME "__invoke"
>>> +
>>> void zend_register_closure_ce(TSRMLS_D);
>>>
>>> +extern ZEND_API zend_class_entry *zend_ce_closure;
>>> +
>>> ZEND_API void zend_create_closure(zval *res, zend_function *op_array,
>>> zend_class_entry *scope, zval *this_ptr TSRMLS_DC);
>>> ZEND_API int zend_get_closure(zval *obj, zend_class_entry **ce_ptr,
>>> zend_function **fptr_ptr, zval **zobj_ptr, zval ***zobj_ptr_ptr TSRMLS_DC);
>>> +ZEND_API zend_function *zend_get_closure_invoke_method(zval *obj TSRMLS_DC);
>>>
>>> END_EXTERN_C()
>>>
>>> http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/closure_022.phpt?r1=1.1&r2=1.2&diff_format=u
>>> Index: ZendEngine2/tests/closure_022.phpt
>>> diff -u ZendEngine2/tests/closure_022.phpt:1.1
>>> ZendEngine2/tests/closure_022.phpt:1.2
>>> --- ZendEngine2/tests/closure_022.phpt:1.1 Tue Jul 22 07:29:14 2008
>>> +++ ZendEngine2/tests/closure_022.phpt Mon Aug 11 08:49:14 2008
>>> @@ -8,5 +8,5 @@
>>> $foo->a = 1;
>>> ?>
>>> --EXPECTF--
>>> -Fatal error: Closure object cannot have properties in %sclosure_022.php on line 5
>>> +Catchable fatal error: Closure object cannot have properties in %sclosure_022.php on line 5
>>>
>>
>>
>>
>>
>>
>> Best regards,
>> Marcus
>>
>>
>> --
>> Zend Engine CVS Mailing List (http://cvs.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
>