當前位置: 首頁>>代碼示例>>Python>>正文


Python CursorKind.STRUCT_DECL屬性代碼示例

本文整理匯總了Python中clang.cindex.CursorKind.STRUCT_DECL屬性的典型用法代碼示例。如果您正苦於以下問題:Python CursorKind.STRUCT_DECL屬性的具體用法?Python CursorKind.STRUCT_DECL怎麽用?Python CursorKind.STRUCT_DECL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在clang.cindex.CursorKind的用法示例。


在下文中一共展示了CursorKind.STRUCT_DECL屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: read_qualified_type

# 需要導入模塊: from clang.cindex import CursorKind [as 別名]
# 或者: from clang.cindex.CursorKind import STRUCT_DECL [as 別名]
def read_qualified_type(asg, qtype):
    specifiers = ''
    while True:
        if qtype.is_const_qualified() and not specifiers.startswith(' const'):
            specifiers = ' const' + specifiers
        if qtype.is_volatile_qualified() and not specifiers.startswith(' volatile'):
            specifiers = ' volatile' + specifiers
        if qtype.kind is TypeKind.POINTER:
            specifiers = ' *' + specifiers
            qtype = qtype.get_pointee()
        elif qtype.kind is TypeKind.LVALUEREFERENCE:
            specifiers = ' &' + specifiers
            qtype = qtype.get_pointee()
        elif qtype.kind is TypeKind.RVALUEREFERENCE:
            specifiers = ' &&' + specifiers
            qtype = qtype.get_pointee()
        elif qtype.kind in [TypeKind.RECORD, TypeKind.TYPEDEF, TypeKind.ENUM, TypeKind.UNEXPOSED]:
            cursor = qtype.get_declaration()
            if cursor.kind is CursorKind.TYPEDEF_DECL:
                qtype = cursor.underlying_typedef_type
            else:
                spelling = '::' + cursor.type.spelling
                if cursor.kind is CursorKind.ENUM_DECL:
                    spelling = 'enum ' + spelling
                elif cursor.kind is CursorKind.STRUCT_DECL:
                    spelling = 'struct ' + spelling
                elif cursor.kind is CursorKind.UNION_DECL:
                    spelling = 'union ' + spelling
                elif cursor.kind is CursorKind.CLASS_DECL:
                    spelling = 'class ' + spelling
                try:
                    if spelling == '::':
                        raise Exception
                    return asg[spelling]._node, specifiers
                except:
                    warnings.warn('record not found')
        else:
            target = read_builtin_type(asg, qtype)
            return target, specifiers 
開發者ID:StatisKit,項目名稱:AutoWIG,代碼行數:41,代碼來源:libclang_parser.py

示例2: read_cursor

# 需要導入模塊: from clang.cindex import CursorKind [as 別名]
# 或者: from clang.cindex.CursorKind import STRUCT_DECL [as 別名]
def read_cursor(asg, cursor, scope):
    if cursor.kind is CursorKind.UNEXPOSED_DECL:
        if cursor.spelling == '':
            children = []
            for child in cursor.get_children():
                children.extend(read_cursor(asg, child, scope))
            return children
        else:
            warnings.warn('Named unexposed cursor not read')
            return []
    elif cursor.kind is CursorKind.TYPEDEF_DECL:
        return read_typedef(asg, cursor, scope)
    elif cursor.kind in [CursorKind.VAR_DECL, CursorKind.PARM_DECL]:
        return read_variable(asg, cursor, scope)
    elif cursor.kind in [CursorKind.FUNCTION_DECL, CursorKind.CXX_METHOD,
            CursorKind.DESTRUCTOR, CursorKind.CONSTRUCTOR]:
        return read_function(asg, cursor, scope)
    elif cursor.kind is CursorKind.FIELD_DECL:
        return read_field(asg, cursor, scope)
    elif cursor.kind in [CursorKind.ENUM_DECL, CursorKind.STRUCT_DECL,
            CursorKind.UNION_DECL, CursorKind.CLASS_DECL]:
        return read_tag(asg, cursor, scope)
    elif cursor.kind is CursorKind.NAMESPACE:
        return read_namespace(asg, cursor, scope)
    elif cursor.kind in [CursorKind.NAMESPACE_ALIAS, CursorKind.FUNCTION_TEMPLATE,
            CursorKind.USING_DECLARATION, CursorKind.USING_DIRECTIVE,
            CursorKind.UNEXPOSED_ATTR, CursorKind.CLASS_TEMPLATE,
            CursorKind.CLASS_TEMPLATE_PARTIAL_SPECIALIZATION,
            CursorKind.CXX_ACCESS_SPEC_DECL, CursorKind.CONVERSION_FUNCTION]:
        return []
    else:
        warnings.warn('Undefined behaviour for \'' + str(cursor.kind) + '\' cursor')
        return [] 
