diff --git a/src/bindings/php/Tests/InTest.php b/src/bindings/php/Tests/InTest.php index 6d1c56237559d833b9d7ac2aa329f3e4d0554b33..cdc1e9306ce5f486245445c714f2b2f834670d64 100644 --- a/src/bindings/php/Tests/InTest.php +++ b/src/bindings/php/Tests/InTest.php @@ -7,7 +7,7 @@ class InTest extends PHPUnit_Framework_TestCase protected function setUp() { - $this->parser = h_in("abc"); + $this->parser = in("abc"); } public function testSuccess() { diff --git a/src/bindings/php/Tests/NotInTest.php b/src/bindings/php/Tests/NotInTest.php index 4a220d382c801cd0ae38a3952b831ed2fdd6d9ed..f06e53f7331c1554fc2bc25f435f8b6a8ebafaa1 100644 --- a/src/bindings/php/Tests/NotInTest.php +++ b/src/bindings/php/Tests/NotInTest.php @@ -7,7 +7,7 @@ class NotInTest extends PHPUnit_Framework_TestCase protected function setUp() { - $this->parser = h_not_in("abc"); + $this->parser = not_in("abc"); } public function testSuccess() { diff --git a/src/bindings/swig/hammer.i b/src/bindings/swig/hammer.i index 49dec23b9ed64949a8fb60cfbcb98b2d91461d71..d7cf3a061a0b0b33d13bad825b30f255af58eec5 100644 --- a/src/bindings/swig/hammer.i +++ b/src/bindings/swig/hammer.i @@ -204,11 +204,19 @@ RETVAL_STRINGL((char*)$1->token, $1->len, 1); } -/* TODO do we need this anymore? -%typemap(out) struct HCountedArray_* { - +%typemap(in) HAction* { + if (IS_CALLABLE == Z_TYPE_PP($input)) { + if (!zend_make_callable($1, *$input TSRMLS_CC)) { + // FIXME some error + $1 = NULL; + } + // don't need an else here, $1 gets populated + } else { + // FIXME some error + $1 = NULL; + } } -*/ + %typemap(out) struct HParseResult_* { if ($1 == NULL) { // TODO: raise parse failure @@ -255,10 +263,6 @@ } */ -%typemap(in) (const HAction a, void* user_data) { - $2 = $input; - $1 = call_action; - } #else #warning no Hammer typemaps defined #endif @@ -565,5 +569,19 @@ function sequence() return h_sequence__a($arg_list); } +function action($p, $act) +{ + return h_action($p, $act); +} + +function in($charset) +{ + return action(h_in($charset), 'chr'); +} + +function not_in($charset) +{ + return action(h_not_in($charset), 'chr'); +} " #endif