From 6a91528b8f0843aaff780f9d0029721c73fd4c1f Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Sat, 16 Jul 2022 15:15:06 +0200 Subject: [PATCH] :art: Error on unknown module --- include/plug.h | 2 +- src/gwion.c | 2 +- src/plug.c | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/plug.h b/include/plug.h index e53a0403..9b872f4c 100644 --- a/include/plug.h +++ b/include/plug.h @@ -3,7 +3,7 @@ ANN m_bool plug_ini(const struct Gwion_ *, const Vector); ANN m_bool driver_ini(const struct Gwion_ *); -ANN void plug_run(const struct Gwion_ *, const Map); +ANN m_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 void set_module(const struct Gwion_ *gwion, const m_str name, diff --git a/src/gwion.c b/src/gwion.c index 76b461f9..4ca0239d 100644 --- a/src/gwion.c +++ b/src/gwion.c @@ -76,7 +76,7 @@ ANN static m_bool gwion_ok(const Gwion gwion, CliArg *arg) { CHECK_BB(plug_ini(gwion, &arg->lib)); shreduler_set_loop(gwion->vm->shreduler, arg->loop); if (gwion_audio(gwion) > 0) { - plug_run(gwion, &arg->mod); + CHECK_BB(plug_run(gwion, &arg->mod)); if (type_engine_init(gwion)) { vector_add(&gwion->data->plugs->vec, (m_uint)gwion->env->global_nspc); gwion->vm->cleaner_shred = gwion_cleaner(gwion); diff --git a/src/plug.c b/src/plug.c index 576cf7df..340ca71d 100644 --- a/src/plug.c +++ b/src/plug.c @@ -129,21 +129,28 @@ ANN void set_module(const struct Gwion_ *gwion, const m_str name, map_set(map, (m_uint)name, (m_uint)plug); } -ANN void plug_run(const struct Gwion_ *gwion, const Map mod) { +ANN m_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); const m_str opt = (m_str)VVAL(mod, i); - for (m_uint j = 0; j < map_size(map); ++j) { + m_uint j; + for (j = 0; j < map_size(map); ++j) { if (!strcmp(name, (m_str)VKEY(map, j))) { Plug plug = (Plug)VVAL(map, j); const Vector arg = opt ? split_args(gwion->mp, opt) : NULL; const modini ini = DLSYM(plug->dl, modini, GWMODINI_NAME); plug->self = ini(gwion, arg); if (arg) plug_free_arg(gwion->mp, arg); + break; } } + if(j == map_size(map)) { + gw_err("{+R}[module]{0} {C}%s{0} not found\n", name); + return GW_ERROR; + } } + return GW_OK; } ANN static m_bool dependencies(struct Gwion_ *gwion, const Plug plug, const loc_t loc) { -- 2.43.0