From 7345ca6aaf57c39eda83650e5d7f87e2d66f5be3 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 19 Sep 2012 11:52:35 +0200 Subject: [PATCH] qmi-codegen: for arrays, use a new 'size-prefix-format' instead of 'array-size' The 'array-size' property was used to define an implicit variable to be found at the beginning of every array. This property expected a dictionary with one single 'format' key. Instead of this setup, create a new 'size-prefix-format' property which directly expects the format string of the variable to be used as array-length indicator. So, instead of: "array-size" : { "format" : "guint16" } We can now just use: "size-prefix-format" : "guint16" Also, remove the explicit size definitions when the format is "guint8", as that is the default already when none specified and the array is not of fixed size. --- build-aux/qmi-codegen/VariableArray.py | 11 +- data/qmi-service-dms.json | 48 +++--- data/qmi-service-nas.json | 230 ++++++++++++------------- data/qmi-service-wds.json | 3 - data/qmi-service-wms.json | 150 ++++++++-------- 5 files changed, 219 insertions(+), 223 deletions(-) diff --git a/build-aux/qmi-codegen/VariableArray.py b/build-aux/qmi-codegen/VariableArray.py index cd102a5..9a647bf 100644 --- a/build-aux/qmi-codegen/VariableArray.py +++ b/build-aux/qmi-codegen/VariableArray.py @@ -51,11 +51,12 @@ class VariableArray(Variable): self.array_element = VariableFactory.create_variable(dictionary['array-element'], '') # Load variable type for the array size prefix - if 'array-size' in dictionary: - # We do NOT allow 64-bit types as array sizes - if dictionary['array-size'] == 'guint64' or dictionary['array-size'] == 'gint64': - raise RuntimeError('Array size should not be given with a 64-bit value (unsupported)') - self.array_size_element = VariableFactory.create_variable(dictionary['array-size'], '') + if 'size-prefix-format' in dictionary: + # We do NOT allow 64-bit types as array sizes (GArray won't support them) + if dictionary['size-prefix-format'] not in [ 'guint8', 'guint16', 'guint32' ]: + raise ValueError('Invalid size prefix format (%s): not guint8 or guint16 or guint32' % dictionary['size-prefix-format']) + default_array_size = { 'format' : dictionary['size-prefix-format'] } + self.array_size_element = VariableFactory.create_variable(default_array_size, '') elif 'fixed-size' in dictionary: # fixed-size arrays have no size element, obviously self.fixed_size = dictionary['fixed-size'] diff --git a/data/qmi-service-dms.json b/data/qmi-service-dms.json index 9b407d2..f14685a 100644 --- a/data/qmi-service-dms.json +++ b/data/qmi-service-dms.json @@ -668,14 +668,14 @@ "id" : "0x0037", "version" : "1.6", "output" : [ { "common-ref" : "Operation Result" }, - { "name" : "User Data", - "id" : "0x01", - "mandatory" : "yes", - "type" : "TLV", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "format" : "guint8" }, - "prerequisites": [ { "common-ref" : "Success" } ] } ] }, + { "name" : "User Data", + "id" : "0x01", + "mandatory" : "yes", + "type" : "TLV", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "format" : "guint8" }, + "prerequisites" : [ { "common-ref" : "Success" } ] } ] }, // ********************************************************************************* { "name" : "Write User Data", @@ -683,14 +683,14 @@ "service" : "DMS", "id" : "0x0038", "version" : "1.6", - "input" : [ { "name" : "User Data", - "id" : "0x01", - "mandatory" : "yes", - "type" : "TLV", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "format" : "guint8" }, - "prerequisites": [ { "common-ref" : "Success" } ] } ], + "input" : [ { "name" : "User Data", + "id" : "0x01", + "mandatory" : "yes", + "type" : "TLV", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "format" : "guint8" }, + "prerequisites" : [ { "common-ref" : "Success" } ] } ], "output" : [ { "common-ref" : "Operation Result" } ] }, // ********************************************************************************* @@ -700,14 +700,14 @@ "id" : "0x0039", "version" : "1.6", "output" : [ { "common-ref" : "Operation Result" }, - { "name" : "ERI File", - "id" : "0x01", - "mandatory" : "yes", - "type" : "TLV", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "format" : "guint8" }, - "prerequisites": [ { "common-ref" : "Success" } ] } ] }, + { "name" : "ERI File", + "id" : "0x01", + "mandatory" : "yes", + "type" : "TLV", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "format" : "guint8" }, + "prerequisites" : [ { "common-ref" : "Success" } ] } ] }, // ********************************************************************************* { "name" : "Restore Factory Defaults", diff --git a/data/qmi-service-nas.json b/data/qmi-service-nas.json index 7e34643..d76b73c 100644 --- a/data/qmi-service-nas.json +++ b/data/qmi-service-nas.json @@ -157,22 +157,21 @@ { "name" : "Radio Interface", "format" : "gint8", "public-format" : "QmiNasRadioInterface" } ] }, - { "name" : "RF Band Information", - "id" : "0x11", - "mandatory" : "no", - "type" : "TLV", - "format" : "array", - "array-size" : { "format" : "guint8" }, - "array-element" : { "name" : "Element", - "format" : "struct", - "contents" : [ { "name" : "Radio Interface", - "format" : "gint8", - "public-format" : "QmiNasRadioInterface" }, - { "name" : "Active Band Class", - "format" : "guint16", - "public-format" : "QmiNasActiveBand" }, - { "name" : "Active Channel", - "format" : "guint16" } ] } }, + { "name" : "RF Band Information", + "id" : "0x11", + "mandatory" : "no", + "type" : "TLV", + "format" : "array", + "array-element" : { "name" : "Element", + "format" : "struct", + "contents" : [ { "name" : "Radio Interface", + "format" : "gint8", + "public-format" : "QmiNasRadioInterface" }, + { "name" : "Active Band Class", + "format" : "guint16", + "public-format" : "QmiNasActiveBand" }, + { "name" : "Active Channel", + "format" : "guint16" } ] } }, { "name" : "Registration Reject Reason", "id" : "0x12", "mandatory" : "no", @@ -367,45 +366,45 @@ "format" : "gint8", "public-format" : "QmiNasRadioInterface" } ], "prerequisites": [ { "common-ref" : "Success" } ] }, - { "name" : "Strength List", - "id" : "0x10", - "mandatory" : "no", - "type" : "TLV", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "name" : "Element", - "format" : "struct", - "contents" : [ { "name" : "Strength", - "format" : "gint8" }, - { "name" : "Radio Interface", - "format" : "gint8", - "public-format" : "QmiNasRadioInterface" } ] } }, - { "name" : "RSSI List", - "id" : "0x11", - "mandatory" : "no", - "type" : "TLV", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "name" : "Element", - "format" : "struct", - "contents" : [ { "name" : "RSSI", - "format" : "guint8" }, - { "name" : "Radio Interface", - "format" : "gint8", - "public-format" : "QmiNasRadioInterface" } ] } }, - { "name" : "ECIO List", - "id" : "0x12", - "mandatory" : "no", - "type" : "TLV", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "name" : "Element", - "format" : "struct", - "contents" : [ { "name" : "ECIO", - "format" : "guint8" }, - { "name" : "Radio Interface", - "format" : "gint8", - "public-format" : "QmiNasRadioInterface" } ] } }, + { "name" : "Strength List", + "id" : "0x10", + "mandatory" : "no", + "type" : "TLV", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "name" : "Element", + "format" : "struct", + "contents" : [ { "name" : "Strength", + "format" : "gint8" }, + { "name" : "Radio Interface", + "format" : "gint8", + "public-format" : "QmiNasRadioInterface" } ] } }, + { "name" : "RSSI List", + "id" : "0x11", + "mandatory" : "no", + "type" : "TLV", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "name" : "Element", + "format" : "struct", + "contents" : [ { "name" : "RSSI", + "format" : "guint8" }, + { "name" : "Radio Interface", + "format" : "gint8", + "public-format" : "QmiNasRadioInterface" } ] } }, + { "name" : "ECIO List", + "id" : "0x12", + "mandatory" : "no", + "type" : "TLV", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "name" : "Element", + "format" : "struct", + "contents" : [ { "name" : "ECIO", + "format" : "guint8" }, + { "name" : "Radio Interface", + "format" : "gint8", + "public-format" : "QmiNasRadioInterface" } ] } }, { "name" : "IO", "id" : "0x13", "mandatory" : "no", @@ -417,19 +416,19 @@ "type" : "TLV", "format" : "guint8", "public-format" : "QmiNasEvdoSinrLevel" }, - { "name" : "Error Rate List", - "id" : "0x15", - "mandatory" : "no", - "type" : "TLV", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "name" : "Element", - "format" : "struct", - "contents" : [ { "name" : "Rate", - "format" : "guint16" }, - { "name" : "Radio Interface", - "format" : "gint8", - "public-format" : "QmiNasRadioInterface" } ] } }, + { "name" : "Error Rate List", + "id" : "0x15", + "mandatory" : "no", + "type" : "TLV", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "name" : "Element", + "format" : "struct", + "contents" : [ { "name" : "Rate", + "format" : "guint16" }, + { "name" : "Radio Interface", + "format" : "gint8", + "public-format" : "QmiNasRadioInterface" } ] } }, { "name" : "RSRQ", "id" : "0x16", "mandatory" : "no", @@ -464,53 +463,53 @@ "format" : "guint8", "public-format" : "QmiNasNetworkScanType" } ], "output" : [ { "common-ref" : "Operation Result" }, - { "name" : "Network Information", - "id" : "0x10", - "mandatory" : "no", - "type" : "TLV", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "name" : "Element", - "format" : "struct", - "contents" : [ { "name" : "MCC", - "format" : "guint16" }, - { "name" : "MNC", - "format" : "guint16" }, - { "name" : "Network Status", - "format" : "guint8", - "public-format" : "QmiNasNetworkStatus" }, - { "name" : "Description", - "format" : "string" } ] } }, - { "name" : "Radio Access Technology", - "id" : "0x11", - "mandatory" : "no", - "type" : "TLV", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "name" : "Element", - "format" : "struct", - "contents" : [ { "name" : "MCC", - "format" : "guint16" }, - { "name" : "MNC", - "format" : "guint16" }, - { "name" : "Radio Interface", - "format" : "gint8", - "public-format" : "QmiNasRadioInterface" } ] } }, - { "name" : "MNC PCS Digit Include Status", - "id" : "0x12", - "mandatory" : "no", - "type" : "TLV", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "name" : "Element", - "format" : "struct", - "contents" : [ { "name" : "MCC", - "format" : "guint16" }, - { "name" : "MNC", - "format" : "guint16" }, - { "name" : "Includes PCS Digit", - "format" : "guint8", - "public-format" : "gboolean" } ] } } ] }, + { "name" : "Network Information", + "id" : "0x10", + "mandatory" : "no", + "type" : "TLV", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "name" : "Element", + "format" : "struct", + "contents" : [ { "name" : "MCC", + "format" : "guint16" }, + { "name" : "MNC", + "format" : "guint16" }, + { "name" : "Network Status", + "format" : "guint8", + "public-format" : "QmiNasNetworkStatus" }, + { "name" : "Description", + "format" : "string" } ] } }, + { "name" : "Radio Access Technology", + "id" : "0x11", + "mandatory" : "no", + "type" : "TLV", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "name" : "Element", + "format" : "struct", + "contents" : [ { "name" : "MCC", + "format" : "guint16" }, + { "name" : "MNC", + "format" : "guint16" }, + { "name" : "Radio Interface", + "format" : "gint8", + "public-format" : "QmiNasRadioInterface" } ] } }, + { "name" : "MNC PCS Digit Include Status", + "id" : "0x12", + "mandatory" : "no", + "type" : "TLV", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "name" : "Element", + "format" : "struct", + "contents" : [ { "name" : "MCC", + "format" : "guint16" }, + { "name" : "MNC", + "format" : "guint16" }, + { "name" : "Includes PCS Digit", + "format" : "guint8", + "public-format" : "gboolean" } ] } } ] }, // ********************************************************************************* { "name" : "Initiate Network Register", @@ -1113,7 +1112,6 @@ "mandatory" : "no", "type" : "TLV", "format" : "array", - "array-size" : { "format" : "guint8" }, "array-element" : { "name" : "Element", "format" : "struct", "contents" : [ { "name" : "Radio Interface", diff --git a/data/qmi-service-wds.json b/data/qmi-service-wds.json index 6b15f95..dc2580d 100644 --- a/data/qmi-service-wds.json +++ b/data/qmi-service-wds.json @@ -295,7 +295,6 @@ "mandatory" : "no", "type" : "TLV", "format" : "array", - "array-size" : { "format" : "guint8" }, "array-element" : { "name" : "IPv4 Address", "format" : "guint32" }, "prerequisites" : [ { "common-ref" : "Success" } ] }, @@ -304,7 +303,6 @@ "mandatory" : "no", "type" : "TLV", "format" : "array", - "array-size" : { "format" : "guint8" }, "array-element" : { "name" : "FQDN", "length-prefix-size" : "16", "format" : "string" }, @@ -360,7 +358,6 @@ "mandatory" : "no", "type" : "TLV", "format" : "array", - "array-size" : { "format" : "guint8" }, "array-element" : { "name" : "Domain Name", "length-prefix-size" : "16", "format" : "string" }, diff --git a/data/qmi-service-wms.json b/data/qmi-service-wms.json index 7dfe3bc..75accd4 100644 --- a/data/qmi-service-wms.json +++ b/data/qmi-service-wms.json @@ -67,10 +67,10 @@ { "name" : "Format", "format" : "guint8", "public-format" : "QmiWmsMessageFormat" }, - { "name" : "Raw Data", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "format" : "guint8" } } ] }, + { "name" : "Raw Data", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "format" : "guint8" } } ] }, { "name" : "Message Mode", "id" : "0x12", "mandatory" : "no", @@ -85,10 +85,10 @@ "contents" : [ { "name" : "Notification Type", "format" : "guint8", "public-format" : "QmiWmsNotificationType" }, - { "name" : "Raw Data", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "format" : "guint8" } } ] }, + { "name" : "Raw Data", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "format" : "guint8" } } ] }, { "name" : "ETWS PLMN Information", "id" : "0x14", "mandatory" : "no", @@ -124,10 +124,10 @@ "contents" : [ { "name" : "Format", "format" : "guint8", "public-format" : "QmiWmsMessageFormat" }, - { "name" : "Raw Data", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "format" : "guint8" } } ] }, + { "name" : "Raw Data", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "format" : "guint8" } } ] }, { "name" : "CDMA Force On DC", "id" : "0x10", "mandatory" : "no", @@ -237,10 +237,10 @@ { "name" : "Format", "format" : "guint8", "public-format" : "QmiWmsMessageFormat" }, - { "name" : "Raw Data", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "format" : "guint8" } } ] } ], + { "name" : "Raw Data", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "format" : "guint8" } } ] } ], "output" : [ { "common-ref" : "Operation Result" }, { "name" : "Memory Index", "id" : "0x01", @@ -289,10 +289,10 @@ { "name" : "Format", "format" : "guint8", "public-format" : "QmiWmsMessageFormat" }, - { "name" : "Raw Data", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "format" : "guint8" } } ], + { "name" : "Raw Data", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "format" : "guint8" } } ], "prerequisites" : [ { "common-ref" : "Success" } ] } ] }, // ********************************************************************************* @@ -393,20 +393,20 @@ "format" : "guint8", "public-format" : "QmiWmsMessageMode" } ], "output" : [ { "common-ref" : "Operation Result" }, - { "name" : "Message List", - "id" : "0x01", - "mandatory" : "yes", - "type" : "TLV", - "format" : "array", - "array-size" : { "format" : "guint32" }, - "array-element" : { "name" : "Element", - "format" : "struct", - "contents" : [ { "name" : "Memory Index", - "format" : "guint32" }, - { "name" : "Message Tag", - "format" : "guint8", - "public-format" : "QmiWmsMessageTagType" } ] }, - "prerequisites" : [ { "common-ref" : "Success" } ] } ] }, + { "name" : "Message List", + "id" : "0x01", + "mandatory" : "yes", + "type" : "TLV", + "format" : "array", + "size-prefix-format" : "guint32" , + "array-element" : { "name" : "Element", + "format" : "struct", + "contents" : [ { "name" : "Memory Index", + "format" : "guint32" }, + { "name" : "Message Tag", + "format" : "guint8", + "public-format" : "QmiWmsMessageTagType" } ] }, + "prerequisites" : [ { "common-ref" : "Success" } ] } ] }, // ********************************************************************************* { "name" : "Set Routes", @@ -414,26 +414,26 @@ "service" : "WMS", "id" : "0x0032", "version" : "1.0", - "input" : [ { "name" : "Route List", - "id" : "0x01", - "mandatory" : "yes", - "type" : "TLV", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "name" : "Element", - "format" : "struct", - "contents" : [ { "name" : "Message Type", - "format" : "guint8", - "public-format" : "QmiWmsMessageType" }, - { "name" : "Message Class", - "format" : "guint8", - "public-format" : "QmiWmsMessageClass" }, - { "name" : "Storage", - "format" : "guint8", - "public-format" : "QmiWmsStorageType" }, - { "name" : "Receipt Action", - "format" : "guint8", - "public-format" : "QmiWmsReceiptAction" } ] } }, + "input" : [ { "name" : "Route List", + "id" : "0x01", + "mandatory" : "yes", + "type" : "TLV", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "name" : "Element", + "format" : "struct", + "contents" : [ { "name" : "Message Type", + "format" : "guint8", + "public-format" : "QmiWmsMessageType" }, + { "name" : "Message Class", + "format" : "guint8", + "public-format" : "QmiWmsMessageClass" }, + { "name" : "Storage", + "format" : "guint8", + "public-format" : "QmiWmsStorageType" }, + { "name" : "Receipt Action", + "format" : "guint8", + "public-format" : "QmiWmsReceiptAction" } ] } }, { "name" : "Transfer Status Report", "id" : "0x10", "mandatory" : "no", @@ -449,27 +449,27 @@ "id" : "0x0033", "version" : "1.0", "output" : [ { "common-ref" : "Operation Result" }, - { "name" : "Route List", - "id" : "0x01", - "mandatory" : "yes", - "type" : "TLV", - "format" : "array", - "array-size" : { "format" : "guint16" }, - "array-element" : { "name" : "Element", - "format" : "struct", - "contents" : [ { "name" : "Message Type", - "format" : "guint8", - "public-format" : "QmiWmsMessageType" }, - { "name" : "Message Class", - "format" : "guint8", - "public-format" : "QmiWmsMessageClass" }, - { "name" : "Storage", - "format" : "guint8", - "public-format" : "QmiWmsStorageType" }, - { "name" : "Receipt Action", - "format" : "guint8", - "public-format" : "QmiWmsReceiptAction" } ] }, - "prerequisites" : [ { "common-ref" : "Success" } ] }, + { "name" : "Route List", + "id" : "0x01", + "mandatory" : "yes", + "type" : "TLV", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "name" : "Element", + "format" : "struct", + "contents" : [ { "name" : "Message Type", + "format" : "guint8", + "public-format" : "QmiWmsMessageType" }, + { "name" : "Message Class", + "format" : "guint8", + "public-format" : "QmiWmsMessageClass" }, + { "name" : "Storage", + "format" : "guint8", + "public-format" : "QmiWmsStorageType" }, + { "name" : "Receipt Action", + "format" : "guint8", + "public-format" : "QmiWmsReceiptAction" } ] }, + "prerequisites" : [ { "common-ref" : "Success" } ] }, { "name" : "Transfer Status Report", "id" : "0x10", "mandatory" : "no",