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


Python calldef.calldef_t方法代碼示例

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


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

示例1: get_annotations

# 需要導入模塊: from pygccxml.declarations import calldef [as 別名]
# 或者: from pygccxml.declarations.calldef import calldef_t [as 別名]
def get_annotations(self, decl):
        """
        :param decl: pygccxml declaration_t object
        """
        assert isinstance(decl, declaration_t)

        if isinstance(decl, calldef.calldef_t) \
                and decl.is_artificial:
            #print >> sys.stderr, "********** ARTIFICIAL:", decl
            return {}, {}

        file_name = decl.location.file_name
        line_number = decl.location.line

        try:
            lines = self.files[file_name]
        except KeyError:
            with open(file_name, "rt") as f:
                lines = f.readlines()
            self.files[file_name] = lines

        line_number -= 2
        global_annotations = {}
        parameter_annotations = {}
        while 1:
            line = lines[line_number]
            line_number -= 1
            m = self._comment_rx.match(line)
            if m is None:
                break
            s = m.group('annotation1')
            if s is None:
                s = m.group('annotation2')
            line = s.strip()
            self._declare_used_annotation(file_name, line_number + 2)
            for annotation_str in line.split(';'):
                annotation_str = annotation_str.strip()
                m = self._global_annotation_rx.match(annotation_str)
                if m is not None:
                    global_annotations[m.group(1)] = m.group(2)
                    continue

                m = self._param_annotation_rx.match(annotation_str)
                if m is not None:
                    param_annotation = {}
                    parameter_annotations[m.group(1)] = param_annotation
                    for param in m.group(2).split(','):
                        m = self._global_annotation_rx.match(param.strip())
                        if m is not None:
                            param_annotation[m.group(1)] = m.group(2)
                        else:
                            warnings.warn_explicit("could not parse %r as parameter annotation element" %
                                                   (param.strip()),
                                                   AnnotationsWarning, file_name, line_number)
                    continue
                warnings.warn_explicit("could not parse %r" % (annotation_str),
                                       AnnotationsWarning, file_name, line_number)
        return global_annotations, parameter_annotations 
開發者ID:KTH,項目名稱:royal-chaos,代碼行數:60,代碼來源:gccxmlparser.py


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