本文整理汇总了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