in reply to Re: Looking at a SV in C
in thread Looking at a SV in C

The struct is self referential. The RV in the union is another pMG *. pMG = private Magic. An MG SVANY is encountered more often than a LV so thats why I based this off a MG rather than LV. Feel free to expand it. Make sure you've read Perl Illguts before and sv.h before interpreting it. Perl loves to use unions.

Replies are listed 'Best First'.
Re^3: Looking at a SV in C
by BrowserUk (Patriarch) on Mar 22, 2012 at 20:07 UTC
    The struct is self referential.

    The primary purpose of the tag name on structs is to allow for self referential definitions.

    This compiles clean with MSVC:

    typedef struct pMG { XPVMG *sv_any; U32 sv_refcnt; union { U32 sv_flags; struct { unsigned long type : 8; unsigned long f_IOK : 1; unsigned long f_NOK : 1; unsigned long f_POK : 1; unsigned long f_ROK : 1; unsigned long p_IOK: 1; unsigned long p_NOK: 1; unsigned long p_POK : 1; unsigned long p_SCREAM_phv_CLONEABLE_phv_CLONEABLE_prv_PCS +_IMPORTED : 1; unsigned long s_PADSTALE_SVpad_STATE : 1; unsigned long s_PADTMP_SVpad_TYPED : 1; unsigned long s_PADMY_SVpad_OUR : 1; unsigned long s_TEMP : 1; unsigned long s_OBJECT : 1; unsigned long s_GMG : 1; unsigned long s_SMG : 1; unsigned long s_RMG : 1; unsigned long f_FAKE_SVphv_REHASH : 1; unsigned long f_OOK : 1; unsigned long f_BREAK: 1; unsigned long f_READONLY : 1; unsigned long f_AMAGIC : 1; unsigned long f_UTF8_SVphv_SHAREKEYS : 1; unsigned long pav_REAL_phv_LAZYDEL_pbm_VALID_repl_EVAL : 1 +; unsigned long f_IVisUV_pav_REIFY_phv_HASKFLAGS_pfm_COMPILE +D_pbm_TAIL_prv_WEAKREF : 1; } flagsraw; }; union { IV svu_iv; UV svu_uv; struct pMG *svu_rv; char *svu_pv; struct pMG **svu_array; HE **svu_hash; GP *svu_gp; } sv_u; };

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?