This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
yyparse: reindent
[perl5.git] / sv.h
diff --git a/sv.h b/sv.h
index b97c175..ee65879 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -374,6 +374,15 @@ perform the upgrade if necessary.  See C<L</svtype>>.
                                       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;
@@ -413,7 +422,12 @@ perform the upgrade if necessary.  See C<L</svtype>>.
 
 #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) */
@@ -1118,7 +1132,8 @@ object type. Exposed to perl code via Internals::SvREADONLY().
 /* 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))         \