diff options
author | Brian Fraser <fraserbn@gmail.com> | 2011-07-06 01:50:31 -0300 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-10-06 13:01:05 -0700 |
commit | 3453414d531db0c778c66f126da0b0269cd8486f (patch) | |
tree | 31e5088e29c31a862522b412bb232bf53e44b244 /ext/XS-APItest | |
parent | d8fdd025024d41a9ad5abe7cd22c7e157f845656 (diff) | |
download | perl-3453414d531db0c778c66f126da0b0269cd8486f.tar.gz |
op.c: newCONSTSUB and newXS UTF8 cleanup.
newXS was merged into newXS_flags; added a line in the docs
recommeding using that instead.
newCONSTSUB got a _flags version, which generates the CV in
the right glob if passed the UTF-8 flag.
Diffstat (limited to 'ext/XS-APItest')
-rw-r--r-- | ext/XS-APItest/APItest.xs | 21 | ||||
-rw-r--r-- | ext/XS-APItest/t/newCONSTSUB.t | 24 |
2 files changed, 45 insertions, 0 deletions
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs index 1af3674088..b3513439ac 100644 --- a/ext/XS-APItest/APItest.xs +++ b/ext/XS-APItest/APItest.xs @@ -1840,6 +1840,27 @@ call_method(methname, flags, ...) PUSHs(sv_2mortal(newSViv(i))); void +newCONSTSUB_type(stash, name, flags, type) + HV* stash + SV* name + I32 flags + int type + PREINIT: + CV* cv; + PPCODE: + switch (type) { + case 0: + cv = newCONSTSUB(stash, SvPV_nolen(name), NULL); + break; + case 1: + cv = newCONSTSUB_flags(stash, SvPV_nolen(name), flags | SvUTF8(name), NULL); + break; + } + EXTEND(SP, 2); + PUSHs( CvCONST(cv) ? &PL_sv_yes : &PL_sv_no ); + PUSHs((SV*)CvGV(cv)); + +void gv_init_type(namesv, multi, flags, type) SV* namesv int multi diff --git a/ext/XS-APItest/t/newCONSTSUB.t b/ext/XS-APItest/t/newCONSTSUB.t new file mode 100644 index 0000000000..4a2edd62ab --- /dev/null +++ b/ext/XS-APItest/t/newCONSTSUB.t @@ -0,0 +1,24 @@ +#!perl + +use strict; +use warnings; +use utf8; +use open qw( :utf8 :std ); +use Test::More "no_plan"; + +use XS::APItest; + +my ($const, $glob) = XS::APItest::newCONSTSUB_type(\%::, "sanity_check", 0, 0); + +ok $const; +ok *{$glob}{CODE}; + +($const, $glob) = XS::APItest::newCONSTSUB_type(\%::, "\x{30cb}", 0, 0); +ok $const, "newCONSTSUB generates the constant,"; +ok *{$glob}{CODE}, "..and the glob,"; +ok !$::{"\x{30cb}"}, "...but not the right one"; + +($const, $glob) = XS::APItest::newCONSTSUB_type(\%::, "\x{30cd}", 0, 1); +ok $const, "newCONSTSUB_flags generates the constant,"; +ok *{$glob}{CODE}, "..and the glob,"; +ok $::{"\x{30cd}"}, "...the right one!"; |