52 function_type = (ast.FUNCTION_VIRTUAL | ast.FUNCTION_PURE_VIRTUAL |
53 ast.FUNCTION_OVERRIDE)
54 ctor_or_dtor = ast.FUNCTION_CTOR | ast.FUNCTION_DTOR
55 indent =
' ' * _INDENT
57 for node
in class_node.body:
60 node.modifiers & function_type
and 61 not node.modifiers & ctor_or_dtor):
64 if node.modifiers & ast.FUNCTION_CONST:
70 if node.return_type.modifiers:
71 modifiers =
' '.
join(node.return_type.modifiers) +
' ' 72 return_type = modifiers + node.return_type.name
73 template_args = [arg.name
for arg
in node.return_type.templated_types]
75 return_type +=
'<' +
', '.
join(template_args) +
'>' 76 if len(template_args) > 1:
78 '// The following line won\'t really compile, as the return',
79 '// type has multiple template arguments. To fix it, use a',
80 '// typedef for the return type.']:
81 output_lines.append(indent + line)
82 if node.return_type.pointer:
84 if node.return_type.reference:
86 num_parameters = len(node.parameters)
87 if len(node.parameters) == 1:
88 first_param = node.parameters[0]
89 if source[first_param.start:first_param.end].
strip() ==
'void':
93 if class_node.templated_types:
95 mock_method_macro =
'MOCK_%sMETHOD%d%s' % (const, num_parameters, tmpl)
106 if len([param
for param
in node.parameters
if param.default]) > 0:
107 args =
', '.
join(param.type.name
for param
in node.parameters)
111 start = node.parameters[0].start
112 end = node.parameters[-1].end
114 args_strings = re.sub(
r'//.*',
'', source[start:end])
119 args = re.sub(
' +',
' ', args_strings.replace(
'\n',
' '))
122 output_lines.extend([
'%s%s(%s,' % (indent, mock_method_macro, node.name),
123 '%s%s(%s));' % (indent*3, return_type, args)])
std::uint64_t strip(std::chrono::nanoseconds t)
def _GenerateMethods(output_lines, source, class_node)