1 # See Plugin.pod for documentation
2 package re::engine::Plugin;
10 # All engines should subclass the core Regexp package
13 XSLoader::load(__PACKAGE__, $VERSION);
16 my $RE_ENGINE_PLUGIN = ENGINE();
23 my @callback = qw<comp exec>;
26 next unless exists $sub{$_};
29 unless (ref $cb eq 'CODE') {
31 Carp::croak("'$_' is not CODE");
37 $^H{+(__PACKAGE__)} = _tag(@sub{@callback});
38 $^H{regcomp} = $RE_ENGINE_PLUGIN;
45 # Delete the regcomp hook
47 if $^H{regcomp} == $RE_ENGINE_PLUGIN;
49 delete $^H{+(__PACKAGE__)};
56 my ($re, %callback) = @_;
58 my %map = map { $_ => "_$_" } qw<exec>;
60 for my $key (keys %callback) {
61 my $name = $map{$key};
62 next unless defined $name;
63 $re->$name($callback{$key});
69 my ($re, %callback) = @_;
71 for my $key (keys %callback) {
72 $key =~ y/a-z/A-Z/; # ASCII uc
73 my $name = '_num_capture_buff_' . $key;
74 $re->$name( $callback{$key} );