Ejemplo n.º 1
0
def add_casts(data, scope, classname, detail_namespace):
    function = cpp_file_parser.get_function_from_text(classname, 'target', 'return ',
                                                      code.get_cast(data, classname, detail_namespace, ''),
                                                      cpp.FUNCTION_TEMPLATE)
    comment = code.get_handle_cast_comment(function.get_declaration())
    scope.add(cpp.Comment(comment))
    scope.add(function)

    function = cpp_file_parser.get_function_from_text(classname, 'target', 'return ',
                                                      code.get_cast(data, classname, detail_namespace, 'const'),
                                                      cpp.FUNCTION_TEMPLATE)
    comment = code.get_handle_cast_comment(function.get_declaration(), 'const')
    scope.add(cpp.Comment(comment))
    scope.add(function)
def add_operators(data, scope, classname, detail_namespace):
    # assignment operators
    scope.add(
        cpp_file_parser.get_function_from_text(
            classname, 'operator=', 'return ',
            code.get_assignment_from_value(data, classname, detail_namespace),
            cpp.FUNCTION_TEMPLATE))

    if not data.copy_on_write:
        if not data.non_copyable:
            scope.add(
                cpp_file_parser.get_function_from_text(
                    classname, 'operator=', 'return ',
                    code.get_copy_operator(data, classname)))

        scope.add(
            cpp_file_parser.get_function_from_text(
                classname, 'operator=', 'return ',
                code.get_move_operator(data, classname)))

    # operator bool
    function = cpp_file_parser.get_function_from_text(
        classname, 'operator bool', 'return ',
        code.get_operator_bool_for_member_ptr(data.impl_member))
    comment = code.get_operator_bool_comment(function.get_declaration())
    scope.add(cpp.Comment(comment))
    scope.add(function)
def add_comment(new_content, entry, comments):
    comment = util.get_comment(comments, entry)
    if comment:
        new_content.append(cpp.Comment(comment))