-# See Plugin.pod for documentation\r
-package re::engine::Plugin;\r
-use 5.009005;\r
-use strict;\r
-use XSLoader ();\r
-\r
-our $VERSION = '0.05';\r
-\r
-# All engines should subclass the core Regexp package\r
-our @ISA = 'Regexp';\r
-\r
-XSLoader::load __PACKAGE__, $VERSION;\r
-\r
-my $RE_ENGINE_PLUGIN = ENGINE();\r
-\r
-# How many? Used to cheat %^H\r
-my $callback = 1;\r
-\r
-# Where we store our CODE refs\r
-my %callback;\r
-\r
-# Generate a key to use in the %^H hash from a string, prefix the\r
-# package name like L<pragma> does\r
-my $key = sub { __PACKAGE__ . "::" . $_[0] };\r
-\r
-sub import\r
-{\r
- my ($pkg, %sub) = @_;\r
-\r
- # Valid callbacks\r
- my @callback = qw(comp exec);\r
-\r
- for (@callback) {\r
- next unless exists $sub{$_};\r
- my $cb = delete $sub{$_};\r
-\r
- unless (ref $cb eq 'CODE') {\r
- require Carp;\r
- Carp::croak("'$_' is not CODE");\r
- }\r
-\r
- # Get an ID to use\r
- my $id = $callback ++;\r
-\r
- # Insert into our callback storage,\r
- $callback{$_}->{$id} = $cb;\r
-\r
- # Instert into our cache with a key we can retrive later\r
- # knowing the ID in %^H and what callback we're getting\r
- $^H{ $key->($_) } = $id;\r
- }\r
-\r
- $^H{regcomp} = $RE_ENGINE_PLUGIN;\r
-}\r
-\r
-sub unimport\r
-{\r
- # Delete the regcomp hook\r
- delete $^H{regcomp}\r
- if $^H{regcomp} == $RE_ENGINE_PLUGIN;\r
-}\r
-\r
-# Minimal function to get CODE for a given key to be called by the\r
-# get_H_callback C function.\r
-sub _get_callback\r
-{\r
- my ($name) = @_; # 'comp', 'exec', ...\r
-\r
- my $h = (caller(0))[10];\r
- my $id = $h->{ $key->($name) };\r
-\r
- my $cb = defined $id ? $callback{$name}->{$id} : 0;\r
-\r
- return $cb;\r
-}\r
-\r
-sub num_captures\r
-{\r
- my ($re, %callback) = @_;\r
-\r
- for my $key (keys %callback) {\r
- $key =~ y/a-z/A-Z/; # ASCII uc\r
- my $name = '_num_capture_buff_' . $key;\r
- $re->$name( $callback{$key} );\r
- }\r
-}\r
-\r
-1;\r
+# See Plugin.pod for documentation
+package re::engine::Plugin;
+use 5.009005;
+use strict;
+use XSLoader ();
+
+our $VERSION = '0.05';
+
+# All engines should subclass the core Regexp package
+our @ISA = 'Regexp';
+
+XSLoader::load __PACKAGE__, $VERSION;
+
+my $RE_ENGINE_PLUGIN = ENGINE();
+
+# How many? Used to cheat %^H
+my $callback = 1;
+
+# Where we store our CODE refs
+my %callback;
+
+# Generate a key to use in the %^H hash from a string, prefix the
+# package name like L<pragma> does
+my $key = sub { __PACKAGE__ . "::" . $_[0] };
+
+sub import
+{
+ my ($pkg, %sub) = @_;
+
+ # Valid callbacks
+ my @callback = qw(comp exec);
+
+ for (@callback) {
+ next unless exists $sub{$_};
+ my $cb = delete $sub{$_};
+
+ unless (ref $cb eq 'CODE') {
+ require Carp;
+ Carp::croak("'$_' is not CODE");
+ }
+
+ # Get an ID to use
+ my $id = $callback ++;
+
+ # Insert into our callback storage,
+ $callback{$_}->{$id} = $cb;
+
+ # Instert into our cache with a key we can retrive later
+ # knowing the ID in %^H and what callback we're getting
+ $^H{ $key->($_) } = $id;
+ }
+
+ $^H{regcomp} = $RE_ENGINE_PLUGIN;
+}
+
+sub unimport
+{
+ # Delete the regcomp hook
+ delete $^H{regcomp}
+ if $^H{regcomp} == $RE_ENGINE_PLUGIN;
+}
+
+# Minimal function to get CODE for a given key to be called by the
+# get_H_callback C function.
+sub _get_callback
+{
+ my ($name) = @_; # 'comp', 'exec', ...
+
+ my $h = (caller(0))[10];
+ my $id = $h->{ $key->($name) };
+
+ my $cb = defined $id ? $callback{$name}->{$id} : 0;
+
+ return $cb;
+}
+
+sub num_captures
+{
+ my ($re, %callback) = @_;
+
+ for my $key (keys %callback) {
+ $key =~ y/a-z/A-Z/; # ASCII uc
+ my $name = '_num_capture_buff_' . $key;
+ $re->$name( $callback{$key} );
+ }
+}
+
+1;