[Bast-commits] r3550 - in trunk/Devel-Declare: . t

matthewt at dev.catalyst.perl.org matthewt at dev.catalyst.perl.org
Fri Jun 29 06:20:24 GMT 2007


Author: matthewt
Date: 2007-06-29 06:20:23 +0100 (Fri, 29 Jun 2007)
New Revision: 3550

Modified:
   trunk/Devel-Declare/Declare.xs
   trunk/Devel-Declare/stolen_chunk_of_toke.c
   trunk/Devel-Declare/t/simple.t
Log:
debug flag, extra test

Modified: trunk/Devel-Declare/Declare.xs
===================================================================
--- trunk/Devel-Declare/Declare.xs	2007-06-29 02:32:08 UTC (rev 3549)
+++ trunk/Devel-Declare/Declare.xs	2007-06-29 05:20:23 UTC (rev 3550)
@@ -9,6 +9,14 @@
 #include <stdio.h>
 #include <string.h>
 
+#define DD_DEBUG 0
+
+#ifdef DD_DEBUG
+#define DD_DEBUG_S printf("Buffer: %s\n", s);
+#else
+#define DD_DEBUG_S
+#endif
+
 #define LEX_NORMAL    10
 #define LEX_INTERPNORMAL   9
 
@@ -54,7 +62,9 @@
 
   stash = GvSTASH(kGVOP_gv);
 
-  /* printf("Checking GV %s -> %s\n", HvNAME(stash), GvNAME(kGVOP_gv)); */
+#ifdef DD_DEBUG
+  printf("Checking GV %s -> %s\n", HvNAME(stash), GvNAME(kGVOP_gv));
+#endif
 
   is_declarator = get_hv("Devel::Declare::declarators", FALSE);
 
@@ -77,20 +87,36 @@
 
   s = PL_bufptr; /* copy the current buffer pointer */
 
+  DD_DEBUG_S
+
+#ifdef DD_DEBUG
+  printf("PL_tokenbuf: %s", PL_tokenbuf);
+#endif
+
+  /*
+   *   buffer will be at the beginning of the declarator, -unless- the
+   *   declarator is at EOL in which case it'll be the next useful line
+   *   so we don't short-circuit out if we don't find the declarator
+   */
+
   while (s < PL_bufend && isSPACE(*s)) s++;
   if (memEQ(s, PL_tokenbuf, strlen(PL_tokenbuf)))
     s += strlen(PL_tokenbuf);
-  else
-    return o;
 
+  DD_DEBUG_S
+
   /* find next word */
 
   s = skipspace(s);
 
+  DD_DEBUG_S
+
   /* 0 in arg 4 is allow_package - not trying that yet :) */
 
   s = scan_word(s, tmpbuf, sizeof tmpbuf, 0, &len);
 
+  DD_DEBUG_S
+
   if (len) {
     cb_args[0] = HvNAME(stash);
     cb_args[1] = GvNAME(kGVOP_gv);

Modified: trunk/Devel-Declare/stolen_chunk_of_toke.c
===================================================================
--- trunk/Devel-Declare/stolen_chunk_of_toke.c	2007-06-29 02:32:08 UTC (rev 3549)
+++ trunk/Devel-Declare/stolen_chunk_of_toke.c	2007-06-29 05:20:23 UTC (rev 3550)
@@ -21,9 +21,16 @@
 
 #define DPTR2FPTR(t,p) ((t)PTR2nat(p))  /* data pointer to function pointer */
 #define FPTR2DPTR(t,p) ((t)PTR2nat(p))  /* function pointer to data pointer */
+#define PTR2nat(p)       (PTRV)(p)       /* pointer to integer of PTRSIZE */
 #define MEM_WRAP_CHECK_(n,t) MEM_WRAP_CHECK(n,t),
 #define Newx(v,n,t) (v = (MEM_WRAP_CHECK_(n,t) (t*)safemalloc((MEM_SIZE)((n)*sizeof(t)))))
 
+/* On MacOS, respect nonbreaking spaces */
+#ifdef MACOS_TRADITIONAL
+#define SPACE_OR_TAB(c) ((c)==' '||(c)=='\312'||(c)=='\t')
+#else
+#define SPACE_OR_TAB(c) ((c)==' '||(c)=='\t')
+#endif
 
 #define LEX_NORMAL    10 /* normal code (ie not within "...")     */
 #define LEX_INTERPNORMAL   9 /* code within a string, eg "$foo[$x+1]" */

Modified: trunk/Devel-Declare/t/simple.t
===================================================================
--- trunk/Devel-Declare/t/simple.t	2007-06-29 02:32:08 UTC (rev 3549)
+++ trunk/Devel-Declare/t/simple.t	2007-06-29 05:20:23 UTC (rev 3550)
@@ -10,9 +10,21 @@
 
 use Devel::Declare 'method';
 
+my ($args1, $args2);
+
 method bar {
-  my $str = join(', ', @_);
-  is($str, 'main, baz, quux', 'Method args ok');
+  $args1 = join(', ', @_);
 };
 
-__PACKAGE__->bar(qw(baz quux));
+method # blather
+  baz
+  # whee
+{
+  $args2 = join(', ', @_);
+};
+
+__PACKAGE__->bar(qw(1 2));
+__PACKAGE__->baz(qw(3 4));
+
+is($args1, 'main, 1, 2', 'Method bar args ok');
+is($args2, 'main, 3, 4', 'Method baz args ok');




More information about the Bast-commits mailing list