X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Hooks.xs;h=ef0c5082bdecc69867f59c85ad19932c0158edc9;hb=303060616fe3ecc18280f0c217e1b3c102a6cf08;hp=af878f3ba502ba703e9dbdde1f90a38d1a7aa222;hpb=d98dbf56343c99b164e93be306735db3f6e6bca5;p=perl%2Fmodules%2Fre-engine-Hooks.git diff --git a/Hooks.xs b/Hooks.xs index af878f3..ef0c508 100644 --- a/Hooks.xs +++ b/Hooks.xs @@ -58,8 +58,7 @@ STATIC SV *reh_hint(pTHX) { typedef struct reh_action { struct reh_action *next; - reh_comp_hook comp; - reh_exec_hook exec; + reh_config cbs; const char *key; STRLEN klen; } reh_action; @@ -73,7 +72,7 @@ STATIC perl_mutex reh_action_list_mutex; #endif /* USE_ITHREADS */ #undef reh_register -void reh_register(pTHX_ const char *key, reh_comp_hook comp, reh_exec_hook exec) { +void reh_register(pTHX_ const char *key, reh_config *cfg) { reh_action *a; char *key_dup; STRLEN i, len; @@ -87,8 +86,7 @@ void reh_register(pTHX_ const char *key, reh_comp_hook comp, reh_exec_hook exec) key_dup[len] = '\0'; a = PerlMemShared_malloc(sizeof *a); - a->comp = comp; - a->exec = exec; + a->cbs = *cfg; a->key = key_dup; a->klen = len; @@ -115,11 +113,11 @@ void reh_call_comp_hook(pTHX_ regexp *rx, regnode *node) { REH_UNLOCK(&reh_action_list_mutex); for (; a; a = a->next) { - if (a->comp) { + if (a->cbs.comp) { char *p = strstr(keys, a->key); if (p && (p + a->klen <= keys + len) && p[a->klen] == ' ') - a->comp(aTHX_ rx, node); + a->cbs.comp(aTHX_ rx, node); } } } @@ -138,11 +136,11 @@ void reh_call_exec_hook(pTHX_ regexp *rx, regnode *node, regmatch_info *reginfo, REH_UNLOCK(&reh_action_list_mutex); for (; a; a = a->next) { - if (a->exec) { + if (a->cbs.exec) { char *p = strstr(keys, a->key); if (p && (p + a->klen <= keys + len) && p[a->klen] == ' ') - a->exec(aTHX_ rx, node, reginfo, st); + a->cbs.exec(aTHX_ rx, node, reginfo, st); } } } @@ -202,12 +200,12 @@ reh_re_compile(pTHX_ SV * const pattern, U32 flags) return RX; } -const struct regexp_engine reh_regexp_engine = { - reh_re_compile, - reh_regexec, - reh_re_intuit_start, - reh_re_intuit_string, - reh_regfree, +const struct regexp_engine reh_regexp_engine = { + reh_re_compile, + reh_regexec, + reh_re_intuit_start, + reh_re_intuit_string, + reh_regfree, reh_reg_numbered_buff_fetch, reh_reg_numbered_buff_store, reh_reg_numbered_buff_length, @@ -215,7 +213,7 @@ const struct regexp_engine reh_regexp_engine = { reh_reg_named_buff_iter, reh_reg_qr_package, #if defined(USE_ITHREADS) - reh_regdupe + reh_regdupe #endif };