#define HINTK_FLAGS_ MY_PKG "/flags:"
#define HINTK_SHIFT_ MY_PKG "/shift:"
#define HINTK_ATTRS_ MY_PKG "/attrs:"
+#define HINTK_REIFY_ MY_PKG "/reify:"
#define DEFSTRUCT(T) typedef struct T T; struct T
-#define UV_BITS (sizeof (UV) * CHAR_BIT)
-
enum {
FLAG_NAME_OK = 0x01,
FLAG_ANON_OK = 0x02,
DEFSTRUCT(KWSpec) {
unsigned flags;
+ I32 reify_type;
SV *shift;
SV *attrs;
};
#include "padop_on_crack.c.inc"
-static void my_require(pTHX_ const char *file) {
- SV *err;
- require_pv(file);
- err = ERRSV;
- if (SvTRUE(err)) {
- croak_sv(err);
- }
-}
-
enum {
MY_ATTR_LVALUE = 0x01,
MY_ATTR_METHOD = 0x02,
return t;
}
-static SV *reify_type(pTHX_ Sentinel sen, const SV *declarator, SV *name) {
- SV *t;
+static SV *reify_type(pTHX_ Sentinel sen, const SV *declarator, const KWSpec *spec, SV *name) {
+ AV *type_reifiers;
+ SV *t, *sv, **psv;
int n;
dSP;
- my_require(aTHX_ "Moose/Util/TypeConstraints.pm");
+ type_reifiers = get_av(MY_PKG "::type_reifiers", 0);
+ assert(type_reifiers != NULL);
+
+ if (spec->reify_type < 0 || spec->reify_type > av_len(type_reifiers)) {
+ croak("In %"SVf": internal error: reify_type [%ld] out of range [%ld]", SVfARG(declarator), (long)spec->reify_type, (long)(av_len(type_reifiers) + 1));
+ }
+
+ psv = av_fetch(type_reifiers, spec->reify_type, 0);
+ assert(psv != NULL);
+ sv = *psv;
ENTER;
SAVETMPS;
PUSHMARK(SP);
- EXTEND(SP, 1);
+ EXTEND(SP, 2);
PUSHs(name);
+ PUSHs(PL_curstname);
PUTBACK;
- n = call_pv("Moose::Util::TypeConstraints::find_or_create_isa_type_constraint", G_SCALAR);
+ n = call_sv(sv, G_SCALAR);
SPAGAIN;
assert(n == 1);
}
*ptype = my_eval(aTHX_ sen, floor, expr);
if (!SvROK(*ptype)) {
- *ptype = reify_type(aTHX_ sen, declarator, *ptype);
+ *ptype = reify_type(aTHX_ sen, declarator, spec, *ptype);
}
if (!sv_isobject(*ptype)) {
croak("In %"SVf": (%"SVf") doesn't look like a type object", SVfARG(declarator), SVfARG(*ptype));
c = lex_peek_unichar(0);
} else if (MY_UNI_IDFIRST(c)) {
*ptype = parse_type(aTHX_ sen, declarator);
- *ptype = reify_type(aTHX_ sen, declarator, *ptype);
+ *ptype = reify_type(aTHX_ sen, declarator, spec, *ptype);
c = lex_peek_unichar(0);
}
SAVEDESTRUCTOR_X(sentinel_clear_void, sen);
spec->flags = 0;
+ spec->reify_type = 0;
spec->shift = sentinel_mortalize(sen, newSVpvs(""));
spec->attrs = sentinel_mortalize(sen, newSVpvs(""));
FETCH_HINTK_INTO(FLAGS_, kw_ptr, kw_len, psv);
spec->flags = SvIV(*psv);
+ FETCH_HINTK_INTO(REIFY_, kw_ptr, kw_len, psv);
+ spec->reify_type = SvIV(*psv);
+
FETCH_HINTK_INTO(SHIFT_, kw_ptr, kw_len, psv);
SvSetSV(spec->shift, *psv);
newCONSTSUB(stash, "HINTK_FLAGS_", newSVpvs(HINTK_FLAGS_));
newCONSTSUB(stash, "HINTK_SHIFT_", newSVpvs(HINTK_SHIFT_));
newCONSTSUB(stash, "HINTK_ATTRS_", newSVpvs(HINTK_ATTRS_));
+ newCONSTSUB(stash, "HINTK_REIFY_", newSVpvs(HINTK_REIFY_));
/**/
next_keyword_plugin = PL_keyword_plugin;
PL_keyword_plugin = my_keyword_plugin;