def parse_file_child(child, of_root):
    if child.spelling.startswith("of"):
        offilename = clang_utils.filenameFromClangChild(child)

        if clang_utils.is_class(child):
            i = 0
            for c in child.get_children():
                if clang_utils.is_variable(c) or clang_utils.is_method(c) or c.kind == CursorKind.CXX_BASE_SPECIFIER:
                    i += 1
            if i > 0 and child.spelling not in visited_classes:
                new_class = DocClass(child, of_root)
                add_class(new_class.serialize(), offilename, new_class.folder)
                visited_classes.append(child.spelling)
                # clang_reference.add_class(new_class)

        elif clang_utils.is_function(child):
            if child.spelling not in visited_function and offilename != "ofMain":
                visited_function.append(child.spelling)
                new_func = DocFunction(child, None, of_root)
                add_function(new_func.serialize(), offilename, new_func.folder)
                # clang_reference.add_function(new_func)

        elif clang_utils.is_enum(child):
            if child.spelling not in visited_enums:
                new_enum = DocEnum(child, of_root)
                add_enum(new_enum.serialize(), offilename, new_enum.folder)
                visited_enums.append(child.spelling)

        elif clang_utils.is_typedef(child):
            if child.spelling not in visited_typedefs:
                add_typedef(DocTypedef(child, of_root).serialize(), offilename)
                visited_typedefs.append(child.spelling)
    def __init__(self, cursor, of_root):
        DocBase.__init__(self, cursor, of_root)

        self.data['type'] = 'class'

        # Parse extends
        self.data['extends'] = []

        for child in cursor.get_children():
            if child.kind == CursorKind.CXX_BASE_SPECIFIER:
                if child.spelling.find("class") == 0:
                    baseclass = child.spelling.split(' ')[1]
                    self.data['extends'].append(baseclass)
                else:
                    self.data['extends'].append(child.spelling)

        # Parse member children
        self.member_variables = []
        self.member_functions = []

        for member in cursor.get_children():
            # Struct decleration
            # TODO
            if member.kind == CursorKind.CLASS_DECL or member.kind == CursorKind.CLASS_TEMPLATE or member.kind == CursorKind.STRUCT_DECL:
                if member.access_specifier.name.lower() == 'public':
                    for child in member.get_children():
                        if clang_utils.is_variable(child) or clang_utils.is_method(child):
                            #print "MEMBER"+member.spelling
                            """if classname[-1] == '_':
                                serialize_class(member,is_addon,classname[:-1])
                                visited_classes.append(classname[:-1] + "::" + member.spelling)
                            else:
                                serialize_class(member,is_addon,classname)
                                visited_classes.append(classname + "::" + member.spelling)
                            break"""

            # Union decleration
            # TODO
            elif member.kind == CursorKind.UNION_DECL:
                for union_member in member.get_children():
                    """
                    if clang_utils.is_variable(union_member):
                        #print "UNION "+union_member.spelling

                        #var = parse_variable(documentation_class, clazz, union_member)
                        #current_variables_list.append(var)
                    if union_member.kind == CursorKind.STRUCT_DECL:
                        for union_struct_member in union_member.get_children():
                            if clang_utils.is_variable(union_struct_member):
                                #print "UNION "+union_struct_member.spelling

                                #var = parse_variable(documentation_class, clazz, union_struct_member)
                                #current_variables_list.append(var)
                    """

            elif clang_utils.is_variable(member):
                if member.access_specifier.name.lower() == 'public':
                    var = DocVariable(member, self, of_root)
                    self.member_variables.append(var)

                #f.write( str(member.type.text) + " " + str(member.name.text) + "\n" )
            elif clang_utils.is_method(member):
                func = DocFunction(member, self, of_root)
                self.member_functions.append(func)
                """
Пример #3
0
    def __init__(self, cursor, of_root):
        DocBase.__init__(self, cursor, of_root)

        self.data['type'] = 'class'

        # Parse extends
        self.data['extends'] = []

        for child in cursor.get_children():
            if child.kind == CursorKind.CXX_BASE_SPECIFIER:
                if child.spelling.find("class") == 0:
                    baseclass = child.spelling.split(' ')[1]
                    self.data['extends'].append(baseclass)
                else:
                    self.data['extends'].append(child.spelling)

        # Parse member children
        self.member_variables = []
        self.member_functions = []

        for member in cursor.get_children():
            # Struct decleration
            # TODO
            if member.kind == CursorKind.CLASS_DECL or member.kind == CursorKind.CLASS_TEMPLATE or member.kind == CursorKind.STRUCT_DECL:
                if member.access_specifier.name.lower() == 'public':
                    for child in member.get_children():
                        if clang_utils.is_variable(
                                child) or clang_utils.is_method(child):
                            #print "MEMBER"+member.spelling
                            """if classname[-1] == '_':
                                serialize_class(member,is_addon,classname[:-1])
                                visited_classes.append(classname[:-1] + "::" + member.spelling)
                            else:
                                serialize_class(member,is_addon,classname)
                                visited_classes.append(classname + "::" + member.spelling)
                            break"""

            # Union decleration
            # TODO
            elif member.kind == CursorKind.UNION_DECL:
                for union_member in member.get_children():
                    """
                    if clang_utils.is_variable(union_member):
                        #print "UNION "+union_member.spelling

                        #var = parse_variable(documentation_class, clazz, union_member)
                        #current_variables_list.append(var)
                    if union_member.kind == CursorKind.STRUCT_DECL:
                        for union_struct_member in union_member.get_children():
                            if clang_utils.is_variable(union_struct_member):
                                #print "UNION "+union_struct_member.spelling

                                #var = parse_variable(documentation_class, clazz, union_struct_member)
                                #current_variables_list.append(var)
                    """

            elif clang_utils.is_variable(member):
                if member.access_specifier.name.lower() == 'public':
                    var = DocVariable(member, self, of_root)
                    self.member_variables.append(var)

                #f.write( str(member.type.text) + " " + str(member.name.text) + "\n" )
            elif clang_utils.is_method(member):
                func = DocFunction(member, self, of_root)
                self.member_functions.append(func)
                """