From f954056fc37e9ae747d64f217265d3fcf5842cd4 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Wed, 25 Jan 2023 22:43:44 +0100 Subject: [PATCH] :art: update librarie system --- .gitignore | 2 + Makefile | 18 ++-- include/driver.h | 3 +- include/import.h | 4 +- include/lang_private.h | 42 ++++---- include/plug.h | 58 ++++++----- scripts/embed.bash | 121 ++++++++++++++++++++++ scripts/gw_embed.sh | 46 -------- src/gwion.c | 5 +- src/lib/engine.c | 42 ++++---- src/lib/modules.c | 14 +-- src/lib/prim.c | 26 ++--- src/lib/ugen.c | 2 +- src/main.c | 10 +- src/plug.c | 54 +++++----- tests/driver/non_driver.c | 2 +- tests/driver/simple_driver.c | 2 +- tests/module/get_module.c | 6 +- tests/module/module.c | 2 +- tests/plug/array.c | 2 +- tests/plug/array_in_var_name.c | 2 +- tests/plug/array_in_var_name_fail.c | 2 +- tests/plug/array_incoherent_in_var_name.c | 2 +- tests/plug/array_invalid_in_var_name.c | 2 +- tests/plug/class_template_invalid.c | 2 +- tests/plug/compile_file.c | 2 +- tests/plug/deps.c | 2 +- tests/plug/empty_union.c | 2 +- tests/plug/enum.c | 2 +- tests/plug/enum_fail.c | 2 +- tests/plug/enum_fail2.c | 2 +- tests/plug/enum_fail3.c | 2 +- tests/plug/extend_array.c | 2 +- tests/plug/fail_on_next_arg2.c | 2 +- tests/plug/fptr.c | 2 +- tests/plug/fptr_tmpl.c | 2 +- tests/plug/fptr_tmpl_fail.c | 2 +- tests/plug/func_fail.c | 2 +- tests/plug/func_fail2.c | 2 +- tests/plug/func_fail3.c | 2 +- tests/plug/func_fail4.c | 2 +- tests/plug/func_subscript_not_empty.c | 2 +- tests/plug/func_tmpl_fail.c | 2 +- tests/plug/func_too_many_arg.c | 2 +- tests/plug/global_func.c | 2 +- tests/plug/global_var.c | 2 +- tests/plug/invalid_arg.c | 2 +- tests/plug/invalid_array.c | 2 +- tests/plug/invalid_func.c | 2 +- tests/plug/invalid_names.c | 2 +- tests/plug/invalid_names0.c | 2 +- tests/plug/invalid_names1.c | 2 +- tests/plug/invalid_names2.c | 2 +- tests/plug/invalid_names3.c | 2 +- tests/plug/invalid_type1.c | 2 +- tests/plug/invalid_type2.c | 2 +- tests/plug/invalid_type3.c | 2 +- tests/plug/mk_type_array.c | 2 +- tests/plug/not_importing.c | 2 +- tests/plug/pass.c | 2 +- tests/plug/specialid_emit.c | 2 +- tests/plug/static_string.c | 2 +- tests/plug/str2decl.c | 2 +- tests/plug/str2list_fail.c | 2 +- tests/plug/struct.c | 2 +- tests/plug/template_arg.c | 2 +- tests/plug/typedef.c | 2 +- tests/plug/typedef_fail.c | 2 +- tests/plug/typedef_tmpl.c | 2 +- tests/plug/union.c | 2 +- tests/plug/union_fail_exp.c | 2 +- tests/plug/union_name.c | 2 +- tests/plug/union_tmpl.c | 2 +- tests/plug/union_tmpl_fail.c | 2 +- tests/plug/union_tmpl_fail2.c | 2 +- tests/plug/union_tmpl_fail3.c | 2 +- tests/plug/vm_remove.c | 2 +- tests/sh/opt.sh | 9 +- util | 2 +- 79 files changed, 330 insertions(+), 256 deletions(-) create mode 100644 scripts/embed.bash delete mode 100644 scripts/gw_embed.sh diff --git a/.gitignore b/.gitignore index f2aec4ea..fcaca41a 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ mkdocs.yml .vscode # ignore gwiond for dev gwiond +embed +gwion.config.json diff --git a/Makefile b/Makefile index 82c630dc..f91c102c 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,11 @@ ifeq ($(shell uname), Linux) LDFLAGS += -lrt endif +ifeq (${USE_CONFIG}, 1) +config_obj := embed/embed.o +include embed/embed.mk +endif + ALMOST_LIBS := fmt/libgwion_fmt.a ALMOST_LIBS += ast/libgwion_ast.a ast/libprettyerr/libprettyerr.a ALMOST_LIBS += util/libgwion_util.a @@ -71,20 +76,19 @@ CFLAGS += -DGWION_BUILTIN all: options-show prg -prg: ${GWLIBS} src/main.o +prg: ${GWLIBS} ${config_obj} src/main.o @$(info link ${PRG}) - @${CC} src/main.o -o ${PRG} ${LDFLAGS} ${LIBS} + ${CC} src/main.o -o ${PRG} ${config_obj} ${PLUGLIBS} ${LDFLAGS} ${LIBS} options-show: @$(call _options) @$(info libs: ${GWLIBS}) -embed_gw: +with_config: + bash scripts/embed.bash gwion.config.json + touch src/main.c + USE_CONFIG=1 CFLAGS="-DGWION_EMBED_GW -Iembed $(eval ${CFLAGS})" ${MAKE} touch src/main.c - mkdir -p embed - bash scripts/gw_embed.sh ${GWION_EMBED_GW} > src/embed.c - CFLAGS="-DGWION_EMBED_GW -Iembed $(eval ${CFLAGS})" ${MAKE} - rm -rf embed src/embed.c almost_gwion: ${almost_obj} ${ALMOST_LIBS} diff --git a/include/driver.h b/include/driver.h index 2a13eb7d..3118941e 100644 --- a/include/driver.h +++ b/include/driver.h @@ -12,7 +12,6 @@ typedef struct DriverData_ { f_drvdel del; } DriverData; -typedef void (*f_bbqset)(struct DriverData_ *); typedef void (*f_bbqrun)(const struct VM_ *); typedef struct BBQ_ { @@ -20,7 +19,7 @@ typedef struct BBQ_ { m_float * in; m_float * out; struct SoundInfo_ * si; - f_bbqset func; + gwdriver_t func; f_bbqrun run; struct DriverData_ *driver; bool is_running; diff --git a/include/import.h b/include/import.h index b173e819..ae35ef84 100644 --- a/include/import.h +++ b/include/import.h @@ -37,7 +37,7 @@ typedef struct Gwi_ *Gwi; gwi_set_loc(gwi, __FILE__, __LINE__); \ (void)(a); \ } -#define GWION_IMPORT(a) ANN m_bool import_##a(const Gwi gwi) +#define GWION_IMPORT(a) ANN m_bool gwimport_##a(const Gwi gwi) #else #define GWI_BB(a) \ { \ @@ -49,7 +49,7 @@ typedef struct Gwi_ *Gwi; gwi_set_loc(gwi, (m_str)__FILE__, __LINE__); \ CHECK_OB(a); \ } -#define GWION_IMPORT(a) ANN m_bool import(const Gwi gwi) +#define GWION_IMPORT(a) ANN m_bool gwimport_##a(const Gwi gwi) #endif #define ALLOC_PTR(p, a, b, c) \ b *a = (b *)_mp_calloc(p, sizeof(b)); \ diff --git a/include/lang_private.h b/include/lang_private.h index 9973412c..5c6fd972 100644 --- a/include/lang_private.h +++ b/include/lang_private.h @@ -1,24 +1,24 @@ #ifndef __LANG_PRIVATE #define __LANG_PRIVATE -ANN m_bool import_class(const Gwi gwi); -ANN m_bool import_prim(const Gwi gwi); -ANN m_bool import_enum(const Gwi gwi); -ANN m_bool import_object(const Gwi gwi); -ANN m_bool import_func(const Gwi gwi); -ANN m_bool import_string(const Gwi gwi); -ANN m_bool import_shred(const Gwi gwi); -ANN m_bool import_event(const Gwi gwi); -ANN m_bool import_ugen(const Gwi gwi); -ANN m_bool import_array(const Gwi gwi); -ANN m_bool import_xork(const Gwi gwi); -ANN m_bool import_modules(const Gwi gwi); -ANN m_bool import_object_op(const Gwi gwi); -ANN m_bool import_values(const Gwi gwi); -ANN m_bool import_union(const Gwi gwi); -ANN m_bool import_ref(const Gwi gwi); -ANN m_bool import_deep_equal(const Gwi gwi); -ANN m_bool import_dict(const Gwi gwi); -ANN m_bool import_gack(const Gwi gwi); -ANN m_bool import_sift(const Gwi gwi); -ANN m_bool import_locale(const Gwi gwi); +ANN m_bool gwimport_class(const Gwi gwi); +ANN m_bool gwimport_prim(const Gwi gwi); +ANN m_bool gwimport_enum(const Gwi gwi); +ANN m_bool gwimport_object(const Gwi gwi); +ANN m_bool gwimport_func(const Gwi gwi); +ANN m_bool gwimport_string(const Gwi gwi); +ANN m_bool gwimport_shred(const Gwi gwi); +ANN m_bool gwimport_event(const Gwi gwi); +ANN m_bool gwimport_ugen(const Gwi gwi); +ANN m_bool gwimport_array(const Gwi gwi); +ANN m_bool gwimport_xork(const Gwi gwi); +ANN m_bool gwimport_modules(const Gwi gwi); +ANN m_bool gwimport_object_op(const Gwi gwi); +ANN m_bool gwimport_values(const Gwi gwi); +ANN m_bool gwimport_union(const Gwi gwi); +ANN m_bool gwimport_ref(const Gwi gwi); +ANN m_bool gwimport_deep_equal(const Gwi gwi); +ANN m_bool gwimport_dict(const Gwi gwi); +ANN m_bool gwimport_gack(const Gwi gwi); +ANN m_bool gwimport_sift(const Gwi gwi); +ANN m_bool gwimport_locale(const Gwi gwi); #endif diff --git a/include/plug.h b/include/plug.h index 1953d4e2..7bac9fb4 100644 --- a/include/plug.h +++ b/include/plug.h @@ -1,45 +1,51 @@ #ifndef __PLUG #define __PLUG +struct DriverData_; +struct Gwi_; +typedef m_bool (*gwplugin_t) (struct Gwi_*); +typedef void* (*gwmodini_t) (struct Gwion_ const* gwion, const Vector args); +typedef void* (*gwmodend_t) (struct Gwion_ const* gwion, void *self); +typedef void (*gwdriver_t) (struct DriverData_ *); +typedef m_str* (*gwdepend_t) (void); + +typedef struct Plug_ { + void *dl; + void *self; + Nspc nspc; + gwplugin_t plugin; + gwdriver_t driver; + gwmodini_t modini; + gwmodend_t modend; + gwdepend_t depend; +} * Plug; + +ANN static inline Plug new_plug(MemPool p) { + return (Plug)mp_calloc(p, Plug); +} + ANN m_bool plug_ini(const struct Gwion_ *, const Vector); ANN m_bool driver_ini(const struct Gwion_ *); 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, +ANN m_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); -struct DriverData_; -struct Gwi_; -typedef m_bool (*gwplugin_t) (struct Gwi_*); -typedef void* (*gwmodini_t) (struct Gwion_ const* gwion, const Vector args); -typedef void* (*gwmodend_t) (struct Gwion_ const* gwion, void *self); -typedef void* (*gwdriver_t) (struct DriverData_ *); -typedef m_str* (*gwdepend_t) (void); -#define GWIMPORT_NAME import -#define GWMODINI_NAME gwmodini -#define GWMODEND_NAME gwmodend -#define GWDRIVER_NAME gwdriver -#define GWDEPEND_NAME gwdepend +#define GWIMPORT_NAME(a) gwimport_##a +#define GWMODINI_NAME(a) gwmodini_##a +#define GWMODEND_NAME(a) gwmodend_##a +#define GWDRIVER_NAME(a) gwdriver_##a +#define GWDEPEND_NAME(a) gwdepend_##a -#ifndef GWION_BUILTIN -#define GWMODINI(a) \ - ANN2(1) \ - void *GWMODINI_NAME(struct Gwion_ *const gwion NUSED, const Vector args NUSED) -#define GWMODEND(a) \ - ANN void GWMODEND_NAME(struct Gwion_ *const gwion NUSED, void *self NUSED) -#define GWDRIVER(a) ANN void GWDRIVER_NAME(DriverData *d) -#define GWDEPEND(a) ANN m_str const *GWDEPEND_NAME(void) -#else -#define GWIMODINI(a) \ +#define GWMODINI(a) \ ANN2(1) \ void *gwmodini_##a(struct Gwion_ *const gwion NUSED, const Vector args NUSED) #define GWMODEND(a) \ ANN void gwmodend_##a(struct Gwion_ *const gwion NUSED, void *self NUSED) -#define GWDRIVER(a) gwdriver_##a(a) ANN void GWDRIVER_NAME(DriverData *d) -#define GWDEPEND(a) gwdepend_##a ANN m_str const *GWDEPEND_NAME(void) -#endif +#define GWDRIVER(a) ANN void gwdriver_##a(DriverData *d) +#define GWDEPEND(a) ANN m_str const *gwdepend_##a(void) #endif diff --git a/scripts/embed.bash b/scripts/embed.bash new file mode 100644 index 00000000..bf56e91b --- /dev/null +++ b/scripts/embed.bash @@ -0,0 +1,121 @@ +#!/usr/bin/bash +mkdir -p embed +rm -f embed/* + +#json=$(jq -c '.' "$1") +json=$(cat "$1") + +cat << EOF >> embed/embed_head +#include "gwion_util.h" +#include "gwion_ast.h" +#include "gwion_env.h" +#include "vm.h" +#include "instr.h" +#include "emit.h" +#include "compile.h" +#include "gwion.h" +#include "object.h" +#include "operator.h" +#include "import.h" +#include "gwi.h" + +EOF + +header() { + echo "$1" >> embed/embed_head +} + +config() { + echo "$1" >> embed/embed.mk +} + +has_func() { + nm "$2" | grep "${1}_${3}" > /dev/null +} +plugin() { + has_func "gwimport" "$1" "$2" && { + header "extern m_bool gwimport_${2}(const Gwi);" + echo " plug->plugin = gwimport_${2};" + } +} +driver() { + has_func "gwdriver" "$1" "$2" && { + header "extern void *gwdriver_$2(struct DriverData_*);" + echo " plug->driver = gwdriver_$2;" + } +} +modini() { + has_func "gwmodini" "$1" "$2" && { + header "extern m_bool gwmodini_${2}(gwion);" + echo " plug->modini = gwmodini_${2};" + } +} +modend() { + has_func "gwmodend" "$1" "$2" && { + header "extern m_bool gwmodend_${2}(gwion);" + echo " plug->modend = gwmodend_${2};" + } +} + +handle_lib() { + cat << EOF >> embed/embed_body +ANN static void embed_${name}(const Gwion gwion) { + Plug plug = new_plug(gwion->mp); +$(modini "$1" "$2")$(modend "$1" "$2")$(plugin "$1" "$2")$(driver "$1" "$2") + map_set(&gwion->data->plugs->map, (vtype)strdup("${2}"), (vtype)plug); +} + +EOF +} + +cat << EOF >> embed/embed_foot +ANN static void compile_script(const Gwion gwion, const m_str filename, + const m_str content, const size_t sz) { + const m_str str = mp_malloc2(gwion->mp, sz + 1); + memcpy(str, content, sz); + str[sz] = 0; + compile_string(gwion, filename, str); + mp_free2(gwion->mp, sz + 1, str); +} + +EOF + +echo "ANN void gwion_embed(const Gwion gwion) {" >> embed/embed_foot +jq -rc '.libraries|.[]' <<< "$json" | + while read -r lib + do + path=$(jq -c '.path' <<< "$lib" | sed -e 's/^"//' -e 's/"$//') + names=$(jq -c '.names' <<< "$lib") + config "LDFLAGS += $path" + if [ "$names" != "null" ] + then + jq -c '.[]' <<< "$names" | sed -e 's/^"//' -e 's/"$//' | + while read -r name + do + echo " embed_${name}(gwion);" >> embed/embed_foot + handle_lib "$path" "$name" + done + fi + done + +handle_script() { + name="script$2" + xxd -name "$name" -i "$1" > "embed/${name}.h" + header "#include \"${name}.h\"" + echo " compile_script(gwion, \"$name\", ${name}, ${name}_len);" +} + +handle_scripts() { + i=0 + jq -r '.scripts|.[]' <<< "$json" | + while read -r name; + do handle_script "$name" "$i"; i=$((i+1)); + done +} + +handle_scripts >> embed/embed_foot +echo "}" >> embed/embed_foot + +cat embed/embed_head embed/embed_body embed/embed_foot > embed/embed.c +rm embed/embed_head embed/embed_body embed/embed_foot + diff --git a/scripts/gw_embed.sh b/scripts/gw_embed.sh deleted file mode 100644 index 391bf039..00000000 --- a/scripts/gw_embed.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -header_name() { - echo "$1" | sed 's/\./_/' | sed 's#/#_#g' -} - -cat << EOF -#include "gwion_util.h" -#include "gwion_ast.h" -#include "gwion_env.h" -#include "vm.h" -#include "instr.h" -#include "emit.h" -#include "compile.h" -#include "gwion.h" - -static void compile_embed_gw(const Gwion gwion, const m_str filename, - const m_str content, const size_t sz) { - const m_str str = mp_malloc2(gwion->mp, sz + 1); - memcpy(str, content, sz); - str[sz] = 0; - compile_string(gwion, filename, str); - mp_free2(gwion->mp, sz + 1, str); -} - -EOF - -for file in $GWION_EMBED_GW -do - name=$(header_name "$file") - xxd -i "$file" > embed/"${name}.h" - echo "#include \"${name}.h\"" -done - - - -echo "void embed_gw(const Gwion gwion) {" - -for file in $GWION_EMBED_GW -do - name=$(header_name "$file") - xxd -i "$file" > "${name}.h" - echo " compile_embed_gw(gwion, \"$file\", ${name}, ${name}_len);" - -done - -echo "}" diff --git a/src/gwion.c b/src/gwion.c index 7b11dedb..a2754a3b 100644 --- a/src/gwion.c +++ b/src/gwion.c @@ -5,8 +5,9 @@ #include "vm.h" #include "instr.h" #include "emit.h" -#include "driver.h" #include "gwion.h" +#include "plug.h" +#include "driver.h" #include "engine.h" #include "arg.h" #include "compile.h" @@ -78,11 +79,9 @@ ANN static m_bool gwion_ok(const Gwion gwion, CliArg *arg) { if (gwion_audio(gwion) > 0) { CHECK_BB(plug_run(gwion, &arg->mod)); if (type_engine_init(gwion)) { - // embed_plug(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); - // (void)arg_compile(gwion, arg); return GW_OK; } } diff --git a/src/lib/engine.c b/src/lib/engine.c index 5cfe0f21..8148b7ac 100644 --- a/src/lib/engine.c +++ b/src/lib/engine.c @@ -105,32 +105,32 @@ ANN static m_bool import_core_libs(const Gwi gwi) { gwidoc(gwi, "internal base of all objects and structures."); - GWI_BB(import_enum(gwi)); + GWI_BB(gwimport_enum(gwi)); const Type t_compound = gwi_mk_type(gwi, "@Compound", SZ_INT, NULL); GWI_BB(gwi_gack(gwi, t_compound, gack_compound)) GWI_BB(gwi_set_global_type(gwi, t_compound, et_compound)) - GWI_BB(import_object(gwi)) + GWI_BB(gwimport_object(gwi)) - GWI_BB(import_prim(gwi)) - GWI_BB(import_func(gwi)) - GWI_BB(import_object_op(gwi)) - GWI_BB(import_values(gwi)) - GWI_BB(import_union(gwi)) + GWI_BB(gwimport_prim(gwi)) + GWI_BB(gwimport_func(gwi)) + GWI_BB(gwimport_object_op(gwi)) + GWI_BB(gwimport_values(gwi)) + GWI_BB(gwimport_union(gwi)) - GWI_BB(import_array(gwi)) - GWI_BB(import_event(gwi)) - GWI_BB(import_ugen(gwi)) - GWI_BB(import_xork(gwi)) + GWI_BB(gwimport_array(gwi)) + GWI_BB(gwimport_event(gwi)) + GWI_BB(gwimport_ugen(gwi)) + GWI_BB(gwimport_xork(gwi)) GWI_BB(gwi_oper_ini(gwi, NULL, (m_str)OP_ANY_TYPE, NULL)) GWI_BB(gwi_oper_add(gwi, opck_new)) GWI_BB(gwi_oper_emi(gwi, opem_new)) GWI_BB(gwi_oper_end(gwi, "new", NULL)) - GWI_BB(import_ref(gwi)) - GWI_BB(import_string(gwi)) - GWI_BB(import_shred(gwi)) - GWI_BB(import_modules(gwi)) + GWI_BB(gwimport_ref(gwi)) + GWI_BB(gwimport_string(gwi)) + GWI_BB(gwimport_shred(gwi)) + GWI_BB(gwimport_modules(gwi)) gwidoc(gwi, "allow member access."); GWI_BB(gwi_oper_ini(gwi, "@Compound", (m_str)OP_ANY_TYPE, NULL)) @@ -138,19 +138,19 @@ ANN static m_bool import_core_libs(const Gwi gwi) { GWI_BB(gwi_oper_emi(gwi, opem_object_dot)) GWI_BB(gwi_oper_end(gwi, ".", NULL)) - GWI_BB(import_class(gwi)) + GWI_BB(gwimport_class(gwi)) gwidoc(gwi, "allow static access."); GWI_BB(gwi_oper_ini(gwi, "Class", (m_str)OP_ANY_TYPE, NULL)) GWI_BB(gwi_oper_add(gwi, opck_object_dot)) GWI_BB(gwi_oper_emi(gwi, opem_object_dot)) GWI_BB(gwi_oper_end(gwi, ".", NULL)) - GWI_BB(import_deep_equal(gwi)); + GWI_BB(gwimport_deep_equal(gwi)); - GWI_BB(import_dict(gwi)); - GWI_BB(import_gack(gwi)); - GWI_BB(import_sift(gwi)); - GWI_BB(import_locale(gwi)); + GWI_BB(gwimport_dict(gwi)); + GWI_BB(gwimport_gack(gwi)); + GWI_BB(gwimport_sift(gwi)); + GWI_BB(gwimport_locale(gwi)); // seemed need at a point to ease liking diff --git a/src/lib/modules.c b/src/lib/modules.c index 46564054..737add0b 100644 --- a/src/lib/modules.c +++ b/src/lib/modules.c @@ -286,11 +286,11 @@ static GWION_IMPORT(usrugen) { } GWION_IMPORT(modules) { - GWI_BB(import_gain(gwi)) - GWI_BB(import_impulse(gwi)) - GWI_BB(import_fullrect(gwi)) - GWI_BB(import_halfrect(gwi)) - GWI_BB(import_step(gwi)) - GWI_BB(import_zerox(gwi)) - return import_usrugen(gwi); + GWI_BB(gwimport_gain(gwi)) + GWI_BB(gwimport_impulse(gwi)) + GWI_BB(gwimport_fullrect(gwi)) + GWI_BB(gwimport_halfrect(gwi)) + GWI_BB(gwimport_step(gwi)) + GWI_BB(gwimport_zerox(gwi)) + return gwimport_usrugen(gwi); } diff --git a/src/lib/prim.c b/src/lib/prim.c index ae2be81c..08471962 100644 --- a/src/lib/prim.c +++ b/src/lib/prim.c @@ -278,13 +278,13 @@ static GWION_IMPORT(int_values) { } static GWION_IMPORT(int) { - GWI_BB(import_int_values(gwi)) + GWI_BB(gwimport_int_values(gwi)) GWI_BB(gwi_oper_cond(gwi, "int", BranchEqInt, BranchNeqInt)) GWI_BB(gwi_oper_ini(gwi, "int", "int", "int")) - GWI_BB(import_int_op(gwi)) - GWI_BB(import_int_logical(gwi)) - GWI_BB(import_int_r(gwi)) - GWI_BB(import_int_unary(gwi)) + GWI_BB(gwimport_int_op(gwi)) + GWI_BB(gwimport_int_logical(gwi)) + GWI_BB(gwimport_int_r(gwi)) + GWI_BB(gwimport_int_unary(gwi)) return GW_OK; } @@ -613,7 +613,7 @@ static GWION_IMPORT(float) { return GW_OK; } -ANN static m_bool import_ux(const Gwi gwi) { +ANN static GWION_IMPORT(ux) { char c[8] = { 'u' }; const Env env = gwi->gwion->env; for(uint i = 1; i <= SZ_INT; i *= 2) { @@ -625,11 +625,11 @@ ANN static m_bool import_ux(const Gwi gwi) { } GWION_IMPORT(prim) { - GWI_BB(import_int(gwi)) - GWI_BB(import_ux(gwi)); - GWI_BB(import_float(gwi)) // const folded - GWI_BB(import_intfloat(gwi)) // const folded - GWI_BB(import_floatint(gwi)) // const folded - GWI_BB(import_dur(gwi)) - return import_time(gwi); + GWI_BB(gwimport_int(gwi)) + GWI_BB(gwimport_ux(gwi)); + GWI_BB(gwimport_float(gwi)) // const folded + GWI_BB(gwimport_intfloat(gwi)) // const folded + GWI_BB(gwimport_floatint(gwi)) // const folded + GWI_BB(gwimport_dur(gwi)) + return gwimport_time(gwi); } diff --git a/src/lib/ugen.c b/src/lib/ugen.c index 59cdfe8e..d6ea4f61 100644 --- a/src/lib/ugen.c +++ b/src/lib/ugen.c @@ -446,5 +446,5 @@ GWION_IMPORT(ugen) { _CHECK_OP(":~>", chuck_ugen, TrigAUConnect) _CHECK_OP(":~<", chuck_ugen, TrigAUDisconnect) - return import_global_ugens(gwi); + return gwimport_global_ugens(gwi); } diff --git a/src/main.c b/src/main.c index 1184752c..9959c8c0 100644 --- a/src/main.c +++ b/src/main.c @@ -44,7 +44,7 @@ int main(int argc, char **argv) { #else #ifdef GWION_EMBED_GW -void embed_gw(const Gwion); +void gwion_embed(const Gwion); #endif int main(int argc, char **argv) { @@ -52,13 +52,11 @@ int main(int argc, char **argv) { signal(SIGINT, sig); signal(SIGTERM, sig); const m_bool ini = gwion_ini(&gwion, &arg); -// embed_plug(&gwion); -gwion_embed(&gwion); - arg_compile(&gwion, &arg); - arg_release(&arg); #ifdef GWION_EMBED_GW -// embed_gw(&gwion); + gwion_embed(&gwion); #endif + arg_compile(&gwion, &arg); + arg_release(&arg); if (ini > 0) gwion_run(&gwion); gwion_end(&gwion); gwion.vm = NULL; diff --git a/src/plug.c b/src/plug.c index 80260697..fe6f73df 100644 --- a/src/plug.c +++ b/src/plug.c @@ -15,32 +15,27 @@ #include "import.h" #include "gwi.h" -typedef m_bool (*plugin)(Gwi); - struct PlugHandle { MemPool mp; Map map; size_t len; }; -typedef struct Plug_ { - void *dl; - void *self; - Nspc nspc; - gwplugin_t plugin; - gwdriver_t driver; - gwmodini_t modini; - gwmodend_t modend; - gwdepend_t depend; -} * Plug; - -ANN static struct Plug_ *new_plug(MemPool p, void *dl) { - struct Plug_ *plug = mp_calloc(p, Plug); - plug->dl = dl; - plug->plugin = DLSYM(plug->dl, gwplugin_t, GWIMPORT_NAME); - plug->modini = DLSYM(plug->dl, gwmodini_t, GWMODINI_NAME); - plug->modend = DLSYM(plug->dl, gwmodend_t, GWMODEND_NAME); - plug->depend = DLSYM(plug->dl, gwdepend_t, GWDEPEND_NAME); +ANN static struct Plug_ *new_dl_plug(MemPool p, void *dl, const char *name) { + Plug plug = new_plug(p); + plug->dl = dl; + char s[256] = { [0] = 'g', [1] = 'w', [8] = '_' }; + strcpy(s + 9, name); + memcpy(s + 2, "import", 6); + plug->plugin = DLSYM(plug->dl, gwplugin_t, s); + memcpy(s + 2, "modini", 6); + plug->modini = DLSYM(plug->dl, gwmodini_t, s); + memcpy(s + 2, "modend", 6); + plug->modend = DLSYM(plug->dl, gwmodend_t, s); + memcpy(s + 2, "driver", 6); + plug->driver = DLSYM(plug->dl, gwdriver_t, s); + memcpy(s + 2, "depend", 6); + plug->depend = DLSYM(plug->dl, gwdepend_t, s); return plug; } @@ -52,7 +47,7 @@ ANN static void plug_get(struct PlugHandle *h, const m_str c) { memcpy(name, pname, sz); name[sz] = '\0'; if (dl) { - Plug plug = new_plug(h->mp, dl); + Plug plug = new_dl_plug(h->mp, dl, name); map_set(h->map, (vtype)strdup(name), (vtype)plug); } else gw_err(_("{+R}error{0} in {/+}%s{0}."), DLERROR()); @@ -89,7 +84,7 @@ ANN m_bool plug_ini(const struct Gwion_ *gwion, const Vector list) { 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; @@ -108,7 +103,7 @@ void free_plug(const Gwion gwion) { const gwmodend_t end = plug->modend; if (end && plug->self) end(gwion, plug->self); free((m_str)VKEY(map, i)); - DLCLOSE(plug->dl); + if(plug->dl) DLCLOSE(plug->dl); } map_release(map); mp_free2(gwion->mp, sizeof(Plugs), gwion->data->plugs); @@ -120,19 +115,18 @@ ANN static void plug_free_arg(MemPool p, const Vector v) { free_vector(p, v); } -ANN void set_module(const struct Gwion_ *gwion, const m_str name, +ANN m_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; + return GW_OK; } } - const Plug plug = new_plug(gwion->mp, name); - plug->self = ptr; - map_set(map, (m_uint)name, (m_uint)plug); + gw_err("module %s not found\n", name); + return GW_ERROR; } ANN m_bool plug_run(const struct Gwion_ *gwion, const Map mod) { @@ -249,9 +243,11 @@ ANN m_bool driver_ini(const struct Gwion_ *gwion) { if (opt) *opt = '\0'; for (m_uint i = 0; i < map_size(map); ++i) { const m_str name = (m_str)VKEY(map, i); + printf("%s %s\n", name, dname); if (!strcmp(name, dname)) { + puts("hey"); const Plug plug = (Plug)VVAL(map, i); - const f_bbqset drv = DLSYM(plug->dl, f_bbqset, GWDRIVER_NAME); + const gwdriver_t drv = plug->driver; if (!drv) break; gwion->vm->bbq->func = drv; if (opt) *opt = c; diff --git a/tests/driver/non_driver.c b/tests/driver/non_driver.c index 2c020b3b..edce9916 100644 --- a/tests/driver/non_driver.c +++ b/tests/driver/non_driver.c @@ -8,7 +8,7 @@ #include "instr.h" #include "import.h" -GWION_IMPORT(end_class) { +GWION_IMPORT(non_driver) { (void)gwi; return GW_OK; } diff --git a/tests/driver/simple_driver.c b/tests/driver/simple_driver.c index 97bb056d..6490254f 100644 --- a/tests/driver/simple_driver.c +++ b/tests/driver/simple_driver.c @@ -4,9 +4,9 @@ #include "gwion_ast.h" #include "gwion_env.h" #include "vm.h" +#include "plug.h" #include "driver.h" #include "gwion.h" -#include "plug.h" static DRVRUN(simple_driver_run) { while (di->is_running) { diff --git a/tests/module/get_module.c b/tests/module/get_module.c index 789b6ec8..c44b1773 100644 --- a/tests/module/get_module.c +++ b/tests/module/get_module.c @@ -4,7 +4,6 @@ #include "gwion_ast.h" #include "gwion_env.h" #include "vm.h" -#include "driver.h" #include "gwion.h" #include "object.h" #include "instr.h" @@ -12,6 +11,7 @@ #include "import.h" #include "gwi.h" #include "plug.h" +#include "driver.h" GWMODINI(get_module) { puts(__func__); @@ -20,8 +20,8 @@ GWMODINI(get_module) { GWMODEND(get_module) { puts(__func__); } -GWION_IMPORT(dummy_module) { - set_module(gwi->gwion, "get_module", (void *)1); +GWION_IMPORT(get_module) { + CHECK_BB(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"); diff --git a/tests/module/module.c b/tests/module/module.c index dffddb40..7deb36b5 100644 --- a/tests/module/module.c +++ b/tests/module/module.c @@ -4,9 +4,9 @@ #include "gwion_ast.h" #include "gwion_env.h" #include "vm.h" +#include "plug.h" #include "driver.h" #include "gwion.h" -#include "plug.h" GWMODINI(dummy_module) { puts(__func__); diff --git a/tests/plug/array.c b/tests/plug/array.c index ad287f2e..54a71d50 100644 --- a/tests/plug/array.c +++ b/tests/plug/array.c @@ -11,7 +11,7 @@ MFUN(test_mfun) {} -GWION_IMPORT(array_test) { +GWION_IMPORT(array) { GWI_OB(gwi_class_ini(gwi, "ArrayTest", NULL)) GWI_BB(gwi_item_ini(gwi, "int[]", "int_array")) GWI_BB(gwi_item_end(gwi, 0, obj, NULL)) // import array var diff --git a/tests/plug/array_in_var_name.c b/tests/plug/array_in_var_name.c index aaf85670..995a8ee4 100644 --- a/tests/plug/array_in_var_name.c +++ b/tests/plug/array_in_var_name.c @@ -9,7 +9,7 @@ #include "import.h" #include "gwi.h" -GWION_IMPORT(checker) { +GWION_IMPORT(array_in_var_name) { gwi_item_ini(gwi, "int", "array[2][3]"); return GW_OK; } diff --git a/tests/plug/array_in_var_name_fail.c b/tests/plug/array_in_var_name_fail.c index 235246d0..ab791ebe 100644 --- a/tests/plug/array_in_var_name_fail.c +++ b/tests/plug/array_in_var_name_fail.c @@ -9,7 +9,7 @@ #include "import.h" #include "gwi.h" -GWION_IMPORT(checker) { +GWION_IMPORT(array_in_var_name_fail) { GWI_BB(gwi_union_ini(gwi, "U")) GWI_BB(gwi_union_add(gwi, "int", "i")) return GW_OK; diff --git a/tests/plug/array_incoherent_in_var_name.c b/tests/plug/array_incoherent_in_var_name.c index 04299027..1cbd95ae 100644 --- a/tests/plug/array_incoherent_in_var_name.c +++ b/tests/plug/array_incoherent_in_var_name.c @@ -9,7 +9,7 @@ #include "import.h" #include "gwi.h" -GWION_IMPORT(checker) { +GWION_IMPORT(array_incoherent_in_var_name) { gwi_item_ini(gwi, "int", "array[2][3][]"); return GW_OK; } diff --git a/tests/plug/array_invalid_in_var_name.c b/tests/plug/array_invalid_in_var_name.c index c0c41944..5ad58b8c 100644 --- a/tests/plug/array_invalid_in_var_name.c +++ b/tests/plug/array_invalid_in_var_name.c @@ -9,7 +9,7 @@ #include "import.h" #include "gwi.h" -GWION_IMPORT(checker) { +GWION_IMPORT(array_invalid_in_var_name) { gwi_item_ini(gwi, "int", "array[.]"); return GW_OK; } diff --git a/tests/plug/class_template_invalid.c b/tests/plug/class_template_invalid.c index 47a4209b..4bd0dd2f 100644 --- a/tests/plug/class_template_invalid.c +++ b/tests/plug/class_template_invalid.c @@ -14,7 +14,7 @@ static m_int o_map_value; #define MAP_KEY(a) *((M_Object *)(a->data + o_map_key)) #define MAP_VAL(a) *((M_Object *)(a->data + o_map_value)) -GWION_IMPORT(class_template) { +GWION_IMPORT(class_template_invalid) { GWI_OB(gwi_class_ini(gwi, "ClassTemplate:[A,B]", NULL)) GWI_BB(gwi_item_ini(gwi, "A[]", "key")) GWI_BB((o_map_key = gwi_item_end(gwi, ae_flag_none, obj, NULL))) diff --git a/tests/plug/compile_file.c b/tests/plug/compile_file.c index 9745d808..5a230959 100644 --- a/tests/plug/compile_file.c +++ b/tests/plug/compile_file.c @@ -12,7 +12,7 @@ #define _XOPEN_SOURCE 500 #include -GWION_IMPORT(compile_string) { +GWION_IMPORT(compile_file) { DECL_OB(FILE *, file, = fopen("rm_me.gw", "w+")); fprintf(file, "1;"); rewind(file); diff --git a/tests/plug/deps.c b/tests/plug/deps.c index b66381f2..d614ea95 100644 --- a/tests/plug/deps.c +++ b/tests/plug/deps.c @@ -15,4 +15,4 @@ GWION_IMPORT(deps) { } static const m_str deps[] = {"array", NULL}; -GWDEPEND { return deps; } +GWDEPEND(deps) { return deps; } diff --git a/tests/plug/empty_union.c b/tests/plug/empty_union.c index 2b10e1df..ca107e84 100644 --- a/tests/plug/empty_union.c +++ b/tests/plug/empty_union.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(empty_union_test) { +GWION_IMPORT(empty_union) { GWI_BB(gwi_union_ini(gwi, "U")) GWI_OB(gwi_union_end(gwi, 0)) return GW_OK; diff --git a/tests/plug/enum.c b/tests/plug/enum.c index cac4005b..a9b35cec 100644 --- a/tests/plug/enum.c +++ b/tests/plug/enum.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(enum_test) { +GWION_IMPORT(enum) { GWI_BB(gwi_enum_ini(gwi, "test")) GWI_BB(gwi_enum_add(gwi, "TYPED_ENUM0", 0)) GWI_BB(gwi_enum_add(gwi, "TYPED_ENUM1", 1)) diff --git a/tests/plug/enum_fail.c b/tests/plug/enum_fail.c index cba7eb0f..c2cafd57 100644 --- a/tests/plug/enum_fail.c +++ b/tests/plug/enum_fail.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(enum_test) { +GWION_IMPORT(enum_fail) { GWI_BB(gwi_enum_ini(gwi, "int")) GWI_BB(gwi_enum_add(gwi, "zero", 0)) GWI_OB(gwi_enum_end(gwi)) diff --git a/tests/plug/enum_fail2.c b/tests/plug/enum_fail2.c index 4ec536f1..63f85fdd 100644 --- a/tests/plug/enum_fail2.c +++ b/tests/plug/enum_fail2.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(enum_test) { +GWION_IMPORT(enum_fail2) { GWI_BB(gwi_enum_ini(gwi, "tmp")) GWI_BB(gwi_enum_add(gwi, "adc", 0)) GWI_OB(gwi_enum_end(gwi)) diff --git a/tests/plug/enum_fail3.c b/tests/plug/enum_fail3.c index 03c16b22..a6c4f0c6 100644 --- a/tests/plug/enum_fail3.c +++ b/tests/plug/enum_fail3.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(enum_test) { +GWION_IMPORT(enum_fail3) { GWI_BB(gwi_enum_ini(gwi, "test")) GWI_BB(gwi_enum_add(gwi, "adc", 0)) GWI_BB(gwi_enum_ini(gwi, "error")) diff --git a/tests/plug/extend_array.c b/tests/plug/extend_array.c index be46b12f..3633ba27 100644 --- a/tests/plug/extend_array.c +++ b/tests/plug/extend_array.c @@ -10,7 +10,7 @@ #include "import.h" #include "gwi.h" -GWION_IMPORT(extend_array_test) { +GWION_IMPORT(extend_array) { GWI_OB(gwi_class_ini(gwi, "ArrayExt", "float[1]")) GWI_BB(gwi_class_end(gwi)) return GW_OK; diff --git a/tests/plug/fail_on_next_arg2.c b/tests/plug/fail_on_next_arg2.c index 329b0366..1abbd5bf 100644 --- a/tests/plug/fail_on_next_arg2.c +++ b/tests/plug/fail_on_next_arg2.c @@ -12,7 +12,7 @@ #include "ugen.h" #include "gwi.h" -GWION_IMPORT(fail_on_next_arg) { +GWION_IMPORT(fail_on_next_arg2) { GWI_BB(gwi_func_ini(gwi, "void", "test")) GWI_BB(gwi_func_arg(gwi, "int", "i")) GWI_BB(gwi_func_arg(gwi, "i;t", "j")) diff --git a/tests/plug/fptr.c b/tests/plug/fptr.c index 7ad1fd49..7a321531 100644 --- a/tests/plug/fptr.c +++ b/tests/plug/fptr.c @@ -9,7 +9,7 @@ #include "import.h" static MFUN(test_func) { puts("test"); } -GWION_IMPORT(typedef_test) { +GWION_IMPORT(fptr) { GWI_BB(gwi_fptr_ini(gwi, "void", "PtrType")) GWI_OB(gwi_fptr_end(gwi, 0)) diff --git a/tests/plug/fptr_tmpl.c b/tests/plug/fptr_tmpl.c index efdcfd31..d46872ad 100644 --- a/tests/plug/fptr_tmpl.c +++ b/tests/plug/fptr_tmpl.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(typedef_test) { +GWION_IMPORT(fptr_tmpl) { Type t_func_typedef; GWI_OB((t_func_typedef = gwi_mk_type(gwi, "FuncTypedef", SZ_INT, NULL))) GWI_BB(gwi_fptr_ini(gwi, "int", "test:[test]")) diff --git a/tests/plug/fptr_tmpl_fail.c b/tests/plug/fptr_tmpl_fail.c index 08483e40..cee2c9d9 100644 --- a/tests/plug/fptr_tmpl_fail.c +++ b/tests/plug/fptr_tmpl_fail.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(typedef_test) { +GWION_IMPORT(fptr_tmpl_fail) { GWI_BB(gwi_fptr_ini(gwi, "int~", "test:[A]")) GWI_OB(gwi_fptr_end(gwi, 0)) return GW_OK; diff --git a/tests/plug/func_fail.c b/tests/plug/func_fail.c index 9a53e094..6a9850ed 100644 --- a/tests/plug/func_fail.c +++ b/tests/plug/func_fail.c @@ -9,7 +9,7 @@ #include "import.h" #include "instr.h" -GWION_IMPORT(too_many_args) { +GWION_IMPORT(func_fail) { GWI_BB(gwi_func_ini(gwi, "int", "test")) GWI_BB(gwi_func_arg(gwi, "int", "i[][]")) GWI_BB(gwi_func_arg(gwi, "Int", "i")) diff --git a/tests/plug/func_fail2.c b/tests/plug/func_fail2.c index e7fd7222..72d631e9 100644 --- a/tests/plug/func_fail2.c +++ b/tests/plug/func_fail2.c @@ -9,7 +9,7 @@ #include "import.h" #include "instr.h" -GWION_IMPORT(too_many_args) { +GWION_IMPORT(func_fail2) { GWI_BB(gwi_func_ini(gwi, ":[int]Ptr", "test")) GWI_BB(gwi_func_arg(gwi, "int", "i[][]")) GWI_BB(gwi_func_arg(gwi, "int", "me")) diff --git a/tests/plug/func_fail3.c b/tests/plug/func_fail3.c index b2292dc1..6dbe5912 100644 --- a/tests/plug/func_fail3.c +++ b/tests/plug/func_fail3.c @@ -9,7 +9,7 @@ #include "import.h" #include "instr.h" -GWION_IMPORT(too_many_args) { +GWION_IMPORT(func_fail3) { GWI_BB(gwi_func_ini(gwi, "Ptr:[int]", "test:[A]")) GWI_BB(gwi_func_ini(gwi, "int", "test")) GWI_BB(gwi_func_arg(gwi, "int", "i[][]")) diff --git a/tests/plug/func_fail4.c b/tests/plug/func_fail4.c index fca1a108..33bd39b6 100644 --- a/tests/plug/func_fail4.c +++ b/tests/plug/func_fail4.c @@ -9,7 +9,7 @@ #include "import.h" #include "instr.h" -GWION_IMPORT(too_many_args) { +GWION_IMPORT(func_fail4) { GWI_BB(gwi_func_ini(gwi, "Ptr:[int]", "test:[A]")) GWI_BB(gwi_func_arg(gwi, "int", "i[][]")) GWI_BB(gwi_item_end(gwi, ae_flag_none, num, 0)) diff --git a/tests/plug/func_subscript_not_empty.c b/tests/plug/func_subscript_not_empty.c index 8e007f59..66b3f14f 100644 --- a/tests/plug/func_subscript_not_empty.c +++ b/tests/plug/func_subscript_not_empty.c @@ -9,7 +9,7 @@ #include "import.h" #include "instr.h" -GWION_IMPORT(too_many_args) { +GWION_IMPORT(func_subscript_not_empty) { GWI_BB(gwi_func_ini(gwi, "int[]", "test")) GWI_BB(gwi_func_end(gwi, (f_xfun)1, ae_flag_none)) return GW_OK; diff --git a/tests/plug/func_tmpl_fail.c b/tests/plug/func_tmpl_fail.c index 5b571765..1eef6c8a 100644 --- a/tests/plug/func_tmpl_fail.c +++ b/tests/plug/func_tmpl_fail.c @@ -11,7 +11,7 @@ static SFUN(func_tmpl_xfun) {} -GWION_IMPORT(func_tmpl) { +GWION_IMPORT(func_tmpl_fail) { GWI_BB(gwi_func_ini(gwi, "voit", "test:[A]")) GWI_BB(gwi_func_end(gwi, func_tmpl_xfun, ae_flag_none)) return GW_OK; diff --git a/tests/plug/func_too_many_arg.c b/tests/plug/func_too_many_arg.c index 88a735d6..80d30711 100644 --- a/tests/plug/func_too_many_arg.c +++ b/tests/plug/func_too_many_arg.c @@ -9,7 +9,7 @@ #include "import.h" #include "instr.h" -GWION_IMPORT(too_many_args) { +GWION_IMPORT(func_too_many_arg) { GWI_BB(gwi_func_ini(gwi, "int", "test")) GWI_BB(gwi_func_arg(gwi, "int", "i")) GWI_BB(gwi_func_arg(gwi, "int", "j")) diff --git a/tests/plug/global_func.c b/tests/plug/global_func.c index b9c69bbe..1494d3d3 100644 --- a/tests/plug/global_func.c +++ b/tests/plug/global_func.c @@ -14,7 +14,7 @@ SFUN(coverage_int) { *(m_int *)RETURN = *(m_int *)MEM(0); } -GWION_IMPORT(global_func_test) { +GWION_IMPORT(global_func) { GWI_BB(gwi_func_ini(gwi, "int", "test")) GWI_BB(gwi_func_arg(gwi, "int", "i")) GWI_BB(gwi_func_end(gwi, coverage_int, ae_flag_none)) diff --git a/tests/plug/global_var.c b/tests/plug/global_var.c index 44eeaf2d..fee9f063 100644 --- a/tests/plug/global_var.c +++ b/tests/plug/global_var.c @@ -9,7 +9,7 @@ #include "import.h" #include "gwi.h" -GWION_IMPORT(global_var_test) { +GWION_IMPORT(global_var) { const M_Object o = new_object(gwi->gwion->mp, gwi->gwion->type[et_string]); STRING(o) = s_name(insert_symbol(gwi->gwion->st, "test")); diff --git a/tests/plug/invalid_arg.c b/tests/plug/invalid_arg.c index 27cb25ad..4739c9d8 100644 --- a/tests/plug/invalid_arg.c +++ b/tests/plug/invalid_arg.c @@ -9,7 +9,7 @@ #include "import.h" static MFUN(test_mfun) {} -GWION_IMPORT(invalid_arg_test) { +GWION_IMPORT(invalid_arg) { GWI_OB(gwi_class_ini(gwi, "InvalidArg", NULL)) GWI_BB(gwi_func_ini(gwi, "int[]", "func")) GWI_BB(gwi_func_arg(gwi, ".int", "i")) diff --git a/tests/plug/invalid_array.c b/tests/plug/invalid_array.c index 339aae28..12d841b1 100644 --- a/tests/plug/invalid_array.c +++ b/tests/plug/invalid_array.c @@ -9,7 +9,7 @@ #include "import.h" static MFUN(test_mfun) {} -GWION_IMPORT(invalid_array_test) { +GWION_IMPORT(invalid_array) { GWI_OB(gwi_class_ini(gwi, "InvalidArray", NULL)) GWI_BB(gwi_func_ini(gwi, "int[]", "func")) GWI_BB(gwi_func_arg(gwi, "int[][]", "i")) diff --git a/tests/plug/invalid_func.c b/tests/plug/invalid_func.c index f30b7398..c2a6e89f 100644 --- a/tests/plug/invalid_func.c +++ b/tests/plug/invalid_func.c @@ -9,7 +9,7 @@ #include "import.h" static MFUN(test_mfun) {} -GWION_IMPORT(invalid_func_test) { +GWION_IMPORT(invalid_func) { GWI_OB(gwi_class_ini(gwi, "t_invalid_var_type", NULL)) GWI_BB(gwi_func_ini(gwi, ".int", "i")) GWI_BB(gwi_func_end(gwi, test_mfun, ae_flag_static)) diff --git a/tests/plug/invalid_names.c b/tests/plug/invalid_names.c index 1ace8d46..df7f9873 100644 --- a/tests/plug/invalid_names.c +++ b/tests/plug/invalid_names.c @@ -12,7 +12,7 @@ #include "ugen.h" #include "gwi.h" -GWION_IMPORT(trig) { +GWION_IMPORT(invalid_names) { DECL_OB(const Type, t0, = gwi_mk_type(gwi, "T~", SZ_INT, NULL)); gwi_add_type(gwi, t0); diff --git a/tests/plug/invalid_names0.c b/tests/plug/invalid_names0.c index bfa055fa..186e9c1e 100644 --- a/tests/plug/invalid_names0.c +++ b/tests/plug/invalid_names0.c @@ -12,7 +12,7 @@ #include "ugen.h" #include "gwi.h" -GWION_IMPORT(trig) { +GWION_IMPORT(invalid_names0) { DECL_OB(const Type, t0, = gwi_mk_type(gwi, "T~", SZ_INT, NULL)); gwi_add_type(gwi, t0); return GW_OK; diff --git a/tests/plug/invalid_names1.c b/tests/plug/invalid_names1.c index 5874a5d2..b8aa0850 100644 --- a/tests/plug/invalid_names1.c +++ b/tests/plug/invalid_names1.c @@ -12,7 +12,7 @@ #include "ugen.h" #include "gwi.h" -GWION_IMPORT(trig) { +GWION_IMPORT(invalid_names1) { DECL_OB(const Type, t0, = gwi_mk_type(gwi, "T,", SZ_INT, NULL)); gwi_add_type(gwi, t0); return GW_OK; diff --git a/tests/plug/invalid_names2.c b/tests/plug/invalid_names2.c index a7cd0f9c..f62630cb 100644 --- a/tests/plug/invalid_names2.c +++ b/tests/plug/invalid_names2.c @@ -12,7 +12,7 @@ #include "ugen.h" #include "gwi.h" -GWION_IMPORT(trig) { +GWION_IMPORT(invalid_names2) { DECL_OB(const Type, t0, = gwi_mk_type(gwi, "T", SZ_INT, NULL)); gwi_add_type(gwi, t0); return GW_OK; diff --git a/tests/plug/invalid_names3.c b/tests/plug/invalid_names3.c index 02db5306..8c125b07 100644 --- a/tests/plug/invalid_names3.c +++ b/tests/plug/invalid_names3.c @@ -12,7 +12,7 @@ #include "ugen.h" #include "gwi.h" -GWION_IMPORT(trig) { +GWION_IMPORT(invalid_names3) { DECL_OB(const Type, t0, = gwi_mk_type(gwi, "T:[a]", SZ_INT, NULL)); gwi_add_type(gwi, t0); return GW_OK; diff --git a/tests/plug/invalid_type1.c b/tests/plug/invalid_type1.c index 2656c619..b735d716 100644 --- a/tests/plug/invalid_type1.c +++ b/tests/plug/invalid_type1.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(invalid_type1_test) { +GWION_IMPORT(invalid_type1) { GWI_OB(gwi_class_ini(gwi, "invalid_var_type", NULL)) GWI_BB(gwi_item_ini(gwi, "i|nt", "test")) GWI_BB(gwi_item_end(gwi, 0, num, 0)) diff --git a/tests/plug/invalid_type2.c b/tests/plug/invalid_type2.c index 6b123756..78b624bb 100644 --- a/tests/plug/invalid_type2.c +++ b/tests/plug/invalid_type2.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(invalid_type2_test) { +GWION_IMPORT(invalid_type2) { GWI_OB(gwi_class_ini(gwi, "invalid_var_type", NULL)) GWI_BB(gwi_item_ini(gwi, ".int", "test")) GWI_BB(gwi_item_end(gwi, 0, num, 0)) diff --git a/tests/plug/invalid_type3.c b/tests/plug/invalid_type3.c index e33fa0fa..4c820386 100644 --- a/tests/plug/invalid_type3.c +++ b/tests/plug/invalid_type3.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(invalid_type3_test) { +GWION_IMPORT(invalid_type3) { GWI_OB(gwi_class_ini(gwi, "InvalidVarType", NULL)) GWI_BB(gwi_item_ini(gwi, ".int", "test")) GWI_BB(gwi_item_end(gwi, 0, num, 0)) diff --git a/tests/plug/mk_type_array.c b/tests/plug/mk_type_array.c index 2d9959d3..cd2dd528 100644 --- a/tests/plug/mk_type_array.c +++ b/tests/plug/mk_type_array.c @@ -10,7 +10,7 @@ #include "gwi.h" MFUN(test_mfun) {} -GWION_IMPORT(begin_class) { +GWION_IMPORT(mk_type_array) { Type t_invalid_var_name; GWI_OB((t_invalid_var_name = gwi_mk_type(gwi, "invalid_var_name", SZ_INT, "Object[]"))) diff --git a/tests/plug/not_importing.c b/tests/plug/not_importing.c index 3d7dbd3b..beb3cce5 100644 --- a/tests/plug/not_importing.c +++ b/tests/plug/not_importing.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(enum_test) { +GWION_IMPORT(not_importing) { GWI_BB(gwi_enum_add(gwi, "adc", 0)) return GW_OK; } diff --git a/tests/plug/pass.c b/tests/plug/pass.c index 5b64aea6..be0cfa80 100644 --- a/tests/plug/pass.c +++ b/tests/plug/pass.c @@ -11,7 +11,7 @@ ANN static m_bool pass(Env nv NUSED, Ast *ast NUSED) { return GW_OK; } -GWION_IMPORT(array_test) { +GWION_IMPORT(pass) { gwi_register_pass(gwi, "dummy", pass); return GW_OK; } diff --git a/tests/plug/specialid_emit.c b/tests/plug/specialid_emit.c index 4ed30430..aa8e7173 100644 --- a/tests/plug/specialid_emit.c +++ b/tests/plug/specialid_emit.c @@ -17,7 +17,7 @@ static ID_EMIT(spidem) { return GW_OK; } -GWION_IMPORT(spid_test) { +GWION_IMPORT(specialid_emit) { struct SpecialId_ spid = { .type = gwi->gwion->type[et_int], .em = spidem, .is_const = 1}; gwi_specialid(gwi, "testid", &spid); diff --git a/tests/plug/static_string.c b/tests/plug/static_string.c index 59b24170..c8b1d85f 100644 --- a/tests/plug/static_string.c +++ b/tests/plug/static_string.c @@ -10,7 +10,7 @@ #include "import.h" #include "gwi.h" -GWION_IMPORT(static_string_test) { +GWION_IMPORT(static_string) { const M_Object o = new_object(gwi->gwion->mp, gwi->gwion->type[et_string]); STRING(o) = s_name(insert_symbol(gwi->gwion->st, "test static string")); diff --git a/tests/plug/str2decl.c b/tests/plug/str2decl.c index acbffe27..68128f10 100644 --- a/tests/plug/str2decl.c +++ b/tests/plug/str2decl.c @@ -12,7 +12,7 @@ #include "ugen.h" #include "gwi.h" -GWION_IMPORT(str2td) { +GWION_IMPORT(str2decl) { GWI_OB(gwi_class_ini(gwi, "Test", NULL)) GWI_OB(gwi_class_ini(gwi, "Child", NULL)) GWI_BB(gwi_class_end(gwi)) diff --git a/tests/plug/str2list_fail.c b/tests/plug/str2list_fail.c index 77ae59dd..0d3ad08d 100644 --- a/tests/plug/str2list_fail.c +++ b/tests/plug/str2list_fail.c @@ -9,7 +9,7 @@ #include "import.h" #include "gwi.h" -GWION_IMPORT(global_var_test) { +GWION_IMPORT(str2list_fail) { GWI_BB(gwi_item_ini(gwi, "SoemClass.child", "i")) GWI_BB(gwi_item_end(gwi, ae_flag_none, num, 0)) return GW_OK; diff --git a/tests/plug/struct.c b/tests/plug/struct.c index 64115913..6f767ae4 100644 --- a/tests/plug/struct.c +++ b/tests/plug/struct.c @@ -12,7 +12,7 @@ SFUN(coverage_int) { *(m_uint *)RETURN = 0; } SFUN(coverage_float) { *(m_float *)RETURN = 0; } -GWION_IMPORT(coverage) { +GWION_IMPORT(struct) { GWI_OB(gwi_struct_ini(gwi, "Struct")) GWI_BB(gwi_func_ini(gwi, "int", "i")) GWI_BB(gwi_func_end(gwi, coverage_int, ae_flag_static)) diff --git a/tests/plug/template_arg.c b/tests/plug/template_arg.c index 75c33ad1..ab585e6b 100644 --- a/tests/plug/template_arg.c +++ b/tests/plug/template_arg.c @@ -9,7 +9,7 @@ #include "import.h" static MFUN(template_arg_fun) {} -GWION_IMPORT(template_arg_test) { +GWION_IMPORT(template_arg) { GWI_OB(gwi_class_ini(gwi, "TemplateArg", NULL)) GWI_BB(gwi_func_ini(gwi, "int", "set")) GWI_BB(gwi_func_arg(gwi, "Pair,float>", "test")) diff --git a/tests/plug/typedef.c b/tests/plug/typedef.c index 634859eb..1f5257c8 100644 --- a/tests/plug/typedef.c +++ b/tests/plug/typedef.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(typedef_test) { +GWION_IMPORT(typedef) { GWI_OB(gwi_typedef_ini(gwi, "int", "Typedef")) GWI_OB(gwi_typedef_end(gwi, ae_flag_none)) return GW_OK; diff --git a/tests/plug/typedef_fail.c b/tests/plug/typedef_fail.c index 714e63bd..08aed56e 100644 --- a/tests/plug/typedef_fail.c +++ b/tests/plug/typedef_fail.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(typedef_test) { +GWION_IMPORT(typedef_fail) { GWI_BB(gwi_typedef_ini(gwi, "int", "Typedef:[A]")) GWI_BB(gwi_typedef_ini(gwi, "int", "Typedef:[A]")) return GW_OK; diff --git a/tests/plug/typedef_tmpl.c b/tests/plug/typedef_tmpl.c index a82a5988..26818f1d 100644 --- a/tests/plug/typedef_tmpl.c +++ b/tests/plug/typedef_tmpl.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(typedef_test) { +GWION_IMPORT(typedef_tmpl) { GWI_BB(gwi_typedef_ini(gwi, "Ptr:[A]", "Typedef:[A]")) GWI_OB(gwi_typedef_end(gwi, ae_flag_none)) return GW_OK; diff --git a/tests/plug/union.c b/tests/plug/union.c index 31c44a44..951ee971 100644 --- a/tests/plug/union.c +++ b/tests/plug/union.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(union_test) { +GWION_IMPORT(union) { GWI_BB(gwi_union_ini(gwi, "U")) GWI_BB(gwi_union_add(gwi, "float", "f")) GWI_BB(gwi_union_add(gwi, "int", "i")) diff --git a/tests/plug/union_fail_exp.c b/tests/plug/union_fail_exp.c index 69267987..7ec37364 100644 --- a/tests/plug/union_fail_exp.c +++ b/tests/plug/union_fail_exp.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(union_test) { +GWION_IMPORT(union_fail_exp) { GWI_BB(gwi_union_ini(gwi, "U")) GWI_BB(gwi_union_add(gwi, "Float", "f")) GWI_BB(gwi_union_add(gwi, "int", "i")) diff --git a/tests/plug/union_name.c b/tests/plug/union_name.c index 81d804fd..bf752294 100644 --- a/tests/plug/union_name.c +++ b/tests/plug/union_name.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(union_test) { +GWION_IMPORT(union_name) { GWI_BB(gwi_union_ini(gwi, "my_union")) GWI_BB(gwi_union_add(gwi, "float", "f")) GWI_BB(gwi_union_add(gwi, "int", "i")) diff --git a/tests/plug/union_tmpl.c b/tests/plug/union_tmpl.c index 77124075..9e4ced33 100644 --- a/tests/plug/union_tmpl.c +++ b/tests/plug/union_tmpl.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(union_test) { +GWION_IMPORT(union_tmpl) { GWI_BB(gwi_union_ini(gwi, "U:[A]")) GWI_BB(gwi_union_add(gwi, "float", "f")) GWI_BB(gwi_union_add(gwi, "int", "i")) diff --git a/tests/plug/union_tmpl_fail.c b/tests/plug/union_tmpl_fail.c index 77124075..25662a6c 100644 --- a/tests/plug/union_tmpl_fail.c +++ b/tests/plug/union_tmpl_fail.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(union_test) { +GWION_IMPORT(union_tmpl_fail) { GWI_BB(gwi_union_ini(gwi, "U:[A]")) GWI_BB(gwi_union_add(gwi, "float", "f")) GWI_BB(gwi_union_add(gwi, "int", "i")) diff --git a/tests/plug/union_tmpl_fail2.c b/tests/plug/union_tmpl_fail2.c index f0e48a37..75c80e92 100644 --- a/tests/plug/union_tmpl_fail2.c +++ b/tests/plug/union_tmpl_fail2.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(union_test) { +GWION_IMPORT(union_tmpl_fail2) { GWI_BB(gwi_union_ini(gwi, "U:[A]")) GWI_BB(gwi_union_add(gwi, "float", "f")) GWI_BB(gwi_union_add(gwi, "int", "i")) diff --git a/tests/plug/union_tmpl_fail3.c b/tests/plug/union_tmpl_fail3.c index 77124075..94e5a1a4 100644 --- a/tests/plug/union_tmpl_fail3.c +++ b/tests/plug/union_tmpl_fail3.c @@ -8,7 +8,7 @@ #include "operator.h" #include "import.h" -GWION_IMPORT(union_test) { +GWION_IMPORT(union_tmpl_fail3) { GWI_BB(gwi_union_ini(gwi, "U:[A]")) GWI_BB(gwi_union_add(gwi, "float", "f")) GWI_BB(gwi_union_add(gwi, "int", "i")) diff --git a/tests/plug/vm_remove.c b/tests/plug/vm_remove.c index 119a6ffb..e4fe8694 100644 --- a/tests/plug/vm_remove.c +++ b/tests/plug/vm_remove.c @@ -11,7 +11,7 @@ SFUN(coverage_int) { vm_remove(shred->info->vm, *(m_int *)MEM(0)); } -GWION_IMPORT(gwion_remove_test) { +GWION_IMPORT(vm_remove) { GWI_BB(gwi_func_ini(gwi, "int", "test")) GWI_BB(gwi_func_arg(gwi, "int", "i")) GWI_BB(gwi_func_end(gwi, coverage_int, ae_flag_none)) diff --git a/tests/sh/opt.sh b/tests/sh/opt.sh index 1c86d66a..19d68b19 100644 --- a/tests/sh/opt.sh +++ b/tests/sh/opt.sh @@ -1,15 +1,14 @@ #!/bin/bash -# [test] #24 +# [test] #23 n=0 [ "$1" ] && n="$1" [ "$n" -eq 0 ] && n=1 source tests/sh/common.sh -run "$n" "test arguments" "examples/shred.gw:12" "file" +run "$n" "test arguments" "examples/array_lit:12" "file" n=$((n+1)) -N=$(printf "% 4i" "$n") run "$n" "simple run" "" "file" # help @@ -78,10 +77,6 @@ run "$n" "no pass" "-g nopass" "file" n=$((n+1)) run "$n" "option needs argument" "-p" "file" -# option needs argument -n=$((n+1)) -echo "<<< __file__ >>>;" | run "$n" "stdin" "-" "file" - # invalid global type n=$((n+1)) run "$n" "invalid global type" "examples/complex/invalid_type0.gw examples/complex/invalid_type1.gw" "file" diff --git a/util b/util index 3779cb72..d1244811 160000 --- a/util +++ b/util @@ -1 +1 @@ -Subproject commit 3779cb727cf3bf1dd379702b7f3665a1432041a2 +Subproject commit d12448118cc4366fb8871f1f149626969fad775a -- 2.43.0