Enables support for Protocol Buffer serialization in C code using protobuf-c.
More...
Inherits org.lflang.federated.serialization.FedSerialization.
|
| static String | protobufCFunctionPrefix (String messageType) |
| | Convert a protobuf message type name to the protobuf-c function prefix.
|
| static String | stripPointer (String type) |
| | Strip trailing * characters from a C pointer type string.
|
|
| static final String | deserializedVarName = "deserialized_message" |
| | Variable name in the target language for the deserialized data.
|
| static final String | PROTOBUF_DESTRUCTOR_NAME = "_lf_protobuf_destructor" |
| | Name of the generated destructor that frees a heap-allocated protobuf-c message.
|
| static final String | serializedVarName = "serialized_message" |
| | Variable name in the target language for the serialized data.
|
Enables support for Protocol Buffer serialization in C code using protobuf-c.
For federated connections that use serializer "proto", the port type must be a protobuf message pointer (e.g. MyMessage*). Sender reactions allocate and initialize messages on the heap; the runtime owns the lifetime of deserialized messages on the receiver side and frees them via org.lflang.federated.serialization.FedProtoCSerialization#PROTOBUF_DESTRUCTOR_NAME (a thin wrapper around protobuf_c_message_free_unpacked).
- Author
- Edward A. Lee
◆ generateCompilerExtensionForSupport()
| StringBuilder org.lflang.federated.serialization.FedProtoCSerialization.generateCompilerExtensionForSupport |
( |
| ) |
|
◆ generateNetworkDeserializerCode()
| StringBuilder org.lflang.federated.serialization.FedProtoCSerialization.generateNetworkDeserializerCode |
( |
String | varName, |
|
|
String | targetType ) |
Generate code that deserializes a network message into a freshly heap-allocated protobuf message via __unpack.
- Parameters
-
| varName | Reference to the receiving action. |
| targetType | The protobuf message type name (without the trailing *). |
Implements org.lflang.federated.serialization.FedSerialization.
◆ generateNetworkSerializerCode()
| StringBuilder org.lflang.federated.serialization.FedProtoCSerialization.generateNetworkSerializerCode |
( |
String | varName, |
|
|
String | originalType ) |
Generate code that serializes the value of a pointer-typed port using __pack.
- Parameters
-
| varName | Reference to the port (e.g. msg[0]). The port's value field is expected to be a pointer to a protobuf message of type originalType. |
| originalType | The protobuf message type name (without the trailing *). |
Implements org.lflang.federated.serialization.FedSerialization.
◆ generatePortAssignmentCode()
| StringBuilder org.lflang.federated.serialization.FedProtoCSerialization.generatePortAssignmentCode |
( |
String | receiveRef | ) |
|
Generate code that hands ownership of the deserialized message to the LF runtime via a token, so that protobuf_c_message_free_unpacked is invoked when the token's reference count drops to zero.
◆ generatePreambleForSupport()
| StringBuilder org.lflang.federated.serialization.FedProtoCSerialization.generatePreambleForSupport |
( |
| ) |
|
◆ isCompatible()
| boolean org.lflang.federated.serialization.FedProtoCSerialization.isCompatible |
( |
GeneratorBase | generator | ) |
|
◆ protobufCFunctionPrefix()
| String org.lflang.federated.serialization.FedProtoCSerialization.protobufCFunctionPrefix |
( |
String | messageType | ) |
|
|
static |
Convert a protobuf message type name to the protobuf-c function prefix.
For example,
Person becomes person and ProtoHelloWorld becomes proto_hello_world.
◆ serializedBufferLength()
| String org.lflang.federated.serialization.FedProtoCSerialization.serializedBufferLength |
( |
| ) |
|
◆ serializedBufferVar()
| String org.lflang.federated.serialization.FedProtoCSerialization.serializedBufferVar |
( |
| ) |
|
◆ stripPointer()
| String org.lflang.federated.serialization.FedProtoCSerialization.stripPointer |
( |
String | type | ) |
|
|
static |
Strip trailing * characters from a C pointer type string.
◆ deserializedVarName
| final String org.lflang.federated.serialization.FedSerialization.deserializedVarName = "deserialized_message" |
|
staticinherited |
Variable name in the target language for the deserialized data.
◆ PROTOBUF_DESTRUCTOR_NAME
| final String org.lflang.federated.serialization.FedProtoCSerialization.PROTOBUF_DESTRUCTOR_NAME = "_lf_protobuf_destructor" |
|
static |
Name of the generated destructor that frees a heap-allocated protobuf-c message.
◆ serializedVarName
| final String org.lflang.federated.serialization.FedSerialization.serializedVarName = "serialized_message" |
|
staticinherited |
Variable name in the target language for the serialized data.
The documentation for this class was generated from the following file:
- /Users/runner/work/lingua-franca/lingua-franca/core/src/main/java/org/lflang/federated/serialization/FedProtoCSerialization.java