当前位置: 首页>>代码示例>>Python>>正文


Python CursorKind.FUNCTION_DECL属性代码示例

本文整理汇总了Python中clang.cindex.CursorKind.FUNCTION_DECL属性的典型用法代码示例。如果您正苦于以下问题:Python CursorKind.FUNCTION_DECL属性的具体用法?Python CursorKind.FUNCTION_DECL怎么用?Python CursorKind.FUNCTION_DECL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在clang.cindex.CursorKind的用法示例。


在下文中一共展示了CursorKind.FUNCTION_DECL属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: show_info

# 需要导入模块: from clang.cindex import CursorKind [as 别名]
# 或者: from clang.cindex.CursorKind import FUNCTION_DECL [as 别名]
def show_info(node, xfiles, xprefs, cur_fun=None):
    if node.kind == CursorKind.FUNCTION_TEMPLATE:
        if not is_excluded(node, xfiles, xprefs):
            cur_fun = node
            FULLNAMES[fully_qualified(cur_fun)].add(
                fully_qualified_pretty(cur_fun))

    if node.kind == CursorKind.CXX_METHOD or \
            node.kind == CursorKind.FUNCTION_DECL:
        if not is_excluded(node, xfiles, xprefs):
            cur_fun = node
            FULLNAMES[fully_qualified(cur_fun)].add(
                fully_qualified_pretty(cur_fun))

    if node.kind == CursorKind.CALL_EXPR:
        if node.referenced and not is_excluded(node.referenced, xfiles, xprefs):
            CALLGRAPH[fully_qualified_pretty(cur_fun)].append(node.referenced)

    for c in node.get_children():
        show_info(c, xfiles, xprefs, cur_fun) 
开发者ID:Vermeille,项目名称:clang-callgraph,代码行数:22,代码来源:clang-callgraph.py

示例2: complexities

# 需要导入模块: from clang.cindex import CursorKind [as 别名]
# 或者: from clang.cindex.CursorKind import FUNCTION_DECL [as 别名]
def complexities(self, cursor, filename):
        """
        Calculates cyclomatic complexities of functions.
        """

        file = cursor.location.file

        if file is not None and file.name != filename:
            # There is nothing to do in another file.
            return

        if cursor.kind == CursorKind.FUNCTION_DECL:
            child = next((child for child in cursor.get_children()
                          if child.kind != CursorKind.PARM_DECL),
                         None)
            if child:
                decisions, exits = self.function_key_points(child, True)
                complexity = max(1, decisions - exits + 2)
                yield cursor, complexity
        else:
            for child in cursor.get_children():
                yield from self.complexities(child, filename) 
开发者ID:coala,项目名称:coala-bears,代码行数:24,代码来源:ClangComplexityBear.py

示例3: read_cursor

# 需要导入模块: from clang.cindex import CursorKind [as 别名]
# 或者: from clang.cindex.CursorKind import FUNCTION_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

示例4: is_inline

# 需要导入模块: from clang.cindex import CursorKind [as 别名]
# 或者: from clang.cindex.CursorKind import FUNCTION_DECL [as 别名]
def is_inline(cursor):
  if cursor.kind != CursorKind.FUNCTION_DECL:
    return False

  for token in cursor.get_tokens():
    tkn = token.spelling
    for name in INLINE_NAMES:
      if tkn.find(name) > -1:
        return True
    if tkn == "{":
      break

  return False

#------------------------------------------------------------------------------- 
开发者ID:joxeankoret,项目名称:pigaios,代码行数:17,代码来源:clang_exporter.py

示例5: is_static

# 需要导入模块: from clang.cindex import CursorKind [as 别名]
# 或者: from clang.cindex.CursorKind import FUNCTION_DECL [as 别名]
def is_static(cursor):
  if cursor.kind != CursorKind.FUNCTION_DECL:
    return False
  token = next(cursor.get_tokens(), None)
  if token is None:
    return False
  return token.spelling == "static"

#------------------------------------------------------------------------------- 
开发者ID:joxeankoret,项目名称:pigaios,代码行数:11,代码来源:clang_exporter.py

示例6: find_func_node

# 需要导入模块: from clang.cindex import CursorKind [as 别名]
# 或者: from clang.cindex.CursorKind import FUNCTION_DECL [as 别名]
def find_func_node(node, func_name):
    if node.kind==CursorKind.FUNCTION_DECL and node.spelling==func_name and str(node.location.file).endswith('.c'):
        return node
    else:
        ch = [c for c in node.get_children()]
        if ch==[]:
            return None
        for c in ch:
            func_node = find_func_node(c, func_name)
            if func_node:
                return func_node

    return None 
开发者ID:tum-i22,项目名称:macke,代码行数:15,代码来源:branch_analyzer.py

示例7: find_func_node

# 需要导入模块: from clang.cindex import CursorKind [as 别名]
# 或者: from clang.cindex.CursorKind import FUNCTION_DECL [as 别名]
def find_func_node(node, func_name):
    ch = [c for c in node.get_children()]
    kinds = [c.kind for c in ch]
    if node.kind==CursorKind.FUNCTION_DECL and node.spelling==func_name and str(node.location.file).endswith('.c') and (CursorKind.COMPOUND_STMT in kinds): # Don't look at the header files or just declarations, but full definitions
        return node
    else:
        ch = [c for c in node.get_children()]
        if ch==[]:
            return None
        for c in ch:
            func_node = find_func_node(c, func_name)
            if func_node:
                return func_node

    return None 
