cvs commit: ponie/src/pmc perl5cargo_cult.pmc

[email protected] (Nicholas Clark) 13 Oct 2004 20:56:29 -0000
Newsgroups perl.ponie.changes
Message-ID <[email protected]>
cvsuser     04/10/13 13:56:29

  Modified:    perl     sv.h
               src/pmc  perl5cargo_cult.pmc
  Log:
  Add enumeration flags and implementation code for IV and NIV tests/sets/clears
  via PMC methods
  
  Revision  Changes    Path
  1.25      +6 -0      ponie/perl/sv.h
  
  Index: sv.h
  ===================================================================
  RCS file: /cvs/public/ponie/perl/sv.h,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -w -r1.24 -r1.25
  --- sv.h	25 Jun 2004 19:38:22 -0000	1.24
  +++ sv.h	13 Oct 2004 20:56:28 -0000	1.25
  @@ -422,6 +422,12 @@
   } Ponie_pointers;
   
   typedef enum {
  +  Ponie_I_SVf_IOK,
  +  Ponie_I_SVp_IOK,
  +  Ponie_I_SVpf_IOK,
  +  Ponie_I_SVf_NIOK,
  +  Ponie_I_SVp_NIOK,
  +  Ponie_I_SVpf_NIOK,
     Ponie_I_SVf_NOK,
     Ponie_I_SVp_NOK,
     Ponie_I_SVpf_NOK,
  
  
  
  1.14      +54 -4     ponie/src/pmc/perl5cargo_cult.pmc
  
  Index: perl5cargo_cult.pmc
  ===================================================================
  RCS file: /cvs/public/ponie/src/pmc/perl5cargo_cult.pmc,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -w -r1.13 -r1.14
  --- perl5cargo_cult.pmc	30 Aug 2004 14:37:45 -0000	1.13
  +++ perl5cargo_cult.pmc	13 Oct 2004 20:56:29 -0000	1.14
  @@ -1,7 +1,7 @@
   /* Perl5QQQ.pmc -*- c -*-
    *  Copyright: 2001-2004 The Perl Foundation.  All Rights Reserved.
    *  CVS Info
  - *     $Id: perl5cargo_cult.pmc,v 1.13 2004/08/30 14:37:45 nicholas Exp $
  + *     $Id: perl5cargo_cult.pmc,v 1.14 2004/10/13 20:56:29 nicholas Exp $
    *  Overview:
    *     These are the vtable functions for the Perl5QQQ base class
    *  Data Structure and Algorithms:
  @@ -53,13 +53,33 @@
   	case Ponie_P_HVPLACEHOLDERS:
   	    return &(((struct STRUCT_SV *)PMC_struct_val(SELF))->xnv_nv);
   	    default:
  -	    croak ("Out of range key %d (max is %d)", key, Ponie_P_MAX - 1);
  +	    croak ("Out of range or illegal key %d (max is %d)"
  +		   " get_pointer_keyed_int", key, Ponie_P_MAX - 1);
   	}
   	return 0;
       }
   
       INTVAL get_integer_keyed_int(INTVAL key) {
   	switch (key) {
  +	case Ponie_I_SVp_IOK:
  +	    return ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
  +			 & SVp_IOK;
  +	case Ponie_I_SVf_IOK:
  +	    return ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
  +			 & SVf_IOK;
  +	case Ponie_I_SVpf_IOK:
  +	    return ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
  +			 & (SVf_IOK|SVf_IOK);
  +
  +	case Ponie_I_SVp_NIOK:
  +	    return ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
  +		& (SVp_IOK|SVp_NOK);
  +	case Ponie_I_SVf_NIOK:
  +	    return ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
  +		& (SVf_IOK|SVf_NOK);
  +	case Ponie_I_SVpf_NIOK:
  +	    croak ("Invalid key %d (Ponie_I_SVpf_NIOK)", key);
  +
   	case Ponie_I_SVp_NOK:
   	    return ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
   			 & SVp_NOK;
  @@ -70,13 +90,42 @@
   	    return ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
   			 & (SVf_NOK|SVf_NOK);
   	default:
  -	    croak ("Out of range key %d (max is %d)", key, Ponie_P_MAX - 1);
  +	    croak ("Out of range or illegal key %d (max is %d) "
  +		   " in get_integer_keyed_int", key, Ponie_P_MAX - 1);
   	}
   	return 0;
       }
   
       void set_integer_keyed_int(INTVAL key, INTVAL value) {
   	switch (key) {
  +	case Ponie_I_SVp_IOK:
  +	    (((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags) &= ~SVp_IOK;
  +	    if (value)
  +		(((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
  +		    |= SVp_IOK;
  +	    return;
  +	case Ponie_I_SVf_IOK:
  +	    (((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags) &= ~SVf_IOK;
  +	    if (value)
  +		(((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
  +		    |= SVf_IOK;
  +	    return;
  +	case Ponie_I_SVpf_IOK:
  +	    (((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
  +		&= ~(SVp_IOK|SVf_IOK);
  +	    if (value)
  +		(((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
  +		    |= (SVp_IOK|SVf_IOK);
  +	    return;
  +
  +	case Ponie_I_SVpf_NIOK:
  +	    if (!value) {
  +		/* Only legal thing to do is turn this off.  */
  +		(((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
  +		    &= ~(SVf_IOK|SVf_NOK|SVp_IOK|SVp_NOK|SVf_IVisUV);
  +		return;
  +	    }
  +
   	case Ponie_I_SVp_NOK:
   	    (((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags) &= ~SVp_NOK;
   	    if (value)
  @@ -97,7 +146,8 @@
   		    |= (SVp_NOK|SVf_NOK);
   	    return;
   	default:
  -	    croak ("Out of range key %d (max is %d)", key, Ponie_P_MAX - 1);
  +	    croak ("Out of range or illegal key %d (max is %d)"
  +		   " in get_integer_keyed_int", key, Ponie_P_MAX - 1);
   	}
   	return;
       }