From: Florian Ragwitz Date: Wed, 22 Oct 2008 18:41:56 +0000 (+0000) Subject: Port to B::Hooks::Parser. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=hook_parser;p=p5sagit%2FDevel-Declare.git Port to B::Hooks::Parser. --- diff --git a/Declare.xs b/Declare.xs index af640e9..83ebc1d 100644 --- a/Declare.xs +++ b/Declare.xs @@ -106,29 +106,6 @@ void dd_linestr_callback (pTHX_ char* type, char* name) { LEAVE; } -char* dd_get_linestr(pTHX) { - if (!DD_HAVE_PARSER) { - return NULL; - } - return SvPVX(PL_linestr); -} - -void dd_set_linestr(pTHX_ char* new_value) { - int new_len = strlen(new_value); - - if (SvLEN(PL_linestr) < new_len) { - croak("forced to realloc PL_linestr for line %s, bailing out before we crash harder", SvPVX(PL_linestr)); - } - - SvGROW(PL_linestr, new_len); - - memcpy(SvPVX(PL_linestr), new_value, new_len+1); - - SvCUR_set(PL_linestr, new_len); - - PL_bufend = SvPVX(PL_linestr) + new_len; -} - char* dd_get_lex_stuff(pTHX) { return (DD_HAVE_LEX_STUFF ? SvPVX(PL_lex_stuff) : ""); } @@ -142,15 +119,6 @@ char* dd_get_curstash_name(pTHX) { return HvNAME(PL_curstash); } -int dd_get_linestr_offset(pTHX) { - char* linestr; - if (!DD_HAVE_PARSER) { - return -1; - } - linestr = SvPVX(PL_linestr); - return PL_bufptr - linestr; -} - char* dd_move_past_token (pTHX_ char* s) { /* @@ -336,18 +304,6 @@ setup() filter_add(dd_filter_realloc, NULL); char* -get_linestr() - CODE: - RETVAL = dd_get_linestr(aTHX); - OUTPUT: - RETVAL - -void -set_linestr(char* new_value) - CODE: - dd_set_linestr(aTHX_ new_value); - -char* get_lex_stuff() CODE: RETVAL = dd_get_lex_stuff(aTHX); @@ -367,13 +323,6 @@ get_curstash_name() RETVAL int -get_linestr_offset() - CODE: - RETVAL = dd_get_linestr_offset(aTHX); - OUTPUT: - RETVAL - -int toke_scan_word(int offset, int handle_package) CODE: RETVAL = dd_toke_scan_word(aTHX_ offset, handle_package); diff --git a/Makefile.PL b/Makefile.PL index ac5ef3f..3ecb2fd 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -9,9 +9,12 @@ all_from 'lib/Devel/Declare.pm'; requires 'Scalar::Util'; requires 'B::Hooks::OP::Check' => '0.10'; +requires 'B::Hooks::Parser'; build_requires 'B::Hooks::OP::Check' => '0.10'; +build_requires 'B::Hooks::Parser'; configure_requires 'ExtUtils::Depends'; configure_requires 'B::Hooks::OP::Check' => '0.10'; +configure_requires 'B::Hooks::Parser'; test_requires 'Test::More'; test_requires 'B::Hooks::EndOfScope'; @@ -19,7 +22,7 @@ postamble(<<'EOM'); $(OBJECT) : stolen_chunk_of_toke.c EOM -my $pkg = ExtUtils::Depends->new('Devel::Declare', 'B::Hooks::OP::Check'); +my $pkg = ExtUtils::Depends->new('Devel::Declare', 'B::Hooks::OP::Check', 'B::Hooks::Parser'); WriteMakefile( dist => { diff --git a/lib/Devel/Declare.pm b/lib/Devel/Declare.pm index 227b3ba..210b6a8 100644 --- a/lib/Devel/Declare.pm +++ b/lib/Devel/Declare.pm @@ -15,11 +15,20 @@ use vars qw(%declarators %declarator_handlers @ISA); use base qw(DynaLoader); use Scalar::Util 'set_prototype'; use B::Hooks::OP::Check; +use B::Hooks::Parser; bootstrap Devel::Declare; @ISA = (); +# temporary backcompat +{ + for (qw/get_linestr get_linestr_offset set_linestr/) { + no strict 'refs'; + *{ $_ } = B::Hooks::Parser->can($_); + } +} + sub import { my ($class, %args) = @_; my $target = caller;