-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only serialize key when C function asks for a key
For some operations, the DDS API requires a key instead of a sample ("dispose" is one of those), and does this by invoking the "ddsi_serdata_from_sample" operation with kind set to "SDK_KEY". The Python binding is a bit unusual in that it serializes the data before calling into C because that allows using Python code to serialize the data without having to call back into Python code from C or being forced to interpret Python objects from C. A mismatch is possible, and this causes failures if the serialized form of the key is not a prefix of the serialized form of the full sample. For example: @DataClass class S(idl.IdlStruct, typename="S"): v: int k: int key("k") ih0 = dw.register_instance(S(0, 1)) Will misinterpret the bytes and treat the key value as 0 instead of as 1. It can be dealt with in two ways: * One is to continue always serializing a full sample in Python, fixing it up in the serdata implementation if a serialized key is requested. This is small change in the Python "clayer"; * The other is to serialize a key when a key is expected. This is somewhat fragile, but the list of operations is small and the API rather stable. This commit implements the second option, and mostly because it means the serializer will not touch the non-key fields. Signed-off-by: Erik Boasson <[email protected]>
- Loading branch information
Showing
4 changed files
with
29 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters