diff options
-rw-r--r-- | embed.fnc | 1 | ||||
-rw-r--r-- | embed.h | 2 | ||||
-rw-r--r-- | global.sym | 1 | ||||
-rw-r--r-- | gv.c | 14 | ||||
-rw-r--r-- | gv.h | 31 | ||||
-rw-r--r-- | proto.h | 3 | ||||
-rw-r--r-- | sv.c | 6 |
7 files changed, 39 insertions, 19 deletions
@@ -278,6 +278,7 @@ Ap |void |gv_fullname |NN SV* sv|NN const GV* gv Apmb |void |gv_fullname3 |NN SV* sv|NN const GV* gv|NULLOK const char* prefix Ap |void |gv_fullname4 |NN SV* sv|NN const GV* gv|NULLOK const char* prefix|bool keepmain Ap |void |gv_init |NN GV* gv|NULLOK HV* stash|NN const char* name|STRLEN len|int multi +Ap |void |gv_name_set |NN GV* gv|NULLOK const char *name|U32 len|U32 flags Apd |HV* |gv_stashpv |NN const char* name|I32 create Apd |HV* |gv_stashpvn |NN const char* name|U32 namelen|I32 create Apd |HV* |gv_stashsv |NULLOK SV* sv|I32 create @@ -265,6 +265,7 @@ #define gv_fullname Perl_gv_fullname #define gv_fullname4 Perl_gv_fullname4 #define gv_init Perl_gv_init +#define gv_name_set Perl_gv_name_set #define gv_stashpv Perl_gv_stashpv #define gv_stashpvn Perl_gv_stashpvn #define gv_stashsv Perl_gv_stashsv @@ -2343,6 +2344,7 @@ #define gv_fullname(a,b) Perl_gv_fullname(aTHX_ a,b) #define gv_fullname4(a,b,c,d) Perl_gv_fullname4(aTHX_ a,b,c,d) #define gv_init(a,b,c,d,e) Perl_gv_init(aTHX_ a,b,c,d,e) +#define gv_name_set(a,b,c,d) Perl_gv_name_set(aTHX_ a,b,c,d) #define gv_stashpv(a,b) Perl_gv_stashpv(aTHX_ a,b) #define gv_stashpvn(a,b,c) Perl_gv_stashpvn(aTHX_ a,b,c) #define gv_stashsv(a,b) Perl_gv_stashsv(aTHX_ a,b) diff --git a/global.sym b/global.sym index a0ad6b2488..222af6d25a 100644 --- a/global.sym +++ b/global.sym @@ -140,6 +140,7 @@ Perl_gv_fullname Perl_gv_fullname3 Perl_gv_fullname4 Perl_gv_init +Perl_gv_name_set Perl_gv_stashpv Perl_gv_stashpvn Perl_gv_stashsv @@ -215,8 +215,7 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi) GvSTASH(gv) = stash; if (stash) Perl_sv_add_backref(aTHX_ (SV*)stash, (SV*)gv); - GvNAME(gv) = savepvn(name, len); - GvNAMELEN(gv) = len; + gv_name_set(gv, name, len, 0); if (multi || doproto) /* doproto means it _was_ mentioned */ GvMULTI_on(gv); if (doproto) { /* Replicate part of newSUB here. */ @@ -2104,6 +2103,17 @@ Perl_is_gv_magical(pTHX_ const char *name, STRLEN len, U32 flags) return FALSE; } +void +Perl_gv_name_set(pTHX_ GV *gv, const char *name, U32 len, U32 flags) +{ + dVAR; + + PERL_UNUSED_ARG(flags); + + GvXPVGV(gv)->xgv_name = name ? savepvn(name, len) : NULL; + GvXPVGV(gv)->xgv_namelen = len; +} + /* * Local variables: * c-indentation-style: bsd @@ -43,26 +43,29 @@ struct gp { assert(SvTYPE(_gv) == SVt_PVGV || SvTYPE(_gv) >= SVt_PVLV); \ &(GvXPVGV(_gv)->xnv_u.xgv_stash); \ })) -# define GvNAME(gv) \ - (*({ GV * const zzzz = (GV *) (gv); \ - assert(isGV_with_GP(zzzz)); \ - assert(SvTYPE(zzzz) == SVt_PVGV || SvTYPE(zzzz) >= SVt_PVLV); \ - &(GvXPVGV(zzzz)->xgv_name); \ - })) -# define GvNAMELEN(gv) \ - (*({ GV * const glank = (GV *) (gv); \ - assert(isGV_with_GP(glank)); \ - assert(SvTYPE(glank) == SVt_PVGV || SvTYPE(glank) >= SVt_PVLV); \ - &(GvXPVGV(glank)->xgv_namelen); \ - })) +# define GvNAME_get(gv) \ + ({ GV * const zzzz = (GV *) (gv); \ + assert(isGV_with_GP(zzzz)); \ + assert(SvTYPE(zzzz) == SVt_PVGV || SvTYPE(zzzz) >= SVt_PVLV); \ + 0 + (GvXPVGV(zzzz)->xgv_name); \ + }) +# define GvNAMELEN_get(gv) \ + ({ GV * const glank = (GV *) (gv); \ + assert(isGV_with_GP(glank)); \ + assert(SvTYPE(glank) == SVt_PVGV || SvTYPE(glank) >= SVt_PVLV); \ + 0 + (GvXPVGV(glank)->xgv_namelen); \ + }) #else # define GvGP(gv) ((gv)->sv_u.svu_gp) # define GvFLAGS(gv) (GvXPVGV(gv)->xpv_cur) # define GvSTASH(gv) (GvXPVGV(gv)->xnv_u.xgv_stash) -# define GvNAME(gv) (GvXPVGV(gv)->xgv_name) -# define GvNAMELEN(gv) (GvXPVGV(gv)->xgv_namelen) +# define GvNAME_get(gv) (0 + GvXPVGV(gv)->xgv_name) +# define GvNAMELEN_get(gv) (0 + GvXPVGV(gv)->xgv_namelen) #endif +#define GvNAME(gv) GvNAME_get(gv) +#define GvNAMELEN(gv) GvNAMELEN_get(gv) + #define GvASSIGN_GENERATION(gv) (0 + ((XPV*) SvANY(gv))->xpv_len) #define GvASSIGN_GENERATION_set(gv,val) \ STMT_START { assert(SvTYPE(gv) == SVt_PVGV); \ @@ -644,6 +644,9 @@ PERL_CALLCONV void Perl_gv_init(pTHX_ GV* gv, HV* stash, const char* name, STRLE __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_3); +PERL_CALLCONV void Perl_gv_name_set(pTHX_ GV* gv, const char *name, U32 len, U32 flags) + __attribute__nonnull__(pTHX_1); + PERL_CALLCONV HV* Perl_gv_stashpv(pTHX_ const char* name, I32 create) __attribute__nonnull__(pTHX_1); @@ -3216,8 +3216,7 @@ S_glob_assign_glob(pTHX_ SV *dstr, SV *sstr, const int dtype) GvSTASH(dstr) = GvSTASH(sstr); if (GvSTASH(dstr)) Perl_sv_add_backref(aTHX_ (SV*)GvSTASH(dstr), dstr); - GvNAME(dstr) = savepvn(name, len); - GvNAMELEN(dstr) = len; + gv_name_set(dstr, name, len, 0); SvFAKE_on(dstr); /* can coerce to non-glob */ } @@ -9837,7 +9836,8 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param) LvTARG(dstr) = sv_dup_inc(LvTARG(dstr), param); break; case SVt_PVGV: - GvNAME(dstr) = SAVEPVN(GvNAME(dstr), GvNAMELEN(dstr)); + GvXPVGV(dstr)->xgv_name = SAVEPVN(GvNAME(dstr), GvNAMELEN(dstr)); + /* Don't call sv_add_backref here as it's going to be created as part of the magic cloning of the symbol table. */ GvSTASH(dstr) = hv_dup(GvSTASH(dstr), param); |