#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
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);
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);
#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]" */
use Devel::Declare 'method';
+my ($args1, $args2);
+
method bar {
- my $str = join(', ', @_);
- is($str, 'main, baz, quux', 'Method args ok');
+ $args1 = join(', ', @_);
+};
+
+method # blather
+ baz
+ # whee
+{
+ $args2 = join(', ', @_);
};
-__PACKAGE__->bar(qw(baz quux));
+__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');