/* {{{ php_foreach_all */ static int php_foreach_all (int instatus, char *inkey, int inkeylen, char *inval, int invallen, char *indata) { int is_stop = 0; zval *args; zval *retval; TSRMLS_FETCH(); MAKE_STD_ZVAL(args); array_init(args); add_index_long(args, 0, instatus); add_index_stringl(args, 1, inkey, inkeylen, 1); add_index_stringl(args, 2, inval, invallen, 1); php_yp_all_callback *cb = (php_yp_all_callback *) indata; zend_fcall_info_args(&cb->fci, args TSRMLS_CC); zend_fcall_info_call(&cb->fci, &cb->fcc, &retval, args TSRMLS_CC); zend_fcall_info_args_clear(&cb->fci, 1); if (retval) { is_stop = zval_is_true(retval); zval_ptr_dtor(&retval); } return is_stop; }
static PHP_METHOD(swoole_coroutine_util, call_user_func_array) { zval *params; zend_fcall_info fci; zend_fcall_info_cache fci_cache; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "fa/",&fci, &fci_cache, ¶ms) == FAILURE) { return; } zend_fcall_info_args(&fci, params TSRMLS_CC); swoole_corountine_call_function(&fci, &fci_cache, return_value_ptr, 1, return_value_used); RETURN_FALSE; }
static PHP_METHOD(swoole_coroutine_util, call_user_func_array) { zval *params; zend_fcall_info fci; zend_fcall_info_cache fci_cache; ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_FUNC(fci, fci_cache) Z_PARAM_ARRAY_EX(params, 0, 1) ZEND_PARSE_PARAMETERS_END(); zend_fcall_info_args(&fci, params); fci.retval = (execute_data->prev_execute_data->opline->result_type != IS_UNUSED) ? return_value : NULL; swoole_corountine_call_function(&fci, &fci_cache, 1); zend_fcall_info_args_clear(&fci, 1); }
static inline int phpdbg_call_register(phpdbg_param_t *stack) /* {{{ */ { phpdbg_param_t *name = NULL; if (stack->type == STACK_PARAM) { char *lc_name; name = stack->next; if (!name || name->type != STR_PARAM) { return FAILURE; } lc_name = zend_str_tolower_dup(name->str, name->len); if (zend_hash_str_exists(&PHPDBG_G(registered), lc_name, name->len)) { zval fretval; zend_fcall_info fci; memset(&fci, 0, sizeof(zend_fcall_info)); ZVAL_STRINGL(&fci.function_name, lc_name, name->len); fci.size = sizeof(zend_fcall_info); fci.function_table = &PHPDBG_G(registered); fci.symbol_table = zend_rebuild_symbol_table(); fci.object = NULL; fci.retval = &fretval; fci.no_separation = 1; if (name->next) { zval params; phpdbg_param_t *next = name->next; array_init(¶ms); while (next) { char *buffered = NULL; switch (next->type) { case OP_PARAM: case COND_PARAM: case STR_PARAM: add_next_index_stringl(¶ms, next->str, next->len); break; case NUMERIC_PARAM: add_next_index_long(¶ms, next->num); break; case METHOD_PARAM: spprintf(&buffered, 0, "%s::%s", next->method.class, next->method.name); add_next_index_string(¶ms, buffered); break; case NUMERIC_METHOD_PARAM: spprintf(&buffered, 0, "%s::%s#%ld", next->method.class, next->method.name, next->num); add_next_index_string(¶ms, buffered); break; case NUMERIC_FUNCTION_PARAM: spprintf(&buffered, 0, "%s#%ld", next->str, next->num); add_next_index_string(¶ms, buffered); break; case FILE_PARAM: spprintf(&buffered, 0, "%s:%ld", next->file.name, next->file.line); add_next_index_string(¶ms, buffered); break; case NUMERIC_FILE_PARAM: spprintf(&buffered, 0, "%s:#%ld", next->file.name, next->file.line); add_next_index_string(¶ms, buffered); break; default: { /* not yet */ } } next = next->next; } zend_fcall_info_args(&fci, ¶ms); } else {
static void php_midgard_closure_default_marshal(GClosure *closure, GValue *return_value, guint n_param_values, const GValue *param_values, gpointer invocation_hint, gpointer marshal_data) { php_mgd_closure *mgdclosure = (php_mgd_closure *) closure; TSRMLS_FETCH(); if (MGDG(can_deliver_signals) == 0) return; // engine is not in sane state if (MGDG(midgard_memory_debug)) { printf("[%p] php_midgard_closure_default_marshal(args = %p)\n", closure, mgdclosure->args); } zval *params = NULL; MAKE_STD_ZVAL(params); array_init(params); // "10000" on next line is a HACK. Just took a number which is slightly above normal, but still doesn't look like invalid if (mgdclosure->zobject != NULL && Z_REFCOUNT_P(mgdclosure->zobject) < 10000) { if (MGDG(midgard_memory_debug)) { printf("[%p] ---> zobject (%p) refcount = %d\n", closure, mgdclosure->zobject, Z_REFCOUNT_P(mgdclosure->zobject)); } Z_ADDREF_P(mgdclosure->zobject); zend_hash_next_index_insert(Z_ARRVAL_P(params), &(mgdclosure->zobject), sizeof(zval *), NULL); } else { zval *dummy = NULL; MAKE_STD_ZVAL(dummy); ZVAL_NULL(dummy); zend_hash_next_index_insert(Z_ARRVAL_P(params), &dummy, sizeof(zval *), NULL); } if (mgdclosure->args != NULL) { // + params HashTable *args_hash = Z_ARRVAL_P(mgdclosure->args); zend_uint argc = 1 + zend_hash_num_elements(args_hash); zend_hash_internal_pointer_reset(args_hash); size_t i; for (i = 1; i < argc; i++) { zval **ptr; zend_hash_get_current_data(args_hash, (void **)&ptr); zend_hash_move_forward(args_hash); if (MGDG(midgard_memory_debug)) { printf("[%p] ----> got ptr = %p, *ptr = %p [refcount = %d]\n", closure, ptr, *ptr, Z_REFCOUNT_P(*ptr)); } Z_ADDREF_PP(ptr); zend_hash_next_index_insert(Z_ARRVAL_P(params), ptr, sizeof(zval *), NULL); } } zval *retval = NULL; zend_fcall_info_args(&(mgdclosure->fci), params TSRMLS_CC); mgdclosure->fci.retval_ptr_ptr = &retval; zend_call_function(&(mgdclosure->fci), &(mgdclosure->fci_cache) TSRMLS_CC); zend_fcall_info_args_clear(&(mgdclosure->fci), 1); if (retval) zval_ptr_dtor(&retval); zval_ptr_dtor(¶ms); }