svn: /pecl/yaf/trunk/ yaf_application.c yaf_application.h

From: Date: Mon, 27 Jun 2011 10:53:54 +0000
Subject: svn: /pecl/yaf/trunk/ yaf_application.c yaf_application.h
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-15900@lists.php.net to get a copy of this message
laruence Mon, 27 Jun 2011 10:53:54 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=312514 Log: Change Yaf_Application::execute to call to call_user_function instead of zif_call_user_func, since zif_call_user function was not declared with dllexport on windows Changed paths: U pecl/yaf/trunk/yaf_application.c U pecl/yaf/trunk/yaf_application.h Modified: pecl/yaf/trunk/yaf_application.c =================================================================== --- pecl/yaf/trunk/yaf_application.c 2011-06-27 10:42:40 UTC (rev 312513) +++ pecl/yaf/trunk/yaf_application.c 2011-06-27 10:53:54 UTC (rev 312514) @@ -10,7 +10,7 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Author: Laruence<laruence@yahoo.com.cn> | + | Author: Xinchen Hui <laruence@php.net> | +----------------------------------------------------------------------+ $Id$ */ @@ -24,6 +24,7 @@ #include "main/SAPI.h" #include "Zend/zend_interfaces.h" #include "ext/standard/php_var.h" +#include "ext/standard/basic_functions.h" #include "php_yaf.h" #include "yaf_namespace.h" @@ -376,9 +377,84 @@ /* }}} */ /** {{{ proto public Yaf_Application::execute(callback $func) + * We can not call to zif_call_user_func on windows, since it was not declared with dllexport */ PHP_METHOD(yaf_application, execute) { - PHP_FN(call_user_func)(INTERNAL_FUNCTION_PARAM_PASSTHRU); +#if ((PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION > 2)) || (PHP_MAJOR_VERSION > 5) + zval *retval_ptr = NULL; + zend_fcall_info fci; + zend_fcall_info_cache fci_cache; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f*", &fci, &fci_cache, &fci.params, &fci.param_count) == FAILURE) { + return; + } + + fci.retval_ptr_ptr = &retval_ptr; + + if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && fci.retval_ptr_ptr && *fci.retval_ptr_ptr) { + COPY_PZVAL_TO_ZVAL(*return_value, *fci.retval_ptr_ptr); + } + + if (fci.params) { + efree(fci.params); + } +#else + zval ***params; + zval *retval_ptr; + char *name; + int argc = ZEND_NUM_ARGS(); + + if (argc < 1) { + WRONG_PARAM_COUNT; + } + + params = safe_emalloc(sizeof(zval **), argc, 0); + + if (zend_get_parameters_array_ex(1, params) == FAILURE) { + efree(params); + RETURN_FALSE; + } + + if (Z_TYPE_PP(params[0]) != IS_STRING && Z_TYPE_PP(params[0]) != IS_ARRAY) { + SEPARATE_ZVAL(params[0]); + convert_to_string_ex(params[0]); + } + + if (!zend_is_callable(*params[0], 0, &name)) { + php_error_docref1(NULL TSRMLS_CC, name, E_WARNING, "First argument is expected to be a valid callback"); + efree(name); + efree(params); + RETURN_NULL(); + } + + if (zend_get_parameters_array_ex(argc, params) == FAILURE) { + efree(params); + RETURN_FALSE; + } + + if (call_user_function_ex(EG(function_table), NULL, *params[0], &retval_ptr, argc-1, params+1, 0, NULL TSRMLS_CC) == SUCCESS) { + if (retval_ptr) { + COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr); + } + } else { + if (argc > 1) { + SEPARATE_ZVAL(params[1]); + convert_to_string_ex(params[1]); + if (argc > 2) { + SEPARATE_ZVAL(params[2]); + convert_to_string_ex(params[2]); + php_error_docref1(NULL TSRMLS_CC, name, E_WARNING, "Unable to call %s(%s,%s)", name, Z_STRVAL_PP(params[1]), Z_STRVAL_PP(params[2])); + } else { + php_error_docref1(NULL TSRMLS_CC, name, E_WARNING, "Unable to call %s(%s)", name, Z_STRVAL_PP(params[1])); + } + } else { + php_error_docref1(NULL TSRMLS_CC, name, E_WARNING, "Unable to call %s()", name); + } + } + + efree(name); + efree(params); +#endif } /* }}} */ Modified: pecl/yaf/trunk/yaf_application.h =================================================================== --- pecl/yaf/trunk/yaf_application.h 2011-06-27 10:42:40 UTC (rev 312513) +++ pecl/yaf/trunk/yaf_application.h 2011-06-27 10:53:54 UTC (rev 312514) @@ -10,7 +10,7 @@ | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Author: Laruence<laruence@yahoo.com.cn> | + | Author: Xinchen Hui <laruence@php.net> | +----------------------------------------------------------------------+ $Id$ */ @@ -28,7 +28,6 @@ extern zend_class_entry *yaf_application_ce; boolean yaf_application_is_module_name(char *name, int len TSRMLS_DC); -PHP_FUNCTION(call_user_func); YAF_STARTUP_FUNCTION(application); #endif

« previous php.pecl.cvs (#15900) next »