}
/** convert a string to a symbol, with error checking **/
-//ANN Symbol str2sym(const Env env, const m_str path, const loc_t pos) {
ANN Symbol str2sym(const Gwi gwi, const m_str path) {
const size_t sz = strlen(path);
m_uint i;
const size_t sz = strlen(path);
if(path[0] == '.' || path[sz] == '.')
GWI_ERR_O(_("path '%s' must not ini or end with '.'."), path)
-// DECL_OO(const Symbol, sym, = str2sym(gwi, path))
-// const ID_List list = new_id_list(gwi->gwion->mp, sym, loc(gwi));
- const ID_List list = str2symlist(gwi, path);
+ DECL_OO(const ID_List, list, = str2symlist(gwi, path))
if(strlen(s_name(list->xid)) < sz)
list->next = path_valid(gwi, path + strlen(s_name(list->xid)));
return list;
}
-
-//
// similar to import array_sub ?
ANN Array_Sub ck_array(MemPool mp, const m_uint depth) {
if(!depth)
struct tmpl_checker {
const m_str str;
ID_List list;
-// const loc_t pos;
};
ANN static m_bool tmpl_list(const Gwi gwi, struct tmpl_checker *ck) {
// we can do better
DECL_OO(const m_str, type_name, = get_type_name(gwi->gwion->env, s, 0))
struct array_checker ck = { .str=type_name };
- const ID_List id = ck2list(gwi, &ck);
- if(id == (ID_List)GW_ERROR)
- return NULL;
+ DECL_OO(const ID_List, id, = ck2list(gwi, &ck))
Type_Decl* td = new_type_decl(gwi->gwion->mp, id);
const m_str tl_name = get_type_name(gwi->gwion->env, s, 1);
if(tl_name) {
str[strlen(base) - (c ? strlen(c) : 0)] = '\0';
ck->name = str;
CHECK_OB((ck->sym = str2sym(gwi, str)))
- if(c && (ck->tmpl = tmpl_valid(gwi, c)) == (ID_List)GW_ERROR)
+ ID_List tmpl = NULL;
+ if(c && (tmpl = tmpl_valid(gwi, c)) == (ID_List)GW_ERROR)
return GW_ERROR;
+ ck->tmpl = tmpl;
ck->name = base;
return GW_OK;
}
ANN void ck_clean(const Gwi gwi) {
cleaners[gwi->ck->type](gwi->gwion->mp, gwi->ck);
+ memset(gwi->ck, 0, sizeof(ImportCK));
}
ANN m_int gwi_typedef_ini(const Gwi gwi, const restrict m_str type, const restrict m_str name) {
CHECK_BB(ck_ini(gwi, ck_tdef))
gwi->ck->name = name;
- if(check_typename_def(gwi, gwi->ck) > 0)
- return (gwi->ck->td = str2decl(gwi, type)) ? GW_OK : GW_ERROR;
- return GW_ERROR;
+ CHECK_BB(check_typename_def(gwi, gwi->ck))
+ return (gwi->ck->td = str2decl(gwi, type)) ? GW_OK : GW_ERROR;
+// if(check_typename_def(gwi, gwi->ck) > 0)
+// return (gwi->ck->td = str2decl(gwi, type)) ? GW_OK : GW_ERROR;
+// return GW_ERROR;
}
ANN Type gwi_typedef_end(const Gwi gwi, const ae_flag flag) {