From: Florian Ragwitz Date: Wed, 1 Oct 2008 09:50:25 +0000 (+0000) Subject: Use B::Hooks::OP::Check to register PL_check callbacks. X-Git-Tag: 0.005000~54^2~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b15aa86450555f59640ab18f5597d636a4da2d35;p=p5sagit%2FDevel-Declare.git Use B::Hooks::OP::Check to register PL_check callbacks. --- diff --git a/Declare.xs b/Declare.xs index d4b74f9..aa6cfad 100644 --- a/Declare.xs +++ b/Declare.xs @@ -3,6 +3,7 @@ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" +#include "hook_op_check.h" #undef printf #include "stolen_chunk_of_toke.c" #include @@ -192,15 +193,11 @@ int dd_toke_skipspace(pTHX_ int offset) { /* replacement PL_check rv2cv entry */ -STATIC OP *(*dd_old_ck_rv2cv)(pTHX_ OP *op); - STATIC OP *dd_ck_rv2cv(pTHX_ OP *o) { OP* kid; int dd_flags; char* cb_args[6]; - o = dd_old_ck_rv2cv(aTHX_ o); /* let the original do its job */ - if (in_declare) { cb_args[0] = NULL; #ifdef DD_DEBUG @@ -251,8 +248,6 @@ STATIC OP *dd_ck_rv2cv(pTHX_ OP *o) { return o; } -STATIC OP *(*dd_old_ck_entereval)(pTHX_ OP *op); - OP* dd_pp_entereval(pTHX) { dSP; dPOPss; @@ -278,7 +273,6 @@ OP* dd_pp_entereval(pTHX) { } STATIC OP *dd_ck_entereval(pTHX_ OP *o) { - o = dd_old_ck_entereval(aTHX_ o); /* let the original do its job */ if (o->op_ppaddr == PL_ppaddr[OP_ENTEREVAL]) o->op_ppaddr = dd_pp_entereval; return o; @@ -292,15 +286,11 @@ static I32 dd_filter_realloc(pTHX_ int idx, SV *sv, int maxlen) return count; } -STATIC OP *(*dd_old_ck_const)(pTHX_ OP*op); - STATIC OP *dd_ck_const(pTHX_ OP *o) { int dd_flags; char* s; char* name; - o = dd_old_ck_const(aTHX_ o); /* let the original do its job */ - /* if this is set, we just grabbed a delimited string or something, not a bareword, so NO TOUCHY */ @@ -333,12 +323,9 @@ void setup() CODE: if (!initialized++) { - dd_old_ck_rv2cv = PL_check[OP_RV2CV]; - PL_check[OP_RV2CV] = dd_ck_rv2cv; - dd_old_ck_entereval = PL_check[OP_ENTEREVAL]; - PL_check[OP_ENTEREVAL] = dd_ck_entereval; - dd_old_ck_const = PL_check[OP_CONST]; - PL_check[OP_CONST] = dd_ck_const; + hook_op_check(OP_RV2CV, dd_ck_rv2cv); + hook_op_check(OP_ENTEREVAL, dd_ck_entereval); + hook_op_check(OP_CONST, dd_ck_const); } filter_add(dd_filter_realloc, NULL); diff --git a/Makefile.PL b/Makefile.PL index 0aa54c8..ee03a1b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -2,19 +2,27 @@ use inc::Module::Install 0.67; use 5.008001; +use ExtUtils::Depends; + name 'Devel-Declare'; all_from 'lib/Devel/Declare.pm'; requires 'Scalar::Util'; +requires 'B::Hooks::OP::Check'; build_requires 'Test::More'; build_requires 'Scope::Guard'; +configure_requires 'ExtUtils::Depends'; +configure_requires 'B::Hooks::OP::Check'; postamble(<<'EOM'); $(OBJECT) : stolen_chunk_of_toke.c EOM +my $pkg = ExtUtils::Depends->new('Devel::Declare', 'B::Hooks::OP::Check'); + WriteMakefile( dist => { PREOP => 'pod2text lib/Devel/Declare.pm >$(DISTVNAME)/README' - } + }, + $pkg->get_makefile_vars, ); diff --git a/lib/Devel/Declare.pm b/lib/Devel/Declare.pm index c90f6a7..6280eec 100644 --- a/lib/Devel/Declare.pm +++ b/lib/Devel/Declare.pm @@ -14,6 +14,7 @@ use constant DECLARE_PACKAGE => 8+1; # name implicit use vars qw(%declarators %declarator_handlers @ISA); use base qw(DynaLoader); use Scalar::Util 'set_prototype'; +use B::Hooks::OP::Check; bootstrap Devel::Declare;