Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: added OVERRIDE_SIGNATURE #22

Merged
merged 1 commit into from
Oct 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions dronecan/dsdl/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ def get_dsdl_signature(self):
Computes DSDL signature of this type.
Please refer to the specification for details about signatures.
"""
if self.override_signature is not None:
return self.override_signature
return compute_signature(self.get_dsdl_signature_source_definition())

def get_normalized_definition(self):
Expand Down Expand Up @@ -641,6 +643,7 @@ def parse_source(self, filename, source_text):
fields, constants, resp_fields, resp_constants = [], [], [], []
union, resp_union = False, False
response_part = False
override_signature = None
for num, tokens in numbered_lines:
try:
if tokens == ['---']:
Expand All @@ -656,6 +659,11 @@ def parse_source(self, filename, source_text):
enforce(not union, 'Data structure has already been declared as union')
union = True
continue

if len(tokens) == 2 and tokens[0] == 'OVERRIDE_SIGNATURE':
override_signature = int(tokens[1],16)
continue

attr = self._parse_line(filename, tokens)
if attr.name and attr.name in all_attributes_names:
error('Duplicated attribute name [%s]', attr.name)
Expand All @@ -682,13 +690,15 @@ def parse_source(self, filename, source_text):
t.response_constants = resp_constants
t.request_union = union
t.response_union = resp_union
t.override_signature = override_signature
max_bitlen = t.get_max_bitlen_request(), t.get_max_bitlen_response()
max_bytelen = tuple(map(bitlen_to_bytelen, max_bitlen))
else:
t = CompoundType(full_typename, CompoundType.KIND_MESSAGE, filename, default_dtid, version, source_text)
t.fields = fields
t.constants = constants
t.union = union
t.override_signature = override_signature
max_bitlen = t.get_max_bitlen()
max_bytelen = bitlen_to_bytelen(max_bitlen)

Expand Down