Skip to content

Commit 71a3de9

Browse files
committed
Release v4.0
2 parents a46ac9d + 0b9f490 commit 71a3de9

20 files changed

+306
-20
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if (NOT ASCIIDOCTOR_PDF_EXE)
1111
message(FATAL_ERROR "asciidoctor-pdf is not found")
1212
endif ()
1313

14-
set (VERSION "v3.1.3")
14+
set (VERSION "v4.0")
1515
set (MAIN_FILE "${PROJECT_SOURCE_DIR}/commsdsl_spec.adoc")
1616

1717
add_custom_target("pdf" ALL

aliases/aliases.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ the generated code as a comment for the relevant access functions.
129129
----
130130

131131
=== More on Aliases in <message>-es ===
132-
When a new <<messages-messages, &lt;message&gt; >> is defined it can
133-
copy all the fields from other already defined <<messages-messages, &lt;message&gt; >>
132+
When a new <<messages-messages, &lt;message&gt; >> is defined, it can
133+
copy all the fields from other already defined <<messages-messages, &lt;message&gt; >> or <<fields-bundle, &lt;bundle&gt; >>
134134
(using **copyFieldsFrom** <<intro-properties, property>>).
135135
By default all the <<aliases-aliases, &lt;alias&gt; >> definitions are also copied.
136136
It is possible to modify this default behavior by using **copyFieldsAliases**
@@ -154,7 +154,7 @@ It is possible to modify this default behavior by using **copyFieldsAliases**
154154
Similar to <<messages-messages, &lt;message&gt; >>-es
155155
<<interfaces-interfaces, &lt;interface&gt; >> can also use **copyFieldsFrom**
156156
<<intro-properties, property>> to copy its field from some other
157-
<<interfaces-interfaces, &lt;interface&gt; >> definition and have all
157+
<<interfaces-interfaces, &lt;interface&gt; >> or <<fields-bundle, &lt;bundle&gt; >> definition and have all
158158
the aliases copied by default. The control of such default copying behavior
159159
is also done by using **copyFieldsAliases**
160160
<<intro-properties, property>> with <<intro-boolean, boolean>> value.

appendix/checksum.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ for detailed description.
88
|===
99
|Property Name|Allowed Type / Value|DSL Version|Required|Default Value ^.^|Description
1010

11-
|**alg**|"sum", "crc-ccitt", "crc-16", "crc-32", "custom"|1|yes||Checksum calculation algorithm.
11+
|**alg**|"sum", "xor", "crc-ccitt", "crc-16", "crc-32", "custom"|1|yes||Checksum calculation algorithm.
1212
|**algName**|<<intro-names, name>> string|1|no (unless **alg** is **custom**)||Name of the custom algorithm. Applicable only if **alg="custom"**.
1313
|**from**|<<intro-names, name>> string|1|yes (only if **until** is not specified)||Name of the frame layer, from which the checksum calculation starts.
1414
|**until**|<<intro-names, name>> string|1|yes (only if **from** is not specified)||Name of the frame layer, until (and including) which the checksum calculation is executed.

appendix/enum.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ for detailed description.
1616
|**hexAssign**|<<intro-boolean, bool>>|1|no|false|Force generated code to assign enum values using hexadecimal numbers.
1717
|**nonUniqueAllowed**|<<intro-boolean, bool>>|1|no|false|Allow non unique **&lt;validValue&gt;**-es.
1818
|**validCheckVersion**|<<intro-boolean, bool>>|1|no|false|Take into account protocol version when generating code for field's value validity check.
19+
|**availableLengthLimit**|<<intro-boolean, bool>>|4|no|false|Allow having less bytes in the buffer than required by the **type** when performing (de)serialization.
1920
|===
2021

2122
==== Properties of &lt;validValue&gt; Child Element of &lt;enum&gt; Field ====

appendix/fields.adoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
=== Common Properties of Fields ===
33
Refer to <<fields-common, Common Properties of Fields>> chapter for detailed description.
44

5-
[cols="^.^28,^.^10,^.^8,^.^8,^.^10,36", options="header"]
5+
[cols="^.^27,^.^11,^.^8,^.^8,^.^10,36", options="header"]
66
|===
77
|Property Name|Allowed Type / Value|DSL Version|Required|Default Value ^.^|Description
88

@@ -24,4 +24,10 @@ Applicable only to members of the <<messages-messages, &lt;message&gt; >> or <<f
2424
|**customizable**|<<intro-boolean, bool>>|1|no|false|Mark the field to allow compile time customization regardless of code generator's level of customization.
2525
|**semanticType**|"none", "messageId", "version", "length"|1|no|none|Specify semantic type of the field. It allows code generator to generate special code for special cases. Value "length" was introduced in **v2** of this specification.
2626
|**forceGen**|<<intro-boolean, bool>>|3|no|false|Force generation of field's code regardless of it's being referenced or not.
27+
|**readOverride**|"any", "replace", "extend", "none"|4|no|any|Control the overriding code for **read** operation.
28+
|**writeOverride**|"any", "replace", "extend", "none"|4|no|any|Control the overriding code for **write** operation.
29+
|**refreshOverride**|"any", "replace", "extend", "none"|4|no|any|Control the overriding code for **refresh** operation.
30+
|**lengthOverride**|"any", "replace", "extend", "none"|4|no|any|Control the overriding code for **length** retrieval.
31+
|**validOverride**|"any", "replace", "extend", "none"|4|no|any|Control the overriding code for **valid** retrieval.
32+
|**nameOverride**|"any", "replace", "extend", "none"|4|no|any|Control the overriding code for **name** retrieval.
2733
|===

appendix/int.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ for detailed description.
2626
|**displayOffset**|<<intro-numeric, numeric>>|1|no|0|Indicates to GUI analysis tools to add specified offset value to a field's value when displaying it.
2727
|**nonUniqueSpecialsAllowed**|<<intro-boolean, bool>>|2|no|false|Allow non unique **&lt;special&gt;**-s.
2828
|**displaySpecials**|<<intro-boolean, bool>>|2|no|true|Control displaying **&lt;special&gt;** values in analysis tools.
29+
|**defaultValidValue**|<<intro-numeric, numeric>> or <<intro-names, name>>|4|no||Convenience bunding of the **defaultValue** and **validValue** into a single property.
30+
|**availableLengthLimit**|<<intro-boolean, bool>>|4|no|false|Allow having less bytes in the buffer than required by the **type** when performing (de)serialization.
2931
|===
3032

3133
==== Properties of &lt;special&gt; Child Element of &lt;int&gt; Field ====

appendix/interface.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ for detailed description.
99

1010
|**name**|<<intro-names, name>> string|1|yes||Name of the interface.
1111
|**description**|string|1|no||Human readable description of the interface.
12-
|**copyFieldsFrom**|<<intro-references, reference>> string|1|no||Interface definition from which fields need to be copied.
13-
|**copyFieldsAliases**|<<intro-boolean, bool>>|3|no|true|Control copy of the defined <<aliases-aliases, aliases>> when **copyFieldsFrom** property is used to copy fields from the other <<interfaces-interfaces, &lt;interface&gt; >>.
12+
|**copyFieldsFrom**|<<intro-references, reference>> string|1|no||Interface or bundle field definition from which fields need to be copied.
13+
|**copyFieldsAliases**|<<intro-boolean, bool>>|3|no|true|Control copy of the defined <<aliases-aliases, aliases>> when **copyFieldsFrom** property is used to copy fields from the other <<interfaces-interfaces, &lt;interface&gt; >> or <<fields-bundle, &lt;bundle&gt; >>.
1414
|===
1515

1616

appendix/message.adoc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,30 @@
33
Refer to <<messages-messages, Messages>> chapter
44
for detailed description.
55

6-
[cols="^.^28,^.^10,^.^8,^.^8,^.^10,36", options="header"]
6+
[cols="^.^27,^.^11,^.^8,^.^8,^.^10,36", options="header"]
77
|===
88
|Property Name|Allowed Type / Value|DSL Version|Required|Default Value ^.^|Description
99

1010
|**name**|<<intro-names, name>> string|1|yes||Name of the message.
1111
|**id**|<<intro-numeric, numeric>>|1|yes||Numeric ID of the message.
1212
|**description**|string|1|no||Human readable description of the message.
1313
|**displayName**|string|1|no||Name of the message to display. If empty, the code generator must use value of property **name** instead.
14-
|**copyFieldsFrom**|<<intro-references, reference>> string|1|no||Message definition from which fields need to be copied.
14+
|**copyFieldsFrom**|<<intro-references, reference>> string|1|no||Message or bundle field definition from which fields need to be copied.
1515
|**order**|<<intro-numeric, numeric>>|1|no|0|Relative order of the messages with the same **id**.
1616
|**sinceVersion**|<<intro-numeric, unsigned>>|1|no|0|Version of the protocol in which message was introduced.
1717
|**deprecated**|<<intro-numeric, unsigned>>|1|no|max unsigned|Version of the protocol in which message was deprecated. +
1818
Must be greater than value of **sinceVersion**.
1919
|**removed**|<<intro-boolean, bool>>|1|no|false|Indicates whether deprecated message has been removed from being supported.
2020
|**sender**|"both", "client", "server"|1|no|both|Endpoint that sends the message.
2121
|**customizable**|<<intro-boolean, bool>>|1|no|false|Mark the message to allow compile time customization regardless of code generator's level of customization.
22-
|**copyFieldsAliases**|<<intro-boolean, bool>>|3|no|true|Control copy of the defined <<aliases-aliases, aliases>> when **copyFieldsFrom** property is used to copy fields from the other <<messages-messages, &lt;message&gt; >>.
22+
|**copyFieldsAliases**|<<intro-boolean, bool>>|3|no|true|Control copy of the defined <<aliases-aliases, aliases>> when **copyFieldsFrom** property is used to copy fields from the other <<messages-messages, &lt;message&gt; >> or <<fields-bundle, &lt;bundle&gt; >>.
23+
|**validateMinLength**|<<intro-numeric, numeric>>|4|no||Specify expected minimal serialization length of the message fields.
24+
|**readOverride**|"any", "replace", "extend", "none"|4|no|any|Control the overriding code for **read** operation.
25+
|**writeOverride**|"any", "replace", "extend", "none"|4|no|any|Control the overriding code for **write** operation.
26+
|**refreshOverride**|"any", "replace", "extend", "none"|4|no|any|Control the overriding code for **refresh** operation.
27+
|**lengthOverride**|"any", "replace", "extend", "none"|4|no|any|Control the overriding code for **length** retrieval.
28+
|**validOverride**|"any", "replace", "extend", "none"|4|no|any|Control the overriding code for **valid** retrieval.
29+
|**nameOverride**|"any", "replace", "extend", "none"|4|no|any|Control the overriding code for **name** retrieval.
2330
|===
2431

2532
Extra child XML elements allowed:

commsdsl_spec.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
= CommsDSL Specification v3.1.3
1+
= CommsDSL Specification v4.0
22
Alex Robenko
3-
v3.1.3, 2020-10
3+
v4.0, 2022-05
44
:doctype: article
55
:toc: left
66
:source-highlighter: rouge

fields/common.adoc

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Every field is different, and defines its own properties and/or other aspects.
44
However, there are common properties, that are applicable to every field.
55
They are summarized below.
66

7+
[[fields-common-name]]
78
==== Name ====
89
Every field must define it's <<intro-names, name>>, which is expected to be
910
used by a code generator when defining a relevant class. The name is defined
@@ -18,6 +19,7 @@ using **name** <<intro-properties, property>>.
1819
</schema>
1920
----
2021

22+
[[fields-common-description]]
2123
==== Description ====
2224
It is possible to provide a description of the field about what it is and
2325
how it is expected to be used. This description is only for documentation
@@ -39,6 +41,7 @@ generated class. The <<intro-properties, property>> is **description**.
3941
</schema>
4042
----
4143

44+
[[fields-common-reusing-other-fields]]
4245
==== Reusing Other Fields ====
4346
Sometimes two different fields are very similar, but differ in one particular
4447
aspect. **CommsDSL** allows copying all the properties from previously defined
@@ -65,6 +68,7 @@ The **reuse** is allowed only from the field of the same **kind**. For example,
6568
it is **NOT** allowed for <<fields-enum, &lt;enum&gt; >> field to reuse definition of
6669
<<fields-int, &lt;int&gt; >>, only other <<fields-enum, &lt;enum&gt; >>.
6770

71+
[[fields-common-forcing-generation]]
6872
==== Forcing Generation ====
6973
By default the code generator is expected not to generate code for fields that
7074
are not <<intro-references, referenced>> by any other field to reduce amount of
@@ -82,6 +86,7 @@ has been introduced with <<intro-boolean, boolean>> value.
8286
</schema>
8387
----
8488

89+
[[fields-common-display-properties]]
8590
==== Display Properties ====
8691
**CommsDSL** supports generation of not only field's serialization and
8792
value access functionality, but also of various GUI protocol visualization, debugging and
@@ -141,6 +146,7 @@ value.
141146
</schema>
142147
----
143148

149+
[[fields-common-versioning]]
144150
==== Versioning ====
145151
**CommsDSL** allows providing an information in what version the field was added
146152
to a particular message, as well as in what version it was deprecated, and whether
@@ -180,6 +186,7 @@ should be ignored by the code generator. It is allowed when field is a member
180186
of a <<messages-messages, &lt;message&gt; >> or a
181187
<<fields-bundle, &lt;bundle&gt; >> field.
182188

189+
[[fields-common-failing-read-of-the-field-on-invalid-value]]
183190
==== Failing Read of the Field on Invalid Value ====
184191
Some fields may specify what values are considered to be valid, and there may
185192
be a need to fail the **read** operation in case the received value is invalid.
@@ -217,6 +224,7 @@ operation doesn't fail. The **order** property of the message specifies in
217224
what order the messages with the same ID must be read. It described in more
218225
detail in <<messages-messages, Messages>> chapter.
219226

227+
[[fields-common-pseudo-fields]]
220228
==== Pseudo Fields ====
221229
Sometimes there may be a need to have "psuedo" fields, which are implemented
222230
using proper field abstration, and are handled as
@@ -235,6 +243,7 @@ value.
235243
</schema>
236244
----
237245

246+
[[fields-common-customizable-fields]]
238247
==== Customizable Fields ====
239248
The code generator is expected to allow some level of compile time customization of the
240249
generated code, such as choosing different data structures and/or adding/replacing
@@ -254,6 +263,7 @@ customizable at compile time.
254263
</schema>
255264
----
256265

266+
[[fields-common-semantic-type]]
257267
==== Semantic Type ====
258268
Sometimes code generator may generate a bit different (or better) code for fields that are
259269
used for some particular purpose. To specify such purpose use **semanticType**
@@ -289,4 +299,44 @@ was introduced in **v2.0** of **CommsDSL** specification.
289299
</schema>
290300
----
291301

302+
[[fields-common-ensuring-overriding-code-injection]]
303+
==== Ensuring Overriding Code Injection ====
304+
In some cases the **CommsDSL** may be insufficient to express the the protocol definition in correct way.
305+
To handle such cases the code generator is expected to allow injection of the custom / overriding code
306+
to fix / replace the default implementation produced by the code generator.
307+
308+
The code generator is expected to generate the default code for the following operations:
309+
310+
* **read** - Reading the field's value from the input buffer
311+
* **write** - Writing the field's value to the output buffer
312+
* **refresh** - Update the field's value to a consistent state. Note, that in some composite fields
313+
like <<fields-bundle, &lt;bundle&gt; >>, values of internal members may depend on the values of other
314+
members creating the situation where the whole state may be inconsistent / incorrect. Invoking the **refresh** operation is
315+
expected to update the values of inner fields to bring the field into a consistent / correct state.
316+
* **length** - Returning the serialization length of the field.
317+
* **valid** - Returning whether the field's value is valid.
318+
* **name** - Returning the name of the field.
319+
320+
To ensure visibility and/or help with forcing the injection of the correcting code,
321+
the **CommsDSL** provides the following <<intro-properties, properties>>.
322+
323+
* **readOverride** - Control the overriding code injection for the **read** operation.
324+
* **writeOverride** - Control the overriding code injection for the **write** operation.
325+
* **refreshOverride** - Control the overriding code injection for the **refresh** operation.
326+
* **lengthOverride** - Control the overriding code injection for the **length** operation.
327+
* **validOverride** - Control the overriding code injection for the **valid** operation.
328+
* **nameOverride** - Control the overriding code injection for the **name** operation.
329+
330+
The value of the <<intro-properties, properties>> above can be one of the following:
331+
332+
* **any** (default) - Inject the overriding code if available, use the code generated by default if not.
333+
* **replace** - The default code code is incorrect, replace it with the provided one. The code generator is expected
334+
to report a failure in case the overriding code is unavailable.
335+
* **extend** - The default code is still incorrect, but the code generator is expected to
336+
produce it (with some minor renaming to avoid names clashing) to allow reuse and extension in the overriding code. The code generator is expected
337+
to report a failure in case the overriding code is unavailable.
338+
* **none** - The code generator is expected to ignore the overriding code if it's available and
339+
produce the one generated by default instead.
340+
341+
292342
Use <<appendix-fields, properties table>> for future references.

fields/data.adoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ as well as extra properties and elements described below.
1313
</schema>
1414
----
1515
Such definition of the **&lt;data&gt;** does **NOT** have any limit on
16-
the length of the data, and will consume all the available bytes in the
17-
input buffer.
16+
the length of the data, and will consume all the __available__ bytes in the
17+
input buffer. Note, that the __available__ bytes may be bound by the
18+
<<frames-size, &lt;size&gt; >> layer of the <<frames-frames, &lt;frame&gt; >> or
19+
other means. It does NOT necessarily mean that all the bytes received from the I/O link
20+
will be consumed.
1821

1922
==== Default Value ====
2023
The default value of the **&lt;data&gt;** field when constructed can be specified

fields/enum.adoc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,29 @@ use **length** property to specify custom serialization length.
142142
<<fields-enum-underlying-type, underlying type>> (**intvar** and **uintvar**),
143143
it means **maximum** allowed length.
144144

145+
Some protocols allow (de)serialization of the **&lt;enum&gt;** field value having less bytes
146+
in the buffer than is required by its <<fields-enum-underlying-type, underlying type>> serialization.
147+
Usually the length of such an **&lt;enum&gt;**
148+
field is specified externally, by the preceding "length" field in TLV (type-length-value) triplet
149+
(explained in detail in <<fields-variant, &lt;variant&gt; Field>> section). In order to allow code
150+
generator to handle such cases use **availableLengthLimit** <<intro-properties, property>>
151+
with <<intro-boolean, boolean>> value.
152+
[source,xml]
153+
----
154+
<?xml version="1.0" encoding="UTF-8"?>
155+
<schema name="MyProtocol" endian="big">
156+
<fields>
157+
<enum name="SomeEnumField" type="uint32" availableLengthLimit="true">
158+
<validValue name="Val1" val="0x0" />
159+
<validValue name="Val2" val="0x0a0b" />
160+
<validValue name="Val3" val="0xffffff" />
161+
</enum>
162+
</fields>
163+
</schema>
164+
----
165+
Note, that the code generator is responsible to allow external limiting serialization length for such fields
166+
before **write** operation takes place.
167+
145168
==== Length in Bits ====
146169
**&lt;enum&gt;** field can be a member of <<fields-bitfield, &lt;bitfield&gt; >> field.
147170
In this case the serialization length may be specified in bits using **bitLength**

0 commit comments

Comments
 (0)