Skip to content

Commit ef8e5a8

Browse files
generator: Add get_printf_format
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
1 parent 85a7559 commit ef8e5a8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/generator.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,22 @@ def get_type_string(self, t, pointer=False, name=''):
9898

9999
return s
100100

101+
def get_printf_format(self, t):
102+
format_dict = {
103+
'int8_t': 'PRId8',
104+
'int16_t': 'PRId16',
105+
'int32_t': 'PRId32',
106+
'int64_t': 'PRId64',
107+
'uint8_t': 'PRIu8',
108+
'uint16_t': 'PRIu16',
109+
'uint32_t': 'PRIu32',
110+
'uint64_t': 'PRIu64',
111+
'float': 'f',
112+
'double': 'f',
113+
}
114+
t = self.get_type_string(t)
115+
return format_dict.get(t, 'd')
116+
101117
def is_vector(self, t):
102118
return ('vector' in t)
103119

0 commit comments

Comments
 (0)