def sort_arg(one, other): assert isinstance(one, cpp_types.FunctionArgument) assert isinstance(other, cpp_types.FunctionArgument) if type_traits.is_integer_type(one.type_): return -1 if type_traits.is_integer_type(other.type_): return 1 if type_traits.is_real_number_type(one.type_): return -1 if type_traits.is_real_number_type(other.type_): return 1 if type_traits.is_string_type(one.type_): return -1 if type_traits.is_string_type(other.type_): return 1 return 0
def get_arguments_declaration(function): assert isinstance(function, cpp_types.SimpleFunction) fmt = '%s %s;' declarations = [] for idx, arg in enumerate([ function.parent.arguments[idx] for idx in xrange(0, function.argc) ]): arg_name = get_argument_name(arg, idx) if type_traits.is_string_type(arg.type_): cpp_type = 'std::string' else: cpp_type = arg.type_.cpp_type declarations.append (fmt % (cpp_type, arg_name)) if function.parent.proto.kind == cpp_types.FunctionKind.ClassMemberMethod: if function.parent.is_const: class_ptr_decl = 'const %s * __class_ptr;' % function.parent.proto.fully_qualified_valid_variable_prefix else: class_ptr_decl = '%s * __class_ptr;' % function.parent.proto.fully_qualified_valid_variable_prefix declarations.append (class_ptr_decl) return os.linesep.join(declarations)