if (!is_declarator)
return -1;
+ /* $declarators{$current_package_name} */
+
is_declarator_pack_ref = hv_fetch(is_declarator, HvNAME(PL_curstash),
strlen(HvNAME(PL_curstash)), FALSE);
is_declarator_pack_hash = (HV*) SvRV(*is_declarator_pack_ref);
+ /* $declarators{$current_package_name}{$name} */
+
is_declarator_flag_ref = hv_fetch(
is_declarator_pack_hash, name,
strlen(name), FALSE
return dd_flags;
}
+/* callback thingy */
+
+void dd_linestr_callback (pTHX_ char* type, char* name, char* s) {
+
+ char* linestr = SvPVX(PL_linestr);
+ int offset = s - linestr;
+
+ char* new_linestr;
+ int count;
+
+ dSP;
+
+ ENTER;
+ SAVETMPS;
+
+ PUSHMARK(SP);
+ XPUSHs(sv_2mortal(newSVpv(type, 0)));
+ XPUSHs(sv_2mortal(newSVpv(name, 0)));
+ XPUSHs(sv_2mortal(newSViv(offset)));
+ PUTBACK;
+
+ count = call_pv("Devel::Declare::linestr_callback", G_SCALAR);
+
+ SPAGAIN;
+
+ if (count != 1)
+ Perl_croak(aTHX_ "linestr_callback didn't return a value, bailing out");
+
+ printf("linestr_callback returned: %s\n", POPp);
+
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
+}
+
+char* dd_get_linestr(pTHX) {
+ return SvPVX(PL_linestr);
+}
+
+void dd_set_linestr(pTHX_ char* new_value) {
+ int new_len = strlen(new_value);
+ char* old_linestr = SvPVX(PL_linestr);
+
+ SvGROW(PL_linestr, strlen(new_value));
+
+ if (SvPVX(PL_linestr) != old_linestr)
+ Perl_croak(aTHX_ "forced to realloc PL_linestr for line %s, bailing out before we crash harder", SvPVX(PL_linestr));
+
+ memcpy(SvPVX(PL_linestr), new_value, new_len+1);
+
+ SvCUR_set(PL_linestr, new_len);
+
+ PL_bufend = SvPVX(PL_linestr) + new_len;
+}
+
+char* dd_move_past_token (pTHX_ char* s) {
+
+ /*
+ * 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);
+ return s;
+}
+
+int dd_toke_scan_word(pTHX_ int offset, int handle_package) {
+ char tmpbuf[sizeof PL_tokenbuf];
+ char* base_s = SvPVX(PL_linestr) + offset;
+ STRLEN len;
+ char* s = scan_word(base_s, tmpbuf, sizeof tmpbuf, handle_package, &len);
+ return s - base_s;
+}
+
+int dd_toke_scan_str(pTHX_ int offset) {
+ char* base_s = SvPVX(PL_linestr) + offset;
+ char* s = scan_str(base_s, FALSE, FALSE);
+ return s - base_s;
+}
+
+int dd_toke_skipspace(pTHX_ int offset) {
+ char* base_s = SvPVX(PL_linestr) + offset;
+ char* s = skipspace(base_s);
+ return s - base_s;
+}
+
/* replacement PL_check rv2cv entry */
STATIC OP *(*dd_old_ck_rv2cv)(pTHX_ OP *op);
printf("PL_tokenbuf: %s\n", 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);
+ s = dd_move_past_token(aTHX_ s);
DD_DEBUG_S
s = PL_bufptr;
- while (s < PL_bufend && isSPACE(*s)) s++;
- if (memEQ(s, PL_tokenbuf, strlen(PL_tokenbuf)))
- s += strlen(PL_tokenbuf);
+ s = dd_move_past_token(aTHX_ s);
+
+ /* dd_linestr_callback(aTHX_ "const", SvPVX(cSVOPo->op_sv), s); */
DD_DEBUG_S
PL_check[OP_CONST] = dd_ck_const;
}
filter_add(dd_filter_realloc, NULL);
+
+char*
+get_linestr()
+ CODE:
+ RETVAL = dd_get_linestr(aTHX);
+ OUTPUT:
+ RETVAL
+
+void
+set_linestr(char* new_value)
+ CODE:
+ dd_set_linestr(aTHX_ new_value);
+
+int
+toke_scan_word(int offset, int handle_package)
+ CODE:
+ RETVAL = dd_toke_scan_word(aTHX_ offset, handle_package);
+ OUTPUT:
+ RETVAL
+
+int
+toke_scan_str(int offset);
+ CODE:
+ RETVAL = dd_toke_scan_str(aTHX_ offset);
+ OUTPUT:
+ RETVAL
+
+int
+toke_skipspace(int offset)
+ CODE:
+ RETVAL = dd_toke_skipspace(aTHX_ offset);
+ OUTPUT:
+ RETVAL