@@ -27,7 +27,7 @@ from templates import helper as th
27
27
% if iname == " pNext" :
28
28
${ x} _params::serializeStruct(os, ${ caller.body()} );
29
29
% elif th.type_traits.is_flags(itype):
30
- ${ x} _params::serializeFlag_ ${ itype} (os, ${ caller.body()} );
30
+ ${ x} _params::serializeFlag< ${ th.type_traits.get_flag_type( itype) } > (os, ${ caller.body()} );
31
31
% elif not loop and th.type_traits.is_pointer(itype):
32
32
${ x} _params::serializePtr(os, ${ caller.body()} );
33
33
% elif loop and th.type_traits.is_pointer_to_pointer(itype):
@@ -57,7 +57,7 @@ from templates import helper as th
57
57
%endif
58
58
## can't iterate over 'void *'...
59
59
% if th.param_traits.is_range(item) and " void*" not in itype:
60
- os << ".${ iname} = [ ";
60
+ os << ".${ iname} = { ";
61
61
for (size_t i = ${ th.param_traits.range_start(item)} ; ${ deref} (params${ access}${ pname} ) != NULL && i < ${ deref} params${ access}${ prefix + th.param_traits.range_end(item)} ; ++i) {
62
62
if (i != 0) {
63
63
os << ", ";
@@ -66,10 +66,10 @@ from templates import helper as th
66
66
(${ deref} (params${ access}${ pname} ))[i]
67
67
</%call >
68
68
}
69
- os << "] ";
69
+ os << "} ";
70
70
% elif typename is not None :
71
71
os << ".${ iname} = ";
72
- ${ x} _params::serializeTaggedTyped_ ${ underlying_type } (os, ${ deref} (params${ access}${ pname} ), ${ deref} (params${ access}${ prefix}${ typename} ), ${ deref} (params${ access}${ prefix}${ typename_size} ));
72
+ ${ x} _params::serializeTagged (os, ${ deref} (params${ access}${ pname} ), ${ deref} (params${ access}${ prefix}${ typename} ), ${ deref} (params${ access}${ prefix}${ typename_size} ));
73
73
% else :
74
74
os << ".${ iname} = ";
75
75
<%call expr = "member(iname, itype, False )">
@@ -80,19 +80,23 @@ from templates import helper as th
80
80
81
81
namespace ${ x} _params {
82
82
template <typename T > inline void serializePtr(std::ostream &os, T *ptr);
83
+ template <typename T > inline void serializeFlag(std::ostream &os, uint32_t flag);
84
+ template <typename T > inline void serializeTagged(std::ostream &os, const void *ptr, T value, size_t size);
83
85
84
86
% for spec in specs:
85
87
% for obj in spec[' objects' ]:
86
88
## ENUM #######################################################################
87
89
% if re.match(r " enum" , obj[' type' ]):
88
90
% if obj.get(' typed_etors' , False ) is True :
89
- inline void serializeTaggedTyped_ ${ th.make_enum_name(n, tags, obj) } ( std::ostream &os, const void *ptr, enum ${ th.make_enum_name(n, tags, obj)} value, size_t size);
91
+ template <> inline void serializeTagged( std::ostream &os, const void *ptr, ${ th.make_enum_name(n, tags, obj)} value, size_t size);
90
92
% elif " structure_type" in obj[' name' ]:
91
93
inline void serializeStruct(std::ostream &os, const void *ptr);
92
94
%endif
93
95
%endif
96
+
97
+
94
98
% if th.type_traits.is_flags(obj[' name' ]):
95
- inline void serializeFlag_ ${ th.make_type_name (n, tags, obj)} (std::ostream &os, ${ th.make_type_name(n, tags, obj) } flag);
99
+ template <> inline void serializeFlag< ${ th.make_enum_name (n, tags, obj)} > (std::ostream &os, uint32_t flag);
96
100
%endif
97
101
%endfor # obj in spec['objects']
98
102
%endfor
@@ -138,7 +142,8 @@ template <typename T> inline void serializePtr(std::ostream &os, T *ptr);
138
142
%endif
139
143
% if obj.get(' typed_etors' , False ) is True :
140
144
namespace ${ x} _params {
141
- inline void serializeTaggedTyped_${ th.make_enum_name(n, tags, obj)} (std::ostream &os, const void *ptr, enum ${ th.make_enum_name(n, tags, obj)} value, size_t size) {
145
+ template <>
146
+ inline void serializeTagged(std::ostream &os, const void *ptr, ${ th.make_enum_name(n, tags, obj)} value, size_t size) {
142
147
if (ptr == NULL) {
143
148
serializePtr(os, ptr);
144
149
return;
@@ -157,7 +162,7 @@ template <typename T> inline void serializePtr(std::ostream &os, T *ptr);
157
162
% if " char" in atype: # # print char* arrays as simple NULL-terminated strings
158
163
serializePtr(os, tptr);
159
164
% else :
160
- os << "[ ";
165
+ os << "{ ";
161
166
size_t nelems = size / sizeof(${ atype} );
162
167
for (size_t i = 0; i < nelems; ++i) {
163
168
if (i != 0) {
@@ -167,7 +172,7 @@ template <typename T> inline void serializePtr(std::ostream &os, T *ptr);
167
172
tptr[i]
168
173
</%call >
169
174
}
170
- os << "] ";
175
+ os << "} ";
171
176
%endif
172
177
% else :
173
178
const ${ vtype} *tptr = (const ${ vtype} *)ptr;
@@ -218,7 +223,9 @@ template <typename T> inline void serializePtr(std::ostream &os, T *ptr);
218
223
%endif
219
224
% if th.type_traits.is_flags(obj[' name' ]):
220
225
namespace ${ x} _params {
221
- inline void serializeFlag_${ th.make_type_name(n, tags, obj)} (std::ostream &os, ${ th.make_type_name(n, tags, obj)} flag) {
226
+
227
+ template<>
228
+ inline void serializeFlag<${ th.make_enum_name(n, tags, obj)} >(std::ostream &os, uint32_t flag) {
222
229
uint32_t val = flag;
223
230
bool first = true;
224
231
% for n, item in enumerate (obj[' etors' ]):
0 commit comments