Skip to content

Instantly share code, notes, and snippets.

@sgolemon
Created January 3, 2015 06:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgolemon/f23dc4f90725bfedc611 to your computer and use it in GitHub Desktop.
Save sgolemon/f23dc4f90725bfedc611 to your computer and use it in GitHub Desktop.
HHVM vs PHP Extension APIs
<<__Native>> function foo(int $bar, string $baz): bool;
bool HHVM_FUNCTION(foo, int bar, const String& baz) {
// Do stuff with bar and baz
return true;
}
ZEND_BEGIN_ARG_INFO(foo_arginfo, 0, ZEND_RETURN_VALUE, 2)
ZEND_ARG_INFO(0, bar)
ZEND_ARG_INFO(0, baz)
ZEND_END_ARG_INFO();
PHP_FUNCTION(foo) {
zend_long bar;
char *baz;
size_t baz_len;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &bar, &baz, &baz_len) == FAILURE) { return; }
// Do something with bar and baz(_len)
RETURN_TRUE;
}
PHP_FE(foo, foo_arginfo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment