diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2013-06-20 17:49:04 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-06-21 18:25:48 +0200 |
commit | 7eafd632376d6f4f428046553f8ccef71ffd40e4 (patch) | |
tree | e9bb8070f94fbf49e8e8ecc04a37954bdd166e18 /build-aux | |
parent | 9f9d5dc4f6b6b10a5f5f7ebf30c36bec407ef064 (diff) | |
download | libmbim-7eafd632376d6f4f428046553f8ccef71ffd40e4.tar.gz |
mbim-codegen: support setting arrays of struct references
Diffstat (limited to 'build-aux')
-rw-r--r-- | build-aux/mbim-codegen/Struct.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/build-aux/mbim-codegen/Struct.py b/build-aux/mbim-codegen/Struct.py index e54b2a2..f7a57d2 100644 --- a/build-aux/mbim-codegen/Struct.py +++ b/build-aux/mbim-codegen/Struct.py @@ -568,8 +568,32 @@ class Struct: ' g_byte_array_unref (raw_all);\n' ' }\n' ' } else {\n' - ' /* TODO */\n' - ' g_assert_not_reached ();\n' + ' for (i = 0; i < n_values; i++) {\n' + ' guint32 length;\n' + ' guint32 offset_offset;\n' + ' GByteArray *raw;\n' + '\n' + ' raw = _${name_underscore}_struct_new (values[i]);\n' + ' g_assert (raw->len > 0);\n' + '\n' + ' /* Offset of the offset */\n' + ' offset_offset = builder->fixed_buffer->len;\n' + '\n' + ' /* Length *not* in LE yet */\n' + ' offset = builder->variable_buffer->len;\n' + ' /* Add the offset value */\n' + ' g_byte_array_append (builder->fixed_buffer, (guint8 *)&offset, sizeof (offset));\n' + ' /* Configure the value to get updated */\n' + ' g_array_append_val (builder->offsets, offset_offset);\n' + '\n' + ' /* Add the length value */\n' + ' length = GUINT32_TO_LE (raw->len);\n' + ' g_byte_array_append (builder->fixed_buffer, (guint8 *)&length, sizeof (length));\n' + '\n' + ' /* And finally, the bytearray itself to the variable buffer */\n' + ' g_byte_array_append (builder->variable_buffer, (const guint8 *)raw->data, (guint)raw->len);\n' + ' g_byte_array_unref (raw);\n' + ' }\n' ' }\n' '}\n') cfile.write(string.Template(template).substitute(translations)) |