X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2Fre%2Fengine%2FHooks.pm;h=97da688e29e21f3c1e1e2a61ef7927eea2a1dad5;hb=3873fbc39d250734131e096da47add0cf601d194;hp=07b71e4e505707b5a43796563b86d9b5d4277b1d;hpb=7b88eb9cbb0c1342a6480820450644708aed019c;p=perl%2Fmodules%2Fre-engine-Hooks.git diff --git a/lib/re/engine/Hooks.pm b/lib/re/engine/Hooks.pm index 07b71e4..97da688 100644 --- a/lib/re/engine/Hooks.pm +++ b/lib/re/engine/Hooks.pm @@ -32,7 +32,7 @@ In your XS file : #include "re_engine_hooks.h" - STATIC void dri_comp_hook(pTHX_ regexp *rx, regnode *node) { + STATIC void dri_comp_node_hook(pTHX_ regexp *rx, regnode *node) { ... } @@ -45,7 +45,10 @@ In your XS file : BOOT: { - reh_register("Devel::Regexp::Instrument", dri_comp_hook, dri_exec_hook); + reh_config cfg; + cfg.comp_node = dri_comp_node_hook; + cfg.exec_node = dri_exec_node_hook; + reh_register("Devel::Regexp::Instrument", &cfg); } In your Perl module file : @@ -93,27 +96,50 @@ This module provides a version of the perl regexp engine that can call user-defi The C API is made available through the F header file. -=head2 C +=head2 C -The typedef for the regexp compilation phase hook. +The typedef for the regexp node compilation phase hook. Currently evaluates to : - typedef void (*reh_comp_hook)(pTHX_ regexp *, regnode *); + typedef void (*reh_comp_node_hook)(pTHX_ regexp *, regnode *); =head2 C -The typedef for the regexp execution phase hook. +The typedef for the regexp node_execution phase hook. Currently evaluates to : - typedef void (*reh_exec_hook)(pTHX_ regexp *, regnode *, regmatch_info *, regmatch_state *); + typedef void (*reh_exec_node_hook)(pTHX_ regexp *, regnode *, regmatch_info *, regmatch_state *); + +=head2 C + +A typedef'd struct that holds a set of all the different callbacks publicized by this module. +It has the following members : + +=over 4 + +=item * + +C + +A function pointer of type C that will be called each time a regnode is compiled. +Allowed to be C if you don't want to call anything for this phase. + +=item * + +C + +A function pointer of type C that will be called each time a regnode is executed. +Allowed to be C if you don't want to call anything for this phase. + +=back =head2 C - 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); -Registers under the given name C a callback C that will run during the compilation phase and a callback C that will run during the execution phase. -Null function pointers are allowed in case you don't want to hook one of the phases. -C should match with the argument passed to L and L in Perl land. +Registers the callbacks specified by the C object C under the given name C. +C can be a pointer to a static object of type C. +C is expected to be a nul-terminated string and should match the argument passed to L and L in Perl land. An exception will be thrown if C has already been used to register callbacks. =cut @@ -131,13 +157,13 @@ my $croak = sub { enable $key; -Lexically enables the hooks associated with the key C<$key> +Lexically enables the hooks associated with the key C<$key>. =head2 C disable $key; -Lexically disables the hooks associated with the key C<$key> +Lexically disables the hooks associated with the key C<$key>. =cut @@ -179,7 +205,7 @@ sub disable { =head1 EXAMPLES -See the F directory in the distribution. +Please refer to the F directory in the distribution. It implements a couple of simple examples. =head1 DEPENDENCIES