From ca1fc2ae9b98629092c3d637f2b4ddd7a35c818b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Fri, 30 Jul 2021 10:09:51 +0200 Subject: [PATCH] :art: Few fixes --- src/import/import_cdef.c | 2 ++ tests/plug/coverage.c | 2 +- tests/plug/coverage.gw | 3 ++- tests/plug/enum.c | 27 +-------------------------- tests/plug/enum.gw | 23 ----------------------- tests/plug/enum_fail2.c | 2 +- 6 files changed, 7 insertions(+), 52 deletions(-) diff --git a/src/import/import_cdef.c b/src/import/import_cdef.c index 8a0058a1..d57b8a27 100644 --- a/src/import/import_cdef.c +++ b/src/import/import_cdef.c @@ -130,6 +130,8 @@ ANN m_int gwi_class_end(const Gwi gwi) { if (!gwi->gwion->env->class_def) GWI_ERR_B(_("import: too many class_end called.")) const Type t = gwi->gwion->env->class_def; + if (t->nspc->info->class_data_size && !t->nspc->info->class_data) + nspc_allocdata(gwi->gwion->mp, t->nspc); if (tflag(t, tflag_tmpl)) { --gwi->tmpls; nspc_pop_type(gwi->gwion->mp, gwi->gwion->env->curr); diff --git a/tests/plug/coverage.c b/tests/plug/coverage.c index 4737dfd9..2340da09 100644 --- a/tests/plug/coverage.c +++ b/tests/plug/coverage.c @@ -22,7 +22,7 @@ GWION_IMPORT(coverage) { GWI_BB(gwi_item_ini(gwi, "int", "s_i")) GWI_BB(gwi_item_end(gwi, ae_flag_static, num, 5)) - GWI_BB(gwi_item_ini(gwi, "int", "s_f")) + GWI_BB(gwi_item_ini(gwi, "float", "s_f")) GWI_BB(gwi_item_end(gwi, ae_flag_static, fnum, 2.1)) GWI_BB(gwi_item_ini(gwi, "int", "sc_i")) diff --git a/tests/plug/coverage.gw b/tests/plug/coverage.gw index f4f75d0e..b3430608 100644 --- a/tests/plug/coverage.gw +++ b/tests/plug/coverage.gw @@ -3,12 +3,13 @@ <<< var float f >>>; var Coverage c; +<<< c >>>; c.s_i; <<< Coverage.i() >>>; <<< Coverage.f() >>>; <<< Coverage.s_i >>>; -<<< Coverage.s_f >>>; +<<< "s_f ", Coverage.s_f >>>; <<< Coverage.sc_i >>>; <<< Coverage.sc_f >>>; diff --git a/tests/plug/enum.c b/tests/plug/enum.c index 749cb51d..898eec8a 100644 --- a/tests/plug/enum.c +++ b/tests/plug/enum.c @@ -9,19 +9,6 @@ #include "import.h" GWION_IMPORT(enum_test) { - GWI_BB(gwi_enum_ini(gwi, NULL)) - GWI_BB(gwi_enum_add(gwi, "ENUM0", 0)) - GWI_BB(gwi_enum_add(gwi, "ENUM1", 1)) - GWI_BB(gwi_enum_add(gwi, "ENUM2", 2)) - GWI_BB(gwi_enum_add(gwi, "ENUM3", 3)) - GWI_BB(gwi_enum_add(gwi, "ENUM4", 4)) - GWI_BB(gwi_enum_add(gwi, "ENUM5", 5)) - GWI_BB(gwi_enum_add(gwi, "ENUM6", 6)) - GWI_BB(gwi_enum_add(gwi, "ENUM7", 7)) - GWI_BB(gwi_enum_add(gwi, "ENUM8", 8)) - GWI_BB(gwi_enum_add(gwi, "ENUM9", 9)) - GWI_OB(gwi_enum_end(gwi)) - 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)) @@ -36,7 +23,7 @@ GWION_IMPORT(enum_test) { GWI_OB(gwi_enum_end(gwi)) GWI_OB(gwi_class_ini(gwi, "Enum", NULL)) - GWI_BB(gwi_enum_ini(gwi, 0)) + GWI_BB(gwi_enum_ini(gwi, "MyTest")) GWI_BB(gwi_enum_add(gwi, "ENUM0", 0)) GWI_BB(gwi_enum_add(gwi, "ENUM1", 1)) GWI_BB(gwi_enum_add(gwi, "ENUM2", 2)) @@ -49,18 +36,6 @@ GWION_IMPORT(enum_test) { GWI_BB(gwi_enum_add(gwi, "ENUM9", 9)) GWI_OB(gwi_enum_end(gwi)) - GWI_BB(gwi_enum_ini(gwi, "Enumtest")) - GWI_BB(gwi_enum_add(gwi, "TYPED_ENUM0", 0)) - GWI_BB(gwi_enum_add(gwi, "TYPED_ENUM1", 1)) - GWI_BB(gwi_enum_add(gwi, "TYPED_ENUM2", 2)) - GWI_BB(gwi_enum_add(gwi, "TYPED_ENUM3", 3)) - GWI_BB(gwi_enum_add(gwi, "TYPED_ENUM4", 4)) - GWI_BB(gwi_enum_add(gwi, "TYPED_ENUM5", 5)) - GWI_BB(gwi_enum_add(gwi, "TYPED_ENUM6", 6)) - GWI_BB(gwi_enum_add(gwi, "TYPED_ENUM7", 7)) - GWI_BB(gwi_enum_add(gwi, "TYPED_ENUM8", 8)) - GWI_BB(gwi_enum_add(gwi, "TYPED_ENUM9", 9)) - GWI_OB(gwi_enum_end(gwi)) GWI_OB(gwi_class_end(gwi)) return GW_OK; diff --git a/tests/plug/enum.gw b/tests/plug/enum.gw index b1801d0f..2321b08f 100644 --- a/tests/plug/enum.gw +++ b/tests/plug/enum.gw @@ -1,15 +1,4 @@ #import enum -#! untyped global enum -<<< ENUM0 >>>; -<<< ENUM1 >>>; -<<< ENUM2 >>>; -<<< ENUM3 >>>; -<<< ENUM4 >>>; -<<< ENUM5 >>>; -<<< ENUM6 >>>; -<<< ENUM7 >>>; -<<< ENUM8 >>>; -<<< ENUM9 >>>; #! typed global enum <<< TYPED_ENUM0 >>>; @@ -35,15 +24,3 @@ <<< Enum.ENUM7 >>>; <<< Enum.ENUM8 >>>; <<< Enum.ENUM9 >>>; - -#! Enum.typed global enum -<<< Enum.TYPED_ENUM0 >>>; -<<< Enum.TYPED_ENUM1 >>>; -<<< Enum.TYPED_ENUM2 >>>; -<<< Enum.TYPED_ENUM3 >>>; -<<< Enum.TYPED_ENUM4 >>>; -<<< Enum.TYPED_ENUM5 >>>; -<<< Enum.TYPED_ENUM6 >>>; -<<< Enum.TYPED_ENUM7 >>>; -<<< Enum.TYPED_ENUM8 >>>; -<<< Enum.TYPED_ENUM9 >>>; diff --git a/tests/plug/enum_fail2.c b/tests/plug/enum_fail2.c index b1026e26..4ec536f1 100644 --- a/tests/plug/enum_fail2.c +++ b/tests/plug/enum_fail2.c @@ -9,7 +9,7 @@ #include "import.h" GWION_IMPORT(enum_test) { - GWI_BB(gwi_enum_ini(gwi, NULL)) + GWI_BB(gwi_enum_ini(gwi, "tmp")) GWI_BB(gwi_enum_add(gwi, "adc", 0)) GWI_OB(gwi_enum_end(gwi)) return GW_OK; -- 2.43.0