From: Nick Ing-Simmons Date: Sat, 20 Oct 2001 10:28:17 +0000 (+0000) Subject: Add a new flag character 'm' to embed.pl set to represent X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=af3c7592a74e7782bf0779c3272ee86140fadf53;p=p5sagit%2Fp5-mst-13.2.git Add a new flag character 'm' to embed.pl set to represent "functions" which are really macros. Use it foe the troublesome sv_setsv() etc. macros in sv.h - changing latter to define sv_setsv rather than sv_setsv_macro etc. p4raw-id: //depot/perlio@12524 --- diff --git a/embed.h b/embed.h index 341f907..58c3b59 100644 --- a/embed.h +++ b/embed.h @@ -637,7 +637,6 @@ #define sv_2iv Perl_sv_2iv #define sv_2mortal Perl_sv_2mortal #define sv_2nv Perl_sv_2nv -#define sv_2pv Perl_sv_2pv #define sv_2pvutf8 Perl_sv_2pvutf8 #define sv_2pvbyte Perl_sv_2pvbyte #define sv_pvn_nomg Perl_sv_pvn_nomg @@ -655,8 +654,6 @@ #define sv_catpvf Perl_sv_catpvf #define sv_vcatpvf Perl_sv_vcatpvf #define sv_catpv Perl_sv_catpv -#define sv_catpvn Perl_sv_catpvn -#define sv_catsv Perl_sv_catsv #define sv_chop Perl_sv_chop #define sv_clean_all Perl_sv_clean_all #define sv_clean_objs Perl_sv_clean_objs @@ -689,7 +686,6 @@ #define sv_peek Perl_sv_peek #define sv_pos_u2b Perl_sv_pos_u2b #define sv_pos_b2u Perl_sv_pos_b2u -#define sv_pvn_force Perl_sv_pvn_force #define sv_pvutf8n_force Perl_sv_pvutf8n_force #define sv_pvbyten_force Perl_sv_pvbyten_force #define sv_reftype Perl_sv_reftype @@ -709,7 +705,6 @@ #define sv_setref_pvn Perl_sv_setref_pvn #define sv_setpv Perl_sv_setpv #define sv_setpvn Perl_sv_setpvn -#define sv_setsv Perl_sv_setsv #define sv_taint Perl_sv_taint #define sv_tainted Perl_sv_tainted #define sv_unmagic Perl_sv_unmagic @@ -830,7 +825,6 @@ #define sv_pv Perl_sv_pv #define sv_pvutf8 Perl_sv_pvutf8 #define sv_pvbyte Perl_sv_pvbyte -#define sv_utf8_upgrade Perl_sv_utf8_upgrade #define sv_utf8_downgrade Perl_sv_utf8_downgrade #define sv_utf8_encode Perl_sv_utf8_encode #define sv_utf8_decode Perl_sv_utf8_decode @@ -2154,7 +2148,6 @@ #define sv_2iv(a) Perl_sv_2iv(aTHX_ a) #define sv_2mortal(a) Perl_sv_2mortal(aTHX_ a) #define sv_2nv(a) Perl_sv_2nv(aTHX_ a) -#define sv_2pv(a,b) Perl_sv_2pv(aTHX_ a,b) #define sv_2pvutf8(a,b) Perl_sv_2pvutf8(aTHX_ a,b) #define sv_2pvbyte(a,b) Perl_sv_2pvbyte(aTHX_ a,b) #define sv_pvn_nomg(a,b) Perl_sv_pvn_nomg(aTHX_ a,b) @@ -2171,8 +2164,6 @@ #define sv_bless(a,b) Perl_sv_bless(aTHX_ a,b) #define sv_vcatpvf(a,b,c) Perl_sv_vcatpvf(aTHX_ a,b,c) #define sv_catpv(a,b) Perl_sv_catpv(aTHX_ a,b) -#define sv_catpvn(a,b,c) Perl_sv_catpvn(aTHX_ a,b,c) -#define sv_catsv(a,b) Perl_sv_catsv(aTHX_ a,b) #define sv_chop(a,b) Perl_sv_chop(aTHX_ a,b) #define sv_clean_all() Perl_sv_clean_all(aTHX) #define sv_clean_objs() Perl_sv_clean_objs(aTHX) @@ -2205,7 +2196,6 @@ #define sv_peek(a) Perl_sv_peek(aTHX_ a) #define sv_pos_u2b(a,b,c) Perl_sv_pos_u2b(aTHX_ a,b,c) #define sv_pos_b2u(a,b) Perl_sv_pos_b2u(aTHX_ a,b) -#define sv_pvn_force(a,b) Perl_sv_pvn_force(aTHX_ a,b) #define sv_pvutf8n_force(a,b) Perl_sv_pvutf8n_force(aTHX_ a,b) #define sv_pvbyten_force(a,b) Perl_sv_pvbyten_force(aTHX_ a,b) #define sv_reftype(a,b) Perl_sv_reftype(aTHX_ a,b) @@ -2224,7 +2214,6 @@ #define sv_setref_pvn(a,b,c,d) Perl_sv_setref_pvn(aTHX_ a,b,c,d) #define sv_setpv(a,b) Perl_sv_setpv(aTHX_ a,b) #define sv_setpvn(a,b,c) Perl_sv_setpvn(aTHX_ a,b,c) -#define sv_setsv(a,b) Perl_sv_setsv(aTHX_ a,b) #define sv_taint(a) Perl_sv_taint(aTHX_ a) #define sv_tainted(a) Perl_sv_tainted(aTHX_ a) #define sv_unmagic(a,b) Perl_sv_unmagic(aTHX_ a,b) @@ -2339,7 +2328,6 @@ #define sv_pv(a) Perl_sv_pv(aTHX_ a) #define sv_pvutf8(a) Perl_sv_pvutf8(aTHX_ a) #define sv_pvbyte(a) Perl_sv_pvbyte(aTHX_ a) -#define sv_utf8_upgrade(a) Perl_sv_utf8_upgrade(aTHX_ a) #define sv_utf8_downgrade(a,b) Perl_sv_utf8_downgrade(aTHX_ a,b) #define sv_utf8_encode(a) Perl_sv_utf8_encode(aTHX_ a) #define sv_utf8_decode(a) Perl_sv_utf8_decode(aTHX_ a) diff --git a/embed.pl b/embed.pl index 9261787..8c3ba3c 100755 --- a/embed.pl +++ b/embed.pl @@ -114,6 +114,7 @@ sub write_protos { } else { my ($flags,$retval,$func,@args) = @_; + $ret .= '/* ' if $flags =~ /m/; if ($flags =~ /s/) { $retval = "STATIC $retval"; $func = "S_$func"; @@ -145,7 +146,9 @@ sub write_protos { $prefix, $args - 1, $prefix, $args; $ret .= "\n#endif\n"; } - $ret .= ";\n"; + $ret .= ";"; + $ret .= ' */' if $flags =~ /m/; + $ret .= "\n"; } $ret; } @@ -155,7 +158,7 @@ sub write_global_sym { my $ret = ""; if (@_ > 1) { my ($flags,$retval,$func,@args) = @_; - if ($flags =~ /A/ && $flags !~ /x/) { # public API, so export + if ($flags =~ /A/ && $flags !~ /[xm]/) { # public API, so export $func = "Perl_$func" if $flags =~ /p/; $ret = "$func\n"; } @@ -343,7 +346,7 @@ walk_table { } else { my ($flags,$retval,$func,@args) = @_; - unless ($flags =~ /o/) { + unless ($flags =~ /[om]/) { if ($flags =~ /s/) { $ret .= hide($func,"S_$func"); } @@ -376,7 +379,7 @@ walk_table { } else { my ($flags,$retval,$func,@args) = @_; - unless ($flags =~ /o/) { + unless ($flags =~ /[om]/) { my $args = scalar @args; if ($args and $args[$args-1] =~ /\.\.\./) { # we're out of luck for varargs functions under CPP @@ -1052,6 +1055,7 @@ __END__ : : flags are single letters with following meanings: : A member of public API +: m Implemented as a macro - no export, no proto, no #define : d function has documentation with its source : s static function, should have an S_ prefix in source : file @@ -1718,7 +1722,7 @@ Apd |IO* |sv_2io |SV* sv Apd |IV |sv_2iv |SV* sv Apd |SV* |sv_2mortal |SV* sv Apd |NV |sv_2nv |SV* sv -Ap |char* |sv_2pv |SV* sv|STRLEN* lp +Am |char* |sv_2pv |SV* sv|STRLEN* lp Apd |char* |sv_2pvutf8 |SV* sv|STRLEN* lp Apd |char* |sv_2pvbyte |SV* sv|STRLEN* lp Ap |char* |sv_pvn_nomg |SV* sv|STRLEN* lp @@ -1736,8 +1740,8 @@ Apd |SV* |sv_bless |SV* sv|HV* stash Afpd |void |sv_catpvf |SV* sv|const char* pat|... Ap |void |sv_vcatpvf |SV* sv|const char* pat|va_list* args Apd |void |sv_catpv |SV* sv|const char* ptr -Apd |void |sv_catpvn |SV* sv|const char* ptr|STRLEN len -Apd |void |sv_catsv |SV* dsv|SV* ssv +Amd |void |sv_catpvn |SV* sv|const char* ptr|STRLEN len +Amd |void |sv_catsv |SV* dsv|SV* ssv Apd |void |sv_chop |SV* sv|char* ptr pd |I32 |sv_clean_all pd |void |sv_clean_objs @@ -1772,7 +1776,7 @@ Apd |SV* |sv_newref |SV* sv Ap |char* |sv_peek |SV* sv Apd |void |sv_pos_u2b |SV* sv|I32* offsetp|I32* lenp Apd |void |sv_pos_b2u |SV* sv|I32* offsetp -Apd |char* |sv_pvn_force |SV* sv|STRLEN* lp +Amd |char* |sv_pvn_force |SV* sv|STRLEN* lp Apd |char* |sv_pvutf8n_force|SV* sv|STRLEN* lp Apd |char* |sv_pvbyten_force|SV* sv|STRLEN* lp Apd |char* |sv_reftype |SV* sv|int ob @@ -1793,7 +1797,7 @@ Apd |SV* |sv_setref_pvn |SV* rv|const char* classname|char* pv \ |STRLEN n Apd |void |sv_setpv |SV* sv|const char* ptr Apd |void |sv_setpvn |SV* sv|const char* ptr|STRLEN len -Apd |void |sv_setsv |SV* dsv|SV* ssv +Amd |void |sv_setsv |SV* dsv|SV* ssv Apd |void |sv_taint |SV* sv Apd |bool |sv_tainted |SV* sv Apd |int |sv_unmagic |SV* sv|int type @@ -1925,7 +1929,7 @@ Apd |char* |sv_2pvbyte_nolen|SV* sv Apd |char* |sv_pv |SV *sv Apd |char* |sv_pvutf8 |SV *sv Apd |char* |sv_pvbyte |SV *sv -Apd |STRLEN |sv_utf8_upgrade|SV *sv +Amd |STRLEN |sv_utf8_upgrade|SV *sv ApdM |bool |sv_utf8_downgrade|SV *sv|bool fail_ok Apd |void |sv_utf8_encode |SV *sv ApdM |bool |sv_utf8_decode |SV *sv diff --git a/global.sym b/global.sym index b5c912b..c5a9246 100644 --- a/global.sym +++ b/global.sym @@ -393,7 +393,6 @@ Perl_sv_2io Perl_sv_2iv Perl_sv_2mortal Perl_sv_2nv -Perl_sv_2pv Perl_sv_2pvutf8 Perl_sv_2pvbyte Perl_sv_pvn_nomg @@ -410,8 +409,6 @@ Perl_sv_bless Perl_sv_catpvf Perl_sv_vcatpvf Perl_sv_catpv -Perl_sv_catpvn -Perl_sv_catsv Perl_sv_chop Perl_sv_clear Perl_sv_cmp @@ -439,7 +436,6 @@ Perl_sv_newref Perl_sv_peek Perl_sv_pos_u2b Perl_sv_pos_b2u -Perl_sv_pvn_force Perl_sv_pvutf8n_force Perl_sv_pvbyten_force Perl_sv_reftype @@ -459,7 +455,6 @@ Perl_sv_setref_pv Perl_sv_setref_pvn Perl_sv_setpv Perl_sv_setpvn -Perl_sv_setsv Perl_sv_taint Perl_sv_tainted Perl_sv_unmagic @@ -549,7 +544,6 @@ Perl_sv_2pvbyte_nolen Perl_sv_pv Perl_sv_pvutf8 Perl_sv_pvbyte -Perl_sv_utf8_upgrade Perl_sv_utf8_downgrade Perl_sv_utf8_encode Perl_sv_utf8_decode diff --git a/pod/perlapi.pod b/pod/perlapi.pod index 0abdc1c..6665191 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -329,7 +329,7 @@ L. SV* cv_const_sv(CV* cv) =for hackers -Found in file op.c +Found in file opmini.c =item dAX @@ -1234,7 +1234,7 @@ method, similar to C. void load_module(U32 flags, SV* name, SV* ver, ...) =for hackers -Found in file op.c +Found in file opmini.c =item looks_like_number @@ -1373,7 +1373,7 @@ eligible for inlining at compile-time. CV* newCONSTSUB(HV* stash, char* name, SV* sv) =for hackers -Found in file op.c +Found in file opmini.c =item newHV @@ -1533,7 +1533,7 @@ Found in file sv.c Used by C to hook up XSUBs as Perl subs. =for hackers -Found in file op.c +Found in file opmini.c =item newXSproto @@ -2397,22 +2397,22 @@ which guarantees to evaluate sv only once. =for hackers Found in file sv.h -=item SvNVX +=item SvNVx -Returns the raw value in the SV's NV slot, without checks or conversions. -Only use when you are sure SvNOK is true. See also C. +Coerces the given SV to a double and returns it. Guarantees to evaluate +sv only once. Use the more efficent C otherwise. - NV SvNVX(SV* sv) + NV SvNVx(SV* sv) =for hackers Found in file sv.h -=item SvNVx +=item SvNVX -Coerces the given SV to a double and returns it. Guarantees to evaluate -sv only once. Use the more efficent C otherwise. +Returns the raw value in the SV's NV slot, without checks or conversions. +Only use when you are sure SvNOK is true. See also C. - NV SvNVx(SV* sv) + NV SvNVX(SV* sv) =for hackers Found in file sv.h @@ -2606,21 +2606,21 @@ Like C, but converts sv to uft8 first if necessary. =for hackers Found in file sv.h -=item SvPVx +=item SvPVX -A version of C which guarantees to evaluate sv only once. +Returns a pointer to the physical string in the SV. The SV must contain a +string. - char* SvPVx(SV* sv, STRLEN len) + char* SvPVX(SV* sv) =for hackers Found in file sv.h -=item SvPVX +=item SvPVx -Returns a pointer to the physical string in the SV. The SV must contain a -string. +A version of C which guarantees to evaluate sv only once. - char* SvPVX(SV* sv) + char* SvPVx(SV* sv, STRLEN len) =for hackers Found in file sv.h @@ -2827,19 +2827,19 @@ false, defined or undefined. Does not handle 'get' magic. =for hackers Found in file sv.h -=item SvTYPE - -Returns the type of the SV. See C. +=item svtype - svtype SvTYPE(SV* sv) +An enum of flags for Perl types. These are found in the file B +in the C enum. Test these flags with the C macro. =for hackers Found in file sv.h -=item svtype +=item SvTYPE -An enum of flags for Perl types. These are found in the file B -in the C enum. Test these flags with the C macro. +Returns the type of the SV. See C. + + svtype SvTYPE(SV* sv) =for hackers Found in file sv.h diff --git a/proto.h b/proto.h index 0e1d3b0..ff3ac5f 100644 --- a/proto.h +++ b/proto.h @@ -701,7 +701,7 @@ PERL_CALLCONV IO* Perl_sv_2io(pTHX_ SV* sv); PERL_CALLCONV IV Perl_sv_2iv(pTHX_ SV* sv); PERL_CALLCONV SV* Perl_sv_2mortal(pTHX_ SV* sv); PERL_CALLCONV NV Perl_sv_2nv(pTHX_ SV* sv); -PERL_CALLCONV char* Perl_sv_2pv(pTHX_ SV* sv, STRLEN* lp); +/* PERL_CALLCONV char* sv_2pv(pTHX_ SV* sv, STRLEN* lp); */ PERL_CALLCONV char* Perl_sv_2pvutf8(pTHX_ SV* sv, STRLEN* lp); PERL_CALLCONV char* Perl_sv_2pvbyte(pTHX_ SV* sv, STRLEN* lp); PERL_CALLCONV char* Perl_sv_pvn_nomg(pTHX_ SV* sv, STRLEN* lp); @@ -723,8 +723,8 @@ PERL_CALLCONV void Perl_sv_catpvf(pTHX_ SV* sv, const char* pat, ...) ; PERL_CALLCONV void Perl_sv_vcatpvf(pTHX_ SV* sv, const char* pat, va_list* args); PERL_CALLCONV void Perl_sv_catpv(pTHX_ SV* sv, const char* ptr); -PERL_CALLCONV void Perl_sv_catpvn(pTHX_ SV* sv, const char* ptr, STRLEN len); -PERL_CALLCONV void Perl_sv_catsv(pTHX_ SV* dsv, SV* ssv); +/* PERL_CALLCONV void sv_catpvn(pTHX_ SV* sv, const char* ptr, STRLEN len); */ +/* PERL_CALLCONV void sv_catsv(pTHX_ SV* dsv, SV* ssv); */ PERL_CALLCONV void Perl_sv_chop(pTHX_ SV* sv, char* ptr); PERL_CALLCONV I32 Perl_sv_clean_all(pTHX); PERL_CALLCONV void Perl_sv_clean_objs(pTHX); @@ -757,7 +757,7 @@ PERL_CALLCONV SV* Perl_sv_newref(pTHX_ SV* sv); PERL_CALLCONV char* Perl_sv_peek(pTHX_ SV* sv); PERL_CALLCONV void Perl_sv_pos_u2b(pTHX_ SV* sv, I32* offsetp, I32* lenp); PERL_CALLCONV void Perl_sv_pos_b2u(pTHX_ SV* sv, I32* offsetp); -PERL_CALLCONV char* Perl_sv_pvn_force(pTHX_ SV* sv, STRLEN* lp); +/* PERL_CALLCONV char* sv_pvn_force(pTHX_ SV* sv, STRLEN* lp); */ PERL_CALLCONV char* Perl_sv_pvutf8n_force(pTHX_ SV* sv, STRLEN* lp); PERL_CALLCONV char* Perl_sv_pvbyten_force(pTHX_ SV* sv, STRLEN* lp); PERL_CALLCONV char* Perl_sv_reftype(pTHX_ SV* sv, int ob); @@ -781,7 +781,7 @@ PERL_CALLCONV SV* Perl_sv_setref_pv(pTHX_ SV* rv, const char* classname, void* p PERL_CALLCONV SV* Perl_sv_setref_pvn(pTHX_ SV* rv, const char* classname, char* pv, STRLEN n); PERL_CALLCONV void Perl_sv_setpv(pTHX_ SV* sv, const char* ptr); PERL_CALLCONV void Perl_sv_setpvn(pTHX_ SV* sv, const char* ptr, STRLEN len); -PERL_CALLCONV void Perl_sv_setsv(pTHX_ SV* dsv, SV* ssv); +/* PERL_CALLCONV void sv_setsv(pTHX_ SV* dsv, SV* ssv); */ PERL_CALLCONV void Perl_sv_taint(pTHX_ SV* sv); PERL_CALLCONV bool Perl_sv_tainted(pTHX_ SV* sv); PERL_CALLCONV int Perl_sv_unmagic(pTHX_ SV* sv, int type); @@ -922,7 +922,7 @@ PERL_CALLCONV char* Perl_sv_2pvbyte_nolen(pTHX_ SV* sv); PERL_CALLCONV char* Perl_sv_pv(pTHX_ SV *sv); PERL_CALLCONV char* Perl_sv_pvutf8(pTHX_ SV *sv); PERL_CALLCONV char* Perl_sv_pvbyte(pTHX_ SV *sv); -PERL_CALLCONV STRLEN Perl_sv_utf8_upgrade(pTHX_ SV *sv); +/* PERL_CALLCONV STRLEN sv_utf8_upgrade(pTHX_ SV *sv); */ PERL_CALLCONV bool Perl_sv_utf8_downgrade(pTHX_ SV *sv, bool fail_ok); PERL_CALLCONV void Perl_sv_utf8_encode(pTHX_ SV *sv); PERL_CALLCONV bool Perl_sv_utf8_decode(pTHX_ SV *sv); diff --git a/sv.h b/sv.h index 4d08a90..039c22f 100644 --- a/sv.h +++ b/sv.h @@ -972,29 +972,15 @@ otherwise. #undef SvNV #define SvNV(sv) (SvNOK(sv) ? SvNVX(sv) : sv_2nv(sv)) -#define sv_setsv_macro(dsv, ssv) sv_setsv_flags(dsv, ssv, SV_GMAGIC) +#define sv_setsv(dsv, ssv) sv_setsv_flags(dsv, ssv, SV_GMAGIC) #define sv_setsv_nomg(dsv, ssv) sv_setsv_flags(dsv, ssv, 0) -#define sv_catsv_macro(dsv, ssv) sv_catsv_flags(dsv, ssv, SV_GMAGIC) +#define sv_catsv(dsv, ssv) sv_catsv_flags(dsv, ssv, SV_GMAGIC) #define sv_catsv_nomg(dsv, ssv) sv_catsv_flags(dsv, ssv, 0) -#define sv_catpvn_macro(dsv, sstr, slen) sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC) -#define sv_2pv_macro(sv, lp) sv_2pv_flags(sv, lp, SV_GMAGIC) +#define sv_catpvn(dsv, sstr, slen) sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC) +#define sv_2pv(sv, lp) sv_2pv_flags(sv, lp, SV_GMAGIC) #define sv_2pv_nomg(sv, lp) sv_2pv_flags(sv, lp, 0) -#define sv_pvn_force_macro(sv, lp) sv_pvn_force_flags(sv, lp, SV_GMAGIC) -#define sv_utf8_upgrade_macro(sv) sv_utf8_upgrade_flags(sv, SV_GMAGIC) - -/* function style also available for sourcecompat */ -#undef sv_setsv -#define sv_setsv(dsv, ssv) sv_setsv_macro(dsv, ssv) -#undef sv_catsv -#define sv_catsv(dsv, ssv) sv_catsv_macro(dsv, ssv) -#undef sv_catpvn -#define sv_catpvn(dsv, sstr, slen) sv_catpvn_macro(dsv, sstr, slen) -#undef sv_2pv -#define sv_2pv(sv, lp) sv_2pv_macro(sv, lp) -#undef sv_pvn_force -#define sv_pvn_force(sv, lp) sv_pvn_force_macro(sv, lp) -#undef sv_utf8_upgrade -#define sv_utf8_upgrade(sv) sv_utf8_upgrade_macro(sv) +#define sv_pvn_force(sv, lp) sv_pvn_force_flags(sv, lp, SV_GMAGIC) +#define sv_utf8_upgrade(sv) sv_utf8_upgrade_flags(sv, SV_GMAGIC) #undef SvPV #define SvPV(sv, lp) SvPV_flags(sv, lp, SV_GMAGIC)