ANN VM* gwi_vm(const Gwi);
-ANN2(1,2) ANEW Type gwi_mk_type(const Gwi, const m_str, const m_uint, const Type);
+ANN2(1,2) ANEW Type gwi_mk_type(const Gwi, const m_str, const m_uint, const m_str);
ANN m_int gwi_add_type(const Gwi gwi, Type type);
ANN m_int gwi_set_global_type(const Gwi gwi, const Type type, const type_enum te);
ANN m_bool gwi_gack(const Gwi gwi, const Type type, const f_gack d);
const m_str start = strchr(name, '<');
const m_str end = strchr(name, '@');
char c[strlen(name)];
- strcpy(c, start + 1);
- c[strlen(start) - strlen(end) - 2] = '\0';
+ strcpy(c, start + 2);
+ c[strlen(start) - strlen(end) - 4] = '\0';
m_uint depth;
return str2tl(env, c, &depth);
}
}
GWION_IMPORT(array) {
- const Type t_array = gwi_mk_type(gwi, "@Array", SZ_INT, gwi->gwion->type[et_object]);
+ const Type t_array = gwi_mk_type(gwi, "@Array", SZ_INT, "Object");
gwi->gwion->type[et_array] = t_array;
GWI_BB(gwi_class_ini(gwi, t_array, NULL, array_dtor))
#include "specialid.h"
static GACK(gack_class) {
- printf("class(%p)", (*(Type*)VALUE)->e->d.base_type);
+ printf("class(%s)", actual_type(shred->info->vm->gwion, t)->name);
}
static GACK(gack_function) {
const Type t_function = gwi_mk_type(gwi, "@function", SZ_INT, NULL);
GWI_BB(gwi_gack(gwi, t_function, gack_function))
GWI_BB(gwi_set_global_type(gwi, t_function, et_function))
- const Type t_fptr = gwi_mk_type(gwi, "@func_ptr", SZ_INT, t_function);
+ const Type t_fptr = gwi_mk_type(gwi, "@func_ptr", SZ_INT, "@function");
GWI_BB(gwi_gack(gwi, t_fptr, gack_fptr))
GWI_BB(gwi_set_global_type(gwi, t_fptr, et_fptr))
- const Type t_lambda = gwi_mk_type(gwi, "@lambda", SZ_INT, t_function);
+ const Type t_lambda = gwi_mk_type(gwi, "@lambda", SZ_INT, "@function");
GWI_BB(gwi_set_global_type(gwi, t_lambda, et_lambda))
const Type t_gack = gwi_mk_type(gwi, "@Gack", SZ_INT, NULL);
GWI_BB(gwi_set_global_type(gwi, t_gack, et_gack))
const Type t_time = gwi_mk_type(gwi, "time", SZ_FLOAT, NULL);
CHECK_BB(gwi_gack(gwi, t_time, gack_float))
GWI_BB(gwi_add_type(gwi, t_time))
- const Type t_now = gwi_mk_type(gwi, "@now", SZ_FLOAT, t_time);
+ const Type t_now = gwi_mk_type(gwi, "@now", SZ_FLOAT, "time");
GWI_BB(gwi_add_type(gwi, t_now))
struct SpecialId_ spid = { .type=t_now, .exec=RegPushNow, .is_const=1 };
gwi_specialid(gwi, "now", &spid);
gwi->gwion->type[et_vec4] = t_vec4;
CHECK_BB(gwi_gack(gwi, t_vec4, gack_vec4))
GWI_BB(import_object(gwi))
- const Type t_union = gwi_mk_type(gwi, "@Union", SZ_INT, gwi->gwion->type[et_object]);
+ const Type t_union = gwi_mk_type(gwi, "@Union", SZ_INT, "Object");
gwi->gwion->type[et_union] = t_union;
GWI_BB(gwi_class_ini(gwi, t_union, NULL, NULL))
GWI_BB(gwi_class_end(gwi))
}
GWION_IMPORT(event) {
- const Type t_event = gwi_mk_type(gwi, "Event", SZ_INT, gwi->gwion->type[et_object]);
+ const Type t_event = gwi_mk_type(gwi, "Event", SZ_INT, "Object");
gwi->gwion->type[et_event] = t_event;
GWI_BB(gwi_class_ini(gwi, t_event, event_ctor, event_dtor))
GWI_BB(gwi_item_ini(gwi, "int", "@shreds"))
continue;
if(c == '<') {
lvl++;
+ ++i;
continue;
}
if(c == ',') {
GWI_ERR_B(_("illegal use of ',' outside of templating in name '%s'."), a)
continue;
}
- if(c == '>') {
+ if(c == '~') {
if(!lvl)
GWI_ERR_B(_("illegal templating in name '%s'."), a)
lvl--;
char last = '\0';
for(m_uint i = p->len + 1; --i;) {
const char c = p->path[i - 1];
- if(c != '.' && check_illegal(p->curr, c, i) < 0) {
+
+// TODO: NOW!!! check templating
+//if( c == '<' && p->path[i - 2] == '~');
+//else
+ if(c != '.' && check_illegal(p->curr, c, i) < 0) {
env_err(env, &p->loc, _("illegal character '%c' in path '%s'."), c, p->path);
return GW_ERROR;
}
return GW_OK;
}
-ANN2(1,2) Type gwi_mk_type(const Gwi gwi NUSED, const m_str name, const m_uint size, const Type parent) {
+ANN2(1,2) Type gwi_mk_type(const Gwi gwi NUSED, const m_str name, const m_uint size, const m_str parent_name) {
+ m_uint depth;
+ const Type_Decl* td = parent_name ? str2decl(gwi->gwion->env, parent_name, &depth) : NULL;
+ const Type parent = td ? known_type(gwi->gwion->env, td) : NULL;
const Type t = new_type(gwi->gwion->mp, 0, name, parent);
t->size = size;
return t;
}
static GWION_IMPORT(gain) {
- const Type t_gain = gwi_mk_type(gwi, "Gain", SZ_INT, gwi->gwion->type[et_ugen]);
+ const Type t_gain = gwi_mk_type(gwi, "Gain", SZ_INT, "UGen");
GWI_BB(gwi_class_ini(gwi, t_gain, gain_ctor, basic_dtor))
gwi_func_ini(gwi, "float", "gain", gain_get_gain);
GWI_BB(gwi_func_end(gwi, 0))
}
static GWION_IMPORT(impulse) {
- const Type t_impulse = gwi_mk_type(gwi, "Impulse", SZ_INT, gwi->gwion->type[et_ugen]);
+ const Type t_impulse = gwi_mk_type(gwi, "Impulse", SZ_INT, "UGen");
GWI_BB(gwi_class_ini(gwi, t_impulse, impulse_ctor, basic_dtor))
gwi_func_ini(gwi, "float", "next", impulse_get_next);
GWI_BB(gwi_func_end(gwi, 0))
}
static GWION_IMPORT(fullrect) {
- const Type t_fullrect = gwi_mk_type(gwi, "FullRect", SZ_INT, gwi->gwion->type[et_ugen]);
+ const Type t_fullrect = gwi_mk_type(gwi, "FullRect", SZ_INT, "UGen");
GWI_BB(gwi_class_ini(gwi, t_fullrect, fullrect_ctor, basic_dtor))
return gwi_class_end(gwi);
}
}
static GWION_IMPORT(halfrect) {
- const Type t_halfrect = gwi_mk_type(gwi, "HalfRect", SZ_INT, gwi->gwion->type[et_ugen]);
+ const Type t_halfrect = gwi_mk_type(gwi, "HalfRect", SZ_INT, "UGen");
GWI_BB(gwi_class_ini(gwi, t_halfrect, halfrect_ctor, basic_dtor))
return gwi_class_end(gwi);
}
}
static GWION_IMPORT(step) {
- const Type t_step = gwi_mk_type(gwi, "Step", SZ_INT, gwi->gwion->type[et_ugen]);
+ const Type t_step = gwi_mk_type(gwi, "Step", SZ_INT, "UGen");
GWI_BB(gwi_class_ini(gwi, t_step, step_ctor, basic_dtor))
gwi_func_ini(gwi, "float", "next", step_get_next);
GWI_BB(gwi_func_end(gwi, 0))
}
static GWION_IMPORT(zerox) {
- const Type t_zerox = gwi_mk_type(gwi, "ZeroX", SZ_INT, gwi->gwion->type[et_ugen]);
+ const Type t_zerox = gwi_mk_type(gwi, "ZeroX", SZ_INT, "UGen");
GWI_BB(gwi_class_ini(gwi, t_zerox, zerox_ctor, basic_dtor))
return gwi_class_end(gwi);
}
GWION_IMPORT(ptr) {
const m_str list[] = { "A" };
- const Type t_ptr = gwi_mk_type(gwi, "Ptr", SZ_INT, gwi->gwion->type[et_object]);
+ const Type t_ptr = gwi_mk_type(gwi, "Ptr", SZ_INT, "Object");
gwi->gwion->type[et_ptr] = t_ptr;
GWI_BB(gwi_tmpl_ini(gwi, 1, list))
GWI_BB(gwi_class_ini(gwi, t_ptr, NULL, NULL))
#include "nspc.h"
GWION_IMPORT(shred) {
- const Type t_shred = gwi_mk_type(gwi, "Shred", SZ_INT, gwi->gwion->type[et_object]);
+ const Type t_shred = gwi_mk_type(gwi, "Shred", SZ_INT, "Object");
gwi->gwion->type[et_shred] = t_shred;
GWI_BB(gwi_class_ini(gwi, t_shred, NULL, shred_dtor))
SET_FLAG((t_shred), abstract);
- const Type t_fork = gwi_mk_type(gwi, "Fork", SZ_INT, t_shred);
+ const Type t_fork = gwi_mk_type(gwi, "Fork", SZ_INT, "Shred");
gwi->gwion->type[et_fork] = t_fork;
GWI_BB(gwi_class_ini(gwi, t_fork, NULL, fork_dtor))
gwi_item_ini(gwi, "int", "@thread");
printf("%s", obj ? STRING(obj) : "(null string)");
}
GWION_IMPORT(string) {
- const Type t_string = gwi_mk_type(gwi, "string", SZ_INT, gwi->gwion->type[et_object]);
+ const Type t_string = gwi_mk_type(gwi, "string", SZ_INT, "Object");
GWI_BB(gwi_gack(gwi, t_string, gack_string))
GWI_BB(gwi_class_ini(gwi, t_string, string_ctor, NULL))
gwi->gwion->type[et_string] = t_string;
}
GWION_IMPORT(tuple) {
- const Type t_tuple = gwi_mk_type(gwi, "Tuple", SZ_INT, gwi->gwion->type[et_object]);
+ const Type t_tuple = gwi_mk_type(gwi, "Tuple", SZ_INT, "Object");
gwi->gwion->type[et_tuple] = t_tuple;
GWI_BB(gwi_class_ini(gwi, t_tuple, NULL, NULL))
GWI_BB(gwi_class_end(gwi))
}
GWION_IMPORT(ugen) {
- const Type t_ugen = gwi_mk_type(gwi, "UGen", SZ_INT, gwi->gwion->type[et_object]);
+ const Type t_ugen = gwi_mk_type(gwi, "UGen", SZ_INT, "Object");
gwi->gwion->type[et_ugen] = t_ugen;
GWI_BB(gwi_class_ini(gwi, t_ugen, ugen_ctor, ugen_dtor))
GWI_BB(gwi_item_ini(gwi, "int", "@ugen"))
}
GWION_IMPORT(vararg) {
- const Type t_vararg = gwi_mk_type(gwi, "@Vararg", SZ_INT, gwi->gwion->type[et_object]);
- const Type t_varobj = gwi_mk_type(gwi, "VarObject", SZ_INT, t_vararg);
+ const Type t_vararg = gwi_mk_type(gwi, "@Vararg", SZ_INT, "Object");
+ const Type t_varobj = gwi_mk_type(gwi, "VarObject", SZ_INT, "Object");
SET_FLAG(t_varobj, abstract);
const Type t_varloop = gwi_mk_type(gwi, "@VarLoop", SZ_INT, NULL);
GWI_BB(gwi_add_type(gwi, t_varobj))
#endif
}
+#include "type.h"
int main(int argc, char** argv) {
Arg arg = { .argc=argc, .argv=argv, .loop=-1 };
signal(SIGINT, sig);
const size_t slen = strlen(s);
const size_t tlen = slen - len + 1;
char c[slen + 1];
-
if(!name)
return index ? NULL : s_name(insert_symbol(s));
if(index == 0) {
snprintf(c, tlen, "%s", s);
return s_name(insert_symbol(c));
}
+ ++name;
while(*name++) {
- if(*name == '<')
+ if(*name == '<') {
lvl++;
- else if(*name == '>' && !lvl--)
+ name++;
+ } else if(*name == '~' && !lvl--)
break;
if(*name == ',' && !lvl) {
++name;
ANN2(1,2) Symbol func_symbol(const Env env, const m_str nspc, const m_str base,
const m_str tmpl, const m_uint i) {
const size_t base_len = strlen(base);
- const size_t tmpl_len = !tmpl ? 0 : strlen(tmpl) + 2;
+ const size_t tmpl_len = !tmpl ? 0 : strlen(tmpl) + 4;
const size_t nspc_len = strlen(nspc);
const size_t idx_len = num_digit(i);
const size_t len = base_len + tmpl_len + nspc_len + idx_len + 2;
char name[len + 1];
CHECK_BO(sprintf(name, "%s%s%s%s@%" UINT_F "@%s",
- base, !tmpl ? "" : "<", !tmpl ? "" : tmpl, !tmpl ? "" : ">",
+ base, !tmpl ? "" : "<~", !tmpl ? "" : tmpl, !tmpl ? "" : "~>",
i, nspc))
return insert_symbol(env->gwion->st, name);
}
m_str str = s;
str = tmpl_get(info, str);
*str++ = '<';
+ *str++ = '~';
const m_uint size = vector_size(&info->type);
for(info->index = 1; info->index < size; ++info->index) {
str = tmpl_get(info, str);
- *str++ = (info->index < size - 1) ? ',' : '>';
- }
- *str = '\0';
+ if(info->index < size - 1)
+ *str++ = ',';
+ else {
+ *str++ = '~';
+ *str++ = '>';
+ }
+ }
+ *str = '\0';
}
ANEW ANN static Symbol template_id(const Env env, const Class_Def c, const Type_List call) {
GWION_IMPORT(array_test) {
Type t_invalid_var_name;
- CHECK_OB((t_invalid_var_name = gwi_mk_type(gwi, "invalid_var_name", SZ_INT, gwi->gwion->type[et_object])))
+ CHECK_OB((t_invalid_var_name = gwi_mk_type(gwi, "invalid_var_name", SZ_INT, "Object")))
CHECK_BB(gwi_class_ini(gwi, t_invalid_var_name, NULL, NULL))
CHECK_BB(gwi_item_ini(gwi, "int[]", "int_array"))
CHECK_BB(gwi_item_end(gwi, 0, NULL)) // import array var
MFUN(test_mfun){}
GWION_IMPORT(begin_class) {
Type t_invalid_var_name;
- CHECK_OB((t_invalid_var_name = gwi_mk_type(gwi, "invalid_var_name", SZ_INT, gwi->gwion->type[et_object])))
+ CHECK_OB((t_invalid_var_name = gwi_mk_type(gwi, "invalid_var_name", SZ_INT, "Object")))
CHECK_BB(gwi_class_ini(gwi, t_invalid_var_name, NULL, NULL))
CHECK_BB(gwi_class_ini(gwi, t_invalid_var_name, NULL, NULL))
return GW_OK;
CHECK_BB(gwi_fptr_ini(gwi, "Vec4", "PtrType"))
CHECK_OB(gwi_fptr_end(gwi, 0))
- const Type t_callback = gwi_mk_type(gwi, "Callback", SZ_INT, gwi->gwion->type[et_object]);
+ const Type t_callback = gwi_mk_type(gwi, "Callback", SZ_INT, "Object");
CHECK_BB(gwi_class_ini(gwi, t_callback, NULL, NULL))
CHECK_BB(gwi_func_ini(gwi, "int", "callback", cb_func))
CHECK_BB(gwi_func_arg(gwi, "PtrType", "func"))
Type t_class_template;
const m_str list[2] = { "A", "B" };
gwi_tmpl_ini(gwi, 2, list);
- CHECK_OB((t_class_template = gwi_mk_type(gwi, "ClassTemplate", SZ_INT, gwi->gwion->type[et_object])))
+ CHECK_OB((t_class_template = gwi_mk_type(gwi, "ClassTemplate", SZ_INT, "Object")))
CHECK_BB(gwi_class_ini(gwi, t_class_template, class_template_ctor, NULL))
gwi_tmpl_end(gwi);
CHECK_BB(gwi_item_ini(gwi, "A[]", "key"))
GWION_IMPORT(coverage) {
Type t_coverage;
- CHECK_OB((t_coverage = gwi_mk_type(gwi, "Coverage", SZ_INT, gwi->gwion->type[et_object])))
+ CHECK_OB((t_coverage = gwi_mk_type(gwi, "Coverage", SZ_INT, "Object")))
CHECK_BB(gwi_class_ini(gwi, t_coverage, NULL, NULL))
CHECK_BB(gwi_func_ini(gwi, "int", "i", coverage_int))
CHECK_BB(gwi_func_end(gwi, ae_flag_static))
}
GWION_IMPORT(variadic test) {
- const Type t_variadic = gwi_mk_type(gwi, "Variadic", SZ_INT, gwi->gwion->type[et_object]);
+ const Type t_variadic = gwi_mk_type(gwi, "Variadic", SZ_INT, "Object");
CHECK_BB(gwi_class_ini(gwi, t_variadic, NULL, NULL))
CHECK_BB(gwi_func_ini(gwi, "void", "member", m_variadic))
CHECK_BB(gwi_func_arg(gwi, "string", "format"))