Skip to content
Closed
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
14 changes: 11 additions & 3 deletions src/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ def calc_payload(self, payloads):

return int(total_size)

def escape_reserved(self, name):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed this because one of the new field names is "string" and ends up generating a string() function.

reserved = {"string"}
ret_name = name + "_" if name in reserved else name
print(f'current name {name}: new name {ret_name}')
return ret_name
def should_convert_atof_to_string(self, type):
return type in "atof_point_data"

def convert_short_type(self, t):
# u/i
ui = t[0]
Expand Down Expand Up @@ -108,11 +116,11 @@ def get_printf_format(self, t):
'uint16_t': 'PRIu16',
'uint32_t': 'PRIu32',
'uint64_t': 'PRIu64',
'float': 'f',
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously I didn't see the f or d specifiers used in existing stuff. but it looks like the single quotes get stripped away and then plain f doesn't get expanded properly. whereas PRIu32 is a macro that gets expanded.

'double': 'f',
'float': '"f"',
'double': '"f"',
}
t = self.get_type_string(t)
return format_dict.get(t, 'd')
return format_dict.get(t, '"d"')

def is_vector(self, t):
return ('vector' in t)
Expand Down