]> git.vpit.fr Git - perl/modules/re-engine-Plugin.git/blobdiff - Plugin.pm
This is 0.12
[perl/modules/re-engine-Plugin.git] / Plugin.pm
index ef2dbaea34c38939567c31373fb19bd94c5659ef..eee5dadd5c24d679a3166432b47106450ce4015c 100644 (file)
--- a/Plugin.pm
+++ b/Plugin.pm
@@ -1,12 +1,12 @@
 # See Plugin.pod for documentation
 package re::engine::Plugin;
-use 5.009005;
+use 5.010;
 use strict;
 
 our ($VERSION, @ISA);
 
 BEGIN {
- $VERSION = '0.07';
+ $VERSION = '0.12';
  # All engines should subclass the core Regexp package
  @ISA = 'Regexp';
  require XSLoader;
@@ -20,7 +20,7 @@ sub import
     my ($pkg, %sub) = @_;
 
     # Valid callbacks
-    my @callback = qw(comp exec);
+    my @callback = qw<comp exec free>;
 
     for (@callback) {
         next unless exists $sub{$_};
@@ -51,6 +51,19 @@ sub unimport
     return;
 }
 
+sub callbacks
+{
+    my ($re, %callback) = @_;
+
+    my %map = map { $_ => "_$_" } qw<exec free>;
+
+    for my $key (keys %callback) {
+        my $name = $map{$key};
+        next unless defined $name;
+        $re->$name($callback{$key});
+    }
+}
+
 sub num_captures
 {
     my ($re, %callback) = @_;