From dbebbdb4f8fce905319dd478ac6436d7a5ae8cad Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Tue, 28 Oct 2008 18:30:54 +0000 Subject: Add MUTABLE_HV(), and remove (HV *) casts from headers. p4raw-id: //depot/perl@34619 --- handy.h | 1 + hv.h | 16 ++++++++-------- scope.h | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/handy.h b/handy.h index e020c3fa61..446df5b2c9 100644 --- a/handy.h +++ b/handy.h @@ -55,6 +55,7 @@ Null SV pointer. (No longer available when C 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 b5d0bda7cb..f92ce9e9fd 100644 --- a/hv.h +++ b/hv.h @@ -242,10 +242,10 @@ C. /* 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. #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 de658f3dae..25ccbf6fdb 100644 --- a/scope.h +++ b/scope.h @@ -137,7 +137,7 @@ Closing bracket on a callback. See C and L. #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)) -- cgit v1.2.1