summaryrefslogtreecommitdiff
path: root/tests/symbolic_values.qmi
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2021-10-01 18:23:38 -0500
committerBjorn Andersson <bjorn.andersson@linaro.org>2021-10-04 14:19:51 -0500
commited896c97dc2b3b7edcba103e02fd0f3368b56ddd (patch)
tree0e3d5d35b5be366475446d9968a5419d604522ec /tests/symbolic_values.qmi
parent2bd95bd13bbf56cd674fa890e1d91e9bf3fd3c93 (diff)
parser: add support for constant value substitution
Register symbolic constants as defined symbols when they are defined. When a constant symbol reference occurs after it's been defined, the parsed token is modified to be a number type, whose value is the value constant symbol. One difference between a "normal" number token and a "constant" number token is that the the string in a constant token contains a copy of the symbolic name, whereas its a null pointer for a "normal" number. Signed-off-by: Alex Elder <elder@linaro.org> Message-Id: <20211001232338.769309-35-elder@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Diffstat (limited to 'tests/symbolic_values.qmi')
-rw-r--r--tests/symbolic_values.qmi26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/symbolic_values.qmi b/tests/symbolic_values.qmi
new file mode 100644
index 0000000..79821b9
--- /dev/null
+++ b/tests/symbolic_values.qmi
@@ -0,0 +1,26 @@
+package test;
+
+# Request identifiers
+const TEST_REQUEST_RESPONSE = 35;
+const TEST_INDICATION = 37;
+
+# Message field identifiers
+const QMI_RESULT = 2;
+
+struct qmi_result {
+ u16 result;
+ u16 error;
+};
+
+request test_request {
+ required u8 test_number = 0x12;
+} = TEST_REQUEST_RESPONSE; # Value 35 gets substitued
+
+response test_response {
+ # Value 2 gets substitued for QMI_RESULT
+ required qmi_result r = QMI_RESULT;
+} = TEST_REQUEST_RESPONSE;
+
+indication test_indication {
+ optional u64 value = 0x99;
+} = TEST_INDICATION; # Value 37 gets substitued