com php-src: Fixed and cleaned up implementaton of Closure::call() for phpng: Zend/zend_closures.c Zend/zend_vm_def.h
| From: | Tjerk Anne Meesters | Date: | Sun, 17 Aug 2014 19:20:23 +0000 |
| Subject: | com php-src: Fixed and cleaned up implementaton of Closure::call() for phpng: Zend/zend_closures.c Zend/zend_vm_def.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-81161@lists.php.net to get a copy of this message | ||
Commit: 6d187d53aea6dce936de2fb6e857e9820039dfbe
Author: Andrea Faulds <ajf@ajf.me> Sun, 17 Aug 2014 20:20:23 +0100
Parents: e35c8ae13eb89984bdb889f2dea15fbf2df2d78b
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6d187d53aea6dce936de2fb6e857e9820039dfbe
Log:
Fixed and cleaned up implementaton of Closure::call() for phpng
Changed paths:
M Zend/zend_closures.c
M Zend/zend_vm_def.h
Diff:
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c
index d9d1179..c3e50f2 100644
--- a/Zend/zend_closures..c
+++ b/Zend/zend_closures.c
@@ -74,11 +74,15 @@ ZEND_METHOD(Closure, call) /* {{{ */
zend_closure *closure;
zend_fcall_info fci;
zend_fcall_info_cache fci_cache;
+ char *error;
+ zval *my_params;
+ zend_uint my_param_count = 0;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo*",
&zclosure, zend_ce_closure, &newthis, &fci.params, &fci.param_count) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o*", &newthis, &my_params,
&my_param_count) == FAILURE) {
RETURN_NULL();
}
+ zclosure = getThis();
closure = (zend_closure *)Z_OBJ_P(zclosure);
if (closure->func.common.fn_flags & ZEND_ACC_STATIC) {
@@ -90,33 +94,24 @@ ZEND_METHOD(Closure, call) /* {{{ */
/* verify that we aren't binding internal function to a wrong object */
if((closure->func.common.fn_flags & ZEND_ACC_STATIC) == 0 &&
!instanceof_function(Z_OBJCE_P(newthis), closure->func.common.scope TSRMLS_CC)) {
- zend_error(E_WARNING, "Cannot bind function %s::%s to object of class %s",
closure->func.common.scope->name, closure->func.common.function_name,
Z_OBJCE_P(newthis)->name);
+ zend_error(E_WARNING, "Cannot bind function %s::%s to object of class %s",
closure->func.common.scope->name->val, closure->func.common.function_name->val,
Z_OBJCE_P(newthis)->name->val);
RETURN_NULL();
}
}
- fci.size = sizeof(fci);
- fci.function_table = CG(function_table);
- fci.object = Z_OBJ_P(newthis);
- fci.function_name = *zclosure;
+ if (zend_fcall_info_init(zclosure, 0, &fci, &fci_cache, NULL, NULL TSRMLS_CC) != SUCCESS)
{
+ zend_error(E_ERROR, "Closure not callable");
+ RETURN_NULL();
+ }
+
fci.retval = &closure_result;
- fci.no_separation = 1;
- fci.symbol_table = NULL;
-
+ fci.params = my_params;
+ fci.param_count = my_param_count;
+ fci.object = fci_cache.object = Z_OBJ_P(newthis);
fci_cache.initialized = 1;
- fci_cache.function_handler = &closure->func;
- fci_cache.object = Z_OBJ_P(newthis);
- fci_cache.calling_scope = fci_cache.called_scope = Z_OBJCE_P(newthis);
- if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == FAILURE) {
- RETVAL_FALSE;
- } else {
- zval_ptr_dtor(&return_value);
- *return_value = closure_result;
- }
-
- if (fci.param_count) {
- efree(fci.params);
+ if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS &&
Z_TYPE(closure_result) != IS_UNDEF) {
+ ZVAL_COPY_VALUE(return_value, &closure_result);
}
}
/* }}} */
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 9e91663..c4f962b 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -2646,7 +2646,6 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
zend_error_noreturn(E_ERROR, "Non-static method %s::%s() cannot be called statically",
fbc->common.scope->name->val, fbc->common.function_name->val);
}
}
-}
LOAD_OPLINE();