-Subproject commit 0c6c6dcd949db0aeb7f292c22411381fb68624f5
+Subproject commit 1bf20cade4401334d94195cd9b245743a1ba096e
ANN2(1,2) Type gwi_class_ini(const Gwi gwi, const m_str name, const m_str parent) {
struct ImportCK ck = { .name=name };
CHECK_BO(check_typename_def(gwi, &ck))
- Type_Decl *td = str2decl(gwi, parent ?: "Object"); // check
+ DECL_OO(Type_Decl *,td, = str2decl(gwi, parent ?: "Object"))
Tmpl* tmpl = ck.tmpl ? new_tmpl_base(gwi->gwion->mp, ck.tmpl) : NULL;
if(tmpl)
template_push_types(gwi->gwion->env, tmpl);
if(str == (m_str)OP_ANY_TYPE)
return OP_ANY_TYPE;
struct array_checker ck = { .str=str };
- const ID_List list = ck2list(gwi, &ck);
+ DECL_OO(const ID_List, list, = ck2list(gwi, &ck))
const Type t = find_type(gwi->gwion->env, list);
if(list)
free_id_list(gwi->gwion->mp, list);
#include "import.h"
#include "gwi.h"
-ANN2(1,2) Type gwi_mk_type(const Gwi gwi NUSED, const m_str name, const m_uint size, const m_str parent_name) {
- CHECK_OO(str2sym(gwi, name))
+ANN2(1) static Type get_parent(const Gwi gwi, const m_str parent_name) {
Type_Decl* td = parent_name ? str2decl(gwi, parent_name) : NULL;
if(td) {
if(td->array || td->types) {
+ const m_str str = td->array ? "array" : "template";
free_type_decl(gwi->gwion->mp, td);
- GWI_ERR_O(_("can't use gwi_mk_type to extend %s types"),
- td->array ? "array" : "template")
+ GWI_ERR_O(_("can't use gwi_mk_type to extend %s types"), str)
}
}
const Type parent = td ? known_type(gwi->gwion->env, td) : NULL;
+ if(td)
+ free_type_decl(gwi->gwion->mp, td);
+ return parent;
+}
+
+ANN2(1,2) Type gwi_mk_type(const Gwi gwi, const m_str name, const m_uint size, const m_str parent_name) {
+ CHECK_OO(str2sym(gwi, name))
+ const Type parent = get_parent(gwi, parent_name);
const Type t = new_type(gwi->gwion->mp, 0, name, parent);
t->size = size;
return t;
CHECK_BO(ck_ok(gwi, ck_udef))
if(!gwi->ck->list)
GWI_ERR_O(_("union is empty"));
+ if(gwi->ck->tmpl && gwi->ck->xid)
+ GWI_ERR_O(_("Template union type can't declare instance at declaration"));
const Union_Def udef = new_union_def(gwi->gwion->mp, gwi->ck->list, loc(gwi));
gwi->ck->list = NULL;
udef->flag = flag;
udef->xid = gwi->ck->xid;
udef->type_xid = gwi->ck->sym;
-// udef->xid = gwi->ck->sym;
-// udef->type_xid = gwi->ck->xid;
if(gwi->ck->tmpl) {
- if(udef->xid)
- GWI_ERR_O(_("Template union type can't declare instance at declaration"));
udef->tmpl = gwi_tmpl(gwi);
gwi->ck->tmpl = NULL;
}
free_decl_list(mp, ck->list);
if(ck->tmpl)
free_id_list(mp, ck->tmpl);
-// do we miss ck->td ?
}
e->d.exp_decl.td->xid->xid = insert_symbol(t->name);
const Exp next = e->next;
e->next = NULL;
- CHECK_BO(traverse_exp(env, e))
+ const m_bool ret = traverse_exp(env, e);
e->next = next;
+ CHECK_BO(ret)
bin->rhs->meta = ae_meta_var;
}
++i;
}
ANN static void plug_get(struct PlugHandle *h, const m_str c) {
- void* dl = DLOPEN(c, RTLD_LAZY | RTLD_GLOBAL);
- if(dl) {
- vector_add(&h->pi->vec[GWPLUG_DL], (vtype)dl);
+ h->dl = DLOPEN(c, RTLD_LAZY | RTLD_GLOBAL);
+ if(h->dl) {
+ vector_add(&h->pi->vec[GWPLUG_DL], (vtype)h->dl);
h->name = plug_name(h);
plug_import(h);
plug_module(h);