path: root/src/tests/eolian/data
diff options
authorDaniel Kolesa <>2016-06-30 14:04:03 +0100
committerDaniel Kolesa <>2016-06-30 16:59:21 +0100
commitab2e608239d0518241454bd7cb6abe3f680764c1 (patch)
tree950be0f34dffe5e3962c6f850e54bd770459fd21 /src/tests/eolian/data
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/data')
2 files changed, 4 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