2 re::engine::Hooks - Hookable variant of the Perl core regular expression
11 #include "re_engine_hooks.h"
13 STATIC void dri_comp_hook(pTHX_ regexp *rx, regnode *node) {
17 STATIC void dri_exec_hook(pTHX_ regexp *rx, regnode *node,
18 regmatch_info *info, regmatch_state *state) {
22 MODULE = Devel::Regexp::Instrument PACKAGE = Devel::Regexp::Instrument
26 reh_register("Devel::Regexp::Instrument", dri_comp_hook, dri_exec_hook);
29 In your Perl module file :
31 package Devel::Regexp::Instrument;
38 use re::engine::Hooks; # Before loading our own shared library
43 push @ISA, 'DynaLoader';
44 __PACKAGE__->bootstrap($VERSION);
47 sub import { re::engine::Hooks::enable(__PACKAGE__) }
49 sub unimport { re::engine::Hooks::disable(__PACKAGE__) }
55 use ExtUtils::Depends;
57 my $ed = ExtUtils::Depends->new(
58 'Devel::Regexp::Instrument' => 're::engine::Hooks',
62 $ed->get_makefile_vars,
67 This module provides a version of the perl regexp engine that can call
68 user-defined XS callbacks at the compilation and at the execution of
72 The C API is made available through the re_engine_hooks.h header file.
75 The typedef for the regexp compilation phase hook. Currently evaluates
78 typedef void (*reh_comp_hook)(pTHX_ regexp *, regnode *);
81 The typedef for the regexp execution phase hook. Currently evaluates to
84 typedef void (*reh_exec_hook)(pTHX_ regexp *, regnode *, regmatch_info *, regmatch_state *);
87 void reh_register(pTHX_ const char *key, reh_comp_hook comp, reh_exec_hook exec);
89 Registers under the given name "key" a callback "comp" that will run
90 during the compilation phase and a callback "exec" that will run during
91 the execution phase. Null function pointers are allowed in case you
92 don't want to hook one of the phases. "key" should match with the
93 argument passed to "enable" and "disable" in Perl land. An exception
94 will be thrown if "key" has already been used to register callbacks.
100 Lexically enables the hooks associated with the key $key
105 Lexically disables the hooks associated with the key $key
108 See the t/re-engine-Hooks-TestDist/ directory in the distribution. It
109 implements a couple of simple examples.
120 Vincent Pit, "<perl at profvince.com>", <http://www.profvince.com>.
122 You can contact me by mail or on "irc.perl.org" (vincent).
125 Please report any bugs or feature requests to "bug-re-engine-hooks at
126 rt.cpan.org", or through the web interface at
127 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=re-engine-Hooks>. I will
128 be notified, and then you'll automatically be notified of progress on
129 your bug as I make changes.
132 You can find documentation for this module with the perldoc command :
134 perldoc re::engine::Hooks
137 Copyright 2012 Vincent Pit, all rights reserved.
139 This program is free software; you can redistribute it and/or modify it
140 under the same terms as Perl itself.