From 90984d75eec5084f8e4de7fdfe0e1f371747b1ad Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Fri, 4 Oct 2019 12:53:36 +0200 Subject: [PATCH] :art: Introduce get_module --- include/plug.h | 2 +- src/plug.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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; +} -- 2.43.0