[Spice-devel] [PATCH v2 43/43] Add some format checks with arrays

Frediano Ziglio fziglio at redhat.com
Wed Jul 8 06:54:16 PDT 2015


Check different format or small arrays formatting.
Is possible to omit to have a tree and dump just the elements.
This is useful for small arrays or if is possible to format all
the item (for instance having a small structure) in a single line.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 codegen/check_dissector |  2 ++
 codegen/out_array2.txt  | 28 ++++++++++++++++++++++++++++
 codegen/test.proto      |  8 ++++++++
 3 files changed, 38 insertions(+)
 create mode 100644 codegen/out_array2.txt

diff --git a/codegen/check_dissector b/codegen/check_dissector
index e2d06b5..7493d20 100755
--- a/codegen/check_dissector
+++ b/codegen/check_dissector
@@ -62,4 +62,6 @@ check data_u16s 1 102 out_array_struct.txt --client
 
 check data_base1 1 2 out_channel.txt
 
+check data_u16s 1 103 out_array2.txt --client
+
 exit 0
diff --git a/codegen/out_array2.txt b/codegen/out_array2.txt
new file mode 100644
index 0000000..f695ca1
--- /dev/null
+++ b/codegen/out_array2.txt
@@ -0,0 +1,28 @@
+--- tree
+    --- item
+    Text: small[0]: 0
+    Name: small
+    Abbrev: spice2.auto.Array2_array_small
+    Type: FT_UINT16
+    Base: BASE_DEC
+    --- item
+    Text: small[1]: 1
+    Name: small
+    Abbrev: spice2.auto.Array2_array_small
+    Type: FT_UINT16
+    Base: BASE_DEC
+    --- item
+    Text: Small array
+        --- tree
+            --- item
+            Text: small_named[0]: 2
+            Name: small_named
+            Abbrev: spice2.auto.Array2_array_small_named
+            Type: FT_UINT16
+            Base: BASE_DEC
+            --- item
+            Text: small_named[1]: 3
+            Name: small_named
+            Abbrev: spice2.auto.Array2_array_small_named
+            Type: FT_UINT16
+            Base: BASE_DEC
diff --git a/codegen/test.proto b/codegen/test.proto
index c58ef7d..0c2915b 100644
--- a/codegen/test.proto
+++ b/codegen/test.proto
@@ -55,6 +55,13 @@ message ArrayStruct {
     Dummy array4[4];
 };
 
+message Array2 {
+    /* small arrays, format with text and numbers, no tree generated */
+    uint16 @ws_txt("small[%u]: %u", INDEX, small) small[2];
+    /* small arrays, format with text and numbers, tree generated due to description */
+    uint16 @ws_txt("small_named[%u]: %u", INDEX, small_named) small_named[2] @ws_desc("Small array");
+};
+
 channel BaseChannel {
   server:
     message {
@@ -86,6 +93,7 @@ channel BaseChannel {
     ArrayPrimitive array_primitive = 100;
     ArrayRaw array_raw;
     ArrayStruct array_struct;
+    Array2 array2;
 };
 
 channel Test1Channel: BaseChannel {
-- 
2.1.0



More information about the Spice-devel mailing list