Skip to content

Commit 82782ec

Browse files
committed
[#597] Add optimizations section into the README.md for code generators
1 parent 894b54b commit 82782ec

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

compiler/extensions/cpp/README.md

+16
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ For a **quick start** see the [C++ Tutorial](https://github.com/ndsev/zserio-tut
4242

4343
[Compatibility Check](#compatibility-check)
4444

45+
[Optimizations](#optimizations)
46+
4547
## Supported C++ Standards
4648

4749
Zserio C++ generator supports the C++11 standard which was published as ISO/IEC 14882:2011.
@@ -409,6 +411,7 @@ a `zserio::CppRuntimeException` during parsing of binary data:
409411
| Generated Sources | Bitmask constructor | "Value for bitmask [NAME] out of bounds: [VALUE]!" | Throws if value stored in stream is bigger than bitmask upper bound. This could happen only in case of data inconsistency when bitmask value stored in the stream is wrong. |
410412
| Generated Sources | `valueToEnum` | "Unknown value for enumeration [NAME]: [VALUE]!" | Throws in case of unknown enumeration value. This could happen only in case of data inconsistency when enumeration value stored in the stream is wrong. |
411413

414+
412415
## Compatibility Check
413416

414417
C++ generator honors the `zserio_compatibility_version` specified in the schema. However note that only
@@ -418,3 +421,16 @@ compatibility version and fires an error when it detects any problem.
418421

419422
> Note: Binary encoding of packed arrays has been changed in version `2.5.0` and thus versions `2.4.x` are
420423
binary incompatible with later versions.
424+
425+
## Optimizations
426+
427+
The C++ generator provides the following optimizations of the generated code:
428+
429+
- If any Zserio structure, choice or union type is not used in the packed array, no packing interface methods
430+
will be generated for them
431+
(e.g. `write(ZserioPackingContext& context, ::zserio::BitStreamWriter& out)`).
432+
433+
Such optimizations can be done because Zserio relays on the fact that the entire schema is known during the
434+
generation. Therefore, splitting schema into two parts and generating them independently cannot guarantee
435+
correct functionality. This can lead to a problem especially for templates, if a template is defined
436+
in one part and instantiated in the other.

compiler/extensions/java/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ For a **quick start** see the [Java Tutorial](https://github.com/ndsev/zserio-tu
3030

3131
[Compatibility Check](#compatibility-check)
3232

33+
[Optimizations](#optimizations)
34+
3335
## Supported Java Versions
3436

3537
Zserio Java generator supports the Java SE 8 (LTS), the Java SE 11 (LTS) and the Java SE 17 (LTS).
@@ -133,3 +135,16 @@ compatibility version and fires an error when it detects any problem.
133135

134136
> Note: Binary encoding of packed arrays has been changed in version `2.5.0` and thus versions `2.4.x` are
135137
binary incompatible with later versions.
138+
139+
## Optimizations
140+
141+
The Java generator provides the following optimizations of the generated code:
142+
143+
- If any Zserio structure, choice or union type is not used in the packed array, no packing interface methods
144+
will be generated for them
145+
(e.g. `write(zserio.runtime.array.PackingContext context, zserio.runtime.io.BitStreamWriter out)`).
146+
147+
Such optimizations can be done because Zserio relays on the fact that the entire schema is known during the
148+
generation. Therefore, splitting schema into two parts and generating them independently cannot guarantee
149+
correct functionality. This can lead to a problem especially for templates, if a template is defined
150+
in one part and instantiated in the other.

compiler/extensions/python/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ For a **quick start** see the [Python Tutorial](https://github.com/ndsev/zserio-
3333

3434
[Compatibility Check](#compatibility-check)
3535

36+
[Optimizations](#optimizations)
37+
3638
## Supported Python Versions
3739

3840
Zserio Python generator supports the Python 3.8, 3.9, 3.10, 3.11 and 3.12.
@@ -170,3 +172,15 @@ language features used in the schema are still encoded in a binary compatible wa
170172
compatibility version and fires an error when it detects any problem.
171173

172174
> Note: Binary encoding of packed arrays has been changed in version `2.5.0`.
175+
176+
## Optimizations
177+
178+
The Python generator provides the following optimizations of the generated code:
179+
180+
- If any Zserio structure, choice or union type is not used in the packed array, no packing interface methods
181+
will be generated for them (e.g. `write_packed(self, zserio_context, zserio_writer)`).
182+
183+
Such optimizations can be done because Zserio relays on the fact that the entire schema is known during the
184+
generation. Therefore, splitting schema into two parts and generating them independently cannot guarantee
185+
correct functionality. This can lead to a problem especially for templates, if a template is defined
186+
in one part and instantiated in the other.

0 commit comments

Comments
 (0)