@@ -18,24 +18,24 @@ from templates import helper as th
18
18
* @file ${ name} .hpp
19
19
*
20
20
*/
21
- # ifndef ${X}_PARAMS_HPP
22
- # define ${X}_PARAMS_HPP 1
21
+ # ifndef ${X}_PRINT_HPP
22
+ # define ${X}_PRINT_HPP 1
23
23
24
24
# include "${x}_api.h"
25
25
# include <ostream>
26
26
# include <bitset>
27
27
28
28
<%def name = "member(iname , itype , loop ) ">
29
29
% if iname == " pNext" :
30
- ${ x} _params::serializeStruct (os, ${ caller.body()} );
30
+ ${ x} _print::printStruct (os, ${ caller.body()} );
31
31
% elif th.type_traits.is_flags(itype):
32
- ${ x} _params::serializeFlag <${ th.type_traits.get_flag_type(itype)} >(os, ${ caller.body()} );
32
+ ${ x} _print::printFlag <${ th.type_traits.get_flag_type(itype)} >(os, ${ caller.body()} );
33
33
% elif not loop and th.type_traits.is_pointer(itype):
34
- ${ x} _params::serializePtr (os, ${ caller.body()} );
34
+ ${ x} _print::printPtr (os, ${ caller.body()} );
35
35
% elif loop and th.type_traits.is_pointer_to_pointer(itype):
36
- ${ x} _params::serializePtr (os, ${ caller.body()} );
36
+ ${ x} _print::printPtr (os, ${ caller.body()} );
37
37
% elif th.type_traits.is_handle(itype):
38
- ${ x} _params::serializePtr (os, ${ caller.body()} );
38
+ ${ x} _print::printPtr (os, ${ caller.body()} );
39
39
% elif iname and iname.startswith(" pfn" ):
40
40
os << reinterpret_cast<void * >(${ caller.body()} );
41
41
% else :
@@ -83,7 +83,7 @@ def findMemberType(_item):
83
83
os << "}";
84
84
% elif findMemberType(item) is not None and findMemberType(item)[' type' ] == " union" :
85
85
os << ".${ iname} = ";
86
- ${ x} _params::serializeUnion (os, ${ deref} (params${ access}${ item[' name' ]} ), params${ access}${ th.param_traits.tagged_member(item)} );
86
+ ${ x} _print::printUnion (os, ${ deref} (params${ access}${ item[' name' ]} ), params${ access}${ th.param_traits.tagged_member(item)} );
87
87
% elif th.type_traits.is_array(item[' type' ]):
88
88
os << ".${ iname} = {";
89
89
for(auto i = 0; i < ${ th.type_traits.get_array_length(item[' type' ])} ; i++){
@@ -97,7 +97,7 @@ def findMemberType(_item):
97
97
os << "}";
98
98
% elif typename is not None :
99
99
os << ".${ iname} = ";
100
- ${ x} _params::serializeTagged (os, ${ deref} (params${ access}${ pname} ), ${ deref} (params${ access}${ prefix}${ typename} ), ${ deref} (params${ access}${ prefix}${ typename_size} ));
100
+ ${ x} _print::printTagged (os, ${ deref} (params${ access}${ pname} ), ${ deref} (params${ access}${ prefix}${ typename} ), ${ deref} (params${ access}${ prefix}${ typename_size} ));
101
101
% else :
102
102
os << ".${ iname} = ";
103
103
<%call expr = "member(iname, itype, False )">
@@ -106,7 +106,7 @@ def findMemberType(_item):
106
106
%endif
107
107
</%def >
108
108
109
- namespace ${ x} _params {
109
+ namespace ${ x} _print {
110
110
template <typename T > struct is_handle : std::false_type {};
111
111
% for spec in specs:
112
112
% for obj in spec[' objects' ]:
@@ -117,24 +117,24 @@ template <> struct is_handle<${th.make_type_name(n, tags, obj)}> : std::true_typ
117
117
%endfor
118
118
template <typename T >
119
119
inline constexpr bool is_handle_v = is_handle<T >::value;
120
- template <typename T > inline void serializePtr (std::ostream &os, const T *ptr);
121
- template <typename T > inline void serializeFlag (std::ostream &os, uint32_t flag);
122
- template <typename T > inline void serializeTagged (std::ostream &os, const void *ptr, T value, size_t size);
120
+ template <typename T > inline void printPtr (std::ostream &os, const T *ptr);
121
+ template <typename T > inline void printFlag (std::ostream &os, uint32_t flag);
122
+ template <typename T > inline void printTagged (std::ostream &os, const void *ptr, T value, size_t size);
123
123
124
124
% for spec in specs:
125
125
% for obj in spec[' objects' ]:
126
126
## ENUM #######################################################################
127
127
% if re.match(r " enum" , obj[' type' ]):
128
128
% if obj.get(' typed_etors' , False ) is True :
129
- template <> inline void serializeTagged (std::ostream &os, const void *ptr, ${ th.make_enum_name(n, tags, obj)} value, size_t size);
129
+ template <> inline void printTagged (std::ostream &os, const void *ptr, ${ th.make_enum_name(n, tags, obj)} value, size_t size);
130
130
% elif " structure_type" in obj[' name' ]:
131
- inline void serializeStruct (std::ostream &os, const void *ptr);
131
+ inline void printStruct (std::ostream &os, const void *ptr);
132
132
%endif
133
133
%endif
134
134
135
135
% if re.match(r " union" , obj[' type' ]) and obj[' name' ]:
136
136
<% tag = [_obj for _s in specs for _obj in _s[' objects' ] if _obj[' name' ] == obj[' tag' ]][0 ] %>
137
- inline void serializeUnion (
137
+ inline void printUnion (
138
138
std::ostream &os,
139
139
const ${ obj[' type' ]} ${ th.make_type_name(n, tags, obj)} params,
140
140
const ${ tag[' type' ]} ${ th.make_type_name(n, tags, tag)} tag
@@ -143,11 +143,11 @@ template <typename T> inline void serializeTagged(std::ostream &os, const void *
143
143
144
144
145
145
% if th.type_traits.is_flags(obj[' name' ]):
146
- template<> inline void serializeFlag <${ th.make_enum_name(n, tags, obj)} >(std::ostream &os, uint32_t flag);
146
+ template<> inline void printFlag <${ th.make_enum_name(n, tags, obj)} >(std::ostream &os, uint32_t flag);
147
147
%endif
148
148
%endfor # obj in spec['objects']
149
149
%endfor
150
- } // namespace ${ x} _params
150
+ } // namespace ${ x} _print
151
151
152
152
% for spec in specs:
153
153
% for obj in spec[' objects' ]:
@@ -188,11 +188,11 @@ template <typename T> inline void serializeTagged(std::ostream &os, const void *
188
188
}
189
189
%endif
190
190
% if obj.get(' typed_etors' , False ) is True :
191
- namespace ${ x} _params {
191
+ namespace ${ x} _print {
192
192
template <>
193
- inline void serializeTagged (std::ostream &os, const void *ptr, ${ th.make_enum_name(n, tags, obj)} value, size_t size) {
193
+ inline void printTagged (std::ostream &os, const void *ptr, ${ th.make_enum_name(n, tags, obj)} value, size_t size) {
194
194
if (ptr == NULL) {
195
- serializePtr (os, ptr);
195
+ printPtr (os, ptr);
196
196
return;
197
197
}
198
198
@@ -211,7 +211,7 @@ template <typename T> inline void serializeTagged(std::ostream &os, const void *
211
211
const ${ atype} *tptr = (const ${ atype} *)ptr;
212
212
%endif
213
213
% if " char" in atype: # # print char* arrays as simple NULL-terminated strings
214
- serializePtr (os, tptr);
214
+ printPtr (os, tptr);
215
215
% else :
216
216
os << "{";
217
217
size_t nelems = size / sizeof(${ atype} );
@@ -250,10 +250,10 @@ template <typename T> inline void serializeTagged(std::ostream &os, const void *
250
250
}
251
251
}
252
252
% elif " structure_type" in obj[' name' ]:
253
- namespace ${ x} _params {
254
- inline void serializeStruct (std::ostream &os, const void *ptr) {
253
+ namespace ${ x} _print {
254
+ inline void printStruct (std::ostream &os, const void *ptr) {
255
255
if (ptr == NULL) {
256
- ${ x} _params::serializePtr (os, ptr);
256
+ ${ x} _print::printPtr (os, ptr);
257
257
return;
258
258
}
259
259
@@ -266,21 +266,21 @@ template <typename T> inline void serializeTagged(std::ostream &os, const void *
266
266
%>
267
267
case ${ ename} : {
268
268
const ${ th.subt(n, tags, item[' desc' ])} *pstruct = (const ${ th.subt(n, tags, item[' desc' ])} *)ptr;
269
- ${ x} _params::serializePtr (os, pstruct);
269
+ ${ x} _print::printPtr (os, pstruct);
270
270
} break;
271
271
%endfor
272
272
default:
273
273
os << "unknown enumerator";
274
274
break;
275
275
}
276
276
}
277
- } // namespace ${ x} _params
277
+ } // namespace ${ x} _print
278
278
%endif
279
279
% if th.type_traits.is_flags(obj[' name' ]):
280
- namespace ${ x} _params {
280
+ namespace ${ x} _print {
281
281
282
282
template<>
283
- inline void serializeFlag <${ th.make_enum_name(n, tags, obj)} >(std::ostream &os, uint32_t flag) {
283
+ inline void printFlag <${ th.make_enum_name(n, tags, obj)} >(std::ostream &os, uint32_t flag) {
284
284
uint32_t val = flag;
285
285
bool first = true;
286
286
% for n, item in enumerate (obj[' etors' ]):
@@ -310,7 +310,7 @@ inline void serializeFlag<${th.make_enum_name(n, tags, obj)}>(std::ostream &os,
310
310
os << "0";
311
311
}
312
312
}
313
- } // namespace ${ x} _params
313
+ } // namespace ${ x} _print
314
314
%endif
315
315
## STRUCT/UNION ###############################################################
316
316
% elif re.match(r " struct" , obj[' type' ]):
@@ -332,7 +332,7 @@ inline std::ostream &operator<<(std::ostream &os, const ${obj['type']} ${th.make
332
332
}
333
333
% elif re.match(r " union" , obj[' type' ]) and obj[' name' ]:
334
334
<% tag = findUnionTag(obj) %>
335
- inline void ${ x} _params::serializeUnion (
335
+ inline void ${ x} _print::printUnion (
336
336
std::ostream &os,
337
337
const ${ obj[' type' ]} ${ th.make_type_name(n, tags, obj)} params,
338
338
const ${ tag[' type' ]} ${ th.make_type_name(n, tags, tag)} tag
@@ -381,14 +381,14 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
381
381
%endfor
382
382
%endfor
383
383
384
- namespace ${ x} _params {
384
+ namespace ${ x} _print {
385
385
386
- template <typename T > inline void serializePtr (std::ostream &os, const T *ptr) {
386
+ template <typename T > inline void printPtr (std::ostream &os, const T *ptr) {
387
387
if (ptr == nullptr) {
388
388
os << "nullptr";
389
389
} else if constexpr (std::is_pointer_v<T >) {
390
390
os << (const void *)(ptr) << " (";
391
- serializePtr (os, *ptr);
391
+ printPtr (os, *ptr);
392
392
os << ")";
393
393
} else if constexpr (std::is_void_v<T > || is_handle_v<T * >) {
394
394
os << (const void *)ptr;
@@ -403,7 +403,7 @@ template <typename T> inline void serializePtr(std::ostream &os, const T *ptr) {
403
403
}
404
404
}
405
405
406
- inline int serializeFunctionParams (std::ostream &os, uint32_t function, const void *params) {
406
+ inline int printFunctionParams (std::ostream &os, uint32_t function, const void *params) {
407
407
switch((enum ${ x} _function_t)function) {
408
408
% for tbl in th.get_pfncbtables(specs, meta, n, tags):
409
409
% for obj in tbl[' functions' ]:
@@ -416,6 +416,6 @@ inline int serializeFunctionParams(std::ostream &os, uint32_t function, const vo
416
416
}
417
417
return 0;
418
418
}
419
- } // namespace ur_params
419
+ } // namespace ur_print
420
420
421
- # endif /* ${X}_PARAMS_HPP */
421
+ # endif /* ${X}_PRINT_HPP */
0 commit comments