Skip to content

Commit

Permalink
generator: Add get_printf_format
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <[email protected]>
  • Loading branch information
patrickelectric committed Jan 20, 2025
1 parent 85a7559 commit ef8e5a8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ def get_type_string(self, t, pointer=False, name=''):

return s

def get_printf_format(self, t):
format_dict = {
'int8_t': 'PRId8',
'int16_t': 'PRId16',
'int32_t': 'PRId32',
'int64_t': 'PRId64',
'uint8_t': 'PRIu8',
'uint16_t': 'PRIu16',
'uint32_t': 'PRIu32',
'uint64_t': 'PRIu64',
'float': 'f',
'double': 'f',
}
t = self.get_type_string(t)
return format_dict.get(t, 'd')

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

Expand Down

0 comments on commit ef8e5a8

Please sign in to comment.