need to figure out how to apply a function in zend to something other than an array; about to run out of battery though

This commit is contained in:
Meredith L. Patterson 2013-11-24 23:10:27 -06:00
parent 5fcd9fa88d
commit 6c4a8f17c6

View file

@ -150,7 +150,7 @@
struct HParseResult_;
static zval* hpt_to_php(const struct HParsedToken_ *token);
//static struct HParsedToken_* call_action(const struct HParseResult_ *p, void* user_data);
static struct HParsedToken_* call_action(const struct HParseResult_ *p, void* user_data);
}
%typemap(in) (const uint8_t* str, const size_t len) {
@ -247,7 +247,15 @@
}
}
}
/*
%typemap(in) (HPredicate* pred, void* user_data) {
}
*/
%typemap(in) (const HAction a, void* user_data) {
$2 = $input;
$1 = call_action;
}
#else
#warning no Hammer typemaps defined
#endif
@ -508,5 +516,19 @@ def int64(): return _h_int64()
break;
}
}
static struct HParsedToken_* call_action(const struct HParseResult_ *p, void* user_data) {
zval *callable = user_data;
zval *ret;
ALLOC_INIT_ZVAL(ret);
FIXME_SOME_ZEND_APPLY_FUNCTION(ret, (apply_func_t)callable TSRMLS_CC);
if (ret == NULL) {
// FIXME throw some error
return NULL;
}
// TODO: add reference to ret to parse-local data
HParsedToken *tok = h_make(p->arena, h_tt_php, ret);
return tok;
}
}
#endif