From: fennecdjay Date: Tue, 15 Oct 2019 16:55:47 +0000 (+0200) Subject: :art: Add char type X-Git-Tag: nightly~2132 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=8ecefe43001a438c7a9c30a564212a8df6b7e058;p=gwion.git :art: Add char type --- diff --git a/include/type.h b/include/type.h index 7b80a27a..12bc9b64 100644 --- a/include/type.h +++ b/include/type.h @@ -49,7 +49,7 @@ ANN m_bool is_class(const struct Gwion_*, const Type t); ANN m_uint get_depth(const Type type); typedef enum { - et_void, et_int, et_bool, et_float, et_complex, et_polar, et_vec3, et_vec4, + et_void, et_int, et_bool, et_char, et_float, et_complex, et_polar, et_vec3, et_vec4, et_null, et_object, et_shred, et_fork, et_event, et_ugen, et_string, et_ptr, et_array, et_gack, et_function, et_fptr, et_varloop, et_vararg, et_lambda, et_class, et_union, et_undefined, et_auto, et_tuple, MAX_TYPE diff --git a/src/lib/engine.c b/src/lib/engine.c index 81eec0ae..2a8b396f 100644 --- a/src/lib/engine.c +++ b/src/lib/engine.c @@ -45,6 +45,10 @@ static GACK(gack_int) { printf("%li", *(m_uint*)VALUE); } +static GACK(gack_char) { + printf("%c", *(char*)VALUE); +} + static GACK(gack_float) { printf("%.4f", *(m_float*)VALUE); } @@ -104,6 +108,9 @@ ANN static m_bool import_core_libs(const Gwi gwi) { const Type t_int = gwi_mk_type(gwi, "int", SZ_INT, NULL); GWI_BB(gwi_gack(gwi, t_int, gack_int)) GWI_BB(gwi_set_global_type(gwi, t_int, et_int)) + const Type t_char = gwi_mk_type(gwi, "char", SZ_INT, "int"); + GWI_BB(gwi_gack(gwi, t_char, gack_char)) + GWI_BB(gwi_set_global_type(gwi, t_char, et_char)) const Type t_float = gwi_mk_type(gwi, "float", SZ_FLOAT, NULL); GWI_BB(gwi_gack(gwi, t_float, gack_float)) GWI_BB(gwi_set_global_type(gwi, t_float, et_float)) diff --git a/tests/tree/char.gw b/tests/tree/char.gw new file mode 100644 index 00000000..f3b14990 --- /dev/null +++ b/tests/tree/char.gw @@ -0,0 +1,3 @@ +#! [contains] a +'a' => char c; +<<< c >>>;