summaryrefslogtreecommitdiff
path: root/src/tests/eolian
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-06-30 14:04:03 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-06-30 16:59:21 +0100
commitab2e608239d0518241454bd7cb6abe3f680764c1 (patch)
tree950be0f34dffe5e3962c6f850e54bd770459fd21 /src/tests/eolian
parentff7a5e4f1b1286b1226fb0a9a1729759d1f72e18 (diff)
eolian: add support for static and terminated arrays
Adds two new type types, STATIC_ARRAY and TERMINATED_ARRAY. Static arrays are only allowed as struct members right now - they translate to regular C static arrays (allowing them elsewhere wouldn't be good, as C isn't very good at working with the size information). Terminated arrays are basically sequences of data terminated at the end. The base type of static arrays can be any type that is not marked ref (explicit ref may get allowed later). The base type of terminated arrays has the same restriction plus that it has to be either implicitly reference type (i.e. translating to pointer in C), integer type or a character. In case of ref types, the terminator is NULL. In case of integer types, the terminator is a zero. In case of character types, the terminator is also a zero (null terminator like C strings). @feature
Diffstat (limited to 'src/tests/eolian')
-rw-r--r--src/tests/eolian/data/struct.eo2
-rw-r--r--src/tests/eolian/data/struct_ref.c2
-rw-r--r--src/tests/eolian/eolian_parsing.c15
3 files changed, 19 insertions, 0 deletions
diff --git a/src/tests/eolian/data/struct.eo b/src/tests/eolian/data/struct.eo
index 077e499..81429b9 100644
--- a/src/tests/eolian/data/struct.eo
+++ b/src/tests/eolian/data/struct.eo
@@ -1,6 +1,8 @@
1struct Named { 1struct Named {
2 field: ref(int); 2 field: ref(int);
3 something: string; 3 something: string;
4 arr: static_array<int, 16>;
5 tarr: terminated_array<string>;
4} 6}
5 7
6struct Another { 8struct Another {
diff --git a/src/tests/eolian/data/struct_ref.c b/src/tests/eolian/data/struct_ref.c
index 1fbec77..dd9c64e 100644
--- a/src/tests/eolian/data/struct_ref.c
+++ b/src/tests/eolian/data/struct_ref.c
@@ -15,6 +15,8 @@ typedef struct _Named
15{ 15{
16 int *field; 16 int *field;
17 const char *something; 17 const char *something;
18 int arr[16];
19 const char **tarr;
18} Named; 20} Named;
19 21
20typedef struct _Another 22typedef struct _Another
diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c
index 6078493..2a880da 100644
--- a/src/tests/eolian/eolian_parsing.c
+++ b/src/tests/eolian/eolian_parsing.c
@@ -692,6 +692,21 @@ START_TEST(eolian_struct)
692 fail_if(!(type_name = eolian_type_c_type_get(ftype))); 692 fail_if(!(type_name = eolian_type_c_type_get(ftype)));
693 fail_if(strcmp(type_name, "const char *")); 693 fail_if(strcmp(type_name, "const char *"));
694 eina_stringshare_del(type_name); 694 eina_stringshare_del(type_name);
695 fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "arr")));
696 fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
697 fail_if(eolian_type_is_ref(ftype));
698 fail_if(eolian_type_array_size_get(ftype) != 16);
699 fail_if(eolian_type_type_get(ftype) != EOLIAN_TYPE_STATIC_ARRAY);
700 fail_if(!(type_name = eolian_type_c_type_get(ftype)));
701 fail_if(strcmp(type_name, "int *"));
702 eina_stringshare_del(type_name);
703 fail_if(!(field = eolian_typedecl_struct_field_get(tdl, "tarr")));
704 fail_if(!(ftype = eolian_typedecl_struct_field_type_get(field)));
705 fail_if(eolian_type_is_ref(ftype));
706 fail_if(!(type_name = eolian_type_c_type_get(ftype)));
707 fail_if(eolian_type_type_get(ftype) != EOLIAN_TYPE_TERMINATED_ARRAY);
708 fail_if(strcmp(type_name, "const char **"));
709 eina_stringshare_del(type_name);
695 710
696 /* referencing */ 711 /* referencing */
697 fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Another"))); 712 fail_if(!(tdl = eolian_typedecl_struct_get_by_name("Another")));