开发者ID:tum-i22,项目名称:macke,代码行数:17,代码来源:generate_unit.py

示例8: get_func_nodes

# 需要导入模块: from clang.cindex import CursorKind [as 别名]
# 或者: from clang.cindex.CursorKind import FUNCTION_DECL [as 别名]
def get_func_nodes(node):
    global func_nodes
    
    if node.spelling!='main' and node.kind==CursorKind.FUNCTION_DECL and str(node.location.file).endswith('.c'): # Don't look at the header files
        ch = [c for c in node.get_children()]
        for c in ch:
            if c.kind==CursorKind.COMPOUND_STMT:
                func_nodes.append(node)
    ch = [c for c in node.get_children()]
    for c in ch:
            get_func_nodes(c) 
开发者ID:tum-i22,项目名称:macke,代码行数:13,代码来源:generate_unit.py

示例9: get_func_nodes

# 需要导入模块: from clang.cindex import CursorKind [as 别名]
# 或者: from clang.cindex.CursorKind import FUNCTION_DECL [as 别名]
def get_func_nodes(node):
    global func_nodes
    
    # if node.spelling!='main' and node.kind==CursorKind.FUNCTION_DECL and str(node.location.file).endswith('.c'): # Don't look at the header files
    if node.kind==CursorKind.FUNCTION_DECL and str(node.location.file).endswith('.c'): # Don't look at the header files
        ch = [c for c in node.get_children()]
        for c in ch:
            if c.kind==CursorKind.COMPOUND_STMT:
                func_nodes.append(node)
    ch = [c for c in node.get_children()]
    for c in ch:
            get_func_nodes(c) 
开发者ID:tum-i22,项目名称:macke,代码行数:14,代码来源:generate_separate_unit.py

示例10: parse_namespace

# 需要导入模块: from clang.cindex import CursorKind [as 别名]
# 或者: from clang.cindex.CursorKind import FUNCTION_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

示例11: parse_unexposed_decl

# 需要导入模块: from clang.cindex import CursorKind [as 别名]
# 或者: from clang.cindex.CursorKind import FUNCTION_DECL [as 别名]
def parse_unexposed_decl(self, cursor):
        for child in cursor.get_children():
            if child.kind == CursorKind.FUNCTION_DECL:
                self.parse_function(child)
            else:
                self.report_unparsed(child) 
开发者ID:cmbruns,项目名称:pyopenvr,代码行数:8,代码来源:parser.py

示例12: read_function

# 需要导入模块: from clang.cindex import CursorKind [as 别名]
# 或者: from clang.cindex.CursorKind import FUNCTION_DECL [as 别名]
def read_function(asg, cursor, scope):
    spelling = scope
    if spelling.startswith('class '):
        spelling = spelling[6:]
    elif spelling.startswith('union '):
        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.kind in [CursorKind.DESTRUCTOR, CursorKind.CXX_METHOD, CursorKind.CONSTRUCTOR] and cursor.lexical_parent.kind is CursorKind.NAMESPACE:
        return []
    else:
        if cursor.kind is not CursorKind.DESTRUCTOR:
            spelling = spelling + '::' + str(uuid.uuid4())
        if cursor.kind is CursorKind.FUNCTION_DECL:
            asg._nodes[spelling] = dict(_proxy=FunctionProxy,
                                        _comment="")
            if cursor.location is not None:
                filename = str(Path(str(cursor.location.file)).abspath())
                asg.add_file(filename, proxy=HeaderProxy, _language=asg._language)
                asg._nodes[spelling]['_header'] = filename
        elif cursor.kind is CursorKind.CXX_METHOD:
            asg._nodes[spelling] = dict(_proxy=MethodProxy,
                    _is_static=cursor.is_static_method(),
                    _is_volatile=False,
                    _is_virtual=True,
                    _is_const=cursor.is_const_method(),
                    _is_pure=True,
                    _comment="")
        elif cursor.kind is CursorKind.CONSTRUCTOR:
            asg._nodes[spelling] = dict(_proxy=ConstructorProxy,
                     _is_virtual=False, #TODO
                     _comment="")
        else:
            asg._nodes[spelling] = dict(_proxy=DestructorProxy,
                    is_virtual=True,
                    _comment="")
        asg._parameter_edges[spelling] = []
        asg._syntax_edges[scope].append(spelling)
        try:
            with warnings.catch_warnings():
                warnings.simplefilter("error")
                if cursor.kind in [CursorKind.FUNCTION_DECL, CursorKind.CXX_METHOD]:
                    target, specifiers = read_qualified_type(asg, cursor.result_type)
                    asg._type_edges[spelling] = dict(target=target, qualifiers=specifiers)
                for child in [child for child in cursor.get_children() if child.kind is CursorKind.PARM_DECL]:
                    target, specifiers = read_qualified_type(asg, child.type)
                    asg._parameter_edges[spelling].append(dict(name = child.spelling, target=target, qualifiers=specifiers))
        except Warning as warning:
            asg._syntax_edges[scope].remove(spelling)
            asg._type_edges.pop(spelling, None)
            asg._parameter_edges.pop(spelling, None)
            asg._nodes.pop(spelling)
            warnings.warn(str(warning), warning.__class__)
            return []
        else:
            read_access(asg, cursor.access_specifier, spelling)
            return [spelling] 
开发者ID:StatisKit,项目名称:AutoWIG,代码行数:63,代码来源:libclang_parser.py


注:本文中的clang.cindex.CursorKind.FUNCTION_DECL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。