![]() |
lingua-franca 0.10.1
Lingua Franca code generator
|
Enables support for Protocol Buffer serialization in Python federated programs. More...
Inherits org.lflang.federated.serialization.FedSerialization.
Public Member Functions | |
| StringBuilder | generateCompilerExtensionForSupport () |
| StringBuilder | generateNetworkDeserializerCode (String varName, String targetType) |
| Generate C code that deserializes a wire buffer into a Python proto object. | |
| StringBuilder | generateNetworkSerializerCode (String varName, String originalType) |
| Generate C code that serializes a Python proto object into a self-describing wire buffer. | |
| StringBuilder | generatePreambleForSupport () |
| boolean | isCompatible (GeneratorBase generator) |
| Check whether the current generator is compatible with the given serialization technique or not. | |
| String | serializedBufferLength () |
| String | serializedBufferVar () |
Static Public Attributes | |
| static final String | BUF_VAR = "_lf_proto_wire_buf" |
| Name of the malloc'd wire-format buffer variable in generated C code. | |
| static final String | deserializedVarName = "deserialized_message" |
| Variable name in the target language for the deserialized data. | |
| static final String | LEN_VAR = "_lf_proto_wire_len" |
| Name of the wire-format buffer length variable in generated C code. | |
| static final String | serializedVarName = "serialized_message" |
| Variable name in the target language for the serialized data. | |
Enables support for Protocol Buffer serialization in Python federated programs.
User reactions work with proto objects directly (no manual SerializeToString / ParseFromString calls). The generated C code:
SerializeToString() on the Python proto object and prepends the message's fully-qualified type name so the receiver can reconstruct the right class.
google.protobuf.symbol_database to obtain the class, creates an instance, and calls ParseFromString(). Wire format: [4-byte big-endian name length][UTF-8 full_name][proto bytes]
| StringBuilder org.lflang.federated.serialization.FedProtoPythonSerialization.generateCompilerExtensionForSupport | ( | ) |
Implements org.lflang.federated.serialization.FedSerialization.
| StringBuilder org.lflang.federated.serialization.FedProtoPythonSerialization.generateNetworkDeserializerCode | ( | String | varName, |
| String | targetType ) |
Generate C code that deserializes a wire buffer into a Python proto object.
The type name embedded in the wire format is used to look up the proto class via Python's google.protobuf.symbol_database, so no port-type annotation is required.
| varName | The action variable name (accessed as varName->token->value). |
| targetType | Unused. |
Implements org.lflang.federated.serialization.FedSerialization.
| StringBuilder org.lflang.federated.serialization.FedProtoPythonSerialization.generateNetworkSerializerCode | ( | String | varName, |
| String | originalType ) |
Generate C code that serializes a Python proto object into a self-describing wire buffer.
Wire format: [4-byte big-endian name_len][full_name bytes][proto bytes]
The caller is responsible for calling free(_lf_proto_wire_buf) after the buffer has been sent.
| varName | C expression for the Python proto object (e.g. sendRef->value). |
| originalType | Unused. |
Implements org.lflang.federated.serialization.FedSerialization.
| StringBuilder org.lflang.federated.serialization.FedProtoPythonSerialization.generatePreambleForSupport | ( | ) |
Implements org.lflang.federated.serialization.FedSerialization.
| boolean org.lflang.federated.serialization.FedProtoPythonSerialization.isCompatible | ( | GeneratorBase | generator | ) |
Check whether the current generator is compatible with the given serialization technique or not.
| generator | The current generator. |
Implements org.lflang.federated.serialization.FedSerialization.
| String org.lflang.federated.serialization.FedProtoPythonSerialization.serializedBufferLength | ( | ) |
Implements org.lflang.federated.serialization.FedSerialization.
| String org.lflang.federated.serialization.FedProtoPythonSerialization.serializedBufferVar | ( | ) |
Implements org.lflang.federated.serialization.FedSerialization.
|
static |
Name of the malloc'd wire-format buffer variable in generated C code.
|
staticinherited |
Variable name in the target language for the deserialized data.
|
static |
Name of the wire-format buffer length variable in generated C code.
|
staticinherited |
Variable name in the target language for the serialized data.