首先,我们需要确定一下这个接口的参数是什么,很显然,是一个PHP函数: #include "study_coroutine.h" ZEND_BEGIN_ARG_INFO_EX(arginfo_study_coroutine_create ZEND_END_ARG_INFO展开如下: #define ZEND_END_ARG_INFO() }; 因此,我们对这个参数声明展开后,会得到如下内容: ZEND_BEGIN_ARG_INFO_EX(arginfo_study_coroutine_create ) ZEND_ARG_CALLABLE_INFO(0, func, 0) ZEND_END_ARG_INFO() static const zend_internal_arg_info arginfo_study_coroutine_create , 0, 0, 1) 中写下了单词arginfo、study_coroutine_create,似乎一定是要这样写,但是,我们把ZEND_BEGIN_ARG_INFO_EX宏展开之后会发现,arginfo_study_coroutine_create 所以这里很明显,我们必须填写arginfo_study_coroutine_create,也就是我们参数展开后定义的那个变量。 num_args是接口方法的参数个数。
) 同时我们看到有定义了这么一个数组 const zend_function_entry cesium_functions[] = { PHP_FE(cesium_test1, arginfo_cesium_test1 ) PHP_FE(cesium_test2, arginfo_cesium_test2) PHP_FE_END }; 我们需要将新添加的函数添加到这个数组里。 像这样 const zend_function_entry cesium_functions[] = { PHP_FE(cesium_test1, arginfo_cesium_test1 ) PHP_FE(cesium_test2, arginfo_cesium_test2) PHP_FE(name, NULL) PHP_FE_END
精美礼品等你拿!
"Hello %s", var);//格式化字符串 RETURN_STR(retval);//返回值 } /* }}}*/ 但这样是不够的,我们还需要定义一个函数的参数声明: /* {{{ arginfo */ ZEND_BEGIN_ARG_INFO(arginfo_tioncico_test1, 0)//函数名,参数是否为引用类型,0代表不是 ZEND_END_ARG_INFO()//结束函数参数信息声明 ZEND_BEGIN_ARG_INFO(arginfo_tioncico_test2, 0)//函数名,参数是否为引用类型,0代表不是 ZEND_ARG_INFO(0, str)//声明一个普通参数 tioncico_functions[] */ static const zend_function_entry tioncico_functions[] = { PHP_FE(tioncico_test1, arginfo_tioncico_test1 ) PHP_FE(tioncico_test2, arginfo_tioncico_test2) PHP_FE_END }; 这时候,一个扩展的2个函数已经编写完成了 重新编译运行,
parsekit_compile_file('/var/www/tb.php'));" 3.如果要查看某个函数的opcode 参考 http://www.php.net/manual/zh/function.parsekit-func-arginfo.php php function foo($bar, stdClass $baz, &$bomb, $bling = false) { } var_dump(parsekit_func_arginfo('foo
test.c文件 (主函数文件) 函数声明 static const zend_function_entry test_functions[] = { PHP_FE(test_test1, arginfo_test_test1 ) PHP_FE(test_test2, arginfo_test_test2) PHP_FE(test_add,NULL) //添加函数声明 PHP_FE_END
ZEND_BEGIN_ARG_INFO_EX(arginfo_sendfile, 0, 0, 3) ZEND_ARG_INFO(0, out) ZEND_ARG_INFO(0, in) ZEND_END_ARG_INFO() 还要把函数加到函数实体结构体里面: static const zend_function_entry church_functions[] = { PHP_FE(sendfile, arginfo_sendfile
33cdeccccebe80329f1fdbee7f5874cb(SB) 0x0000 00000 (E:\add.go:3) FUNCDATA $5, "".demo.arginfo1 33cdeccccebe80329f1fdbee7f5874cb(SB) 0x0000 00000 (E:\add.go:3) FUNCDATA $5, "".demo.arginfo1
twose) 修复 Co\Http\Client->setCookies 在特殊情况下的内存错误 (#2644) (@Yurunsoft) 修复#2639 (#2656) (@mabu233) 修复 arginfo_swoole_process_pool_getProcess
inspect模块类 inspect.ArgInfo inspect.getmoduleinfo inspect.ArgSpec inspect.getmodulename
FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB) 0x000e 00014 (main.go:12) FUNCDATA $5, "".Add.arginfo1
PHP Yaf 框架中yaf_controller.c文件中对控制器的render方法进行类型提示的一小段代码: ZEND_BEGIN_ARG_INFO_EX(yaf_controller_render_arginfo
33cdeccccebe80329f1fdbee7f5874cb(SB) 0x000e 00014 (main.go:3) FUNCDATA $5, "".Test.arginfo1
0x0022 00034 (main.go:7)FUNCDATA$2, main.test1.stkobj(SB)+0x0022 00034 (main.go:7)FUNCDATA$5, main.test1.arginfo1
33cdeccccebe80329f1fdbee7f5874cb(SB) 0x000e 00014 (main.go:10) FUNCDATA $5, "".A.arginfo1 33cdeccccebe80329f1fdbee7f5874cb(SB) 0x0000 00000 (main.go:8) FUNCDATA $5, "".A.arginfo1
其中,前三个参数可以与后面几个组合使用,多个参数组合时,使用|进行分隔, 例如: PHP_ME( Test, protectedFinalStaticMethod, arginfo_xyz,
这些操作码将根据arginfo检查参数的种类并相应地执行操作。在大多数情况下,不使用实际的arginfo结构,而是直接在函数结构中使用紧凑的位向量表示。 然后是SEND_VAR_NO_REF_EX。 FUNC_ARG获取模式将通过检查当前EX(call)函数的arginfo来动态选择两种行为之一(R或W)。
y=1, *z): print inspect.getargvalues(inspect.currentframe()) return x + y + sum(z) add(2) #ArgInfo
d571c0f6cf0af59df28f76498f639cf2(SB) 0x0018 00024 (main.go:5) FUNCDATA $5, "".testFunc.arginfo1
扫码关注腾讯云开发者
领取腾讯云代金券