summaryrefslogtreecommitdiff
path: root/tests/offsets
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2019-01-07 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2019-01-07 11:19:30 +0100
commitd020c524bad9a9e26b124b85a356d3858b03cab7 (patch)
treeedede2442f1152cf6825c0093d07cc72284fa072 /tests/offsets
parent58e97dc13e33fc4fdfe83090fbde8ecc40662386 (diff)
downloadgobject-introspection-d020c524bad9a9e26b124b85a356d3858b03cab7.tar.gz
scanner: Flatten multi-dimensional arrays fields
Provide partial support for multi-dimensional arrays by representing them as flattened one dimensional array with size that is equal to product of sizes in each dimension. Previously only the first dimension would be actually used. This should be sufficient to ensure that those fields have layout compatible with C, without using nested array types that are currently unsupported by vapigen Issue #255.
Diffstat (limited to 'tests/offsets')
-rw-r--r--tests/offsets/gitestoffsets.c11
-rw-r--r--tests/offsets/offsets.h15
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/offsets/gitestoffsets.c b/tests/offsets/gitestoffsets.c
index 9ce673e9..a84e8e8a 100644
--- a/tests/offsets/gitestoffsets.c
+++ b/tests/offsets/gitestoffsets.c
@@ -92,6 +92,16 @@ compiled (FILE *outfile)
PRINT_MEMBER (OffsetsArray, some_ptrs);
g_fprintf (outfile, "\n");
+ PRINT_TYPE (OffsetsMultiDimArray);
+ PRINT_MEMBER (OffsetsMultiDimArray, ints);
+ PRINT_MEMBER (OffsetsMultiDimArray, chars);
+ PRINT_MEMBER (OffsetsMultiDimArray, floats);
+ PRINT_MEMBER (OffsetsMultiDimArray, pointers1);
+ PRINT_MEMBER (OffsetsMultiDimArray, pointers2);
+ PRINT_MEMBER (OffsetsMultiDimArray, pointers3);
+ PRINT_MEMBER (OffsetsMultiDimArray, dummy);
+ fprintf (outfile, "\n");
+
PRINT_TYPE (OffsetsBasic);
PRINT_MEMBER (OffsetsBasic, dummy1);
PRINT_MEMBER (OffsetsBasic, field_int8);
@@ -183,6 +193,7 @@ int main(int argc, char **argv)
g_error ("Cannot open '%s': %s'", argv[1], g_strerror(errno));
introspected_struct (outfile, "Array");
+ introspected_struct (outfile, "MultiDimArray");
introspected_struct (outfile, "Basic");
introspected_struct (outfile, "Enum");
introspected_struct (outfile, "Nested");
diff --git a/tests/offsets/offsets.h b/tests/offsets/offsets.h
index 658601f5..7d89fe8d 100644
--- a/tests/offsets/offsets.h
+++ b/tests/offsets/offsets.h
@@ -124,6 +124,21 @@ struct _OffsetsArray
gpointer some_ptrs[5];
};
+/* Test multi-dimensional arrays */
+
+typedef struct _OffsetsMultiDimArray OffsetsMultiDimArray;
+
+struct _OffsetsMultiDimArray
+{
+ gint ints[10][2];
+ gchar chars[255][10];
+ float floats[11][13][17];
+ gchar* pointers1[3][5];
+ gpointer pointers2[7][9];
+ double** pointers3[2][3][4];
+ gchar dummy;
+};
+
/* Test object offsets */
typedef struct _OffsetsObj OffsetsObj;