#include <stdio.h>
#include <string.h>
+#define DD_HAS_TRAITS
#if 0
#define DD_DEBUG
#endif
char* save_s;
char tmpbuf[sizeof PL_tokenbuf];
char found_name[sizeof PL_tokenbuf];
- char* found_proto = NULL;
+ char* found_proto = NULL, *found_traits = NULL;
STRLEN len = 0;
HV *stash;
HV* is_declarator;
if (*s == '(') { /* found a prototype-ish thing */
save_s = s;
s = scan_str(s, FALSE, FALSE); /* no keep_quoted, no keep_delims */
+#ifdef DD_HAS_TRAITS
+ {
+ char *traitstart = s = skipspace(s);
+
+ while (*s && *s != '{') ++s;
+ if (*s) {
+ int tlen = s - traitstart;
+ Newx(found_traits, tlen+1, char);
+ Copy(traitstart, found_traits, tlen, char);
+ found_traits[tlen] = 0;
+#ifdef DD_DEBUG
+ printf("found traits..... (%s)\n", found_traits);
+#endif
+ }
+ }
+#endif
+
if (SvPOK(PL_lex_stuff)) {
#ifdef DD_DEBUG
printf("Found proto %s\n", SvPVX(PL_lex_stuff));
cb_args[2] = HvNAME(PL_curstash);
cb_args[3] = found_name;
cb_args[4] = found_proto;
- cb_args[5] = NULL;
+ cb_args[5] = found_traits;
+ cb_args[6] = NULL;
if (len && found_proto)
in_declare = 2;
const int old_len = SvCUR(PL_linestr);
#ifdef DD_DEBUG
printf("Got string %s\n", retstr);
+ printf("retstr len: %d, old_len %d\n", strlen(retstr), old_len);
#endif
SvGROW(PL_linestr, (STRLEN)(old_len + strlen(retstr)));
memmove(s+strlen(retstr), s, (PL_bufend - s)+1);
my $temp_save;
sub init_declare {
- my ($usepack, $use, $inpack, $name, $proto) = @_;
+ my ($usepack, $use, $inpack, $name, $proto, $traits) = @_;
my ($name_h, $XX_h, $extra_code)
= $declarator_handlers{$usepack}{$use}->(
- $usepack, $use, $inpack, $name, $proto, defined(wantarray)
+ $usepack, $use, $inpack, $name, $proto, defined(wantarray), $traits
);
($temp_name, $temp_save) = ([], []);
if ($name) {
$setup_for_args{$name} = [
$flags,
sub {
- my ($usepack, $use, $inpack, $name, $proto, $shift_hashref) = @_;
- my $extra_code = $compile->($name, $proto);
+ my ($usepack, $use, $inpack, $name, $proto, $shift_hashref, $traits) = @_;
+ my $extra_code = $compile->($name, $proto, $traits);
my $main_handler = sub { shift if $shift_hashref;
("DONE", $run->($name, $proto, @_));
};