cvs commit: ponie/perl sv.h

[email protected] (Nicholas Clark) 15 Oct 2004 10:06:48 -0000
Newsgroups perl.ponie.changes
Message-ID <[email protected]>
cvsuser     04/10/15 03:06:48

  Modified:    src/pmc  perl5cargo_cult.pmc
               perl     sv.h
  Log:
  Enumerations for all the remaining actions
  Correct SvIOK_off() [needs to also turn off the IV flag]
  SvVOK(), SvOOK() and SvFAKE() into the PMC
  
  Revision  Changes    Path
  1.23      +40 -1     ponie/src/pmc/perl5cargo_cult.pmc
  
  Index: perl5cargo_cult.pmc
  ===================================================================
  RCS file: /cvs/public/ponie/src/pmc/perl5cargo_cult.pmc,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -w -r1.22 -r1.23
  --- perl5cargo_cult.pmc	14 Oct 2004 23:36:13 -0000	1.22
  +++ perl5cargo_cult.pmc	15 Oct 2004 10:06:45 -0000	1.23
  @@ -1,7 +1,7 @@
   /* Perl5QQQ.pmc -*- c -*-
    *  Copyright: 2001-2004 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: perl5cargo_cult.pmc,v 1.22 2004/10/14 23:36:13 nicholas Exp $
  + *     $Id: perl5cargo_cult.pmc,v 1.23 2004/10/15 10:06:45 nicholas Exp $
    *  Overview:
    *     These are the vtable functions for the Perl5QQQ base class
    *  Data Structure and Algorithms:
  @@ -31,6 +31,11 @@
       SvOOK_off(MUMBLE(pmc));
   }
   
  +static I32 S_SvMAGICAL(PMC *pmc) {
  +  return (((struct STRUCT_SV *)PMC_struct_val(pmc))->sv_flags)
  +      & (SVs_GMG|SVs_SMG|SVs_RMG);
  +}
  +
   pmclass Perl5QQQ dynpmc {
   
       void init () {	
  @@ -134,6 +139,14 @@
   	case Ponie_I_SVf_UTF8:
   	    return ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
   			 & SVf_UTF8;
  +	case Ponie_I_SV_VOK:
  +	    return S_SvMAGICAL(SELF) && mg_find(MUMBLE(SELF),'V');
  +	case Ponie_I_SVf_OOK:
  +	    return ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
  +			 & SVf_OOK;
  +	case Ponie_I_SVf_FAKE:
  +	    return ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
  +			 & SVf_FAKE;
   
   	default:
   	    croak ("Out of range or illegal key %d (max is %d) "
  @@ -202,6 +215,12 @@
   		    |= (SVp_IOK|SVf_IOK);
   	    }
   	    return;
  +	case Ponie_I_SVpf_IOK_UTF8:
  +	    if (!value) {
  +		(((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
  +		    &= ~(SVp_IOK|SVf_IOK|SVf_IVisUV);
  +		return;
  +	    }
   	case Ponie_I_SVf_IVisUV:
   	    (((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
   		&= ~SVf_IVisUV;
  @@ -303,6 +322,26 @@
   		    |= SVf_UTF8;
   	    }
   	    return;
  +	case Ponie_I_SVf_OOK:
  +	    if (value) {
  +		(((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
  +		    &= ~(SVp_IOK|SVf_IOK|SVf_IVisUV);
  +		(((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
  +		    |= SVf_OOK;
  +	    } else {
  +		if ((((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
  +		    & SVf_OOK) {
  +		    sv_backoff(MUMBLE(SELF));
  +		}
  +	    }
  +	    return;
  +	case Ponie_I_SVf_FAKE:
  +	    (((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags) &= ~SVf_FAKE;
  +	    if (value) {
  +		(((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
  +		    |= SVf_FAKE;
  +	    }
  +	    return;
   
   	default:
   	    /* Hush gcc. There is a default.  */;
  
  
  
  1.34      +34 -9     ponie/perl/sv.h
  
  Index: sv.h
  ===================================================================
  RCS file: /cvs/public/ponie/perl/sv.h,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -w -r1.33 -r1.34
  --- sv.h	14 Oct 2004 23:36:13 -0000	1.33
  +++ sv.h	15 Oct 2004 10:06:47 -0000	1.34
  @@ -428,6 +428,7 @@
     Ponie_I_SVf_IOK,
     Ponie_I_SVp_IOK,
     Ponie_I_SVpf_IOK,
  +  Ponie_I_SVpf_IOK_UTF8,
     Ponie_I_SVpf_IOK_only,
     Ponie_I_SVpf_IOK_only_exc_UV,
     Ponie_I_SVf_IOK_UV,
  @@ -446,6 +447,29 @@
     Ponie_I_SVpf_POK_only,
     Ponie_I_SVpf_POK_only_UTF8,
     Ponie_I_SVf_UTF8,
  +  Ponie_I_SV_VOK,
  +  Ponie_I_SVf_OOK,
  +  Ponie_I_SVf_FAKE,
  +  Ponie_I_SVf_ROK,
  +  Ponie_I_SVf_ROK_AMAGIC,
  +  Ponie_I_SV_GMAGICAL,
  +  Ponie_I_SV_SMAGICAL,
  +  Ponie_I_SV_RMAGICAL,
  +  Ponie_I_SV_AMAGIC,
  +  Ponie_I_SV_GAMAGIC,
  +  Ponie_I_SV_WEAKREF,
  +  Ponie_I_SV_THINKFIRST,
  +  Ponie_I_SV_PADSTALE,
  +  Ponie_I_SV_PADTMP,
  +  Ponie_I_SV_PADMY,
  +  Ponie_I_SV_TEMP,
  +  Ponie_I_SV_OBJECT,
  +  Ponie_I_SV_READONLY,
  +  Ponie_I_SV_SCREAM,
  +  Ponie_I_SV_COMPILED,
  +  Ponie_I_SV_EVALED,
  +  Ponie_I_SV_TAIL,
  +  Ponie_I_SV_VALID,
     Ponie_I_MAX
   } Ponie_integers;
   
  @@ -609,7 +633,7 @@
   
   #define SvIOK(sv)		((U32)Parrot_PMC_get_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_IOK))
   #define SvIOK_on(sv)		Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVpf_IOK, 1)
  -#define SvIOK_off(sv)		Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVpf_IOK, 0)
  +#define SvIOK_off(sv)		Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVpf_IOK_UTF8, 0)
   #define SvIOK_only(sv)		Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVpf_IOK_only, 1)
   #define SvIOK_only_UV(sv)	Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVpf_IOK_only_exc_UV, 1)
   
  @@ -654,14 +678,15 @@
   #define SvPOK_only(sv)		Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVpf_POK_only, 1)
   #define SvPOK_only_UTF8(sv)	Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVpf_POK_only_UTF8, 1)
   
  -#define SvVOK(sv)		(SvMAGICAL(sv) && mg_find(sv,'V'))
  -#define SvOOK(sv)		(SvFLAGS(sv) & SVf_OOK)
  -#define SvOOK_on(sv)		((void)SvIOK_off(sv), SvFLAGS(sv) |= SVf_OOK)
  -#define SvOOK_off(sv)		(SvOOK(sv) && sv_backoff(sv))
  -
  -#define SvFAKE(sv)		(SvFLAGS(sv) & SVf_FAKE)
  -#define SvFAKE_on(sv)		(SvFLAGS(sv) |= SVf_FAKE)
  -#define SvFAKE_off(sv)		(SvFLAGS(sv) &= ~SVf_FAKE)
  +#define SvVOK(sv)		((U32)Parrot_PMC_get_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SV_VOK))
  +#define SvOOK(sv)		((U32)Parrot_PMC_get_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_OOK))
  +#define SvOOK_on(sv)		Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_OOK, 1)
  +#define SvOOK_off(sv)		Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_OOK, 0)
  +
  +#define SvFAKE(sv)		((U32)Parrot_PMC_get_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_FAKE))
  +#define SvFAKE_on(sv)		Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_FAKE, 1)
  +#define SvFAKE_off(sv)		Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_FAKE, 0)
  +
   
   #define SvROK(sv)		(SvFLAGS(sv) & SVf_ROK)
   #define SvROK_on(sv)		(SvFLAGS(sv) |= SVf_ROK)