-2007-05-29 Ævar Arnfjörð Bjarmason <avar@cpan.org> (0.04_01)
+2007-12-27 Ævar Arnfjörð Bjarmason <avar@cpan.org> (0.04)
- * Plugin.xs: Implementation of named buffer callbacks, there is
- some debate about whether this patch should go into
- blead so I'm making a dev release
- * named_capture.patch: The patch to blead that makes this tick
+ * Plugin.pm: Setting @ISA instead of using base.pm
+ * Makefile.PL: Now using ExtUtils::MakeMaker instead of Module::Install
+ * Plugin.(xs|h): Fix up prototypes to match the callbacks in the actual 5.10 release
* Plugin.xs: Dumped CODE: in favor of PPCODE:, the former is teh sux
* Plugin.xs: Minor cleanups here and there
* Plugin.pod: New todo and a developer release notice
- * Plugin.h: Named buffer callbacks
- * Plugin.pm: Named buffer callbacks
+ * Plugin.[h|pm]: Named buffer callbacks
* t/methods/stash.t: Test return value of $rx->stash({});
* t/methods/str/modify.t: New test for modification of ->str when
a reference is used
* t/methods/str/types.t: This was testing pattern types, fixed
-
* t/Example.[t|pm]: Moved to t/usage
- * t/named_buff: Tests for named buffer callbacks
2007-05-17 Ævar Arnfjörð Bjarmason <avar@cpan.org> (0.03)
-
+
* Plugin.xs: The exec callback would call_sv on a NULL value
causing a segfault
* Plugin.pod: Use %hash ~~ 'i' instead of $hash{i}, more stylish!
blead itself, too many changes to list
2007-02-18 Ævar Arnfjörð Bjarmason <avar@cpan.org> (0.01)
-
+
* Initial release
ChangeLog
-inc/Module/AutoInstall.pm
-inc/Module/Install.pm
-inc/Module/Install/AutoInstall.pm
-inc/Module/Install/Base.pm
-inc/Module/Install/Can.pm
-inc/Module/Install/Fetch.pm
-inc/Module/Install/Include.pm
-inc/Module/Install/Makefile.pm
-inc/Module/Install/Makefile/Version.pm
-inc/Module/Install/Metadata.pm
-inc/Module/Install/Win32.pm
-inc/Module/Install/WriteAll.pm
Makefile.PL
MANIFEST This list of files
-META.yml
-named-capture.patch
+MANIFEST.SKIP
Plugin.h
Plugin.pm
Plugin.pod
t/methods/str/modify.t
t/methods/str/types.t
t/methods/str/undef.t
-t/named_buff/CLEAR.t
-t/named_buff/DELETE.t
-t/named_buff/EXISTS.t
-t/named_buff/FETCH.t
-t/named_buff/FIRSTKEY.t
-t/named_buff/NEXTKEY.t
-t/named_buff/SCALAR.t
-t/named_buff/STORE.t
t/num_buff/FETCH.t
t/num_buff/LENGTH.t
t/num_buff/STORE.t
t/taint/util.t
t/usage/basic.pm
t/usage/basic.t
-t/usage/import.pm
t/usage/import.t
+t/usage/import.pm
typemap
+META.yml Module meta-data (added by MakeMaker)
--- /dev/null
+\.bs$
+\.c$
+\.o$
+^\.git
+^blib/
+\.old$
+\.bak$
+^pm_to_blib$
+^Makefile$
\ No newline at end of file
----
-abstract: API to write custom regex engines
-author: 'Ævar Arnfjörð Bjarmason <avar@cpan.org>'
-build_requires:
- Test::More: 0
-distribution_type: module
-generated_by: Module::Install version 0.65
-license: perl
+--- #YAML:1.0
+name: re-engine-Plugin
+version: 0.04
+abstract: API to write custom regex engines
+license: perl
+author:
+ - Ævar Arnfjörð Bjarmason <avar@cpan.org>
+generated_by: ExtUtils::MakeMaker version 6.42
+distribution_type: module
+requires:
meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.3.html
- version: 1.3
-name: re-engine-Plugin
-no_index:
- directory:
- - inc
- - t
-requires:
- perl: 5.9.5
-tests: t/*.t t/*/*.t t/*/*/*.t
+ url: http://module-build.sourceforge.net/META-spec-v1.3.html
+ version: 1.3
-use strict;\r
-use inc::Module::Install;\r
-\r
-name 're-engine-Plugin';\r
-\r
-perl_version '5.009005';\r
-\r
-author 'Ævar Arnfjörð Bjarmason <avar@cpan.org>';\r
-\r
-abstract_from 'Plugin.pod';\r
-license_from 'Plugin.pod';\r
-\r
-# t/\r
-build_requires 'Test::More' => 0; # 5.007003\r
-\r
-tests 't/*.t t/*/*.t t/*/*/*.t';\r
-\r
-auto_install;\r
-WriteAll;\r
+use 5.009005;\r
+use ExtUtils::MakeMaker;\r
+\r
+WriteMakefile(\r
+ NAME => 're::engine::Plugin',\r
+ AUTHOR => 'Ævar Arnfjörð Bjarmason <avar@cpan.org>',\r
+ ABSTRACT_FROM => 'Plugin.pod',\r
+ VERSION_FROM => 'Plugin.pm',\r
+ LICENSE => 'perl',\r
+ test => {\r
+ TESTS => 't/*.t t/*/*.t t/*/*/*.t',\r
+ },\r
+);\r
-
#define GET_SELF_FROM_PPRIVATE(pprivate) \
re__engine__Plugin self; \
SELF_FROM_PPRIVATE(self,pprivate);
const I32, SV const * const);
EXTERN_C I32 Plugin_numbered_buff_LENGTH(pTHX_ REGEXP * const,
const SV * const, const I32);
-EXTERN_C SV * Plugin_named_buff_FETCH(pTHX_ REGEXP * const, SV * const,
+EXTERN_C SV * Plugin_named_buff (pTHX_ REGEXP * const, SV * const,
+ SV * const, const U32);
+EXTERN_C SV * Plugin_named_buff_iter (pTHX_ REGEXP * const, const SV * const,
const U32);
-EXTERN_C void Plugin_named_buff_STORE(pTHX_ REGEXP * const rx,
- SV * const key, SV * const value,
- const U32 flags);
-EXTERN_C void Plugin_named_buff_DELETE(pTHX_ REGEXP * const rx,
- SV * const key, const U32 flags);
-EXTERN_C void Plugin_named_buff_CLEAR (pTHX_ REGEXP * const rx, const U32 flags);
-EXTERN_C bool Plugin_named_buff_EXISTS (pTHX_ REGEXP * const rx,
- SV * const key, const U32 flags);
-EXTERN_C SV * Plugin_named_buff_FIRSTKEY (pTHX_ REGEXP * const rx,
- const U32 flags);
-EXTERN_C SV * Plugin_named_buff_NEXTKEY (pTHX_ REGEXP * const rx,
- SV * const lastkey, const U32 flags);
-EXTERN_C SV * Plugin_named_buff_SCALAR (pTHX_ REGEXP * const rx,
- const U32 flags);
EXTERN_C SV * Plugin_package(pTHX_ REGEXP * const);
#ifdef USE_ITHREADS
EXTERN_C void * Plugin_dupe(pTHX_ REGEXP * const, CLONE_PARAMS *);
Plugin_numbered_buff_FETCH,
Plugin_numbered_buff_STORE,
Plugin_numbered_buff_LENGTH,
- Plugin_named_buff_FETCH,
- Plugin_named_buff_STORE,
- Plugin_named_buff_DELETE,
- Plugin_named_buff_CLEAR,
- Plugin_named_buff_EXISTS,
- Plugin_named_buff_FIRSTKEY,
- Plugin_named_buff_NEXTKEY,
- Plugin_named_buff_SCALAR,
+ Plugin_named_buff,
+ Plugin_named_buff_iter,
Plugin_package,
#if defined(USE_ITHREADS)
Plugin_dupe,
* Callbacks
*/
+ SV * cb_free;
+
/* ->num_captures */
SV * cb_num_capture_buff_FETCH;
SV * cb_num_capture_buff_STORE;
SV * cb_num_capture_buff_LENGTH;
-
- /* ->named_captures */
- SV * cb_named_capture_buff_FETCH;
- SV * cb_named_capture_buff_STORE;
- SV * cb_named_capture_buff_DELETE;
- SV * cb_named_capture_buff_CLEAR;
- SV * cb_named_capture_buff_EXISTS;
- SV * cb_named_capture_buff_FIRSTKEY;
- SV * cb_named_capture_buff_NEXTKEY;
- SV * cb_named_capture_buff_SCALAR;
} *re__engine__Plugin;
# See Plugin.pod for documentation\r
package re::engine::Plugin;\r
use 5.009005;\r
-use base 'Regexp';\r
use strict;\r
use XSLoader ();\r
\r
-our $VERSION = '0.04_01';\r
+our $VERSION = '0.04';\r
+\r
+# All engines should subclass the core Regexp package\r
+our @ISA = 'Regexp';\r
\r
XSLoader::load __PACKAGE__, $VERSION;\r
\r
my ($pkg, %sub) = @_;\r
\r
# Valid callbacks\r
- my @callback = qw(comp exec); #intuit checkstr free dupe);\r
+ my @callback = qw(comp exec);\r
\r
for (@callback) {\r
next unless exists $sub{$_};\r
}\r
}\r
\r
-sub named_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 = '_named_capture_buff_' . $key;\r
- $re->$name( $callback{$key} );\r
- }\r
-}\r
-\r
1;\r
re::engine::Plugin - API to write custom regex engines
-=head1 NOTICE
-
-This is a B<developer release> that requires a patch to blead to work,
-the patch can be found in F<named_capture.patch> in this distribution.
-
=head1 DESCRIPTION
As of perl 5.9.5 it's possible to lexically replace perl's built-in
=head2 named_captures
-B<TODO>: document
+B<TODO>: implement
-This is implemented but not documented, see F<t/named_buff> for usage
-examples.
+perl internals still needs to be changed to support this but when it's
+done it'll allow the binding of C<%+> and C<%-> and support the
+L<Tie::Hash> methods FETCH, STORE, DELETE, CLEAR, EXISTS, FIRSTKEY,
+NEXTKEY and SCALAR.
=head1 Tainting
=item *
-Export constants defined as macros in core relevant to our interests,
-e.g. PMf_ stuff and things needed by extflags.
-
-=item *
-
Engines implemented with this module don't support C<s///> and C<split
//>, the appropriate parts of the C<REGEXP> struct need to be wrapped
and documented.
rx->extflags = flags; /* Flags for perl to use */
rx->engine = RE_ENGINE_PLUGIN; /* Compile to use this engine */
- /* Precompiled regexp for pp_regcomp to use */
+ /* Precompiled pattern for pp_regcomp to use */
rx->prelen = plen;
rx->precomp = savepvn(exp, rx->prelen);
return rx->pprivate;
}
+
void
Plugin_numbered_buff_FETCH(pTHX_ REGEXP * const rx, const I32 paren,
SV * const sv)
SV*
-Plugin_named_buff_FETCH(pTHX_ REGEXP * const rx, SV * const key, U32 flags)
-{
- dSP;
- SV * callback;
- GET_SELF_FROM_PPRIVATE(rx->pprivate);
-
- callback = self->cb_named_capture_buff_FETCH;
-
- if (callback) {
- ENTER;
- SAVETMPS;
-
- PUSHMARK(SP);
- XPUSHs(rx->pprivate);
- XPUSHs(SvREFCNT_inc(key));
- XPUSHs(sv_2mortal(newSViv(flags & 1 ? 1 : 0)));
- PUTBACK;
-
- call_sv(callback, G_SCALAR);
-
- SPAGAIN;
-
- SV* ret = POPs;
- SvREFCNT_inc(ret);
-
- PUTBACK;
- FREETMPS;
- LEAVE;
-
- return ret;
- } else {
- return NULL;
- }
-}
-
-void
-Plugin_named_buff_STORE(pTHX_ REGEXP * const rx, SV * const key,
- SV * const value, const U32 flags)
-{
- dSP;
- SV * callback;
- GET_SELF_FROM_PPRIVATE(rx->pprivate);
-
- callback = self->cb_named_capture_buff_STORE;
-
- if (callback) {
- ENTER;
- SAVETMPS;
-
- PUSHMARK(SP);
- XPUSHs(rx->pprivate);
- XPUSHs(SvREFCNT_inc(key));
- XPUSHs(SvREFCNT_inc(value));
- XPUSHs(sv_2mortal(newSViv(flags)));
- PUTBACK;
-
- call_sv(callback, G_DISCARD);
-
- PUTBACK;
- FREETMPS;
- LEAVE;
- }
-}
-
-void
-Plugin_named_buff_DELETE(pTHX_ REGEXP * const rx, SV * const key, const U32 flags)
-{
- dSP;
- SV * callback;
- GET_SELF_FROM_PPRIVATE(rx->pprivate);
-
- callback = self->cb_named_capture_buff_DELETE;
-
- if (callback) {
- ENTER;
- SAVETMPS;
-
- PUSHMARK(SP);
- XPUSHs(rx->pprivate);
- XPUSHs(SvREFCNT_inc(key));
- XPUSHs(sv_2mortal(newSViv(flags)));
- PUTBACK;
-
- call_sv(callback, G_DISCARD);
-
- PUTBACK;
- FREETMPS;
- LEAVE;
- }
-}
-
-void
-Plugin_named_buff_CLEAR(pTHX_ REGEXP * const rx, const U32 flags)
-{
- dSP;
- SV * callback;
- GET_SELF_FROM_PPRIVATE(rx->pprivate);
-
- callback = self->cb_named_capture_buff_CLEAR;
-
- if (callback) {
- ENTER;
- SAVETMPS;
-
- PUSHMARK(SP);
- XPUSHs(rx->pprivate);
- XPUSHs(sv_2mortal(newSViv(flags)));
- PUTBACK;
-
- call_sv(callback, G_DISCARD);
-
- PUTBACK;
- FREETMPS;
- LEAVE;
- }
-}
-
-bool
-Plugin_named_buff_EXISTS(pTHX_ REGEXP * const rx, SV * const key,
- const U32 flags)
-{
- dSP;
- SV * callback;
- bool truthiness = FALSE;
- GET_SELF_FROM_PPRIVATE(rx->pprivate);
-
- callback = self->cb_named_capture_buff_EXISTS;
-
- if (callback) {
- ENTER;
- SAVETMPS;
-
- PUSHMARK(SP);
- XPUSHs(rx->pprivate);
- XPUSHs(SvREFCNT_inc(key));
- XPUSHs(sv_2mortal(newSViv(flags)));
- PUTBACK;
-
- call_sv(callback, G_SCALAR);
-
- SPAGAIN;
-
- SV * ret = POPs;
- truthiness = SvTRUE(ret);
-
- PUTBACK;
- FREETMPS;
- LEAVE;
- }
-
- return truthiness;
-}
-
-SV*
-Plugin_named_buff_FIRSTKEY(pTHX_ REGEXP * const rx, const U32 flags)
-{
- dSP;
- SV * callback;
- GET_SELF_FROM_PPRIVATE(rx->pprivate);
-
- callback = self->cb_named_capture_buff_FIRSTKEY;
-
- if (callback) {
- ENTER;
- SAVETMPS;
-
- PUSHMARK(SP);
- XPUSHs(rx->pprivate);
- XPUSHs(sv_2mortal(newSViv(flags)));
- PUTBACK;
-
- call_sv(callback, G_SCALAR);
-
- SPAGAIN;
-
- SV * ret = POPs;
- SvREFCNT_inc(ret);
-
- PUTBACK;
- FREETMPS;
- LEAVE;
-
- return ret;
- } else {
- return NULL;
- }
-}
-
-SV*
-Plugin_named_buff_NEXTKEY(pTHX_ REGEXP * const rx, SV * const lastkey,
- const U32 flags)
+Plugin_named_buff (pTHX_ REGEXP * const rx, SV * const key, SV * const value,
+ const U32 flags)
{
- dSP;
- SV * callback;
- GET_SELF_FROM_PPRIVATE(rx->pprivate);
-
- callback = self->cb_named_capture_buff_NEXTKEY;
-
- if (callback) {
- ENTER;
- SAVETMPS;
-
- PUSHMARK(SP);
- XPUSHs(rx->pprivate);
- XPUSHs(SvREFCNT_inc(lastkey));
- XPUSHs(sv_2mortal(newSViv(flags)));
- PUTBACK;
-
- call_sv(callback, G_SCALAR);
-
- SPAGAIN;
-
- SV * ret = POPs;
- SvREFCNT_inc(ret);
-
- PUTBACK;
- FREETMPS;
- LEAVE;
-
- return ret;
- } else {
- return NULL;
- }
+ return NULL;
}
SV*
-Plugin_named_buff_SCALAR(pTHX_ REGEXP * const rx, const U32 flags)
+Plugin_named_buff_iter (pTHX_ REGEXP * const rx, const SV * const lastkey,
+ const U32 flags)
{
- dSP;
- SV * callback;
- GET_SELF_FROM_PPRIVATE(rx->pprivate);
-
- callback = self->cb_named_capture_buff_SCALAR;
-
- if (callback) {
- ENTER;
- SAVETMPS;
-
- PUSHMARK(SP);
- XPUSHs(rx->pprivate);
- XPUSHs(sv_2mortal(newSViv(flags)));
- PUTBACK;
-
- call_sv(callback, G_SCALAR);
-
- SPAGAIN;
-
- SV * ret = POPs;
- SvREFCNT_inc(ret);
-
- PUTBACK;
- FREETMPS;
- LEAVE;
-
- return ret;
- } else {
- return NULL;
- }
+ return NULL;
}
SV*
PPCODE:
XPUSHs(self->str);
-void
+char*
mod(re::engine::Plugin self, ...)
PPCODE:
/* /i */
SvREFCNT_inc(self->cb_num_capture_buff_LENGTH);
}
-void
-_named_capture_buff_FETCH(re::engine::Plugin self, ...)
-PPCODE:
- if (items > 1) {
- self->cb_named_capture_buff_FETCH = ST(1);
- SvREFCNT_inc(self->cb_named_capture_buff_FETCH);
- }
-
-void
-_named_capture_buff_STORE(re::engine::Plugin self, ...)
-PPCODE:
- if (items > 1) {
- self->cb_named_capture_buff_STORE = ST(1);
- SvREFCNT_inc(self->cb_named_capture_buff_STORE);
- }
-
-void
-_named_capture_buff_DELETE(re::engine::Plugin self, ...)
-PPCODE:
- if (items > 1) {
- self->cb_named_capture_buff_DELETE = ST(1);
- SvREFCNT_inc(self->cb_named_capture_buff_DELETE);
- }
-
-void
-_named_capture_buff_CLEAR(re::engine::Plugin self, ...)
-PPCODE:
- if (items > 1) {
- self->cb_named_capture_buff_CLEAR = ST(1);
- SvREFCNT_inc(self->cb_named_capture_buff_CLEAR);
- }
-
-void
-_named_capture_buff_EXISTS(re::engine::Plugin self, ...)
-PPCODE:
- if (items > 1) {
- self->cb_named_capture_buff_EXISTS = ST(1);
- SvREFCNT_inc(self->cb_named_capture_buff_EXISTS);
- }
-
-void
-_named_capture_buff_FIRSTKEY(re::engine::Plugin self, ...)
-PPCODE:
- if (items > 1) {
- self->cb_named_capture_buff_FIRSTKEY = ST(1);
- SvREFCNT_inc(self->cb_named_capture_buff_FIRSTKEY);
- }
-
-void
-_named_capture_buff_NEXTKEY(re::engine::Plugin self, ...)
-PPCODE:
- if (items > 1) {
- self->cb_named_capture_buff_NEXTKEY = ST(1);
- SvREFCNT_inc(self->cb_named_capture_buff_NEXTKEY);
- }
-
-void
-_named_capture_buff_SCALAR(re::engine::Plugin self, ...)
-PPCODE:
- if (items > 1) {
- self->cb_named_capture_buff_SCALAR = ST(1);
- SvREFCNT_inc(self->cb_named_capture_buff_SCALAR);
- }
-
void
ENGINE()
PPCODE:
my $stash = $re->stash;
my $ret = $re->stash( $stash );
ok(!$ret, "stash returns no value on assignment");
-
my %h = qw( 0 a 1 o 2 e 3 u );
for (keys %h) {
is($h{$_}, $stash->[$_]);
if (\$sv =~ /pattern/) {
is($sv, "eek");
}
-
\*STDIN =~ "GLOB";
sub {} =~ "CODE";
bless({} => "main") =~ "main"
-