2 re::engine::Hooks - Hookable variant of the Perl core regular expression
11 #include "re_engine_hooks.h"
13 STATIC void dri_comp_node_hook(pTHX_ regexp *rx, regnode *node) {
17 STATIC void dri_exec_node_hook(pTHX_
18 regexp *rx, regnode *node, regmatch_info *info, regmatch_state *state) {
22 MODULE = Devel::Regexp::Instrument PACKAGE = Devel::Regexp::Instrument
27 cfg.comp_node = dri_comp_node_hook;
28 cfg.exec_node = dri_exec_node_hook;
29 reh_register("Devel::Regexp::Instrument", &cfg);
32 In your Perl module file :
34 package Devel::Regexp::Instrument;
41 use re::engine::Hooks; # Before loading our own shared library
46 push @ISA, 'DynaLoader';
47 __PACKAGE__->bootstrap($VERSION);
50 sub import { re::engine::Hooks::enable(__PACKAGE__) }
52 sub unimport { re::engine::Hooks::disable(__PACKAGE__) }
58 use ExtUtils::Depends;
60 my $ed = ExtUtils::Depends->new(
61 'Devel::Regexp::Instrument' => 're::engine::Hooks',
65 $ed->get_makefile_vars,
70 This module provides a version of the perl regexp engine that can call
71 user-defined XS callbacks at the compilation and at the execution of
75 The C API is made available through the re_engine_hooks.h header file.
78 The typedef for the regexp node compilation phase hook. Currently
81 typedef void (*reh_comp_node_hook)(pTHX_ regexp *, regnode *);
84 The typedef for the regexp node_execution phase hook. Currently
87 typedef void (*reh_exec_node_hook)(pTHX_ regexp *, regnode *, regmatch_info *, regmatch_state *);
90 A typedef'd struct that holds a set of all the different callbacks
91 publicized by this module. It has the following members :
95 A function pointer of type "reh_comp_node_hook" that will be called
96 each time a regnode is compiled. Allowed to be "NULL" if you don't
97 want to call anything for this phase.
101 A function pointer of type "reh_exec_node_hook" that will be called
102 each time a regnode is executed. Allowed to be "NULL" if you don't
103 want to call anything for this phase.
106 void reh_register(pTHX_ const char *key, reh_config *cfg);
108 Registers the callbacks specified by the "reh_config *" object "cfg"
109 under the given name "key". "cfg" can be a pointer to a static object of
110 type "reh_config". "key" is expected to be a nul-terminated string and
111 should match the argument passed to "enable" and "disable" in Perl land.
112 An exception will be thrown if "key" has already been used to register
119 Lexically enables the hooks associated with the key $key.
124 Lexically disables the hooks associated with the key $key.
127 Please refer to the t/re-engine-Hooks-TestDist/ directory in the
128 distribution. It implements a couple of simple examples.
139 Vincent Pit, "<perl at profvince.com>", <http://www.profvince.com>.
141 You can contact me by mail or on "irc.perl.org" (vincent).
144 Please report any bugs or feature requests to "bug-re-engine-hooks at
145 rt.cpan.org", or through the web interface at
146 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=re-engine-Hooks>. I will
147 be notified, and then you'll automatically be notified of progress on
148 your bug as I make changes.
151 You can find documentation for this module with the perldoc command :
153 perldoc re::engine::Hooks
156 Copyright 2012,2013 Vincent Pit, all rights reserved.
158 This program is free software; you can redistribute it and/or modify it
159 under the same terms as Perl itself.