Skip to content

Commit 187b6e1

Browse files
chris-smithIanTheEngineer
authored andcommitted
fix issue checking fixed size (#14)
1 parent 9f166c3 commit 187b6e1

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/gennodejs/generate.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def get_default_value(field, current_message_package):
137137
def is_message_fixed_size(spec, search_path):
138138
"""Check if a particular message specification has a constant size in bytes"""
139139
parsed_fields = spec.parsed_fields()
140-
types = [f.type for f in parsed_fields]
140+
types = [f.base_type for f in parsed_fields]
141141
variableLengthArrays = [f.is_array and not f.array_len for f in parsed_fields]
142142
isBuiltin = [f.is_builtin for f in parsed_fields]
143143
if 'string' in types:
@@ -169,19 +169,19 @@ def get_message_fixed_size(spec, search_path):
169169
if f.is_builtin:
170170
type_size = get_type_size(f.base_type)
171171
if type_size is None:
172-
raise Error('Field {} has a non-constant size'.format(f.base_type))
172+
raise Exception('Field {} has a non-constant size'.format(f.base_type))
173173
if not f.is_array:
174174
length += type_size
175175
elif not f.array_len:
176-
raise Error('Array field {} has a variable length'.format(f.base_type))
176+
raise Exception('Array field {} has a variable length'.format(f.base_type))
177177
else:
178178
length += (f.array_len * type_size)
179179
else:
180180
field_msg_context = MsgContext.create_default()
181181
field_spec = genmsg.msg_loader.load_msg_by_type(field_msg_context, f.base_type, search_path)
182182
field_size = get_message_fixed_size(field_spec, search_path)
183183
if field_size is None:
184-
raise Error('Field {} has a non-constant size'.format(f.base_type))
184+
raise Exception('Field {} has a non-constant size'.format(f.base_type))
185185
length += field_size
186186
return length
187187

@@ -556,7 +556,7 @@ def write_get_message_size(s, spec, search_path):
556556
def get_dynamic_field_length_line(field, query):
557557
if field.is_builtin:
558558
if not is_string(field.base_type):
559-
raise Error('Unexpected field {} with type {} has unknown length'.format(field.name, field.base_type))
559+
raise Exception('Unexpected field {} with type {} has unknown length'.format(field.name, field.base_type))
560560
# it's a string array!
561561
return 'length += 4 + {}.length;'.format(query)
562562
# else
@@ -595,7 +595,7 @@ def get_dynamic_field_length_line(field, query):
595595
else:
596596
if f.is_builtin:
597597
if not is_string(f.base_type):
598-
raise Error('Unexpected field {} with type {} has unknown length'.format(f.name, f.base_type))
598+
raise Exception('Unexpected field {} with type {} has unknown length'.format(f.name, f.base_type))
599599
# it's a string array!
600600
line_to_write = 'length += 4 + val.length;'
601601
else:
@@ -615,7 +615,7 @@ def get_dynamic_field_length_line(field, query):
615615
# field size is dynamic!
616616
if f.is_builtin:
617617
if not is_string(f.base_type):
618-
raise Error('Unexpected field {} with type {} has unknown length'.format(f.name, f.base_type))
618+
raise Exception('Unexpected field {} with type {} has unknown length'.format(f.name, f.base_type))
619619
# it's a string array!
620620
len_constant_length_fields += 4
621621
line_to_write = 'length += object.{}.length;'.format(f.name)

0 commit comments

Comments
 (0)