cvs commit: ponie/src/pmc perl5cargo_cult.pmc
[email protected] (Nicholas Clark) 14 Oct 2004 23:36:13 -0000
| Newsgroups | perl.ponie.changes |
|---|---|
| Message-ID | <[email protected]> |
cvsuser 04/10/14 16:36:13
Modified: perl sv.h
src/pmc perl5cargo_cult.pmc
Log:
Move UV, UTF8 and _only() macros into PMC
Revision Changes Path
1.33 +15 -17 ponie/perl/sv.h
Index: sv.h
===================================================================
RCS file: /cvs/public/ponie/perl/sv.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -w -r1.32 -r1.33
--- sv.h 14 Oct 2004 18:26:16 -0000 1.32
+++ sv.h 14 Oct 2004 23:36:13 -0000 1.33
@@ -432,15 +432,20 @@
Ponie_I_SVpf_IOK_only_exc_UV,
Ponie_I_SVf_IOK_UV,
Ponie_I_SVf_IOK_notUV,
+ Ponie_I_SVf_IVisUV,
Ponie_I_SVf_NIOK,
Ponie_I_SVp_NIOK,
Ponie_I_SVpf_NIOK,
Ponie_I_SVf_NOK,
Ponie_I_SVp_NOK,
Ponie_I_SVpf_NOK,
+ Ponie_I_SVpf_NOK_only,
Ponie_I_SVf_POK,
Ponie_I_SVp_POK,
Ponie_I_SVpf_POK,
+ Ponie_I_SVpf_POK_only,
+ Ponie_I_SVpf_POK_only_UTF8,
+ Ponie_I_SVf_UTF8,
Ponie_I_MAX
} Ponie_integers;
@@ -612,15 +617,14 @@
#define SvUOK(sv) SvIOK_UV(sv)
#define SvIOK_notUV(sv) ((U32)Parrot_PMC_get_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_IOK_notUV))
-#define SvIsUV(sv) (SvFLAGS(sv) & SVf_IVisUV)
-#define SvIsUV_on(sv) (SvFLAGS(sv) |= SVf_IVisUV)
-#define SvIsUV_off(sv) (SvFLAGS(sv) &= ~SVf_IVisUV)
+#define SvIsUV(sv) ((U32)Parrot_PMC_get_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_IVisUV))
+#define SvIsUV_on(sv) Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_IVisUV, 1)
+#define SvIsUV_off(sv) Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_IVisUV, 0)
#define SvNOK(sv) ((U32)Parrot_PMC_get_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_NOK))
#define SvNOK_on(sv) Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVpf_NOK, 1)
#define SvNOK_off(sv) Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVpf_NOK, 0)
-#define SvNOK_only(sv) ((void)SvOK_off(sv), \
- SvFLAGS(sv) |= (SVf_NOK|SVp_NOK))
+#define SvNOK_only(sv) Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVpf_NOK_only, 1)
/*
=for apidoc Am|bool|SvUTF8|SV* sv
@@ -640,21 +644,15 @@
=cut
*/
-#define SvUTF8(sv) (SvFLAGS(sv) & SVf_UTF8)
-#define SvUTF8_on(sv) (SvFLAGS(sv) |= (SVf_UTF8))
-#define SvUTF8_off(sv) (SvFLAGS(sv) &= ~(SVf_UTF8))
+#define SvUTF8(sv) ((U32)Parrot_PMC_get_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_UTF8))
+#define SvUTF8_on(sv) Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_UTF8, 1)
+#define SvUTF8_off(sv) Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_UTF8, 0)
#define SvPOK(sv) ((U32)Parrot_PMC_get_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVf_POK))
#define SvPOK_on(sv) Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVpf_POK, 1)
#define SvPOK_off(sv) Parrot_PMC_set_intval_intkey(PL_Parrot,MUMBLE(sv), Ponie_I_SVpf_POK, 0)
-#define SvPOK_only(sv) (assert_not_ROK(sv) \
- SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC| \
- SVf_IVisUV|SVf_UTF8), \
- SvFLAGS(sv) |= (SVf_POK|SVp_POK))
-#define SvPOK_only_UTF8(sv) (assert_not_ROK(sv) \
- SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC| \
- SVf_IVisUV), \
- SvFLAGS(sv) |= (SVf_POK|SVp_POK))
+#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)
1.22 +68 -5 ponie/src/pmc/perl5cargo_cult.pmc
Index: perl5cargo_cult.pmc
===================================================================
RCS file: /cvs/public/ponie/src/pmc/perl5cargo_cult.pmc,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -w -r1.21 -r1.22
--- perl5cargo_cult.pmc 14 Oct 2004 18:26:16 -0000 1.21
+++ perl5cargo_cult.pmc 14 Oct 2004 23:36:13 -0000 1.22
@@ -1,7 +1,7 @@
/* Perl5QQQ.pmc -*- c -*-
* Copyright: 2001-2004 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: perl5cargo_cult.pmc,v 1.21 2004/10/14 18:26:16 nicholas Exp $
+ * $Id: perl5cargo_cult.pmc,v 1.22 2004/10/14 23:36:13 nicholas Exp $
* Overview:
* These are the vtable functions for the Perl5QQQ base class
* Data Structure and Algorithms:
@@ -88,6 +88,9 @@
case Ponie_I_SVf_IOK:
return ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
& SVf_IOK;
+ case Ponie_I_SVf_IVisUV:
+ return ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
+ & SVf_IVisUV;
case Ponie_I_SVpf_IOK:
return ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
& (SVf_IOK|SVf_IOK);
@@ -128,10 +131,13 @@
case Ponie_I_SVpf_POK:
return ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
& (SVf_POK|SVf_POK);
+ case Ponie_I_SVf_UTF8:
+ return ((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags
+ & SVf_UTF8;
default:
croak ("Out of range or illegal key %d (max is %d) "
- " in get_integer_keyed_int", key, Ponie_P_MAX - 1);
+ "in get_integer_keyed_int", key, Ponie_I_MAX - 1);
}
return 0;
}
@@ -142,26 +148,34 @@
if (!value) {
/* Only legal thing to do is turn this off. */
S_SvOK_off(SELF);
+ return;
}
+ break;
case Ponie_I_SVpf_IOK_only:
if (value) {
/* Only legal thing to do is turn this on. */
S_SvOK_off(SELF);
(((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
|= (SVp_IOK|SVf_IOK);
+ return;
}
+ break;
case Ponie_I_SVf_OK_exc_UV:
if (!value) {
/* Only legal thing to do is turn this off. */
S_SvOK_off_exc_UV(SELF);
+ return;
}
+ break;
case Ponie_I_SVpf_IOK_only_exc_UV:
if (value) {
/* Only legal thing to do is turn this on. */
S_SvOK_off_exc_UV(SELF);
(((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
|= (SVp_IOK|SVf_IOK);
+ return;
}
+ break;
case Ponie_I_SVp_IOK:
(((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags) &= ~SVp_IOK;
@@ -188,6 +202,15 @@
|= (SVp_IOK|SVf_IOK);
}
return;
+ case Ponie_I_SVf_IVisUV:
+ (((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
+ &= ~SVf_IVisUV;
+ if (value) {
+ SvRELEASE_IVX(MUMBLE(SELF));
+ (((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
+ |= SVf_IVisUV;
+ }
+ return;
case Ponie_I_SVpf_NIOK:
if (!value) {
@@ -196,6 +219,7 @@
&= ~(SVf_IOK|SVf_NOK|SVp_IOK|SVp_NOK|SVf_IVisUV);
return;
}
+ break;
case Ponie_I_SVp_NOK:
(((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags) &= ~SVp_NOK;
@@ -216,6 +240,15 @@
(((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
|= (SVp_NOK|SVf_NOK);
return;
+ case Ponie_I_SVpf_NOK_only:
+ if (value) {
+ /* Only legal thing to do is turn this on. */
+ S_SvOK_off(SELF);
+ (((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
+ |= (SVp_NOK|SVf_NOK);
+ return;
+ }
+ break;
case Ponie_I_SVp_POK:
@@ -237,15 +270,45 @@
case Ponie_I_SVpf_POK:
(((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
&= ~(SVp_POK|SVf_POK);
- if (value)
+ if (value) {
+ assert_not_ROK(MUMBLE(SELF)) 0;
(((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
|= (SVp_POK|SVf_POK);
+ }
+ return;
+ case Ponie_I_SVpf_POK_only:
+ if (value) {
+ assert_not_ROK(MUMBLE(SELF)) 0;
+ (((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
+ &= ~(SVf_OK|SVf_AMAGIC|SVf_IVisUV|SVf_UTF8);
+ (((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
+ |= (SVp_POK|SVf_POK);
+ return;
+ }
+ break;
+ case Ponie_I_SVpf_POK_only_UTF8:
+ if (value) {
+ assert_not_ROK(MUMBLE(SELF)) 0;
+ (((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
+ &= ~(SVf_OK|SVf_AMAGIC|SVf_IVisUV);
+ (((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
+ |= (SVp_POK|SVf_POK);
+ return;
+ }
+ break;
+ case Ponie_I_SVf_UTF8:
+ (((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags) &= ~SVf_UTF8;
+ if (value) {
+ (((struct STRUCT_SV *)PMC_struct_val(SELF))->sv_flags)
+ |= SVf_UTF8;
+ }
return;
default:
- croak ("Out of range or illegal key %d (max is %d)"
- " in get_integer_keyed_int", key, Ponie_P_MAX - 1);
+ /* Hush gcc. There is a default. */;
}
+ croak ("Out of range or illegal key %d (max is %d), value is %d"
+ " in set_integer_keyed_int", key, Ponie_I_MAX - 1, value);
return;
}
}