開發者ID:StatisKit,項目名稱:AutoWIG,代碼行數:35,代碼來源:libclang_parser.py

示例3: element2kind

# 需要導入模塊: from clang.cindex import CursorKind [as 別名]
# 或者: from clang.cindex.CursorKind import STRUCT_DECL [as 別名]
def element2kind(self, element):
    if element.kind == CursorKind.STRUCT_DECL:
      return "struct"
    elif element.kind == CursorKind.ENUM_DECL:
      return "enum"
    elif element.kind == CursorKind.UNION_DECL:
      return "union"
    elif element.kind == CursorKind.TYPEDEF_DECL:
      return "typedef"
    elif element.kind == CursorKind.ENUM_CONSTANT_DECL:
      return ""
    else:
      return "" # Unknown thing 
開發者ID:joxeankoret,項目名稱:pigaios,代碼行數:15,代碼來源:clang_exporter.py

示例4: parse_namespace

# 需要導入模塊: from clang.cindex import CursorKind [as 別名]
# 或者: from clang.cindex.CursorKind import STRUCT_DECL [as 別名]
def parse_namespace(self, cursor):
        assert str(cursor.spelling) == 'vr'
        for child in cursor.get_children():
            if child.kind == CursorKind.VAR_DECL:
                self.parse_var_decl(child)
            elif child.kind == CursorKind.TYPEDEF_DECL:
                self.parse_typedef(child)
            elif child.kind == CursorKind.STRUCT_DECL:
                self.items.append(self.parse_struct(child))
            elif child.kind == CursorKind.UNION_DECL:
                union = self.parse_struct(child)
                union.base = 'Union'
                self.items.append(union)
            elif child.kind == CursorKind.ENUM_DECL:
                self.parse_enum(child)
            elif child.kind == CursorKind.FUNCTION_DECL:
                self.parse_function(child)
            elif child.kind == CursorKind.UNEXPOSED_DECL:
                self.parse_unexposed_decl(child)
            elif child.kind == CursorKind.CLASS_DECL:
                if child.spelling.startswith('IVR'):
                    self.items.append(self.parse_ivrclass(child))
                elif child.spelling.startswith('COpenVRContext'):
                    self.items.append(self.parse_copenvrcontext(child))
                else:
                    print(f'*** WARNING *** skipping class {child.spelling}(...)')
            elif child.kind == CursorKind.CXX_METHOD:
                cn = child.semantic_parent.spelling
                mn = child.spelling
                if cn == 'COpenVRContext' and mn == 'Clear':
                    pass  # OK - we manually wrap this one
                else:
                    print(f'*** WARNING *** skipping class method implementation {child.spelling}(...)')
            else:
                self.report_unparsed(child) 
開發者ID:cmbruns,項目名稱:pyopenvr,代碼行數:37,代碼來源:parser.py

示例5: parse_translation_unit

# 需要導入模塊: from clang.cindex import CursorKind [as 別名]
# 或者: from clang.cindex.CursorKind import STRUCT_DECL [as 別名]
def parse_translation_unit(self, cursor):
        tu_file_name = str(cursor.spelling)
        for child in cursor.get_children():
            # Skip external declarations
            child_file_name = str(child.location.file)
            if not child_file_name == tu_file_name:
                continue
            if child.kind == CursorKind.STRUCT_DECL:
                # Parse forward declarations
                self.parse_struct_decl(child)
            elif child.kind == CursorKind.NAMESPACE:
                self.parse_namespace(child)
            else:
                self.report_unparsed(child) 
開發者ID:cmbruns,項目名稱:pyopenvr,代碼行數:16,代碼來源:parser.py


注:本文中的clang.cindex.CursorKind.STRUCT_DECL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。