Python clang.cindex.CursorKind.ENUM_CONSTANT_DECL Examples

The following are 3 code examples of clang.cindex.CursorKind.ENUM_CONSTANT_DECL(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module clang.cindex.CursorKind , or try the search function .
Example #1
Source File: clang_exporter.py    From pigaios with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #2
Source File: parser.py    From pyopenvr with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def parse_enum(self, cursor):
        name = cursor.spelling
        enum = model.EnumDecl(name=name)
        for child in cursor.get_children():
            if child.kind == CursorKind.ENUM_CONSTANT_DECL:
                value1 = child.enum_value
                enum_const = model.EnumConstant(name=child.spelling, value=value1)
                enum.add_constant(enum_const)
            else:
                self.report_unparsed(child)
        self.items.append(enum) 
Example #3
Source File: libclang_parser.py    From AutoWIG with Apache License 2.0 4 votes vote down vote up
def read_enum(asg, cursor, scope):
    spelling = scope
    if spelling.startswith('class '):
        spelling = spelling[6:]
    elif spelling.startswith('struct '):
        spelling = spelling[7:]
    if not scope.endswith('::'):
        spelling = spelling + "::" + cursor.spelling
    else:
        spelling = spelling + cursor.spelling
    if cursor.spelling == '':
        children = []
        decls = []
        #if not spelling == '::':
        #    spelling = spelling[:-2]
        spelling = scope
        for child in cursor.get_children():
            if child.kind is CursorKind.ENUM_CONSTANT_DECL:
                children.extend(read_enum_constant(asg, child, spelling))
                decls.append(child)
        filename = str(Path(str(cursor.location.file)).abspath())
        asg.add_file(filename, proxy=HeaderProxy, _language=asg._language)
        for childspelling, child in zip(children, decls):
            asg._nodes[childspelling]['_header'] = filename
        read_access(asg, cursor.access_specifier, *children)
        return children
    else:
        spelling = 'enum ' + spelling
        if spelling not in asg:
            asg._syntax_edges[spelling] = []
            asg._nodes[spelling] = dict(_proxy = EnumerationProxy,
                                        _comment = "",
                                        _is_scoped = False) # TODO
            read_access(asg, cursor.access_specifier, spelling)
            asg._syntax_edges[scope].append(spelling)
        elif not asg[spelling].is_complete:
            asg._syntax_edges[scope].remove(spelling)
            asg._syntax_edges[scope].append(spelling)
        if not asg[spelling].is_complete:
            read_access(asg, cursor.access_specifier, spelling)
            for child in cursor.get_children():
                read_enum_constant(asg, child, spelling)
        if asg[spelling].is_complete:
            filename = str(Path(str(cursor.location.file)).abspath())
            asg.add_file(filename, proxy=HeaderProxy, _language=asg._language)
            asg._nodes[spelling]['_header'] = filename
        return [spelling]