/* *** any alterations to the SV types above need to be reflected in
* SVt_MASK and the various PL_valid_types_* tables. As of this writing those
* tables are in perl.h. There are also two affected names tables in dump.c,
- * one in B.xs, and 'bodies_by_type[]' in sv.c */
+ * one in B.xs, and 'bodies_by_type[]' in sv.c.
+ *
+ * The bits that match 0xf0 are CURRENTLY UNUSED, except that 0xFF means a
+ * freed SV. The bits above that are for flags, like SVf_IOK */
#define SVt_MASK 0xf /* smallest bitmask that covers all types */
subroutine in another package. Set the
GvIMPORTED_CV_on() if it needs to be
expanded to a real GV */
+
+/* SVf_PROTECT is what SVf_READONLY should have been: i.e. modifying
+ * this SV is completely illegal. However, SVf_READONLY (via
+ * Internals::SvREADONLY()) has come to be seen as a flag that can be
+ * temporarily set and unset by the user to indicate e.g. whether a hash
+ * is "locked". Now, Hash::Util et al only set SVf_READONLY, while core
+ * sets both (SVf_READONLY|SVf_PROTECT) to indicate both to core and user
+ * code that this SV should not be messed with.
+ */
#define SVf_PROTECT 0x00010000 /* very read-only */
#define SVs_PADTMP 0x00020000 /* in use as tmp */
#define SVs_PADSTALE 0x00040000 /* lexical has gone out of scope;
#define PRIVSHIFT 4 /* (SVp_?OK >> PRIVSHIFT) == SVf_?OK */
-/* Note that SVf_AMAGIC is now only set on stashes. */
+/* SVf_AMAGIC means that the stash *may* have have overload methods. It's
+ * set each time a function is compiled into a stash, and is reset by the
+ * overload code when called for the first time and finds that there are
+ * no overload methods. Note that this used to be set on the object; but
+ * is now only set on stashes.
+ */
#define SVf_AMAGIC 0x10000000 /* has magical overloaded methods */
#define SVf_IsCOW 0x10000000 /* copy on write (shared hash key if
SvLEN == 0) */
SV* xlv_targ;
char xlv_type; /* k=keys .=pos x=substr v=vec /=join/re
* y=alem/helem/iter t=tie T=tied HE */
- char xlv_flags; /* 1 = negative offset 2 = negative len */
+ char xlv_flags; /* 1 = negative offset 2 = negative len
+ 4 = out of range (vec) */
};
#define xlv_targoff xlv_targoff_u.xlvu_targoff
/* Does the SV have a Boyer-Moore table attached as magic?
* 'VALID' is a poor name, but is kept for historical reasons. */
#define SvVALID(_svvalid) ( \
- SvSMAGICAL(_svvalid) \
+ SvPOKp(_svvalid) \
+ && SvSMAGICAL(_svvalid) \
&& SvMAGIC(_svvalid) \
&& (SvMAGIC(_svvalid)->mg_type == PERL_MAGIC_bm \
|| mg_find(_svvalid, PERL_MAGIC_bm)) \
Like C<SvPV_nolen> but doesn't process magic.
=for apidoc Am|IV|SvIV|SV* sv
-Coerces the given SV to an integer and returns it. See C<L</SvIVx>> for a
-version which guarantees to evaluate C<sv> only once.
+Coerces the given SV to IV and returns it. The returned value in many
+circumstances will get stored in C<sv>'s IV slot, but not in all cases. (Use
+C<L</sv_setiv>> to make sure it does).
+
+See C<L</SvIVx>> for a version which guarantees to evaluate C<sv> only once.
=for apidoc Am|IV|SvIV_nomg|SV* sv
Like C<SvIV> but doesn't process magic.
=for apidoc Am|IV|SvIVx|SV* sv
-Coerces the given SV to an integer and returns it.
-Guarantees to evaluate C<sv> only once. Only use
-this if C<sv> is an expression with side effects,
-otherwise use the more efficient C<SvIV>.
+Coerces the given SV to IV and returns it. The returned value in many
+circumstances will get stored in C<sv>'s IV slot, but not in all cases. (Use
+C<L</sv_setiv>> to make sure it does).
+
+This form guarantees to evaluate C<sv> only once. Only use this if C<sv> is an
+expression with side effects, otherwise use the more efficient C<SvIV>.
=for apidoc Am|NV|SvNV|SV* sv
-Coerce the given SV to a double and return it. See C<L</SvNVx>> for a version
-which guarantees to evaluate C<sv> only once.
+Coerces the given SV to NV and returns it. The returned value in many
+circumstances will get stored in C<sv>'s NV slot, but not in all cases. (Use
+C<L</sv_setnv>> to make sure it does).
+
+See C<L</SvNVx>> for a version which guarantees to evaluate C<sv> only once.
=for apidoc Am|NV|SvNV_nomg|SV* sv
Like C<SvNV> but doesn't process magic.
=for apidoc Am|NV|SvNVx|SV* sv
-Coerces the given SV to a double and returns it.
-Guarantees to evaluate C<sv> only once. Only use
-this if C<sv> is an expression with side effects,
-otherwise use the more efficient C<SvNV>.
+Coerces the given SV to NV and returns it. The returned value in many
+circumstances will get stored in C<sv>'s NV slot, but not in all cases. (Use
+C<L</sv_setnv>> to make sure it does).
+
+This form guarantees to evaluate C<sv> only once. Only use this if C<sv> is an
+expression with side effects, otherwise use the more efficient C<SvNV>.
=for apidoc Am|UV|SvUV|SV* sv
-Coerces the given SV to an unsigned integer and returns it. See C<L</SvUVx>>
-for a version which guarantees to evaluate C<sv> only once.
+Coerces the given SV to UV and returns it. The returned value in many
+circumstances will get stored in C<sv>'s UV slot, but not in all cases. (Use
+C<L</sv_setuv>> to make sure it does).
+
+See C<L</SvUVx>> for a version which guarantees to evaluate C<sv> only once.
=for apidoc Am|UV|SvUV_nomg|SV* sv
Like C<SvUV> but doesn't process magic.
=for apidoc Am|UV|SvUVx|SV* sv
-Coerces the given SV to an unsigned integer and
-returns it. Guarantees to evaluate C<sv> only once. Only
-use this if C<sv> is an expression with side effects,
-otherwise use the more efficient C<SvUV>.
+Coerces the given SV to UV and returns it. The returned value in many
+circumstances will get stored in C<sv>'s UV slot, but not in all cases. (Use
+C<L</sv_setuv>> to make sure it does).
+
+This form guarantees to evaluate C<sv> only once. Only use this if C<sv> is an
+expression with side effects, otherwise use the more efficient C<SvUV>.
=for apidoc Am|bool|SvTRUE|SV* sv
Returns a boolean indicating whether Perl would evaluate the SV as true or
#define SvSHARED_HASH(sv) (0 + SvSHARED_HEK_FROM_PV(SvPVX_const(sv))->hek_hash)
/* flag values for sv_*_flags functions */
+#define SV_UTF8_NO_ENCODING 0 /* No longer used */
#define SV_IMMEDIATE_UNREF 1
#define SV_GMAGIC 2
#define SV_COW_DROP_PV 4
-#define SV_UTF8_NO_ENCODING 8
#define SV_NOSTEAL 16
#define SV_CONST_RETURN 32
#define SV_MUTABLE_RETURN 64
buffer. SV must be of type >= C<SVt_PV>. One
alternative is to call C<sv_grow> if you are not sure of the type of SV.
+You might mistakenly think that C<len> is the number of bytes to add to the
+existing size, but instead it is the total size C<sv> should be.
+
=for apidoc Am|char *|SvPVCLEAR|SV* sv
Ensures that sv is a SVt_PV and that its SvCUR is 0, and that it is
properly null terminated. Equivalent to sv_setpvs(""), but more efficient.