Skip to content

Instantly share code, notes, and snippets.

@wudi
Forked from chobie/closure.c
Created August 14, 2018 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wudi/a4366cc0415b6729822d5ef718450dd8 to your computer and use it in GitHub Desktop.
Save wudi/a4366cc0415b6729822d5ef718450dd8 to your computer and use it in GitHub Desktop.
static void git_ex_cb(INTERNAL_FUNCTION_PARAMETERS)
{
zval *payload, *this = getThis();
char *oid;
int oid_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"sz", &oid, &oid_len, &payload) == FAILURE) {
return;
}
php_var_dump(&payload, 1 TSRMLS_CC);
php_var_dump(&this, 1 TSRMLS_CC);
RETURN_STRING("Hello World", 1);
}
static const zend_arg_info arginfo_git_odb_backend_foreach_callback[] = {
ZEND_ARG_INFO(0, oid)
ZEND_ARG_INFO(1, payload)
};
PHP_FUNCTION(git_ex)
{
zend_function function = {0};
zend_arg_info args[2] = {0}, **_args = NULL;
zval *hoge;
MAKE_STD_ZVAL(hoge);
object_init_ex(hoge, php_git2_odb_backend_foreach_callback_class_entry);
Z_ADDREF_P(hoge);
// Git2\ODB\Backend\ForeachCallback
function.type = ZEND_INTERNAL_FUNCTION;
function.common.function_name = "callback";
function.common.fn_flags = ZEND_ACC_CLOSURE;
function.common.num_args = 2;
function.common.required_num_args = 2;
function.common.arg_info = &arginfo_git_odb_backend_foreach_callback;
function.common.scope = php_git2_odb_backend_foreach_callback_class_entry;
function.internal_function.type = ZEND_INTERNAL_FUNCTION;
function.internal_function.scope = php_git2_odb_backend_foreach_callback_class_entry;
function.internal_function.fn_flags = ZEND_ACC_CLOSURE;
function.internal_function.handler = git_ex_cb;
function.internal_function.module = &git2_module_entry;
function.internal_function.num_args = 2;
function.internal_function.required_num_args = 2;
function.internal_function.arg_info = &arginfo_git_odb_backend_foreach_callback;
zend_create_closure(return_value, &function, php_git2_odb_backend_foreach_callback_class_entry, hoge TSRMLS_CC);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment