This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Refactoring to Sv*_set() macros - patch #6
authorSteve Peters <steve@fisharerojo.org>
Wed, 20 Apr 2005 06:27:20 +0000 (01:27 -0500)
committerNicholas Clark <nick@ccl4.org>
Wed, 20 Apr 2005 13:51:54 +0000 (13:51 +0000)
Message-ID: <20050420112720.GA31042@mccoy.peters.homeunix.org>
Date: Wed, 20 Apr 2005 06:27:20 -0500

p4raw-id: //depot/perl@24260

bytecode.pl
ext/ByteLoader/bytecode.h
malloc.c
sv.c

index d471763..adf1d1f 100644 (file)
@@ -368,12 +368,12 @@ sv_upgrade        bstate->bs_sv                           U8              x
 sv_refcnt      SvREFCNT(bstate->bs_sv)                 U32
 sv_refcnt_add  SvREFCNT(bstate->bs_sv)                 I32             x
 sv_flags       SvFLAGS(bstate->bs_sv)                  U32
-xrv            SvRV(bstate->bs_sv)                     svindex
+xrv            bstate->bs_sv                           svindex         x
 xpv            bstate->bs_sv                           none            x
-xpv_cur                SvCUR(bstate->bs_sv)                    STRLEN
-xpv_len                SvLEN(bstate->bs_sv)                    STRLEN
-xiv            SvIVX(bstate->bs_sv)                    IV
-xnv            SvNVX(bstate->bs_sv)                    NV
+xpv_cur                bstate->bs_sv                           STRLEN          x
+xpv_len                bstate->bs_sv                           STRLEN          x
+xiv            bstate->bs_sv                           IV              x
+xnv            bstate->bs_sv                           NV              x
 xlv_targoff    LvTARGOFF(bstate->bs_sv)                STRLEN
 xlv_targlen    LvTARGLEN(bstate->bs_sv)                STRLEN
 xlv_targ       LvTARG(bstate->bs_sv)                   svindex
@@ -422,7 +422,7 @@ mg_private  SvMAGIC(bstate->bs_sv)->mg_private      U16
 mg_flags       SvMAGIC(bstate->bs_sv)->mg_flags        U8
 mg_name                SvMAGIC(bstate->bs_sv)                  pvcontents      x
 mg_namex       SvMAGIC(bstate->bs_sv)                  svindex         x
-xmg_stash      *(SV**)&SvSTASH(bstate->bs_sv)          svindex
+xmg_stash      bstate->bs_sv                           svindex         X
 gv_fetchpv     bstate->bs_sv                           strconst        x
 gv_fetchpvx    bstate->bs_sv                           strconst        x
 gv_stashpv     bstate->bs_sv                           strconst        x
index 0224625..11e7f5f 100644 (file)
@@ -126,12 +126,19 @@ typedef char *pvindex;
 #define BSET_mg_namex(mg, arg)                 \
        (mg->mg_ptr = (char*)SvREFCNT_inc((SV*)arg),    \
         mg->mg_len = HEf_SVKEY)
+#define BSET_xmg_stash(sv, arg) SvSTASH_set(sv, arg)
 #define BSET_sv_upgrade(sv, arg)       (void)SvUPGRADE(sv, arg)
+#define BSET_xrv(sv, arg) SvRV_set(sv, arg)
 #define BSET_xpv(sv)   do {    \
        SvPV_set(sv, bstate->bs_pv.xpv_pv);     \
        SvCUR_set(sv, bstate->bs_pv.xpv_cur);   \
        SvLEN_set(sv, bstate->bs_pv.xpv_len);   \
     } while (0)
+#define BSET_xpv_cur(sv, arg) SvCUR_set(sv, arg)
+#define BSET_xpv_len(sv, arg) SvLEN_set(sv, arg)
+#define BSET_xiv(sv, arg) SvIV_set(sv, arg)
+#define BSET_xnv(sv, arg) SvNV_set(sv, arg)
+
 #define BSET_av_extend(sv, arg)        av_extend((AV*)sv, arg)
 
 #define BSET_av_push(sv, arg)  av_push((AV*)sv, arg)
index 569ac49..de5766d 100644 (file)
--- a/malloc.c
+++ b/malloc.c
@@ -1176,7 +1176,8 @@ perl_get_emergency_buffer(IV *size)
 
     SvPOK_off(sv);
     SvPV_set(sv, Nullch);
-    SvCUR(sv) = SvLEN(sv) = 0;
+    SvCUR_set(sv, 0);
+    SvLEN_set(sv, 0);
     *size = malloced_size(pv) + M_OVERHEAD;
     return pv - sizeof(union overhead);
 }
diff --git a/sv.c b/sv.c
index ff5ba0d..f0a5a0f 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -4541,8 +4541,8 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags)
                                       (sflags & SVf_UTF8?-cur:cur), hash));
                     SvUV_set(dstr, hash);
                 }
-                SvLEN(dstr) = len;
-                SvCUR(dstr) = cur;
+                SvLEN_set(dstr, len);
+                SvCUR_set(dstr, cur);
                 SvREADONLY_on(dstr);
                 SvFAKE_on(dstr);
                 /* Relesase a global SV mutex.  */
@@ -4703,8 +4703,8 @@ Perl_sv_setsv_cow(pTHX_ SV *dstr, SV *sstr)
     SvFLAGS(dstr) = (SVt_PVIV|SVf_POK|SVp_POK|SVf_FAKE|SVf_READONLY);
     if (SvUTF8(sstr))
        SvUTF8_on(dstr);
-    SvLEN(dstr) = len;
-    SvCUR(dstr) = cur;
+    SvLEN_set(dstr, len);
+    SvCUR_set(dstr, cur);
     if (DEBUG_C_TEST) {
        sv_dump(dstr);
     }
@@ -4944,14 +4944,14 @@ Perl_sv_force_normal_flags(pTHX_ register SV *sv, U32 flags)
             SvREADONLY_off(sv);
             /* This SV doesn't own the buffer, so need to New() a new one:  */
             SvPV_set(sv, (char*)0);
-            SvLEN(sv) = 0;
+            SvLEN_set(sv, 0);
             if (flags & SV_COW_DROP_PV) {
                 /* OK, so we don't need to copy our buffer.  */
                 SvPOK_off(sv);
             } else {
                 SvGROW(sv, cur + 1);
                 Move(pvx,SvPVX(sv),cur,char);
-                SvCUR(sv) = cur;
+                SvCUR_set(sv, cur);
                 *SvEND(sv) = '\0';
             }
             sv_release_COW(sv, pvx, cur, len, hash, next);