zval *dim = spl_get_zval_ptr(op2, Ts, &EG(free_op2) TSRMLS_CC);
zval *exists;
- spl_begin_method_call_arg_ex1(obj, obj_ce, NULL, "exists", sizeof("exists")-1, &exists, dim);
+ spl_call_method_1(obj, obj_ce, NULL, "exists", sizeof("exists")-1, &exists, dim);
if (!i_zend_is_true(exists)) {
if (type == BP_VAR_R || type == BP_VAR_RW) {
SEPARATE_ZVAL(&dim);
}
DELETE_RET_ZVAL(exists);
if (type == BP_VAR_R || type == BP_VAR_IS) {
- spl_begin_method_call_arg_ex1(obj, obj_ce, NULL, "get", sizeof("get")-1, retval, dim);
+ spl_call_method_1(obj, obj_ce, NULL, "get", sizeof("get")-1, retval, dim);
}
FREE_OP(Ts, op2, EG(free_op2));
return 0;
value->refcount = 0;
}
- spl_begin_method_call_arg_ex2(obj, obj_ce, NULL, "set", sizeof("set")-1, &retval, index, value);
+ spl_call_method_2(obj, obj_ce, NULL, "set", sizeof("set")-1, &retval, index, value);
if (index == &tmp) {
zval_dtor(index);
break;
}
- spl_begin_method_call_arg_ex1(obj, obj_ce, NULL, "del", sizeof("del")-1, &retval, index);
+ spl_call_method_1(obj, obj_ce, NULL, "del", sizeof("del")-1, &retval, index);
if (index == &tmp) {
zval_dtor(index);
int result;
zend_fcall_info fci;
zval z_fname;
+ zval *retval;
zval **params[2];
/*fci.function_table = NULL; will be read form zend_class_entry of object if needed */
fci.object_pp = object_pp;
fci.function_name = &z_fname;
- fci.retval_ptr_ptr = retval_ptr;
+ fci.retval_ptr_ptr = retval_ptr ? retval_ptr : &retval;
fci.param_count = param_count;
fci.params = params;
fci.no_separation = 1;
result = zend_call_function(&fci, &fcic TSRMLS_CC);
}
}
+ if (!retval_ptr && fci.retval_ptr_ptr) {
+ zval_dtor(*fci.retval_ptr_ptr);
+ FREE_ZVAL(*fci.retval_ptr_ptr);
+ }
return result;
}
/* }}} */
}
/* }}} */
-/* {{{ spl_begin_method_call_arg */
-static inline int spl_begin_method_call_arg(zval **obj, zend_class_entry *obj_ce, zend_function **fn_proxy, char *function_name, int fname_len, zval *retval, zval *arg1 TSRMLS_DC)
-{
- zval *local_retval;
- int ret = spl_call_method(obj, obj_ce, fn_proxy, function_name, fname_len, &local_retval, 1, arg1, NULL TSRMLS_CC);
- if (local_retval) {
- COPY_PZVAL_TO_ZVAL(*retval, local_retval);
- } else {
- INIT_ZVAL(*retval);
- }
- return ret;
-}
-/* }}} */
-
-/* {{{ spl_begin_method_call_no_retval */
-static inline int spl_begin_method_call_no_retval(zval **obj, zend_class_entry *obj_ce, zend_function **fn_proxy, char *function_name, int fname_len TSRMLS_DC)
-{
- zval *retval;
- int ret = spl_call_method(obj, obj_ce, fn_proxy, function_name, fname_len, &retval, 0, NULL, NULL TSRMLS_CC);
- if (retval) {
- zval_dtor(retval);
- FREE_ZVAL(retval);
- }
- return ret;
-}
-/* }}} */
-
-#define spl_begin_method_call_ex(obj, obj_ce, fn_proxy, function_name, fname_len, retval) \
+#define spl_call_method_0(obj, obj_ce, fn_proxy, function_name, fname_len, retval) \
spl_call_method(obj, obj_ce, fn_proxy, function_name, fname_len, retval, 0, NULL, NULL TSRMLS_CC)
-#define spl_begin_method_call_arg_ex1(obj, obj_ce, fn_proxy, function_name, fname_len, retval, arg1) \
+#define spl_call_method_1(obj, obj_ce, fn_proxy, function_name, fname_len, retval, arg1) \
spl_call_method(obj, obj_ce, fn_proxy, function_name, fname_len, retval, 1, arg1, NULL TSRMLS_CC)
-#define spl_begin_method_call_arg_ex2(obj, obj_ce, fn_proxy, function_name, fname_len, retval, arg1, arg2) \
+#define spl_call_method_2(obj, obj_ce, fn_proxy, function_name, fname_len, retval, arg1, arg2) \
spl_call_method(obj, obj_ce, fn_proxy, function_name, fname_len, retval, 2, arg1, arg2 TSRMLS_CC)
void spl_instanciate(zend_class_entry *pce, zval **object TSRMLS_DC);
if (is_a & SPL_IS_A_ITERATOR) {
spl_unlock_zval_ptr_ptr(&EX(opline)->op1, EX(Ts) TSRMLS_CC);
obj_ce = instance_ce;
- spl_begin_method_call_ex(obj, obj_ce, NULL, "new_iterator", sizeof("new_iterator")-1, &retval);
+ spl_call_method_0(obj, obj_ce, NULL, "new_iterator", sizeof("new_iterator")-1, &retval);
instance_ce = spl_get_class_entry(retval TSRMLS_CC);
is_a = spl_implements(instance_ce);
if (!(is_a & SPL_IS_A_FORWARD)) {
obj = &proxy->obj; /* will be optimized out */
if (proxy->index++) {
- spl_begin_method_call_no_retval(obj, proxy->obj_ce, &proxy->funcs.next, "next", sizeof("next")-1 TSRMLS_CC);
+ spl_call_method_0(obj, proxy->obj_ce, &proxy->funcs.next, "next", sizeof("next")-1, NULL);
} else {
if (proxy->is_a & SPL_IS_A_SEQUENCE) {
- spl_begin_method_call_no_retval(obj, proxy->obj_ce, &proxy->funcs.rewind, "rewind", sizeof("rewind")-1 TSRMLS_CC);
+ spl_call_method_0(obj, proxy->obj_ce, &proxy->funcs.rewind, "rewind", sizeof("rewind")-1, NULL);
}
/* now this is an optimization trick:
ZEND_SWITCH_FREE receives the array copy or the spl object in op1 and has an unused op2
op_array->opcodes[EX(opline)->op2.u.opline_num].op2 = *op1;
}
- spl_begin_method_call_ex(obj, proxy->obj_ce, &proxy->funcs.more, "has_more", sizeof("has_more")-1, &more);
+ spl_call_method_0(obj, proxy->obj_ce, &proxy->funcs.more, "has_more", sizeof("has_more")-1, &more);
if (!more->type == IS_BOOL && !more->type == IS_LONG) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Method %s::has_more implements spl_forward::has_more and should return a value of type boolean or int");
convert_to_boolean(more);
FREE_ZVAL(more);
result = &EX_T(EX(opline)->result.u.var).tmp_var;
- spl_begin_method_call_ex(obj, proxy->obj_ce, &proxy->funcs.current, "current", sizeof("current")-1, &value);
+ spl_call_method_0(obj, proxy->obj_ce, &proxy->funcs.current, "current", sizeof("current")-1, &value);
if (proxy->is_a & SPL_IS_A_ASSOC) {
- spl_begin_method_call_ex(obj, proxy->obj_ce, &proxy->funcs.key, "key", sizeof("key")-1, &key);
+ spl_call_method_0(obj, proxy->obj_ce, &proxy->funcs.key, "key", sizeof("key")-1, &key);
} else {
MAKE_STD_ZVAL(key);
key->value.lval = proxy->index;