zerodds-idl-python — Python Codegen
1 Purpose
Emits a Python 3.10+ module from an OMG IDL 4.2 source file —
@dataclass-based types with explicit
encode_cdr() / decode_cdr() helpers.
Wire-compatible with every other ZeroDDS codegen target (C, C++, C#,
Java, Rust, TypeScript) and with the on-the-wire RTPS 2.5 payload the
runtime ships.
2 Vendor Spec
zerodds-xcdr2-bindings-conformance-1.0
— the cross-language conformance suite that pins encode/decode parity
across all binding languages, Python included.
3 CLI
zerodds-idlc --python -o gen/py chat.idl
# → gen/py/chat.py
One module per .idl file. IDL module names
map to the dotted Python package path. With XTypes TypeObject emission
on (the default), the module also carries the serialized Minimal
TypeObject of each type; --no-typeobject
suppresses it. --scaffold additionally emits a
pyproject.toml.
4 Scope
Implemented:
- Structs with
@final/@appendable/@mutableextensibility - Unions and enums (with literal case labels)
- Primitive types,
string/wstring,sequence<T>, arrays - Nested modules → nested Python packages
@keymembers → key-hash helper@id(N)/@optionalfor evolvable types
Out of scope (returns a codegen error if encountered):
valuetype,interfacefixed,map,any- Union cases with non-literal constant expressions
5 Combining with the Python runtime
A typical Python application installs the
zerodds runtime package and imports
the modules generated by zerodds-idlc --python. The
generated encode_cdr() / decode_cdr() helpers
produce the same wire bytes the PyO3 and ctypes paths
expect — a Python publisher and, say, a Rust subscriber on the same
topic exchange byte-identical CDR payloads.
6 Wiring
6.1 Dependencies
Crate crates/idl-python/ —
3 src-files,
756 LOC,
4
public items,
27 tests.
Public API: generate_python_module,
PythonGenOptions, IdlPythonError,
Result. Depends only on zerodds-idl (AST +
parser).
6.2 Dependents
tools/idlc CLI (--python flag dispatch) plus
codegen snapshot tests.
7 See also
py— the runtime Python binding/bindings/python/— 5-minute Python Quickstartidlc— CLI usage and other backend flagsidl— the shared IDL 4.2 parser crate
8 Stability
Crate version 1.0.0-rc.4. The
generated-code shape is stable for 1.0.x.
zerodds-idl-python — Python-Codegen
1 Zweck
Emittiert ein Python-3.10+-Modul aus einer OMG-IDL-4.2-Quelldatei —
@dataclass-basierte Typen mit expliziten
encode_cdr() / decode_cdr()-Helpers.
Wire-kompatibel mit jedem anderen ZeroDDS-Codegen-Target (C, C++, C#,
Java, Rust, TypeScript) und mit dem On-the-Wire-RTPS-2.5-Payload, den die
Runtime ausliefert.
2 Vendor-Spec
zerodds-xcdr2-bindings-conformance-1.0
— die Cross-Language-Conformance-Suite, die Encode/Decode-Parität über
alle Binding-Sprachen festnagelt, Python inklusive.
3 CLI
zerodds-idlc --python -o gen/py chat.idl
# → gen/py/chat.py
Ein Modul pro .idl-Datei. IDL-module-Namen
mappen auf den punktierten Python-Package-Pfad. Mit aktivierter
XTypes-TypeObject-Emission (Default) trägt das Modul außerdem das
serialisierte Minimal-TypeObject jedes Typs;
--no-typeobject unterdrückt es. --scaffold
emittiert zusätzlich eine pyproject.toml.
4 Scope
Implementiert:
- Structs mit
@final/@appendable/@mutable-Extensibility - Unions und Enums (mit Literal-Case-Labels)
- Primitive Typen,
string/wstring,sequence<T>, Arrays - Verschachtelte Module → verschachtelte Python-Packages
@key-Members → Key-Hash-Helper@id(N)/@optionalfür evolvierbare Typen
Out-of-Scope (gibt einen Codegen-Fehler zurück, wenn angetroffen):
valuetype,interfacefixed,map,any- Union-Cases mit Nicht-Literal-Constant-Expressions
5 Kombination mit der Python-Runtime
Eine typische Python-Anwendung installiert das
zerodds-Runtime-Paket und importiert
die Module, die zerodds-idlc --python generiert. Die
generierten encode_cdr() / decode_cdr()-Helpers
erzeugen dieselben Wire-Bytes, die der PyO3- und der ctypes-
Pfad erwarten — ein Python-Publisher und z. B. ein Rust-Subscriber auf
demselben Topic tauschen byte-identische CDR-Payloads aus.
6 Wiring
6.1 Dependencies
Crate crates/idl-python/ —
3 src-files,
756 LOC,
4
Public-Items,
27 Tests.
Public API: generate_python_module,
PythonGenOptions, IdlPythonError,
Result. Hängt nur von zerodds-idl (AST +
Parser) ab.
6.2 Dependents
tools/idlc-CLI (--python-Flag-Dispatch) plus
Codegen-Snapshot-Tests.
7 Siehe auch
py— das Runtime-Python-Binding/bindings/python/— 5-Minuten-Python-Quickstartidlc— CLI-Nutzung und weitere Backend-Flagsidl— die geteilte IDL-4.2-Parser- Crate
8 Stabilität
Crate-Version 1.0.0-rc.4. Die Form des
generierten Codes ist stabil für 1.0.x.