Add MUTABLE_HV(), and remove (HV *) casts from headers.
Nicholas Clark [Tue, 28 Oct 2008 18:30:54 +0000 (18:30 +0000)]
p4raw-id: //depot/perl@34619

handy.h
hv.h
scope.h

diff --git a/handy.h b/handy.h
index e020c3f..446df5b 100644 (file)
--- a/handy.h
+++ b/handy.h
@@ -55,6 +55,7 @@ Null SV pointer. (No longer available when C<PERL_CORE> is defined.)
 #endif
 
 #define MUTABLE_AV(p)  ((AV *)MUTABLE_PTR(p))
+#define MUTABLE_HV(p)  ((HV *)MUTABLE_PTR(p))
 #define MUTABLE_SV(p)  ((SV *)MUTABLE_PTR(p))
 
 /* XXX Configure ought to have a test for a boolean type, if I can
diff --git a/hv.h b/hv.h
index b5d0bda..f92ce9e 100644 (file)
--- a/hv.h
+++ b/hv.h
@@ -242,10 +242,10 @@ C<SV*>.
 /* This quite intentionally does no flag checking first. That's your
    responsibility.  */
 #define HvAUX(hv)      ((struct xpvhv_aux*)&(HvARRAY(hv)[HvMAX(hv)+1]))
-#define HvRITER(hv)    (*Perl_hv_riter_p(aTHX_ (HV*)(hv)))
-#define HvEITER(hv)    (*Perl_hv_eiter_p(aTHX_ (HV*)(hv)))
-#define HvRITER_set(hv,r)      Perl_hv_riter_set(aTHX_ (HV*)(hv), r)
-#define HvEITER_set(hv,e)      Perl_hv_eiter_set(aTHX_ (HV*)(hv), e)
+#define HvRITER(hv)    (*Perl_hv_riter_p(aTHX_ MUTABLE_HV(hv)))
+#define HvEITER(hv)    (*Perl_hv_eiter_p(aTHX_ MUTABLE_HV(hv)))
+#define HvRITER_set(hv,r)      Perl_hv_riter_set(aTHX_ MUTABLE_HV(hv), r)
+#define HvEITER_set(hv,e)      Perl_hv_eiter_set(aTHX_ MUTABLE_HV(hv), e)
 #define HvRITER_get(hv)        (SvOOK(hv) ? HvAUX(hv)->xhv_riter : -1)
 #define HvEITER_get(hv)        (SvOOK(hv) ? HvAUX(hv)->xhv_eiter : NULL)
 #define HvNAME(hv)     HvNAME_get(hv)
@@ -276,9 +276,9 @@ C<SV*>.
 #define HvKEYS(hv)             HvUSEDKEYS(hv)
 #define HvUSEDKEYS(hv)         (HvTOTALKEYS(hv) - HvPLACEHOLDERS_get(hv))
 #define HvTOTALKEYS(hv)                XHvTOTALKEYS((XPVHV*)  SvANY(hv))
-#define HvPLACEHOLDERS(hv)     (*Perl_hv_placeholders_p(aTHX_ (HV*)hv))
-#define HvPLACEHOLDERS_get(hv) (SvMAGIC(hv) ? Perl_hv_placeholders_get(aTHX_ (HV*)hv) : 0)
-#define HvPLACEHOLDERS_set(hv,p)       Perl_hv_placeholders_set(aTHX_ (HV*)hv, p)
+#define HvPLACEHOLDERS(hv)     (*Perl_hv_placeholders_p(aTHX_ MUTABLE_HV(hv)))
+#define HvPLACEHOLDERS_get(hv) (SvMAGIC(hv) ? Perl_hv_placeholders_get(aTHX_ (const HV *)hv) : 0)
+#define HvPLACEHOLDERS_set(hv,p)       Perl_hv_placeholders_set(aTHX_ MUTABLE_HV(hv), p)
 
 #define HvSHAREKEYS(hv)                (SvFLAGS(hv) & SVphv_SHAREKEYS)
 #define HvSHAREKEYS_on(hv)     (SvFLAGS(hv) |= SVphv_SHAREKEYS)
@@ -531,7 +531,7 @@ Creates a new HV.  The reference count is set to 1.
 =cut
 */
 
-#define newHV()        ((HV*)newSV_type(SVt_PVHV))
+#define newHV()        MUTABLE_HV(newSV_type(SVt_PVHV))
 
 /*
  * Local variables:
diff --git a/scope.h b/scope.h
index de658f3..25ccbf6 100644 (file)
--- a/scope.h
+++ b/scope.h
@@ -137,7 +137,7 @@ Closing bracket on a callback.  See C<ENTER> and L<perlcall>.
 #define SAVESHAREDPV(s)                save_shared_pvref((char**)&(s))
 #define SAVESETSVFLAGS(sv,mask,val)    save_set_svflags(sv,mask,val)
 #define SAVEDELETE(h,k,l) \
-         save_delete((HV*)(h), (char*)(k), (I32)(l))
+         save_delete(MUTABLE_HV(h), (char*)(k), (I32)(l))
 #define SAVEDESTRUCTOR(f,p) \
          save_destructor((DESTRUCTORFUNC_NOCONTEXT_t)(f), (void*)(p))