we now have
struct STRUCT_SV { /* struct sv { */ void* sv_any; /* pointer to something */ U32 sv_refcnt; /* how many references to us */ U32 sv_flags; /* what we are */ union { IV svu_iv; UV svu_uv; SV* svu_rv; /* pointer to another SV */ char* svu_pv; /* pointer to malloced string */ SV** svu_array; } sv_u; } wherein the 2 'data' fields are separated by the 'management' fields. It seems potentially useful to juggle them so that the 2 data are contiguous, then we could (after a bit more tweaking) store doubles, complex numbers, and other nasties. attached patch defines 2 new macros SV_DATA(type), and SV_MGMT, and uses them in the 7 sv-head struct variations. All passes tests too, despite the tectonics.
diff -u ../bleadperl/sv.h juggle/sv.h --- ../bleadperl/sv.h 2005-06-15 16:59:45.000000000 -0600 +++ juggle/sv.h 2005-06-18 11:15:38.000000000 -0600 @@ -62,19 +62,28 @@ SVt_PVIO /* 15 */ } svtype; -/* Using C's structural equivalence to help emulate C++ inheritance here... */ +/* Using C's structural equivalence to help emulate C++ inheritance here. + Start with 2 macros which define the fields comprising every SV flavor, + then define 7 flavors of sv-heads with them. +*/ +#define SV_DATA(TYPE) \ + TYPE sv_any; /* pointer to something */ \ + union { \ + IV svu_iv; \ + UV svu_uv; \ + SV* svu_rv; /* pointer to another SV */ \ + char* svu_pv; /* pointer to malloced string */ \ + SV** svu_array; \ + } sv_u + +#define SV_MGMT \ + U32 sv_refcnt; /* how many references to us */ \ + U32 sv_flags /* what we are (whats in DATA) */ + struct STRUCT_SV { /* struct sv { */ - void* sv_any; /* pointer to something */ - U32 sv_refcnt; /* how many references to us */ - U32 sv_flags; /* what we are */ - union { - IV svu_iv; - UV svu_uv; - SV* svu_rv; /* pointer to another SV */ - char* svu_pv; /* pointer to malloced string */ - SV** svu_array; - } sv_u; + SV_DATA(void*); + SV_MGMT; #ifdef DEBUG_LEAKING_SCALARS unsigned sv_debug_optype:9; /* the type of OP that allocated us */ unsigned sv_debug_inpad:1; /* was allocated in a pad for an OP */ @@ -85,68 +94,28 @@ }; struct gv { - XPVGV* sv_any; /* pointer to something */ - U32 sv_refcnt; /* how many references to us */ - U32 sv_flags; /* what we are */ - union { - IV svu_iv; - UV svu_uv; - SV* svu_rv; - char* svu_pv; - SV** svu_array; - } sv_u; + SV_DATA(XPVGV*); + SV_MGMT; }; struct cv { - XPVCV* sv_any; /* pointer to something */ - U32 sv_refcnt; /* how many references to us */ - U32 sv_flags; /* what we are */ - union { - IV svu_iv; - UV svu_uv; - SV* svu_rv; - char* svu_pv; - SV** svu_array; - } sv_u; + SV_DATA(XPVCV*); + SV_MGMT; }; struct av { - XPVAV* sv_any; /* pointer to something */ - U32 sv_refcnt; /* how many references to us */ - U32 sv_flags; /* what we are */ - union { - IV svu_iv; - UV svu_uv; - SV* svu_rv; - char* svu_pv; /* pointer to first array element */ - SV** svu_array; - } sv_u; + SV_DATA(XPVAV*); + SV_MGMT; }; struct hv { - XPVHV* sv_any; /* pointer to something */ - U32 sv_refcnt; /* how many references to us */ - U32 sv_flags; /* what we are */ - union { - IV svu_iv; - UV svu_uv; - SV* svu_rv; - char* svu_pv; - SV** svu_array; - } sv_u; + SV_DATA(XPVHV*); + SV_MGMT; }; struct io { - XPVIO* sv_any; /* pointer to something */ - U32 sv_refcnt; /* how many references to us */ - U32 sv_flags; /* what we are */ - union { - IV svu_iv; - UV svu_uv; - SV* svu_rv; - char* svu_pv; - SV** svu_array; - } sv_u; + SV_DATA(XPVIO*); + SV_MGMT; }; /*