All tests pass.
This commit is contained in:
parent
4199ad8758
commit
8c44d583e6
2 changed files with 39 additions and 6 deletions
|
|
@ -202,7 +202,36 @@
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int call_predicate(HParseResult *p, void* user_data) {
|
||||
SV *func = (SV*)user_data;
|
||||
|
||||
dSP;
|
||||
ENTER;
|
||||
SAVETMPS;
|
||||
PUSHMARK(SP);
|
||||
if (p->ast != NULL) {
|
||||
mXPUSHs(hpt_to_perl(p->ast));
|
||||
} else {
|
||||
mXPUSHs(newSV(0));
|
||||
}
|
||||
PUTBACK;
|
||||
|
||||
int nret = call_sv(func, G_SCALAR);
|
||||
|
||||
SPAGAIN;
|
||||
if (nret != 1)
|
||||
croak("Expected 1 return value, got %d", nret);
|
||||
|
||||
SV* svret = POPs;
|
||||
int ret = SvTRUE(svret);
|
||||
PUTBACK;
|
||||
FREETMPS;
|
||||
LEAVE;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
%}
|
||||
%inline {
|
||||
HParser* ch(uint8_t chr) {
|
||||
|
|
@ -220,6 +249,9 @@
|
|||
HParser* action(HParser *parser, SV* sub) {
|
||||
return h_action(parser, call_action, SvREFCNT_inc(sub));
|
||||
}
|
||||
HParser* attr_bool(HParser *parser, SV* sub) {
|
||||
return h_attr_bool(parser, call_predicate, SvREFCNT_inc(sub));
|
||||
}
|
||||
}
|
||||
|
||||
%extend HParser_ {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue