[Bast-commits] r4859 - Devel-Declare/1.000/trunk

matthewt at dev.catalyst.perl.org matthewt at dev.catalyst.perl.org
Tue Sep 30 12:17:32 BST 2008


Author: matthewt
Date: 2008-09-30 12:17:32 +0100 (Tue, 30 Sep 2008)
New Revision: 4859

Modified:
   Devel-Declare/1.000/trunk/Changes
   Devel-Declare/1.000/trunk/Declare.xs
Log:
clean up lexing checks

Modified: Devel-Declare/1.000/trunk/Changes
===================================================================
--- Devel-Declare/1.000/trunk/Changes	2008-09-30 09:29:02 UTC (rev 4858)
+++ Devel-Declare/1.000/trunk/Changes	2008-09-30 11:17:32 UTC (rev 4859)
@@ -1,5 +1,8 @@
 Changes for Devel-Declare
 
+  - clean up checks for whether we're lexing and whether lex_stuff exists
+    to handle the PL_parser factor-out in 5.10
+
 0.002000
   - rewrite guts into perl, add tests for new declaration style
 

Modified: Devel-Declare/1.000/trunk/Declare.xs
===================================================================
--- Devel-Declare/1.000/trunk/Declare.xs	2008-09-30 09:29:02 UTC (rev 4858)
+++ Devel-Declare/1.000/trunk/Declare.xs	2008-09-30 11:17:32 UTC (rev 4859)
@@ -29,6 +29,22 @@
 
 static int in_declare = 0;
 
+/* in 5.10, PL_parser will be NULL if we aren't parsing, and PL_lex_stuff
+   is a lookup into it - so if anything else we can use to tell, so we
+   need to be a bit more careful if PL_parser exists */
+
+#define DD_AM_LEXING_CHECK (PL_lex_state == LEX_NORMAL || PL_lex_state == LEX_INTERPNORMAL)
+
+#ifdef PL_parser
+#define DD_HAVE_PARSER PL_parser
+#define DD_HAVE_LEX_STUFF (PL_parser && PL_lex_stuff)
+#define DD_AM_LEXING (PL_parser && DD_AM_LEXING_CHECK)
+#else
+#define DD_HAVE_PARSER 1
+#define DD_HAVE_LEX_STUFF PL_lex_stuff
+#define DD_AM_LEXING DD_AM_LEXING_CHECK
+#endif
+
 /* thing that decides whether we're dealing with a declarator */
 
 int dd_is_declarator(pTHX_ char* name) {
@@ -117,11 +133,12 @@
 }
 
 char* dd_get_lex_stuff(pTHX) {
-  return (PL_lex_stuff ? SvPVX(PL_lex_stuff) : "");
+  return (DD_HAVE_LEX_STUFF ? SvPVX(PL_lex_stuff) : "");
 }
 
 char* dd_clear_lex_stuff(pTHX) {
-  PL_lex_stuff = Nullsv;
+  if (DD_HAVE_PARSER)
+    PL_lex_stuff = Nullsv;
 }
 
 char* dd_get_curstash_name(pTHX) {
@@ -209,7 +226,7 @@
   if (kid->op_type != OP_GV) /* not a GV so ignore */
     return o;
 
-  if (PL_lex_state != LEX_NORMAL && PL_lex_state != LEX_INTERPNORMAL)
+  if (!DD_AM_LEXING)
     return o; /* not lexing? */
 
 #ifdef DD_DEBUG




More information about the Bast-commits mailing list