Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Start with SV_TYPED API bits

  • Loading branch information...
commit 38ff6907dc852c6f765d24a0cf5334529819c42e 1 parent a7d7be9
@rurban authored
Showing with 44 additions and 1 deletion.
  1. +4 −0 hv.h
  2. +18 −1 sv.h
  3. +22 −0 types.pod
View
4 hv.h
@@ -403,6 +403,7 @@ C<SV*>.
#define HVhek_WASUTF8 0x02 /* Key is bytes here, but was supplied as utf8. */
#define HVhek_REHASH 0x04 /* This key is in an hv using a custom HASH . */
#define HVhek_UNSHARED 0x08 /* This key isn't a shared hash key. */
+#define HVhek_TAINT 0x80 /* This key is tainted. */
#define HVhek_FREEKEY 0x100 /* Internal flag to say key is malloc()ed. */
#define HVhek_PLACEHOLD 0x200 /* Internal flag to create placeholder.
* (may change, but Storable is a core module) */
@@ -430,6 +431,9 @@ C<SV*>.
#define HEK_WASUTF8_off(hek) (HEK_FLAGS(hek) &= ~HVhek_WASUTF8)
#define HEK_REHASH(hek) (HEK_FLAGS(hek) & HVhek_REHASH)
#define HEK_REHASH_on(hek) (HEK_FLAGS(hek) |= HVhek_REHASH)
+#define HEK_TAINTED(hek) (HEK_FLAGS(hek) & HVhek_TAINT)
+#define HEK_TAINT_on(hek) (HEK_FLAGS(hek) |= HVhek_TAINT)
+#define HEK_TAINT_off(hek) (HEK_FLAGS(hek) &= ~HVhek_TAINT)
/* calculate HV array allocation */
#ifndef PERL_USE_LARGE_HV_ALLOC
View
19 sv.h
@@ -107,6 +107,7 @@ typedef struct hek HEK;
char* svu_pv; /* pointer to malloced string */ \
IV svu_iv; \
UV svu_uv; \
+ NV svu_nv; \
SV* svu_rv; /* pointer to another SV */ \
SV** svu_array; \
HE** svu_hash; \
@@ -220,7 +221,11 @@ perform the upgrade if necessary. See C<svtype>.
=cut
*/
+#if DEBUGGING
+#define SvANY(sv) ({SV_TYPED(sv) ? assert(!SV_TYPED(sv)) : (sv)->sv_any})
+#else
#define SvANY(sv) (sv)->sv_any
+#endif
#define SvFLAGS(sv) (sv)->sv_flags
#define SvREFCNT(sv) (sv)->sv_refcnt
@@ -334,7 +339,9 @@ perform the upgrade if necessary. See C<svtype>.
4: On a pad name SV, that slot in the
frame AV is a REFCNT'ed reference
to a lexical from "outside". */
-#define SVphv_REHASH SVf_FAKE /* 5: On a PVHV, hash values are being
+ 5: On a typed pad name SV/AV/HV with SVf_READONLY,
+ marks a strict bare type without xpv*. */
+#define SVphv_REHASH SVf_FAKE /* 6: On a PVHV, hash values are being
recalculated */
#define SVf_OOK 0x02000000 /* has valid offset value. For a PVHV this
means that a hv_aux struct is present
@@ -350,6 +357,16 @@ perform the upgrade if necessary. See C<svtype>.
#define SVf_THINKFIRST (SVf_READONLY|SVf_ROK|SVf_FAKE)
+/* pad is a strict bare typed lexical: int, double or string.
+ As SV it has no sv_any pointer, _SV_HEAD_UNION contains the value.
+ IV in sv_u.svu_iv
+ NV in sv_u.svu_nv
+*/
+#define SV_TYPED (SVpad_TYPED|SVf_READONLY|SVf_FAKE|~SVf_AMAGIC)
+#define SV_TYPED_int (SV_TYPED && SVf_IOK)
+#define SV_TYPED_double (SV_TYPED && SVf_NOK)
+#define SV_TYPED_string (SV_TYPED && SVf_POK)
+
#define SVf_OK (SVf_IOK|SVf_NOK|SVf_POK|SVf_ROK| \
SVp_IOK|SVp_NOK|SVp_POK|SVpgv_GP)
View
22 types.pod
@@ -0,0 +1,22 @@
+PLAN for 5.18:
+
+types/sv
+ int,double,string detection with flags and impl (FAKE, BARE)
+
+types/av
+ typed array values
+
+types/hv
+ typed hash values
+
+types/ro
+ constants via flags, see Const::Fast
+
+types/my
+ 3 new CHECK_.. attribute hooks for my
+
+types/ck
+ use types checks (in C)
+
+types/ph
+ perfect hashes

0 comments on commit 38ff690

Please sign in to comment.
Something went wrong with that request. Please try again.