-Subproject commit a9c86cda990ff3e065dedf2b02c2843d42016f65
+Subproject commit 8baa0aec75a67e220fc9209351c9fbcf82659748
*(m_str *)(VALUE - SZ_INT) = ret; \
}
-ANN m_bool mk_gack(MemPool p, const Type type, const f_gack d);
+ANN bool mk_gack(MemPool p, const Type type, const f_gack d);
#endif
return new_tmpl(gwi->gwion->mp, gwi->ck->sl);
}
-ANN void gwi_effects(const Gwi gwi, const m_str name);
-ANN m_bool gwi_run(const Gwion gwion, m_bool (*f)(const Gwi));
+ANN void gwi_effects(const Gwi gwi, const m_str name);
+ANN bool gwi_run(const Gwion gwion, m_bool (*f)(const Gwi));
#endif
struct PPArg_ * ppa;
};
-ANN m_bool gwion_ini(const Gwion, CliArg*);
+ANN bool gwion_ini(const Gwion, CliArg*);
ANN VM * gwion_cpy(const VM *);
ANN void gwion_run(const Gwion gwion);
ANN void gwion_end(const Gwion gwion);
m_str ret;
Symbol sym;
Type (*ck)(Env, void *); // oper
- m_bool (*em)(Emitter, void *); // oper
+ m_bool (*em)(Emitter, void *); // oper should be opem
m_str lhs; // oper
m_str rhs; // oper
struct Vector_ effect;
return (Plug)mp_calloc(p, Plug);
}
-ANN m_bool plug_ini(const struct Gwion_ *, const Vector);
+ANN bool plug_ini(const struct Gwion_ *, const Vector);
ANN gwdriver_t driver_ini(const struct Gwion_ *, struct SoundInfo_ *);
-ANN m_bool plug_run(const struct Gwion_ *, const Map);
+ANN bool plug_run(const struct Gwion_ *, const Map);
ANN void free_plug(const Gwion);
ANN void * get_module(const struct Gwion_ *, const m_str);
-ANN m_bool set_module(const struct Gwion_ *gwion, const m_str name,
+ANN bool set_module(const struct Gwion_ *gwion, const m_str name,
void *const ptr);
-ANN m_bool plugin_ini(struct Gwion_ *gwion, const m_str iname, const loc_t);
+ANN bool plugin_ini(struct Gwion_ *gwion, const m_str iname, const loc_t);
#define GWIMPORT_NAME(a) gwimport_##a
-Subproject commit 8eab3d20a622cc86b3daf2d5760338f80f6856a0
+Subproject commit d4a5df7434b11b76b1b56b7132d7037840a4227a
static struct Gwion_ gwion;
static void initialize() {
Arg arg = { .loop=-1 };
- const m_bool ini = gwion_ini(&gwion, &arg);
+ const bool ini = gwion_ini(&gwion, &arg);
arg_release(&arg);
}
if (c->type != COMPILE_FILE && c->file) fclose(c->file);
}
-ANN static m_bool _compiler_open(struct Compiler *c) {
+ANN static bool _compiler_open(struct Compiler *c) {
if (c->type == COMPILE_NAME) {
m_str name = c->name;
c->name = realpath(name, NULL);
xfree(name);
- return c->name ? !!(c->file = fopen(c->name, "r")) : GW_ERROR;
+ return c->name ? !!(c->file = fopen(c->name, "r")) : false;
} else if (c->type == COMPILE_MSTR) {
c->file = c->data ? fmemopen(c->data, strlen(c->data), "r") : NULL;
- return c->file ? GW_OK : GW_ERROR;
+ return !!c->file;
}
- return GW_OK;
+ return true;
}
#ifndef BUILD_ON_WINDOWS
#include <sys/stat.h>
-ANN static int is_reg(const m_str path) {
+ANN static bool is_reg(const m_str path) {
struct stat s = {};
stat(path, &s);
return !S_ISDIR(s.st_mode) && (S_ISREG(s.st_mode) || !S_ISFIFO(s.st_mode));
}
#else
-ANN static m_bool is_reg(const m_str path) {
+ANN static bool is_reg(const m_str path) {
const DWORD dw = GetFileAttributes(path);
return !(dw == INVALID_FILE_ATTRIBUTES || dw & FILE_ATTRIBUTE_DIRECTORY);
}
#endif
-ANN static inline m_bool compiler_open(struct Compiler *c) {
+ANN static inline bool compiler_open(struct Compiler *c) {
char name[strlen(c->name) + 1];
strcpy(name, c->name);
#ifndef __FUZZING__
if ((c->type == COMPILE_FILE || c->type == COMPILE_NAME) && !is_reg(name)) {
gw_err(_("'%s': is a not a regular file\n"), name);
- return GW_ERROR;
+ return false;
}
#endif
- if (_compiler_open(c) < 0) {
+ if (!_compiler_open(c)) {
compiler_error(c);
gw_err(_("can't open '%s'\n"), name);
- return GW_ERROR;
+ return false;
}
- return GW_OK;
+ return true;
}
-ANN static inline m_bool _passes(struct Gwion_ *gwion, struct Compiler *c) {
+ANN static inline bool _passes(struct Gwion_ *gwion, struct Compiler *c) {
for (m_uint i = 0; i < vector_size(&gwion->data->passes->vec); ++i) {
const compilation_pass pass =
(compilation_pass)vector_at(&gwion->data->passes->vec, i);
if(pass(gwion->env, &c->ast) < 0) {
gwion->data->errored = true;
- return GW_ERROR;
+ return false;
}
}
- return GW_OK;
+ return true;
}
-ANN static inline m_bool passes(struct Gwion_ *gwion, struct Compiler *c) {
+ANN static inline bool passes(struct Gwion_ *gwion, struct Compiler *c) {
const Env env = gwion->env;
const Context ctx = new_context(env->gwion->mp, c->ast, env->name);
env_reset(env);
} else
valid_value(gwion->env, insert_symbol(gwion->st, v->name), v);
}
- const m_bool ret = _passes(gwion, c);
+ const bool ret = _passes(gwion, c);
ctx->tree = c->ast;
- if (ret > 0) //{
+ if (ret) //{
nspc_commit(env->curr);
- if (ret > 0 || env->context->global)
+ if (ret || env->context->global)
vector_add(&env->scope->known_ctx, (vtype)ctx);
else { // nspc_rollback(env->global_nspc);
context_remref(ctx, env->gwion);
void gwion_set_default_pos(const pos_t _pos) {
pos = _pos;
}
-ANN static inline m_bool _check(struct Gwion_ *gwion, struct Compiler *c) {
+ANN static inline bool _check(struct Gwion_ *gwion, struct Compiler *c) {
struct AstGetter_ arg = {c->name, c->file, gwion->st, .ppa = gwion->ppa};
- CHECK_OB((c->ast = parse_pos(&arg, pos)));
+ CHECK_B((c->ast = parse_pos(&arg, pos)));
gwion->env->name = c->name;
- const m_bool ret = passes(gwion, c);
- return ret;
+ return passes(gwion, c);
}
ANN static m_uint _compile(struct Gwion_ *gwion, struct Compiler *c) {
- if (compiler_open(c) < 0) return 0;
- if (_check(gwion, c) < 0) return 0;
+ if (!compiler_open(c)) return 0;
+ if (!_check(gwion, c)) return 0;
if (gwion->emit->info->code) {
c->shred = new_vm_shred(gwion->mp, gwion->emit->info->code);
c->shred->info->args.ptr = c->args.ptr;
#include "shreduler_private.h"
#include "ugen.h"
-ANN m_bool gwion_audio(const Gwion gwion) {
+ANN static bool gwion_audio(const Gwion gwion) {
Driver *const di = gwion->vm->bbq;
- if (di->si->arg) CHECK_OB((di->func = driver_ini(gwion, di->si)));
+ if (di->si->arg) CHECK_B((di->func = driver_ini(gwion, di->si)));
di->func(di->driver);
- CHECK_BB(di->driver->ini(gwion->vm, di));
+ if(di->driver->ini(gwion->vm, di) < 0)
+ return false;
driver_alloc(di);
- return GW_OK;
+ return true;
}
ANN static VM_Shred gwion_cleaner(const Gwion gwion) {
return v->d.func_ref;
}
-ANN static m_bool gwion_ok(const Gwion gwion, CliArg *arg) {
- CHECK_BB(plug_ini(gwion, &arg->lib));
+ANN static bool gwion_ok(const Gwion gwion, CliArg *arg) {
+ if(!plug_ini(gwion, &arg->lib)) return false;
shreduler_set_loop(gwion->vm->shreduler, arg->loop);
if(arg->embed_libs) arg->embed_libs(gwion);
- if (gwion_audio(gwion) > 0) {
- CHECK_BB(plug_run(gwion, &arg->mod));
+ if (gwion_audio(gwion)) {
+ if(!plug_run(gwion, &arg->mod)) return false;
if (type_engine_init(gwion)) {
vector_add(&gwion->data->plugs->vec, (m_uint)gwion->env->global_nspc);
gwion->vm->cleaner_shred = gwion_cleaner(gwion);
gwion->emit->locale = gwion_locale(gwion);
if(arg->embed_scripts) arg->embed_scripts(gwion);
arg_compile(gwion, arg);
- return GW_OK;
+ return true;
}
}
- return GW_ERROR;
+ return false;
}
#define LOCALE_INFO INSTALL_PREFIX "/share"
vector_release(&v);
}
-ANN m_bool gwion_ini(const Gwion gwion, CliArg *arg) {
+ANN bool gwion_ini(const Gwion gwion, CliArg *arg) {
#ifdef USE_GETTEXT
setlocale(LC_ALL, NULL);
bindtextdomain(GWION_PACKAGE, LOCALE_INFO);
pass_default(gwion);
else doc_mode(gwion);
}
- return !arg->quit ? gwion_ok(gwion, arg) : GW_ERROR;
+ return !arg->quit ? gwion_ok(gwion, arg) : false;
}
ANN void gwion_run(const Gwion gwion) {
env_reset(gwi->gwion->env);
}
-ANN static m_bool run_with_doc(const Gwi gwi, m_bool (*f)(const Gwi)) {
+ANN static bool run_with_doc(const Gwi gwi, m_bool (*f)(const Gwi)) {
struct GwfmtState ls = {.builtin = true, .nindent = 4};
text_init(&ls.text, gwi->gwion->mp);
Gwfmt gwfmter = {.mp = gwi->gwion->mp, .ls = &ls, .st = gwi->gwion->st };
gwi->gwfmt = &gwfmter;
const m_bool ret = f(gwi);
fprintf(stdout, "%s", ls.text.str);
- return ret;
+ return ret > 0;
}
-ANN m_bool gwi_run(const Gwion gwion, m_bool (*f)(const Gwi)) {
+ANN bool gwi_run(const Gwion gwion, m_bool (*f)(const Gwi)) {
const m_str name = gwion->env->name;
// const Context ctx = gwion->env->context;
// gwion->env->context = NULL;
if (ret < 0) gwi_reset(&gwi);
gwion->env->name = name;
// gwion->env->context = ctx;
- return ret;
+ return ret > 0;
}
prim_op(env, t, "$", NULL, (opem)dummy_func);
prim_implicit(env, t);
} // else provide function to get slices
- CHECK_BO(mk_gack(env->gwion->mp, t, gack_prim));
+ CHECK_O(mk_gack(env->gwion->mp, t, gack_prim));
return t;
}
gwi->gwion->env->name = file;
}
-ANN m_bool mk_gack(MemPool p, const Type type, const f_gack d) {
+ANN bool mk_gack(MemPool p, const Type type, const f_gack d) {
const VM_Code code = new_vmcode(p, NULL, NULL, "@gack", SZ_INT, true, false);
code->native_func = (m_uint)d;
type->info->gack = code;
- return GW_OK;
+ return true;
}
ANN m_bool gwi_gack(const Gwi gwi, const Type type, const f_gack d) {
ANN m_bool type_engine_init(const Gwion gwion) {
gwion->env->name = "[builtin]";
- CHECK_BB(gwi_run(gwion, import_core_libs));
+ CHECK_b(gwi_run(gwion, import_core_libs));
gwion->data->cdoc = false;
push_global(gwion, "[user]");
return GW_OK;
.thread_count = 4,
.queue_size = 16
};
- const m_bool ini = gwion_ini(&gwion, &arg);
+ const bool ini = gwion_ini(&gwion, &arg);
arg_release(&arg);
- if (ini > 0) gwion_run(&gwion);
+ if (ini) gwion_run(&gwion);
const bool ret = gwion.data->errored;
gwion_end(&gwion);
gwion.vm = NULL;
if (stmt->d.stmt_pp.pp_type == ae_pp_include)
env->name = stmt->d.stmt_pp.data;
else if (stmt->d.stmt_pp.pp_type == ae_pp_import) {
- if(plugin_ini(env->gwion, stmt->d.stmt_pp.data, stmt->loc) < 0)
+ if(!plugin_ini(env->gwion, stmt->d.stmt_pp.data, stmt->loc))
ok = false;
}
} else if (stmt->stmt_type == ae_stmt_spread) {
#endif
}
-ANN m_bool plug_ini(const struct Gwion_ *gwion, const Vector list) {
+ANN bool plug_ini(const struct Gwion_ *gwion, const Vector list) {
gwion->data->plugs = mp_calloc2(gwion->mp, sizeof(Plugs));
const Map map = &gwion->data->plugs->map;
map_init(map);
const m_str dir = (m_str)vector_at(list, i - 1);
h.len = strlen(dir);
char name[PATH_MAX];
- sprintf(name, "%s/*.so", dir);
+ sprintf(name, "%s/" "*.so", dir);
plug_get_all(&h, name);
}
- return GW_OK;
+ return true;
}
void free_plug(const Gwion gwion) {
free_vector(p, v);
}
-ANN m_bool set_module(const struct Gwion_ *gwion, const m_str name,
+ANN bool set_module(const struct Gwion_ *gwion, const m_str name,
void *const ptr) {
const Map map = &gwion->data->plugs->map;
for (m_uint j = 0; j < map_size(map); ++j) {
if (!strcmp(name, (m_str)VKEY(map, j))) {
Plug plug = (Plug)VVAL(map, j);
plug->self = ptr;
- return GW_OK;
+ return true;
}
}
gw_err("%s: no such module\n", name);
- return GW_ERROR;
+ return false;
}
-ANN m_bool plug_run(const struct Gwion_ *gwion, const Map mod) {
+ANN bool plug_run(const struct Gwion_ *gwion, const Map mod) {
const Map map = &gwion->data->plugs->map;
for (m_uint i = 0; i < map_size(mod); ++i) {
const m_str name = (m_str)VKEY(mod, i);
}
if(j == map_size(map)) {
gw_err("%s: no such module\n", name);
- return GW_ERROR;
+ return false;
}
}
- return GW_OK;
+ return true;
}
-ANN static m_bool dependencies(struct Gwion_ *gwion, const Plug plug, const loc_t loc) {
+ANN static bool dependencies(struct Gwion_ *gwion, const Plug plug, const loc_t loc) {
const gwdepend_t dep = plug->depend;
bool ret = true;
if (dep) {
m_str *const base = dep();
m_str * deps = base;
while (*deps) {
- if(plugin_ini(gwion, *deps, loc) < 0) {
+ if(!plugin_ini(gwion, *deps, loc)) {
gw_err("%s: no such plugin (dependency)\n", *deps);
ret = false;
}
++deps;
}
}
- return ret ? GW_OK : GW_ERROR;
+ return ret;
}
ANN static void plug_name(m_str name, const m_str iname, const m_uint size) {
user->parent = nspc;
}
-ANN static m_bool start(const Plug plug, const Gwion gwion, const m_str iname, const loc_t loc) {
- if(!plug->plugin) return GW_ERROR;
+ANN static bool start(const Plug plug, const Gwion gwion, const m_str iname, const loc_t loc) {
+ if(!plug->plugin) return false;
const bool cdoc = gwion->data->cdoc;
gwion->data->cdoc = 0; // check cdoc
- CHECK_BB(dependencies(gwion, plug, loc));
+ CHECK_B(dependencies(gwion, plug, loc));
gwion->data->cdoc = cdoc;
plug->nspc = new_nspc(gwion->mp, iname);
vector_add(&gwion->data->plugs->vec, (m_uint)plug->nspc);
const m_uint scope = env_push(gwion->env, NULL, plug->nspc);
const m_str name = gwion->env->name;
gwion->env->name = iname;
- const m_bool ret = gwi_run(gwion, plug->plugin);
+ const bool ret = gwi_run(gwion, plug->plugin);
gwion->env->name = name;
env_pop(gwion->env, scope);
return ret;
}
-ANN static m_bool started(const Plug plug, const Gwion gwion, const m_str iname) {
+ANN static bool started(const Plug plug, const Gwion gwion, const m_str iname) {
Nspc nspc = gwion->env->global_nspc->parent;
do if(!strcmp(nspc->name, iname))
- return GW_OK;
+ return true;
while((nspc = nspc->parent));
set_parent(plug->nspc, gwion);
- return GW_OK;
+ return true;
}
-ANN static m_bool _plugin_ini(struct Gwion_ *gwion, const m_str iname, const loc_t loc) {
+ANN static bool _plugin_ini(struct Gwion_ *gwion, const m_str iname, const loc_t loc) {
const Map map = &gwion->data->plugs->map;
for (m_uint i = 0; i < map_size(map); ++i) {
const Plug plug = (Plug)VVAL(map, i);
else return started(plug, gwion, iname);
}
}
- return GW_ERROR;
+ return false;
}
-ANN m_bool plugin_ini(struct Gwion_ *gwion, const m_str iname, const loc_t loc) {
+ANN bool plugin_ini(struct Gwion_ *gwion, const m_str iname, const loc_t loc) {
const Env env = gwion->env;
- if(_plugin_ini(gwion, iname, loc) < 0) {
+ if(!_plugin_ini(gwion, iname, loc)) {
if(gwion->env->context && !gwion->env->context->error)
env_err(env, loc, "%s: no such plugin\n", iname);
- return GW_ERROR;
+ return false;
}
return GW_OK;
}
GWMODEND(get_module) { puts(__func__); }
GWION_IMPORT(get_module) {
- CHECK_BB(set_module(gwi->gwion, "get_module", (void *)1));
+ CHECK_b(set_module(gwi->gwion, "get_module", (void *)1));
GWI_OB(get_module(gwi->gwion, "get_module"))
puts("test passed");
get_module(gwi->gwion, "non_existant_module");
-Subproject commit 794ebb72427e9baf957ffbba306be864899d2728
+Subproject commit 373c31f93cc54f6dd0f04dee5b685bb8f73d4a88