From: fennecdjay Date: Fri, 4 Oct 2019 10:53:36 +0000 (+0200) Subject: :art: Introduce get_module X-Git-Tag: nightly~2198^2~162 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=90984d75eec5084f8e4de7fdfe0e1f371747b1ad;p=gwion.git :art: Introduce get_module --- diff --git a/include/plug.h b/include/plug.h index e668cca3..06c922b1 100644 --- a/include/plug.h +++ b/include/plug.h @@ -16,7 +16,7 @@ typedef struct PlugInfo_ { ANN PlugInfo* new_plug(MemPool, Vector); ANN void plug_run(const Gwion gwion, const Vector); ANN void free_plug(const Gwion gwion); - +ANN void* get_module(const Gwion, const m_str); #define GWIMPORT_NAME import #define GWMODSTR_NAME gwmodstr #define GWMODINI_NAME gwmodini diff --git a/src/plug.c b/src/plug.c index 19313806..c0dd2193 100644 --- a/src/plug.c +++ b/src/plug.c @@ -152,3 +152,13 @@ void plug_run(const Gwion gwion, const Vector args) { } } } + +ANN void* get_module(const Gwion gwion, const m_str name) { + const Vector v = &gwion->plug->vec[GWPLUG_MODULE]; + for(m_uint i = 0; i < vector_size(v); ++i) { + struct Plug_ *plug = (struct Plug_*)vector_at(v, i); + if(!strcmp(name, plug->name)) + return plug->self; + } + return NULL; +}