repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 39
1.84M
| func_code_tokens
listlengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
listlengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
gccxml/pygccxml
|
pygccxml/declarations/type_traits_classes.py
|
is_unary_operator
|
def is_unary_operator(oper):
"""returns True, if operator is unary operator, otherwise False"""
# definition:
# member in class
# ret-type operator symbol()
# ret-type operator [++ --](int)
# globally
# ret-type operator symbol( arg )
# ret-type operator [++ --](X&, int)
symbols = ['!', '&', '~', '*', '+', '++', '-', '--']
if not isinstance(oper, calldef_members.operator_t):
return False
if oper.symbol not in symbols:
return False
if isinstance(oper, calldef_members.member_operator_t):
if len(oper.arguments) == 0:
return True
elif oper.symbol in ['++', '--'] and \
isinstance(oper.arguments[0].decl_type, cpptypes.int_t):
return True
return False
if len(oper.arguments) == 1:
return True
elif oper.symbol in ['++', '--'] \
and len(oper.arguments) == 2 \
and isinstance(oper.arguments[1].decl_type, cpptypes.int_t):
# may be I need to add additional check whether first argument is
# reference or not?
return True
return False
|
python
|
def is_unary_operator(oper):
symbols = ['!', '&', '~', '*', '+', '++', '-', '--']
if not isinstance(oper, calldef_members.operator_t):
return False
if oper.symbol not in symbols:
return False
if isinstance(oper, calldef_members.member_operator_t):
if len(oper.arguments) == 0:
return True
elif oper.symbol in ['++', '--'] and \
isinstance(oper.arguments[0].decl_type, cpptypes.int_t):
return True
return False
if len(oper.arguments) == 1:
return True
elif oper.symbol in ['++', '--'] \
and len(oper.arguments) == 2 \
and isinstance(oper.arguments[1].decl_type, cpptypes.int_t):
return True
return False
|
[
"def",
"is_unary_operator",
"(",
"oper",
")",
":",
"# definition:",
"# member in class",
"# ret-type operator symbol()",
"# ret-type operator [++ --](int)",
"# globally",
"# ret-type operator symbol( arg )",
"# ret-type operator [++ --](X&, int)",
"symbols",
"=",
"[",
"'!'",
",",
"'&'",
",",
"'~'",
",",
"'*'",
",",
"'+'",
",",
"'++'",
",",
"'-'",
",",
"'--'",
"]",
"if",
"not",
"isinstance",
"(",
"oper",
",",
"calldef_members",
".",
"operator_t",
")",
":",
"return",
"False",
"if",
"oper",
".",
"symbol",
"not",
"in",
"symbols",
":",
"return",
"False",
"if",
"isinstance",
"(",
"oper",
",",
"calldef_members",
".",
"member_operator_t",
")",
":",
"if",
"len",
"(",
"oper",
".",
"arguments",
")",
"==",
"0",
":",
"return",
"True",
"elif",
"oper",
".",
"symbol",
"in",
"[",
"'++'",
",",
"'--'",
"]",
"and",
"isinstance",
"(",
"oper",
".",
"arguments",
"[",
"0",
"]",
".",
"decl_type",
",",
"cpptypes",
".",
"int_t",
")",
":",
"return",
"True",
"return",
"False",
"if",
"len",
"(",
"oper",
".",
"arguments",
")",
"==",
"1",
":",
"return",
"True",
"elif",
"oper",
".",
"symbol",
"in",
"[",
"'++'",
",",
"'--'",
"]",
"and",
"len",
"(",
"oper",
".",
"arguments",
")",
"==",
"2",
"and",
"isinstance",
"(",
"oper",
".",
"arguments",
"[",
"1",
"]",
".",
"decl_type",
",",
"cpptypes",
".",
"int_t",
")",
":",
"# may be I need to add additional check whether first argument is",
"# reference or not?",
"return",
"True",
"return",
"False"
] |
returns True, if operator is unary operator, otherwise False
|
[
"returns",
"True",
"if",
"operator",
"is",
"unary",
"operator",
"otherwise",
"False"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L788-L818
|
gccxml/pygccxml
|
pygccxml/declarations/type_traits_classes.py
|
is_binary_operator
|
def is_binary_operator(oper):
"""returns True, if operator is binary operator, otherwise False"""
# definition:
# member in class
# ret-type operator symbol(arg)
# globally
# ret-type operator symbol( arg1, arg2 )
symbols = [
',', '()', '[]', '!=', '%', '%=', '&', '&&', '&=', '*', '*=', '+',
'+=', '-', '-=', '->', '->*', '/', '/=', '<', '<<', '<<=', '<=', '=',
'==', '>', '>=', '>>', '>>=', '^', '^=', '|', '|=', '||']
if not isinstance(oper, calldef_members.operator_t):
return False
if oper.symbol not in symbols:
return False
if isinstance(oper, calldef_members.member_operator_t):
if len(oper.arguments) == 1:
return True
return False
if len(oper.arguments) == 2:
return True
return False
|
python
|
def is_binary_operator(oper):
symbols = [
',', '()', '[]', '!=', '%', '%=', '&', '&&', '&=', '*', '*=', '+',
'+=', '-', '-=', '->', '->*', '/', '/=', '<', '<<', '<<=', '<=', '=',
'==', '>', '>=', '>>', '>>=', '^', '^=', '|', '|=', '||']
if not isinstance(oper, calldef_members.operator_t):
return False
if oper.symbol not in symbols:
return False
if isinstance(oper, calldef_members.member_operator_t):
if len(oper.arguments) == 1:
return True
return False
if len(oper.arguments) == 2:
return True
return False
|
[
"def",
"is_binary_operator",
"(",
"oper",
")",
":",
"# definition:",
"# member in class",
"# ret-type operator symbol(arg)",
"# globally",
"# ret-type operator symbol( arg1, arg2 )",
"symbols",
"=",
"[",
"','",
",",
"'()'",
",",
"'[]'",
",",
"'!='",
",",
"'%'",
",",
"'%='",
",",
"'&'",
",",
"'&&'",
",",
"'&='",
",",
"'*'",
",",
"'*='",
",",
"'+'",
",",
"'+='",
",",
"'-'",
",",
"'-='",
",",
"'->'",
",",
"'->*'",
",",
"'/'",
",",
"'/='",
",",
"'<'",
",",
"'<<'",
",",
"'<<='",
",",
"'<='",
",",
"'='",
",",
"'=='",
",",
"'>'",
",",
"'>='",
",",
"'>>'",
",",
"'>>='",
",",
"'^'",
",",
"'^='",
",",
"'|'",
",",
"'|='",
",",
"'||'",
"]",
"if",
"not",
"isinstance",
"(",
"oper",
",",
"calldef_members",
".",
"operator_t",
")",
":",
"return",
"False",
"if",
"oper",
".",
"symbol",
"not",
"in",
"symbols",
":",
"return",
"False",
"if",
"isinstance",
"(",
"oper",
",",
"calldef_members",
".",
"member_operator_t",
")",
":",
"if",
"len",
"(",
"oper",
".",
"arguments",
")",
"==",
"1",
":",
"return",
"True",
"return",
"False",
"if",
"len",
"(",
"oper",
".",
"arguments",
")",
"==",
"2",
":",
"return",
"True",
"return",
"False"
] |
returns True, if operator is binary operator, otherwise False
|
[
"returns",
"True",
"if",
"operator",
"is",
"binary",
"operator",
"otherwise",
"False"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L821-L844
|
gccxml/pygccxml
|
pygccxml/declarations/type_traits_classes.py
|
is_copy_constructor
|
def is_copy_constructor(constructor):
"""
Check if the declaration is a copy constructor,
Args:
constructor (declarations.constructor_t): the constructor
to be checked.
Returns:
bool: True if this is a copy constructor, False instead.
"""
assert isinstance(constructor, calldef_members.constructor_t)
args = constructor.arguments
parent = constructor.parent
# A copy constructor has only one argument
if len(args) != 1:
return False
# We have only one argument, get it
arg = args[0]
if not isinstance(arg.decl_type, cpptypes.compound_t):
# An argument of type declarated_t (a typedef) could be passed to
# the constructor; and it could be a reference.
# But in c++ you can NOT write :
# "typedef class MyClass { MyClass(const MyClass & arg) {} }"
# If the argument is a typedef, this is not a copy constructor.
# See the hierarchy of declarated_t and coumpound_t. They both
# inherit from type_t but are not related so we can discriminate
# between them.
return False
# The argument needs to be passed by reference in a copy constructor
if not type_traits.is_reference(arg.decl_type):
return False
# The argument needs to be const for a copy constructor
if not type_traits.is_const(arg.decl_type.base):
return False
un_aliased = type_traits.remove_alias(arg.decl_type.base)
# un_aliased now refers to const_t instance
if not isinstance(un_aliased.base, cpptypes.declarated_t):
# We are looking for a declaration
# If "class MyClass { MyClass(const int & arg) {} }" is used,
# this is not copy constructor, so we return False here.
# -> un_aliased.base == cpptypes.int_t (!= cpptypes.declarated_t)
return False
# Final check: compare the parent (the class declaration for example)
# with the declaration of the type passed as argument.
return id(un_aliased.base.declaration) == id(parent)
|
python
|
def is_copy_constructor(constructor):
assert isinstance(constructor, calldef_members.constructor_t)
args = constructor.arguments
parent = constructor.parent
if len(args) != 1:
return False
arg = args[0]
if not isinstance(arg.decl_type, cpptypes.compound_t):
return False
if not type_traits.is_reference(arg.decl_type):
return False
if not type_traits.is_const(arg.decl_type.base):
return False
un_aliased = type_traits.remove_alias(arg.decl_type.base)
if not isinstance(un_aliased.base, cpptypes.declarated_t):
return False
return id(un_aliased.base.declaration) == id(parent)
|
[
"def",
"is_copy_constructor",
"(",
"constructor",
")",
":",
"assert",
"isinstance",
"(",
"constructor",
",",
"calldef_members",
".",
"constructor_t",
")",
"args",
"=",
"constructor",
".",
"arguments",
"parent",
"=",
"constructor",
".",
"parent",
"# A copy constructor has only one argument",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
":",
"return",
"False",
"# We have only one argument, get it",
"arg",
"=",
"args",
"[",
"0",
"]",
"if",
"not",
"isinstance",
"(",
"arg",
".",
"decl_type",
",",
"cpptypes",
".",
"compound_t",
")",
":",
"# An argument of type declarated_t (a typedef) could be passed to",
"# the constructor; and it could be a reference.",
"# But in c++ you can NOT write :",
"# \"typedef class MyClass { MyClass(const MyClass & arg) {} }\"",
"# If the argument is a typedef, this is not a copy constructor.",
"# See the hierarchy of declarated_t and coumpound_t. They both",
"# inherit from type_t but are not related so we can discriminate",
"# between them.",
"return",
"False",
"# The argument needs to be passed by reference in a copy constructor",
"if",
"not",
"type_traits",
".",
"is_reference",
"(",
"arg",
".",
"decl_type",
")",
":",
"return",
"False",
"# The argument needs to be const for a copy constructor",
"if",
"not",
"type_traits",
".",
"is_const",
"(",
"arg",
".",
"decl_type",
".",
"base",
")",
":",
"return",
"False",
"un_aliased",
"=",
"type_traits",
".",
"remove_alias",
"(",
"arg",
".",
"decl_type",
".",
"base",
")",
"# un_aliased now refers to const_t instance",
"if",
"not",
"isinstance",
"(",
"un_aliased",
".",
"base",
",",
"cpptypes",
".",
"declarated_t",
")",
":",
"# We are looking for a declaration",
"# If \"class MyClass { MyClass(const int & arg) {} }\" is used,",
"# this is not copy constructor, so we return False here.",
"# -> un_aliased.base == cpptypes.int_t (!= cpptypes.declarated_t)",
"return",
"False",
"# Final check: compare the parent (the class declaration for example)",
"# with the declaration of the type passed as argument.",
"return",
"id",
"(",
"un_aliased",
".",
"base",
".",
"declaration",
")",
"==",
"id",
"(",
"parent",
")"
] |
Check if the declaration is a copy constructor,
Args:
constructor (declarations.constructor_t): the constructor
to be checked.
Returns:
bool: True if this is a copy constructor, False instead.
|
[
"Check",
"if",
"the",
"declaration",
"is",
"a",
"copy",
"constructor"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L847-L900
|
gccxml/pygccxml
|
pygccxml/declarations/class_declaration.py
|
class_t.recursive_bases
|
def recursive_bases(self):
"""list of all :class:`base classes <hierarchy_info_t>`"""
if self._recursive_bases is None:
to_go = self.bases[:]
all_bases = []
while to_go:
base = to_go.pop()
if base not in all_bases:
all_bases.append(base)
to_go.extend(base.related_class.bases)
self._recursive_bases = all_bases
return self._recursive_bases
|
python
|
def recursive_bases(self):
if self._recursive_bases is None:
to_go = self.bases[:]
all_bases = []
while to_go:
base = to_go.pop()
if base not in all_bases:
all_bases.append(base)
to_go.extend(base.related_class.bases)
self._recursive_bases = all_bases
return self._recursive_bases
|
[
"def",
"recursive_bases",
"(",
"self",
")",
":",
"if",
"self",
".",
"_recursive_bases",
"is",
"None",
":",
"to_go",
"=",
"self",
".",
"bases",
"[",
":",
"]",
"all_bases",
"=",
"[",
"]",
"while",
"to_go",
":",
"base",
"=",
"to_go",
".",
"pop",
"(",
")",
"if",
"base",
"not",
"in",
"all_bases",
":",
"all_bases",
".",
"append",
"(",
"base",
")",
"to_go",
".",
"extend",
"(",
"base",
".",
"related_class",
".",
"bases",
")",
"self",
".",
"_recursive_bases",
"=",
"all_bases",
"return",
"self",
".",
"_recursive_bases"
] |
list of all :class:`base classes <hierarchy_info_t>`
|
[
"list",
"of",
"all",
":",
"class",
":",
"base",
"classes",
"<hierarchy_info_t",
">"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/class_declaration.py#L279-L290
|
gccxml/pygccxml
|
pygccxml/declarations/class_declaration.py
|
class_t.recursive_derived
|
def recursive_derived(self):
"""list of all :class:`derive classes <hierarchy_info_t>`"""
if self._recursive_derived is None:
to_go = self.derived[:]
all_derived = []
while to_go:
derive = to_go.pop()
if derive not in all_derived:
all_derived.append(derive)
to_go.extend(derive.related_class.derived)
self._recursive_derived = all_derived
return self._recursive_derived
|
python
|
def recursive_derived(self):
if self._recursive_derived is None:
to_go = self.derived[:]
all_derived = []
while to_go:
derive = to_go.pop()
if derive not in all_derived:
all_derived.append(derive)
to_go.extend(derive.related_class.derived)
self._recursive_derived = all_derived
return self._recursive_derived
|
[
"def",
"recursive_derived",
"(",
"self",
")",
":",
"if",
"self",
".",
"_recursive_derived",
"is",
"None",
":",
"to_go",
"=",
"self",
".",
"derived",
"[",
":",
"]",
"all_derived",
"=",
"[",
"]",
"while",
"to_go",
":",
"derive",
"=",
"to_go",
".",
"pop",
"(",
")",
"if",
"derive",
"not",
"in",
"all_derived",
":",
"all_derived",
".",
"append",
"(",
"derive",
")",
"to_go",
".",
"extend",
"(",
"derive",
".",
"related_class",
".",
"derived",
")",
"self",
".",
"_recursive_derived",
"=",
"all_derived",
"return",
"self",
".",
"_recursive_derived"
] |
list of all :class:`derive classes <hierarchy_info_t>`
|
[
"list",
"of",
"all",
":",
"class",
":",
"derive",
"classes",
"<hierarchy_info_t",
">"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/class_declaration.py#L302-L313
|
gccxml/pygccxml
|
pygccxml/declarations/class_declaration.py
|
class_t.get_members
|
def get_members(self, access=None):
"""
returns list of members according to access type
If access equals to None, then returned list will contain all members.
You should not modify the list content, otherwise different
optimization data will stop work and may to give you wrong results.
:param access: describes desired members
:type access: :class:ACCESS_TYPES
:rtype: [ members ]
"""
if access == ACCESS_TYPES.PUBLIC:
return self.public_members
elif access == ACCESS_TYPES.PROTECTED:
return self.protected_members
elif access == ACCESS_TYPES.PRIVATE:
return self.private_members
all_members = []
all_members.extend(self.public_members)
all_members.extend(self.protected_members)
all_members.extend(self.private_members)
return all_members
|
python
|
def get_members(self, access=None):
if access == ACCESS_TYPES.PUBLIC:
return self.public_members
elif access == ACCESS_TYPES.PROTECTED:
return self.protected_members
elif access == ACCESS_TYPES.PRIVATE:
return self.private_members
all_members = []
all_members.extend(self.public_members)
all_members.extend(self.protected_members)
all_members.extend(self.private_members)
return all_members
|
[
"def",
"get_members",
"(",
"self",
",",
"access",
"=",
"None",
")",
":",
"if",
"access",
"==",
"ACCESS_TYPES",
".",
"PUBLIC",
":",
"return",
"self",
".",
"public_members",
"elif",
"access",
"==",
"ACCESS_TYPES",
".",
"PROTECTED",
":",
"return",
"self",
".",
"protected_members",
"elif",
"access",
"==",
"ACCESS_TYPES",
".",
"PRIVATE",
":",
"return",
"self",
".",
"private_members",
"all_members",
"=",
"[",
"]",
"all_members",
".",
"extend",
"(",
"self",
".",
"public_members",
")",
"all_members",
".",
"extend",
"(",
"self",
".",
"protected_members",
")",
"all_members",
".",
"extend",
"(",
"self",
".",
"private_members",
")",
"return",
"all_members"
] |
returns list of members according to access type
If access equals to None, then returned list will contain all members.
You should not modify the list content, otherwise different
optimization data will stop work and may to give you wrong results.
:param access: describes desired members
:type access: :class:ACCESS_TYPES
:rtype: [ members ]
|
[
"returns",
"list",
"of",
"members",
"according",
"to",
"access",
"type"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/class_declaration.py#L363-L387
|
gccxml/pygccxml
|
pygccxml/declarations/class_declaration.py
|
class_t.adopt_declaration
|
def adopt_declaration(self, decl, access):
"""adds new declaration to the class
:param decl: reference to a :class:`declaration_t`
:param access: member access type
:type access: :class:ACCESS_TYPES
"""
if access == ACCESS_TYPES.PUBLIC:
self.public_members.append(decl)
elif access == ACCESS_TYPES.PROTECTED:
self.protected_members.append(decl)
elif access == ACCESS_TYPES.PRIVATE:
self.private_members.append(decl)
else:
raise RuntimeError("Invalid access type: %s." % access)
decl.parent = self
decl.cache.reset()
decl.cache.access_type = access
|
python
|
def adopt_declaration(self, decl, access):
if access == ACCESS_TYPES.PUBLIC:
self.public_members.append(decl)
elif access == ACCESS_TYPES.PROTECTED:
self.protected_members.append(decl)
elif access == ACCESS_TYPES.PRIVATE:
self.private_members.append(decl)
else:
raise RuntimeError("Invalid access type: %s." % access)
decl.parent = self
decl.cache.reset()
decl.cache.access_type = access
|
[
"def",
"adopt_declaration",
"(",
"self",
",",
"decl",
",",
"access",
")",
":",
"if",
"access",
"==",
"ACCESS_TYPES",
".",
"PUBLIC",
":",
"self",
".",
"public_members",
".",
"append",
"(",
"decl",
")",
"elif",
"access",
"==",
"ACCESS_TYPES",
".",
"PROTECTED",
":",
"self",
".",
"protected_members",
".",
"append",
"(",
"decl",
")",
"elif",
"access",
"==",
"ACCESS_TYPES",
".",
"PRIVATE",
":",
"self",
".",
"private_members",
".",
"append",
"(",
"decl",
")",
"else",
":",
"raise",
"RuntimeError",
"(",
"\"Invalid access type: %s.\"",
"%",
"access",
")",
"decl",
".",
"parent",
"=",
"self",
"decl",
".",
"cache",
".",
"reset",
"(",
")",
"decl",
".",
"cache",
".",
"access_type",
"=",
"access"
] |
adds new declaration to the class
:param decl: reference to a :class:`declaration_t`
:param access: member access type
:type access: :class:ACCESS_TYPES
|
[
"adds",
"new",
"declaration",
"to",
"the",
"class"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/class_declaration.py#L389-L407
|
gccxml/pygccxml
|
pygccxml/declarations/class_declaration.py
|
class_t.remove_declaration
|
def remove_declaration(self, decl):
"""
removes decl from members list
:param decl: declaration to be removed
:type decl: :class:`declaration_t`
"""
access_type = self.find_out_member_access_type(decl)
if access_type == ACCESS_TYPES.PUBLIC:
container = self.public_members
elif access_type == ACCESS_TYPES.PROTECTED:
container = self.protected_members
else: # decl.cache.access_type == ACCESS_TYPES.PRVATE
container = self.private_members
del container[container.index(decl)]
decl.cache.reset()
|
python
|
def remove_declaration(self, decl):
access_type = self.find_out_member_access_type(decl)
if access_type == ACCESS_TYPES.PUBLIC:
container = self.public_members
elif access_type == ACCESS_TYPES.PROTECTED:
container = self.protected_members
else:
container = self.private_members
del container[container.index(decl)]
decl.cache.reset()
|
[
"def",
"remove_declaration",
"(",
"self",
",",
"decl",
")",
":",
"access_type",
"=",
"self",
".",
"find_out_member_access_type",
"(",
"decl",
")",
"if",
"access_type",
"==",
"ACCESS_TYPES",
".",
"PUBLIC",
":",
"container",
"=",
"self",
".",
"public_members",
"elif",
"access_type",
"==",
"ACCESS_TYPES",
".",
"PROTECTED",
":",
"container",
"=",
"self",
".",
"protected_members",
"else",
":",
"# decl.cache.access_type == ACCESS_TYPES.PRVATE",
"container",
"=",
"self",
".",
"private_members",
"del",
"container",
"[",
"container",
".",
"index",
"(",
"decl",
")",
"]",
"decl",
".",
"cache",
".",
"reset",
"(",
")"
] |
removes decl from members list
:param decl: declaration to be removed
:type decl: :class:`declaration_t`
|
[
"removes",
"decl",
"from",
"members",
"list"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/class_declaration.py#L409-L425
|
gccxml/pygccxml
|
pygccxml/declarations/class_declaration.py
|
class_t.find_out_member_access_type
|
def find_out_member_access_type(self, member):
"""
returns member access type
:param member: member of the class
:type member: :class:`declaration_t`
:rtype: :class:ACCESS_TYPES
"""
assert member.parent is self
if not member.cache.access_type:
if member in self.public_members:
access_type = ACCESS_TYPES.PUBLIC
elif member in self.protected_members:
access_type = ACCESS_TYPES.PROTECTED
elif member in self.private_members:
access_type = ACCESS_TYPES.PRIVATE
else:
raise RuntimeError(
"Unable to find member within internal members list.")
member.cache.access_type = access_type
return access_type
else:
return member.cache.access_type
|
python
|
def find_out_member_access_type(self, member):
assert member.parent is self
if not member.cache.access_type:
if member in self.public_members:
access_type = ACCESS_TYPES.PUBLIC
elif member in self.protected_members:
access_type = ACCESS_TYPES.PROTECTED
elif member in self.private_members:
access_type = ACCESS_TYPES.PRIVATE
else:
raise RuntimeError(
"Unable to find member within internal members list.")
member.cache.access_type = access_type
return access_type
else:
return member.cache.access_type
|
[
"def",
"find_out_member_access_type",
"(",
"self",
",",
"member",
")",
":",
"assert",
"member",
".",
"parent",
"is",
"self",
"if",
"not",
"member",
".",
"cache",
".",
"access_type",
":",
"if",
"member",
"in",
"self",
".",
"public_members",
":",
"access_type",
"=",
"ACCESS_TYPES",
".",
"PUBLIC",
"elif",
"member",
"in",
"self",
".",
"protected_members",
":",
"access_type",
"=",
"ACCESS_TYPES",
".",
"PROTECTED",
"elif",
"member",
"in",
"self",
".",
"private_members",
":",
"access_type",
"=",
"ACCESS_TYPES",
".",
"PRIVATE",
"else",
":",
"raise",
"RuntimeError",
"(",
"\"Unable to find member within internal members list.\"",
")",
"member",
".",
"cache",
".",
"access_type",
"=",
"access_type",
"return",
"access_type",
"else",
":",
"return",
"member",
".",
"cache",
".",
"access_type"
] |
returns member access type
:param member: member of the class
:type member: :class:`declaration_t`
:rtype: :class:ACCESS_TYPES
|
[
"returns",
"member",
"access",
"type"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/class_declaration.py#L427-L450
|
gccxml/pygccxml
|
pygccxml/declarations/class_declaration.py
|
class_t.top_class
|
def top_class(self):
"""reference to a parent class, which contains this class and defined
within a namespace
if this class is defined under a namespace, self will be returned"""
curr = self
parent = self.parent
while isinstance(parent, class_t):
curr = parent
parent = parent.parent
return curr
|
python
|
def top_class(self):
curr = self
parent = self.parent
while isinstance(parent, class_t):
curr = parent
parent = parent.parent
return curr
|
[
"def",
"top_class",
"(",
"self",
")",
":",
"curr",
"=",
"self",
"parent",
"=",
"self",
".",
"parent",
"while",
"isinstance",
"(",
"parent",
",",
"class_t",
")",
":",
"curr",
"=",
"parent",
"parent",
"=",
"parent",
".",
"parent",
"return",
"curr"
] |
reference to a parent class, which contains this class and defined
within a namespace
if this class is defined under a namespace, self will be returned
|
[
"reference",
"to",
"a",
"parent",
"class",
"which",
"contains",
"this",
"class",
"and",
"defined",
"within",
"a",
"namespace"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/class_declaration.py#L494-L504
|
gccxml/pygccxml
|
pygccxml/declarations/enumeration.py
|
enumeration_t.append_value
|
def append_value(self, valuename, valuenum=None):
"""Append another enumeration value to the `enum`.
The numeric value may be None in which case it is automatically
determined by increasing the value of the last item.
When the 'values' attribute is accessed the resulting list will be in
the same order as append_value() was called.
:param valuename: The name of the value.
:type valuename: str
:param valuenum: The numeric value or None.
:type valuenum: int
"""
# No number given? Then use the previous one + 1
if valuenum is None:
if not self._values:
valuenum = 0
else:
valuenum = self._values[-1][1] + 1
# Store the new value
self._values.append((valuename, int(valuenum)))
|
python
|
def append_value(self, valuename, valuenum=None):
if valuenum is None:
if not self._values:
valuenum = 0
else:
valuenum = self._values[-1][1] + 1
self._values.append((valuename, int(valuenum)))
|
[
"def",
"append_value",
"(",
"self",
",",
"valuename",
",",
"valuenum",
"=",
"None",
")",
":",
"# No number given? Then use the previous one + 1",
"if",
"valuenum",
"is",
"None",
":",
"if",
"not",
"self",
".",
"_values",
":",
"valuenum",
"=",
"0",
"else",
":",
"valuenum",
"=",
"self",
".",
"_values",
"[",
"-",
"1",
"]",
"[",
"1",
"]",
"+",
"1",
"# Store the new value",
"self",
".",
"_values",
".",
"append",
"(",
"(",
"valuename",
",",
"int",
"(",
"valuenum",
")",
")",
")"
] |
Append another enumeration value to the `enum`.
The numeric value may be None in which case it is automatically
determined by increasing the value of the last item.
When the 'values' attribute is accessed the resulting list will be in
the same order as append_value() was called.
:param valuename: The name of the value.
:type valuename: str
:param valuenum: The numeric value or None.
:type valuenum: int
|
[
"Append",
"another",
"enumeration",
"value",
"to",
"the",
"enum",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/enumeration.py#L92-L114
|
gccxml/pygccxml
|
pygccxml/declarations/enumeration.py
|
enumeration_t.has_value_name
|
def has_value_name(self, name):
"""Check if this `enum` has a particular name among its values.
:param name: Enumeration value name
:type name: str
:rtype: True if there is an enumeration value with the given name
"""
for val, _ in self._values:
if val == name:
return True
return False
|
python
|
def has_value_name(self, name):
for val, _ in self._values:
if val == name:
return True
return False
|
[
"def",
"has_value_name",
"(",
"self",
",",
"name",
")",
":",
"for",
"val",
",",
"_",
"in",
"self",
".",
"_values",
":",
"if",
"val",
"==",
"name",
":",
"return",
"True",
"return",
"False"
] |
Check if this `enum` has a particular name among its values.
:param name: Enumeration value name
:type name: str
:rtype: True if there is an enumeration value with the given name
|
[
"Check",
"if",
"this",
"enum",
"has",
"a",
"particular",
"name",
"among",
"its",
"values",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/enumeration.py#L116-L126
|
gccxml/pygccxml
|
pygccxml/declarations/enumeration.py
|
enumeration_t.get_name2value_dict
|
def get_name2value_dict(self):
"""returns a dictionary, that maps between `enum` name( key ) and
`enum` value( value )"""
x = {}
for val, num in self._values:
x[val] = num
return x
|
python
|
def get_name2value_dict(self):
x = {}
for val, num in self._values:
x[val] = num
return x
|
[
"def",
"get_name2value_dict",
"(",
"self",
")",
":",
"x",
"=",
"{",
"}",
"for",
"val",
",",
"num",
"in",
"self",
".",
"_values",
":",
"x",
"[",
"val",
"]",
"=",
"num",
"return",
"x"
] |
returns a dictionary, that maps between `enum` name( key ) and
`enum` value( value )
|
[
"returns",
"a",
"dictionary",
"that",
"maps",
"between",
"enum",
"name",
"(",
"key",
")",
"and",
"enum",
"value",
"(",
"value",
")"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/enumeration.py#L128-L134
|
gccxml/pygccxml
|
pygccxml/parser/patcher.py
|
fix_calldef_decls
|
def fix_calldef_decls(decls, enums, cxx_std):
"""
some times gccxml report typedefs defined in no namespace
it happens for example in next situation
template< typename X>
void ddd(){ typedef typename X::Y YY;}
if I will fail on this bug next time, the right way to fix it may be
different
"""
default_arg_patcher = default_argument_patcher_t(enums, cxx_std)
# decls should be flat list of all declarations, you want to apply patch on
for decl in decls:
default_arg_patcher(decl)
if isinstance(decl, declarations.casting_operator_t):
_casting_oper_patcher_(decl)
|
python
|
def fix_calldef_decls(decls, enums, cxx_std):
default_arg_patcher = default_argument_patcher_t(enums, cxx_std)
for decl in decls:
default_arg_patcher(decl)
if isinstance(decl, declarations.casting_operator_t):
_casting_oper_patcher_(decl)
|
[
"def",
"fix_calldef_decls",
"(",
"decls",
",",
"enums",
",",
"cxx_std",
")",
":",
"default_arg_patcher",
"=",
"default_argument_patcher_t",
"(",
"enums",
",",
"cxx_std",
")",
"# decls should be flat list of all declarations, you want to apply patch on",
"for",
"decl",
"in",
"decls",
":",
"default_arg_patcher",
"(",
"decl",
")",
"if",
"isinstance",
"(",
"decl",
",",
"declarations",
".",
"casting_operator_t",
")",
":",
"_casting_oper_patcher_",
"(",
"decl",
")"
] |
some times gccxml report typedefs defined in no namespace
it happens for example in next situation
template< typename X>
void ddd(){ typedef typename X::Y YY;}
if I will fail on this bug next time, the right way to fix it may be
different
|
[
"some",
"times",
"gccxml",
"report",
"typedefs",
"defined",
"in",
"no",
"namespace",
"it",
"happens",
"for",
"example",
"in",
"next",
"situation",
"template<",
"typename",
"X",
">",
"void",
"ddd",
"()",
"{",
"typedef",
"typename",
"X",
"::",
"Y",
"YY",
";",
"}",
"if",
"I",
"will",
"fail",
"on",
"this",
"bug",
"next",
"time",
"the",
"right",
"way",
"to",
"fix",
"it",
"may",
"be",
"different"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/patcher.py#L249-L263
|
gccxml/pygccxml
|
pygccxml/parser/patcher.py
|
update_unnamed_class
|
def update_unnamed_class(decls):
"""
Adds name to class_t declarations.
If CastXML is being used, the type definitions with an unnamed
class/struct are split across two nodes in the XML tree. For example,
typedef struct {} cls;
produces
<Struct id="_7" name="" context="_1" .../>
<Typedef id="_8" name="cls" type="_7" context="_1" .../>
For each typedef, we look at which class it refers to, and update the name
accordingly. This helps the matcher classes finding these declarations.
This was the behaviour with gccxml too, so this is important for
backward compatibility.
If the castxml epic version 1 is used, there is even an elaborated type
declaration between the typedef and the struct/class, that also needs to be
taken care of.
Args:
decls (list[declaration_t]): a list of declarations to be patched.
Returns:
None
"""
for decl in decls:
if isinstance(decl, declarations.typedef_t):
referent = decl.decl_type
if isinstance(referent, declarations.elaborated_t):
referent = referent.base
if not isinstance(referent, declarations.declarated_t):
continue
referent = referent.declaration
if referent.name or not isinstance(referent, declarations.class_t):
continue
referent.name = decl.name
|
python
|
def update_unnamed_class(decls):
for decl in decls:
if isinstance(decl, declarations.typedef_t):
referent = decl.decl_type
if isinstance(referent, declarations.elaborated_t):
referent = referent.base
if not isinstance(referent, declarations.declarated_t):
continue
referent = referent.declaration
if referent.name or not isinstance(referent, declarations.class_t):
continue
referent.name = decl.name
|
[
"def",
"update_unnamed_class",
"(",
"decls",
")",
":",
"for",
"decl",
"in",
"decls",
":",
"if",
"isinstance",
"(",
"decl",
",",
"declarations",
".",
"typedef_t",
")",
":",
"referent",
"=",
"decl",
".",
"decl_type",
"if",
"isinstance",
"(",
"referent",
",",
"declarations",
".",
"elaborated_t",
")",
":",
"referent",
"=",
"referent",
".",
"base",
"if",
"not",
"isinstance",
"(",
"referent",
",",
"declarations",
".",
"declarated_t",
")",
":",
"continue",
"referent",
"=",
"referent",
".",
"declaration",
"if",
"referent",
".",
"name",
"or",
"not",
"isinstance",
"(",
"referent",
",",
"declarations",
".",
"class_t",
")",
":",
"continue",
"referent",
".",
"name",
"=",
"decl",
".",
"name"
] |
Adds name to class_t declarations.
If CastXML is being used, the type definitions with an unnamed
class/struct are split across two nodes in the XML tree. For example,
typedef struct {} cls;
produces
<Struct id="_7" name="" context="_1" .../>
<Typedef id="_8" name="cls" type="_7" context="_1" .../>
For each typedef, we look at which class it refers to, and update the name
accordingly. This helps the matcher classes finding these declarations.
This was the behaviour with gccxml too, so this is important for
backward compatibility.
If the castxml epic version 1 is used, there is even an elaborated type
declaration between the typedef and the struct/class, that also needs to be
taken care of.
Args:
decls (list[declaration_t]): a list of declarations to be patched.
Returns:
None
|
[
"Adds",
"name",
"to",
"class_t",
"declarations",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/patcher.py#L266-L305
|
gccxml/pygccxml
|
pygccxml/parser/project_reader.py
|
create_cached_source_fc
|
def create_cached_source_fc(header, cached_source_file):
"""
Creates :class:`parser.file_configuration_t` instance, configured to
contain path to GCC-XML generated XML file and C++ source file. If XML file
does not exists, it will be created and used for parsing. If XML file
exists, it will be used for parsing.
:param header: path to C++ source file
:type header: str
:param cached_source_file: path to GCC-XML generated XML file
:type cached_source_file: str
:rtype: :class:`parser.file_configuration_t`
"""
return file_configuration_t(
data=header,
cached_source_file=cached_source_file,
content_type=file_configuration_t.CONTENT_TYPE.CACHED_SOURCE_FILE)
|
python
|
def create_cached_source_fc(header, cached_source_file):
return file_configuration_t(
data=header,
cached_source_file=cached_source_file,
content_type=file_configuration_t.CONTENT_TYPE.CACHED_SOURCE_FILE)
|
[
"def",
"create_cached_source_fc",
"(",
"header",
",",
"cached_source_file",
")",
":",
"return",
"file_configuration_t",
"(",
"data",
"=",
"header",
",",
"cached_source_file",
"=",
"cached_source_file",
",",
"content_type",
"=",
"file_configuration_t",
".",
"CONTENT_TYPE",
".",
"CACHED_SOURCE_FILE",
")"
] |
Creates :class:`parser.file_configuration_t` instance, configured to
contain path to GCC-XML generated XML file and C++ source file. If XML file
does not exists, it will be created and used for parsing. If XML file
exists, it will be used for parsing.
:param header: path to C++ source file
:type header: str
:param cached_source_file: path to GCC-XML generated XML file
:type cached_source_file: str
:rtype: :class:`parser.file_configuration_t`
|
[
"Creates",
":",
"class",
":",
"parser",
".",
"file_configuration_t",
"instance",
"configured",
"to",
"contain",
"path",
"to",
"GCC",
"-",
"XML",
"generated",
"XML",
"file",
"and",
"C",
"++",
"source",
"file",
".",
"If",
"XML",
"file",
"does",
"not",
"exists",
"it",
"will",
"be",
"created",
"and",
"used",
"for",
"parsing",
".",
"If",
"XML",
"file",
"exists",
"it",
"will",
"be",
"used",
"for",
"parsing",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/project_reader.py#L147-L166
|
gccxml/pygccxml
|
pygccxml/parser/project_reader.py
|
project_reader_t.get_os_file_names
|
def get_os_file_names(files):
"""
returns file names
:param files: list of strings and\\or :class:`file_configuration_t`
instances.
:type files: list
"""
fnames = []
for f in files:
if utils.is_str(f):
fnames.append(f)
elif isinstance(f, file_configuration_t):
if f.content_type in (
file_configuration_t.CONTENT_TYPE.STANDARD_SOURCE_FILE,
file_configuration_t.CONTENT_TYPE.CACHED_SOURCE_FILE):
fnames.append(f.data)
else:
pass
return fnames
|
python
|
def get_os_file_names(files):
fnames = []
for f in files:
if utils.is_str(f):
fnames.append(f)
elif isinstance(f, file_configuration_t):
if f.content_type in (
file_configuration_t.CONTENT_TYPE.STANDARD_SOURCE_FILE,
file_configuration_t.CONTENT_TYPE.CACHED_SOURCE_FILE):
fnames.append(f.data)
else:
pass
return fnames
|
[
"def",
"get_os_file_names",
"(",
"files",
")",
":",
"fnames",
"=",
"[",
"]",
"for",
"f",
"in",
"files",
":",
"if",
"utils",
".",
"is_str",
"(",
"f",
")",
":",
"fnames",
".",
"append",
"(",
"f",
")",
"elif",
"isinstance",
"(",
"f",
",",
"file_configuration_t",
")",
":",
"if",
"f",
".",
"content_type",
"in",
"(",
"file_configuration_t",
".",
"CONTENT_TYPE",
".",
"STANDARD_SOURCE_FILE",
",",
"file_configuration_t",
".",
"CONTENT_TYPE",
".",
"CACHED_SOURCE_FILE",
")",
":",
"fnames",
".",
"append",
"(",
"f",
".",
"data",
")",
"else",
":",
"pass",
"return",
"fnames"
] |
returns file names
:param files: list of strings and\\or :class:`file_configuration_t`
instances.
:type files: list
|
[
"returns",
"file",
"names"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/project_reader.py#L213-L234
|
gccxml/pygccxml
|
pygccxml/parser/project_reader.py
|
project_reader_t.read_files
|
def read_files(
self,
files,
compilation_mode=COMPILATION_MODE.FILE_BY_FILE):
"""
parses a set of files
:param files: list of strings and\\or :class:`file_configuration_t`
instances.
:type files: list
:param compilation_mode: determines whether the files are parsed
individually or as one single chunk
:type compilation_mode: :class:`COMPILATION_MODE`
:rtype: [:class:`declaration_t`]
"""
if compilation_mode == COMPILATION_MODE.ALL_AT_ONCE \
and len(files) == len(self.get_os_file_names(files)):
return self.__parse_all_at_once(files)
else:
if compilation_mode == COMPILATION_MODE.ALL_AT_ONCE:
msg = ''.join([
"Unable to parse files using ALL_AT_ONCE mode. ",
"There is some file configuration that is not file. ",
"pygccxml.parser.project_reader_t switches to ",
"FILE_BY_FILE mode."])
self.logger.warning(msg)
return self.__parse_file_by_file(files)
|
python
|
def read_files(
self,
files,
compilation_mode=COMPILATION_MODE.FILE_BY_FILE):
if compilation_mode == COMPILATION_MODE.ALL_AT_ONCE \
and len(files) == len(self.get_os_file_names(files)):
return self.__parse_all_at_once(files)
else:
if compilation_mode == COMPILATION_MODE.ALL_AT_ONCE:
msg = ''.join([
"Unable to parse files using ALL_AT_ONCE mode. ",
"There is some file configuration that is not file. ",
"pygccxml.parser.project_reader_t switches to ",
"FILE_BY_FILE mode."])
self.logger.warning(msg)
return self.__parse_file_by_file(files)
|
[
"def",
"read_files",
"(",
"self",
",",
"files",
",",
"compilation_mode",
"=",
"COMPILATION_MODE",
".",
"FILE_BY_FILE",
")",
":",
"if",
"compilation_mode",
"==",
"COMPILATION_MODE",
".",
"ALL_AT_ONCE",
"and",
"len",
"(",
"files",
")",
"==",
"len",
"(",
"self",
".",
"get_os_file_names",
"(",
"files",
")",
")",
":",
"return",
"self",
".",
"__parse_all_at_once",
"(",
"files",
")",
"else",
":",
"if",
"compilation_mode",
"==",
"COMPILATION_MODE",
".",
"ALL_AT_ONCE",
":",
"msg",
"=",
"''",
".",
"join",
"(",
"[",
"\"Unable to parse files using ALL_AT_ONCE mode. \"",
",",
"\"There is some file configuration that is not file. \"",
",",
"\"pygccxml.parser.project_reader_t switches to \"",
",",
"\"FILE_BY_FILE mode.\"",
"]",
")",
"self",
".",
"logger",
".",
"warning",
"(",
"msg",
")",
"return",
"self",
".",
"__parse_file_by_file",
"(",
"files",
")"
] |
parses a set of files
:param files: list of strings and\\or :class:`file_configuration_t`
instances.
:type files: list
:param compilation_mode: determines whether the files are parsed
individually or as one single chunk
:type compilation_mode: :class:`COMPILATION_MODE`
:rtype: [:class:`declaration_t`]
|
[
"parses",
"a",
"set",
"of",
"files"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/project_reader.py#L236-L264
|
gccxml/pygccxml
|
pygccxml/parser/project_reader.py
|
project_reader_t.read_string
|
def read_string(self, content):
"""Parse a string containing C/C++ source code.
:param content: C/C++ source code.
:type content: str
:rtype: Declarations
"""
reader = source_reader.source_reader_t(
self.__config,
None,
self.__decl_factory)
decls = reader.read_string(content)
self.__xml_generator_from_xml_file = reader.xml_generator_from_xml_file
return decls
|
python
|
def read_string(self, content):
reader = source_reader.source_reader_t(
self.__config,
None,
self.__decl_factory)
decls = reader.read_string(content)
self.__xml_generator_from_xml_file = reader.xml_generator_from_xml_file
return decls
|
[
"def",
"read_string",
"(",
"self",
",",
"content",
")",
":",
"reader",
"=",
"source_reader",
".",
"source_reader_t",
"(",
"self",
".",
"__config",
",",
"None",
",",
"self",
".",
"__decl_factory",
")",
"decls",
"=",
"reader",
".",
"read_string",
"(",
"content",
")",
"self",
".",
"__xml_generator_from_xml_file",
"=",
"reader",
".",
"xml_generator_from_xml_file",
"return",
"decls"
] |
Parse a string containing C/C++ source code.
:param content: C/C++ source code.
:type content: str
:rtype: Declarations
|
[
"Parse",
"a",
"string",
"containing",
"C",
"/",
"C",
"++",
"source",
"code",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/project_reader.py#L358-L371
|
gccxml/pygccxml
|
pygccxml/parser/project_reader.py
|
project_reader_t.read_xml
|
def read_xml(self, file_configuration):
"""parses C++ code, defined on the file_configurations and returns
GCCXML generated file content"""
xml_file_path = None
delete_xml_file = True
fc = file_configuration
reader = source_reader.source_reader_t(
self.__config,
None,
self.__decl_factory)
try:
if fc.content_type == fc.CONTENT_TYPE.STANDARD_SOURCE_FILE:
self.logger.info('Parsing source file "%s" ... ', fc.data)
xml_file_path = reader.create_xml_file(fc.data)
elif fc.content_type == \
file_configuration_t.CONTENT_TYPE.GCCXML_GENERATED_FILE:
self.logger.info('Parsing xml file "%s" ... ', fc.data)
xml_file_path = fc.data
delete_xml_file = False
elif fc.content_type == fc.CONTENT_TYPE.CACHED_SOURCE_FILE:
# TODO: raise error when header file does not exist
if not os.path.exists(fc.cached_source_file):
dir_ = os.path.split(fc.cached_source_file)[0]
if dir_ and not os.path.exists(dir_):
os.makedirs(dir_)
self.logger.info(
'Creating xml file "%s" from source file "%s" ... ',
fc.cached_source_file, fc.data)
xml_file_path = reader.create_xml_file(
fc.data,
fc.cached_source_file)
else:
xml_file_path = fc.cached_source_file
else:
xml_file_path = reader.create_xml_file_from_string(fc.data)
with open(xml_file_path, "r") as xml_file:
xml = xml_file.read()
utils.remove_file_no_raise(xml_file_path, self.__config)
self.__xml_generator_from_xml_file = \
reader.xml_generator_from_xml_file
return xml
finally:
if xml_file_path and delete_xml_file:
utils.remove_file_no_raise(xml_file_path, self.__config)
|
python
|
def read_xml(self, file_configuration):
xml_file_path = None
delete_xml_file = True
fc = file_configuration
reader = source_reader.source_reader_t(
self.__config,
None,
self.__decl_factory)
try:
if fc.content_type == fc.CONTENT_TYPE.STANDARD_SOURCE_FILE:
self.logger.info('Parsing source file "%s" ... ', fc.data)
xml_file_path = reader.create_xml_file(fc.data)
elif fc.content_type == \
file_configuration_t.CONTENT_TYPE.GCCXML_GENERATED_FILE:
self.logger.info('Parsing xml file "%s" ... ', fc.data)
xml_file_path = fc.data
delete_xml_file = False
elif fc.content_type == fc.CONTENT_TYPE.CACHED_SOURCE_FILE:
if not os.path.exists(fc.cached_source_file):
dir_ = os.path.split(fc.cached_source_file)[0]
if dir_ and not os.path.exists(dir_):
os.makedirs(dir_)
self.logger.info(
'Creating xml file "%s" from source file "%s" ... ',
fc.cached_source_file, fc.data)
xml_file_path = reader.create_xml_file(
fc.data,
fc.cached_source_file)
else:
xml_file_path = fc.cached_source_file
else:
xml_file_path = reader.create_xml_file_from_string(fc.data)
with open(xml_file_path, "r") as xml_file:
xml = xml_file.read()
utils.remove_file_no_raise(xml_file_path, self.__config)
self.__xml_generator_from_xml_file = \
reader.xml_generator_from_xml_file
return xml
finally:
if xml_file_path and delete_xml_file:
utils.remove_file_no_raise(xml_file_path, self.__config)
|
[
"def",
"read_xml",
"(",
"self",
",",
"file_configuration",
")",
":",
"xml_file_path",
"=",
"None",
"delete_xml_file",
"=",
"True",
"fc",
"=",
"file_configuration",
"reader",
"=",
"source_reader",
".",
"source_reader_t",
"(",
"self",
".",
"__config",
",",
"None",
",",
"self",
".",
"__decl_factory",
")",
"try",
":",
"if",
"fc",
".",
"content_type",
"==",
"fc",
".",
"CONTENT_TYPE",
".",
"STANDARD_SOURCE_FILE",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Parsing source file \"%s\" ... '",
",",
"fc",
".",
"data",
")",
"xml_file_path",
"=",
"reader",
".",
"create_xml_file",
"(",
"fc",
".",
"data",
")",
"elif",
"fc",
".",
"content_type",
"==",
"file_configuration_t",
".",
"CONTENT_TYPE",
".",
"GCCXML_GENERATED_FILE",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Parsing xml file \"%s\" ... '",
",",
"fc",
".",
"data",
")",
"xml_file_path",
"=",
"fc",
".",
"data",
"delete_xml_file",
"=",
"False",
"elif",
"fc",
".",
"content_type",
"==",
"fc",
".",
"CONTENT_TYPE",
".",
"CACHED_SOURCE_FILE",
":",
"# TODO: raise error when header file does not exist",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"fc",
".",
"cached_source_file",
")",
":",
"dir_",
"=",
"os",
".",
"path",
".",
"split",
"(",
"fc",
".",
"cached_source_file",
")",
"[",
"0",
"]",
"if",
"dir_",
"and",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"dir_",
")",
":",
"os",
".",
"makedirs",
"(",
"dir_",
")",
"self",
".",
"logger",
".",
"info",
"(",
"'Creating xml file \"%s\" from source file \"%s\" ... '",
",",
"fc",
".",
"cached_source_file",
",",
"fc",
".",
"data",
")",
"xml_file_path",
"=",
"reader",
".",
"create_xml_file",
"(",
"fc",
".",
"data",
",",
"fc",
".",
"cached_source_file",
")",
"else",
":",
"xml_file_path",
"=",
"fc",
".",
"cached_source_file",
"else",
":",
"xml_file_path",
"=",
"reader",
".",
"create_xml_file_from_string",
"(",
"fc",
".",
"data",
")",
"with",
"open",
"(",
"xml_file_path",
",",
"\"r\"",
")",
"as",
"xml_file",
":",
"xml",
"=",
"xml_file",
".",
"read",
"(",
")",
"utils",
".",
"remove_file_no_raise",
"(",
"xml_file_path",
",",
"self",
".",
"__config",
")",
"self",
".",
"__xml_generator_from_xml_file",
"=",
"reader",
".",
"xml_generator_from_xml_file",
"return",
"xml",
"finally",
":",
"if",
"xml_file_path",
"and",
"delete_xml_file",
":",
"utils",
".",
"remove_file_no_raise",
"(",
"xml_file_path",
",",
"self",
".",
"__config",
")"
] |
parses C++ code, defined on the file_configurations and returns
GCCXML generated file content
|
[
"parses",
"C",
"++",
"code",
"defined",
"on",
"the",
"file_configurations",
"and",
"returns",
"GCCXML",
"generated",
"file",
"content"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/project_reader.py#L373-L417
|
gccxml/pygccxml
|
pygccxml/declarations/dependencies.py
|
get_dependencies_from_decl
|
def get_dependencies_from_decl(decl, recursive=True):
"""
Returns the list of all types and declarations the declaration depends on.
"""
result = []
if isinstance(decl, typedef.typedef_t) or \
isinstance(decl, variable.variable_t):
return [dependency_info_t(decl, decl.decl_type)]
if isinstance(decl, namespace.namespace_t):
if recursive:
for d in decl.declarations:
result.extend(get_dependencies_from_decl(d))
return result
if isinstance(decl, calldef.calldef_t):
if decl.return_type:
result.append(
dependency_info_t(decl, decl.return_type, hint="return type"))
for arg in decl.arguments:
result.append(dependency_info_t(decl, arg.decl_type))
for exc in decl.exceptions:
result.append(dependency_info_t(decl, exc, hint="exception"))
return result
if isinstance(decl, class_declaration.class_t):
for base in decl.bases:
result.append(
dependency_info_t(
decl,
base.related_class,
base.access_type,
"base class"))
if recursive:
for access_type in class_declaration.ACCESS_TYPES.ALL:
result.extend(
__find_out_member_dependencies(
decl.get_members(access_type), access_type))
return result
return result
|
python
|
def get_dependencies_from_decl(decl, recursive=True):
result = []
if isinstance(decl, typedef.typedef_t) or \
isinstance(decl, variable.variable_t):
return [dependency_info_t(decl, decl.decl_type)]
if isinstance(decl, namespace.namespace_t):
if recursive:
for d in decl.declarations:
result.extend(get_dependencies_from_decl(d))
return result
if isinstance(decl, calldef.calldef_t):
if decl.return_type:
result.append(
dependency_info_t(decl, decl.return_type, hint="return type"))
for arg in decl.arguments:
result.append(dependency_info_t(decl, arg.decl_type))
for exc in decl.exceptions:
result.append(dependency_info_t(decl, exc, hint="exception"))
return result
if isinstance(decl, class_declaration.class_t):
for base in decl.bases:
result.append(
dependency_info_t(
decl,
base.related_class,
base.access_type,
"base class"))
if recursive:
for access_type in class_declaration.ACCESS_TYPES.ALL:
result.extend(
__find_out_member_dependencies(
decl.get_members(access_type), access_type))
return result
return result
|
[
"def",
"get_dependencies_from_decl",
"(",
"decl",
",",
"recursive",
"=",
"True",
")",
":",
"result",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"decl",
",",
"typedef",
".",
"typedef_t",
")",
"or",
"isinstance",
"(",
"decl",
",",
"variable",
".",
"variable_t",
")",
":",
"return",
"[",
"dependency_info_t",
"(",
"decl",
",",
"decl",
".",
"decl_type",
")",
"]",
"if",
"isinstance",
"(",
"decl",
",",
"namespace",
".",
"namespace_t",
")",
":",
"if",
"recursive",
":",
"for",
"d",
"in",
"decl",
".",
"declarations",
":",
"result",
".",
"extend",
"(",
"get_dependencies_from_decl",
"(",
"d",
")",
")",
"return",
"result",
"if",
"isinstance",
"(",
"decl",
",",
"calldef",
".",
"calldef_t",
")",
":",
"if",
"decl",
".",
"return_type",
":",
"result",
".",
"append",
"(",
"dependency_info_t",
"(",
"decl",
",",
"decl",
".",
"return_type",
",",
"hint",
"=",
"\"return type\"",
")",
")",
"for",
"arg",
"in",
"decl",
".",
"arguments",
":",
"result",
".",
"append",
"(",
"dependency_info_t",
"(",
"decl",
",",
"arg",
".",
"decl_type",
")",
")",
"for",
"exc",
"in",
"decl",
".",
"exceptions",
":",
"result",
".",
"append",
"(",
"dependency_info_t",
"(",
"decl",
",",
"exc",
",",
"hint",
"=",
"\"exception\"",
")",
")",
"return",
"result",
"if",
"isinstance",
"(",
"decl",
",",
"class_declaration",
".",
"class_t",
")",
":",
"for",
"base",
"in",
"decl",
".",
"bases",
":",
"result",
".",
"append",
"(",
"dependency_info_t",
"(",
"decl",
",",
"base",
".",
"related_class",
",",
"base",
".",
"access_type",
",",
"\"base class\"",
")",
")",
"if",
"recursive",
":",
"for",
"access_type",
"in",
"class_declaration",
".",
"ACCESS_TYPES",
".",
"ALL",
":",
"result",
".",
"extend",
"(",
"__find_out_member_dependencies",
"(",
"decl",
".",
"get_members",
"(",
"access_type",
")",
",",
"access_type",
")",
")",
"return",
"result",
"return",
"result"
] |
Returns the list of all types and declarations the declaration depends on.
|
[
"Returns",
"the",
"list",
"of",
"all",
"types",
"and",
"declarations",
"the",
"declaration",
"depends",
"on",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/dependencies.py#L16-L53
|
gccxml/pygccxml
|
pygccxml/declarations/dependencies.py
|
dependency_info_t.i_depend_on_them
|
def i_depend_on_them(decl):
"""Returns set of declarations. every item in the returned set,
depends on a declaration from the input"""
to_be_included = set()
for dependency_info in get_dependencies_from_decl(decl):
for ddecl in dependency_info.find_out_depend_on_it_declarations():
if ddecl:
to_be_included.add(ddecl)
if isinstance(decl.parent, class_declaration.class_t):
to_be_included.add(decl.parent)
return to_be_included
|
python
|
def i_depend_on_them(decl):
to_be_included = set()
for dependency_info in get_dependencies_from_decl(decl):
for ddecl in dependency_info.find_out_depend_on_it_declarations():
if ddecl:
to_be_included.add(ddecl)
if isinstance(decl.parent, class_declaration.class_t):
to_be_included.add(decl.parent)
return to_be_included
|
[
"def",
"i_depend_on_them",
"(",
"decl",
")",
":",
"to_be_included",
"=",
"set",
"(",
")",
"for",
"dependency_info",
"in",
"get_dependencies_from_decl",
"(",
"decl",
")",
":",
"for",
"ddecl",
"in",
"dependency_info",
".",
"find_out_depend_on_it_declarations",
"(",
")",
":",
"if",
"ddecl",
":",
"to_be_included",
".",
"add",
"(",
"ddecl",
")",
"if",
"isinstance",
"(",
"decl",
".",
"parent",
",",
"class_declaration",
".",
"class_t",
")",
":",
"to_be_included",
".",
"add",
"(",
"decl",
".",
"parent",
")",
"return",
"to_be_included"
] |
Returns set of declarations. every item in the returned set,
depends on a declaration from the input
|
[
"Returns",
"set",
"of",
"declarations",
".",
"every",
"item",
"in",
"the",
"returned",
"set",
"depends",
"on",
"a",
"declaration",
"from",
"the",
"input"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/dependencies.py#L113-L125
|
gccxml/pygccxml
|
pygccxml/declarations/dependencies.py
|
dependency_info_t.we_depend_on_them
|
def we_depend_on_them(decls):
"""Returns set of declarations. every item in the returned set,
depends on a declaration from the input"""
to_be_included = set()
for decl in decls:
to_be_included.update(dependency_info_t.i_depend_on_them(decl))
return to_be_included
|
python
|
def we_depend_on_them(decls):
to_be_included = set()
for decl in decls:
to_be_included.update(dependency_info_t.i_depend_on_them(decl))
return to_be_included
|
[
"def",
"we_depend_on_them",
"(",
"decls",
")",
":",
"to_be_included",
"=",
"set",
"(",
")",
"for",
"decl",
"in",
"decls",
":",
"to_be_included",
".",
"update",
"(",
"dependency_info_t",
".",
"i_depend_on_them",
"(",
"decl",
")",
")",
"return",
"to_be_included"
] |
Returns set of declarations. every item in the returned set,
depends on a declaration from the input
|
[
"Returns",
"set",
"of",
"declarations",
".",
"every",
"item",
"in",
"the",
"returned",
"set",
"depends",
"on",
"a",
"declaration",
"from",
"the",
"input"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/dependencies.py#L128-L134
|
gccxml/pygccxml
|
pygccxml/declarations/templates.py
|
normalize_name
|
def normalize_name(decl):
"""
Cached variant of normalize
Args:
decl (declaration.declaration_t): the declaration
Returns:
str: normalized name
"""
if decl.cache.normalized_name is None:
decl.cache.normalized_name = normalize(decl.name)
return decl.cache.normalized_name
|
python
|
def normalize_name(decl):
if decl.cache.normalized_name is None:
decl.cache.normalized_name = normalize(decl.name)
return decl.cache.normalized_name
|
[
"def",
"normalize_name",
"(",
"decl",
")",
":",
"if",
"decl",
".",
"cache",
".",
"normalized_name",
"is",
"None",
":",
"decl",
".",
"cache",
".",
"normalized_name",
"=",
"normalize",
"(",
"decl",
".",
"name",
")",
"return",
"decl",
".",
"cache",
".",
"normalized_name"
] |
Cached variant of normalize
Args:
decl (declaration.declaration_t): the declaration
Returns:
str: normalized name
|
[
"Cached",
"variant",
"of",
"normalize"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/templates.py#L81-L93
|
gccxml/pygccxml
|
pygccxml/declarations/templates.py
|
normalize_partial_name
|
def normalize_partial_name(decl):
"""
Cached variant of normalize
Args:
decl (declaration.declaration_t): the declaration
Returns:
str: normalized name
"""
if decl.cache.normalized_partial_name is None:
decl.cache.normalized_partial_name = normalize(decl.partial_name)
return decl.cache.normalized_partial_name
|
python
|
def normalize_partial_name(decl):
if decl.cache.normalized_partial_name is None:
decl.cache.normalized_partial_name = normalize(decl.partial_name)
return decl.cache.normalized_partial_name
|
[
"def",
"normalize_partial_name",
"(",
"decl",
")",
":",
"if",
"decl",
".",
"cache",
".",
"normalized_partial_name",
"is",
"None",
":",
"decl",
".",
"cache",
".",
"normalized_partial_name",
"=",
"normalize",
"(",
"decl",
".",
"partial_name",
")",
"return",
"decl",
".",
"cache",
".",
"normalized_partial_name"
] |
Cached variant of normalize
Args:
decl (declaration.declaration_t): the declaration
Returns:
str: normalized name
|
[
"Cached",
"variant",
"of",
"normalize"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/templates.py#L96-L108
|
gccxml/pygccxml
|
pygccxml/declarations/templates.py
|
normalize_full_name_true
|
def normalize_full_name_true(decl):
"""
Cached variant of normalize
Args:
decl (declaration.declaration_t): the declaration
Returns:
str: normalized name
"""
if decl.cache.normalized_full_name_true is None:
decl.cache.normalized_full_name_true = normalize(
declaration_utils.full_name(decl, with_defaults=True))
return decl.cache.normalized_full_name_true
|
python
|
def normalize_full_name_true(decl):
if decl.cache.normalized_full_name_true is None:
decl.cache.normalized_full_name_true = normalize(
declaration_utils.full_name(decl, with_defaults=True))
return decl.cache.normalized_full_name_true
|
[
"def",
"normalize_full_name_true",
"(",
"decl",
")",
":",
"if",
"decl",
".",
"cache",
".",
"normalized_full_name_true",
"is",
"None",
":",
"decl",
".",
"cache",
".",
"normalized_full_name_true",
"=",
"normalize",
"(",
"declaration_utils",
".",
"full_name",
"(",
"decl",
",",
"with_defaults",
"=",
"True",
")",
")",
"return",
"decl",
".",
"cache",
".",
"normalized_full_name_true"
] |
Cached variant of normalize
Args:
decl (declaration.declaration_t): the declaration
Returns:
str: normalized name
|
[
"Cached",
"variant",
"of",
"normalize"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/templates.py#L111-L124
|
gccxml/pygccxml
|
pygccxml/declarations/templates.py
|
normalize_full_name_false
|
def normalize_full_name_false(decl):
"""
Cached variant of normalize
Args:
decl (declaration.declaration_t): the declaration
Returns:
str: normalized name
"""
if decl.cache.normalized_full_name_false is None:
decl.cache.normalized_full_name_false = normalize(
declaration_utils.full_name(decl, with_defaults=False))
return decl.cache.normalized_full_name_false
|
python
|
def normalize_full_name_false(decl):
if decl.cache.normalized_full_name_false is None:
decl.cache.normalized_full_name_false = normalize(
declaration_utils.full_name(decl, with_defaults=False))
return decl.cache.normalized_full_name_false
|
[
"def",
"normalize_full_name_false",
"(",
"decl",
")",
":",
"if",
"decl",
".",
"cache",
".",
"normalized_full_name_false",
"is",
"None",
":",
"decl",
".",
"cache",
".",
"normalized_full_name_false",
"=",
"normalize",
"(",
"declaration_utils",
".",
"full_name",
"(",
"decl",
",",
"with_defaults",
"=",
"False",
")",
")",
"return",
"decl",
".",
"cache",
".",
"normalized_full_name_false"
] |
Cached variant of normalize
Args:
decl (declaration.declaration_t): the declaration
Returns:
str: normalized name
|
[
"Cached",
"variant",
"of",
"normalize"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/templates.py#L127-L140
|
gccxml/pygccxml
|
pygccxml/declarations/container_traits.py
|
find_container_traits
|
def find_container_traits(cls_or_string):
"""
Find the container traits type of a declaration.
Args:
cls_or_string (str | declarations.declaration_t): a string
Returns:
declarations.container_traits: a container traits
"""
if utils.is_str(cls_or_string):
if not templates.is_instantiation(cls_or_string):
return None
name = templates.name(cls_or_string)
if name.startswith('std::'):
name = name[len('std::'):]
if name.startswith('std::tr1::'):
name = name[len('std::tr1::'):]
for cls_traits in all_container_traits:
if cls_traits.name() == name:
return cls_traits
else:
if isinstance(cls_or_string, class_declaration.class_types):
# Look in the cache.
if cls_or_string.cache.container_traits is not None:
return cls_or_string.cache.container_traits
# Look for a container traits
for cls_traits in all_container_traits:
if cls_traits.is_my_case(cls_or_string):
# Store in the cache
if isinstance(cls_or_string, class_declaration.class_types):
cls_or_string.cache.container_traits = cls_traits
return cls_traits
|
python
|
def find_container_traits(cls_or_string):
if utils.is_str(cls_or_string):
if not templates.is_instantiation(cls_or_string):
return None
name = templates.name(cls_or_string)
if name.startswith('std::'):
name = name[len('std::'):]
if name.startswith('std::tr1::'):
name = name[len('std::tr1::'):]
for cls_traits in all_container_traits:
if cls_traits.name() == name:
return cls_traits
else:
if isinstance(cls_or_string, class_declaration.class_types):
if cls_or_string.cache.container_traits is not None:
return cls_or_string.cache.container_traits
for cls_traits in all_container_traits:
if cls_traits.is_my_case(cls_or_string):
if isinstance(cls_or_string, class_declaration.class_types):
cls_or_string.cache.container_traits = cls_traits
return cls_traits
|
[
"def",
"find_container_traits",
"(",
"cls_or_string",
")",
":",
"if",
"utils",
".",
"is_str",
"(",
"cls_or_string",
")",
":",
"if",
"not",
"templates",
".",
"is_instantiation",
"(",
"cls_or_string",
")",
":",
"return",
"None",
"name",
"=",
"templates",
".",
"name",
"(",
"cls_or_string",
")",
"if",
"name",
".",
"startswith",
"(",
"'std::'",
")",
":",
"name",
"=",
"name",
"[",
"len",
"(",
"'std::'",
")",
":",
"]",
"if",
"name",
".",
"startswith",
"(",
"'std::tr1::'",
")",
":",
"name",
"=",
"name",
"[",
"len",
"(",
"'std::tr1::'",
")",
":",
"]",
"for",
"cls_traits",
"in",
"all_container_traits",
":",
"if",
"cls_traits",
".",
"name",
"(",
")",
"==",
"name",
":",
"return",
"cls_traits",
"else",
":",
"if",
"isinstance",
"(",
"cls_or_string",
",",
"class_declaration",
".",
"class_types",
")",
":",
"# Look in the cache.",
"if",
"cls_or_string",
".",
"cache",
".",
"container_traits",
"is",
"not",
"None",
":",
"return",
"cls_or_string",
".",
"cache",
".",
"container_traits",
"# Look for a container traits",
"for",
"cls_traits",
"in",
"all_container_traits",
":",
"if",
"cls_traits",
".",
"is_my_case",
"(",
"cls_or_string",
")",
":",
"# Store in the cache",
"if",
"isinstance",
"(",
"cls_or_string",
",",
"class_declaration",
".",
"class_types",
")",
":",
"cls_or_string",
".",
"cache",
".",
"container_traits",
"=",
"cls_traits",
"return",
"cls_traits"
] |
Find the container traits type of a declaration.
Args:
cls_or_string (str | declarations.declaration_t): a string
Returns:
declarations.container_traits: a container traits
|
[
"Find",
"the",
"container",
"traits",
"type",
"of",
"a",
"declaration",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/container_traits.py#L697-L732
|
gccxml/pygccxml
|
pygccxml/declarations/container_traits.py
|
container_traits_impl_t.get_container_or_none
|
def get_container_or_none(self, type_):
"""
Returns reference to the class declaration or None.
"""
type_ = type_traits.remove_alias(type_)
type_ = type_traits.remove_cv(type_)
utils.loggers.queries_engine.debug(
"Container traits: cleaned up search %s", type_)
if isinstance(type_, cpptypes.declarated_t):
cls_declaration = type_traits.remove_alias(type_.declaration)
elif isinstance(type_, class_declaration.class_t):
cls_declaration = type_
elif isinstance(type_, class_declaration.class_declaration_t):
cls_declaration = type_
else:
utils.loggers.queries_engine.debug(
"Container traits: returning None, type not known\n")
return
if not cls_declaration.name.startswith(self.name() + '<'):
utils.loggers.queries_engine.debug(
"Container traits: returning None, " +
"declaration starts with " + self.name() + '<\n')
return
# When using libstd++, some container traits are defined in
# std::tr1::. See remove_template_defaults_tester.py.
# In this case the is_defined_in_xxx test needs to be done
# on the parent
decl = cls_declaration
if isinstance(type_, class_declaration.class_declaration_t):
is_ns = isinstance(type_.parent, namespace.namespace_t)
if is_ns and type_.parent.name == "tr1":
decl = cls_declaration.parent
elif isinstance(type_, cpptypes.declarated_t):
is_ns = isinstance(type_.declaration.parent, namespace.namespace_t)
if is_ns and type_.declaration.parent.name == "tr1":
decl = cls_declaration.parent
for ns in std_namespaces:
if traits_impl_details.impl_details.is_defined_in_xxx(ns, decl):
utils.loggers.queries_engine.debug(
"Container traits: get_container_or_none() will return " +
cls_declaration.name)
# The is_defined_in_xxx check is done on decl, but we return
# the original declation so that the rest of the algorithm
# is able to work with it.
return cls_declaration
# This should not happen
utils.loggers.queries_engine.debug(
"Container traits: get_container_or_none() will return None\n")
|
python
|
def get_container_or_none(self, type_):
type_ = type_traits.remove_alias(type_)
type_ = type_traits.remove_cv(type_)
utils.loggers.queries_engine.debug(
"Container traits: cleaned up search %s", type_)
if isinstance(type_, cpptypes.declarated_t):
cls_declaration = type_traits.remove_alias(type_.declaration)
elif isinstance(type_, class_declaration.class_t):
cls_declaration = type_
elif isinstance(type_, class_declaration.class_declaration_t):
cls_declaration = type_
else:
utils.loggers.queries_engine.debug(
"Container traits: returning None, type not known\n")
return
if not cls_declaration.name.startswith(self.name() + '<'):
utils.loggers.queries_engine.debug(
"Container traits: returning None, " +
"declaration starts with " + self.name() + '<\n')
return
decl = cls_declaration
if isinstance(type_, class_declaration.class_declaration_t):
is_ns = isinstance(type_.parent, namespace.namespace_t)
if is_ns and type_.parent.name == "tr1":
decl = cls_declaration.parent
elif isinstance(type_, cpptypes.declarated_t):
is_ns = isinstance(type_.declaration.parent, namespace.namespace_t)
if is_ns and type_.declaration.parent.name == "tr1":
decl = cls_declaration.parent
for ns in std_namespaces:
if traits_impl_details.impl_details.is_defined_in_xxx(ns, decl):
utils.loggers.queries_engine.debug(
"Container traits: get_container_or_none() will return " +
cls_declaration.name)
return cls_declaration
utils.loggers.queries_engine.debug(
"Container traits: get_container_or_none() will return None\n")
|
[
"def",
"get_container_or_none",
"(",
"self",
",",
"type_",
")",
":",
"type_",
"=",
"type_traits",
".",
"remove_alias",
"(",
"type_",
")",
"type_",
"=",
"type_traits",
".",
"remove_cv",
"(",
"type_",
")",
"utils",
".",
"loggers",
".",
"queries_engine",
".",
"debug",
"(",
"\"Container traits: cleaned up search %s\"",
",",
"type_",
")",
"if",
"isinstance",
"(",
"type_",
",",
"cpptypes",
".",
"declarated_t",
")",
":",
"cls_declaration",
"=",
"type_traits",
".",
"remove_alias",
"(",
"type_",
".",
"declaration",
")",
"elif",
"isinstance",
"(",
"type_",
",",
"class_declaration",
".",
"class_t",
")",
":",
"cls_declaration",
"=",
"type_",
"elif",
"isinstance",
"(",
"type_",
",",
"class_declaration",
".",
"class_declaration_t",
")",
":",
"cls_declaration",
"=",
"type_",
"else",
":",
"utils",
".",
"loggers",
".",
"queries_engine",
".",
"debug",
"(",
"\"Container traits: returning None, type not known\\n\"",
")",
"return",
"if",
"not",
"cls_declaration",
".",
"name",
".",
"startswith",
"(",
"self",
".",
"name",
"(",
")",
"+",
"'<'",
")",
":",
"utils",
".",
"loggers",
".",
"queries_engine",
".",
"debug",
"(",
"\"Container traits: returning None, \"",
"+",
"\"declaration starts with \"",
"+",
"self",
".",
"name",
"(",
")",
"+",
"'<\\n'",
")",
"return",
"# When using libstd++, some container traits are defined in",
"# std::tr1::. See remove_template_defaults_tester.py.",
"# In this case the is_defined_in_xxx test needs to be done",
"# on the parent",
"decl",
"=",
"cls_declaration",
"if",
"isinstance",
"(",
"type_",
",",
"class_declaration",
".",
"class_declaration_t",
")",
":",
"is_ns",
"=",
"isinstance",
"(",
"type_",
".",
"parent",
",",
"namespace",
".",
"namespace_t",
")",
"if",
"is_ns",
"and",
"type_",
".",
"parent",
".",
"name",
"==",
"\"tr1\"",
":",
"decl",
"=",
"cls_declaration",
".",
"parent",
"elif",
"isinstance",
"(",
"type_",
",",
"cpptypes",
".",
"declarated_t",
")",
":",
"is_ns",
"=",
"isinstance",
"(",
"type_",
".",
"declaration",
".",
"parent",
",",
"namespace",
".",
"namespace_t",
")",
"if",
"is_ns",
"and",
"type_",
".",
"declaration",
".",
"parent",
".",
"name",
"==",
"\"tr1\"",
":",
"decl",
"=",
"cls_declaration",
".",
"parent",
"for",
"ns",
"in",
"std_namespaces",
":",
"if",
"traits_impl_details",
".",
"impl_details",
".",
"is_defined_in_xxx",
"(",
"ns",
",",
"decl",
")",
":",
"utils",
".",
"loggers",
".",
"queries_engine",
".",
"debug",
"(",
"\"Container traits: get_container_or_none() will return \"",
"+",
"cls_declaration",
".",
"name",
")",
"# The is_defined_in_xxx check is done on decl, but we return",
"# the original declation so that the rest of the algorithm",
"# is able to work with it.",
"return",
"cls_declaration",
"# This should not happen",
"utils",
".",
"loggers",
".",
"queries_engine",
".",
"debug",
"(",
"\"Container traits: get_container_or_none() will return None\\n\"",
")"
] |
Returns reference to the class declaration or None.
|
[
"Returns",
"reference",
"to",
"the",
"class",
"declaration",
"or",
"None",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/container_traits.py#L375-L430
|
gccxml/pygccxml
|
pygccxml/declarations/container_traits.py
|
container_traits_impl_t.class_declaration
|
def class_declaration(self, type_):
"""
Returns reference to the class declaration.
"""
utils.loggers.queries_engine.debug(
"Container traits: searching class declaration for %s", type_)
cls_declaration = self.get_container_or_none(type_)
if not cls_declaration:
raise TypeError(
'Type "%s" is not instantiation of std::%s' %
(type_.decl_string, self.name()))
return cls_declaration
|
python
|
def class_declaration(self, type_):
utils.loggers.queries_engine.debug(
"Container traits: searching class declaration for %s", type_)
cls_declaration = self.get_container_or_none(type_)
if not cls_declaration:
raise TypeError(
'Type "%s" is not instantiation of std::%s' %
(type_.decl_string, self.name()))
return cls_declaration
|
[
"def",
"class_declaration",
"(",
"self",
",",
"type_",
")",
":",
"utils",
".",
"loggers",
".",
"queries_engine",
".",
"debug",
"(",
"\"Container traits: searching class declaration for %s\"",
",",
"type_",
")",
"cls_declaration",
"=",
"self",
".",
"get_container_or_none",
"(",
"type_",
")",
"if",
"not",
"cls_declaration",
":",
"raise",
"TypeError",
"(",
"'Type \"%s\" is not instantiation of std::%s'",
"%",
"(",
"type_",
".",
"decl_string",
",",
"self",
".",
"name",
"(",
")",
")",
")",
"return",
"cls_declaration"
] |
Returns reference to the class declaration.
|
[
"Returns",
"reference",
"to",
"the",
"class",
"declaration",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/container_traits.py#L440-L454
|
gccxml/pygccxml
|
pygccxml/declarations/container_traits.py
|
container_traits_impl_t.element_type
|
def element_type(self, type_):
"""returns reference to the class value\\mapped type declaration"""
return self.__find_xxx_type(
type_,
self.element_type_index,
self.element_type_typedef,
'container_element_type')
|
python
|
def element_type(self, type_):
return self.__find_xxx_type(
type_,
self.element_type_index,
self.element_type_typedef,
'container_element_type')
|
[
"def",
"element_type",
"(",
"self",
",",
"type_",
")",
":",
"return",
"self",
".",
"__find_xxx_type",
"(",
"type_",
",",
"self",
".",
"element_type_index",
",",
"self",
".",
"element_type_typedef",
",",
"'container_element_type'",
")"
] |
returns reference to the class value\\mapped type declaration
|
[
"returns",
"reference",
"to",
"the",
"class",
"value",
"\\\\",
"mapped",
"type",
"declaration"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/container_traits.py#L488-L494
|
gccxml/pygccxml
|
pygccxml/declarations/container_traits.py
|
container_traits_impl_t.key_type
|
def key_type(self, type_):
"""returns reference to the class key type declaration"""
if not self.is_mapping(type_):
raise TypeError(
'Type "%s" is not "mapping" container' %
str(type_))
return self.__find_xxx_type(
type_,
self.key_type_index,
self.key_type_typedef,
'container_key_type')
|
python
|
def key_type(self, type_):
if not self.is_mapping(type_):
raise TypeError(
'Type "%s" is not "mapping" container' %
str(type_))
return self.__find_xxx_type(
type_,
self.key_type_index,
self.key_type_typedef,
'container_key_type')
|
[
"def",
"key_type",
"(",
"self",
",",
"type_",
")",
":",
"if",
"not",
"self",
".",
"is_mapping",
"(",
"type_",
")",
":",
"raise",
"TypeError",
"(",
"'Type \"%s\" is not \"mapping\" container'",
"%",
"str",
"(",
"type_",
")",
")",
"return",
"self",
".",
"__find_xxx_type",
"(",
"type_",
",",
"self",
".",
"key_type_index",
",",
"self",
".",
"key_type_typedef",
",",
"'container_key_type'",
")"
] |
returns reference to the class key type declaration
|
[
"returns",
"reference",
"to",
"the",
"class",
"key",
"type",
"declaration"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/container_traits.py#L496-L506
|
gccxml/pygccxml
|
pygccxml/declarations/container_traits.py
|
container_traits_impl_t.remove_defaults
|
def remove_defaults(self, type_or_string):
"""
Removes template defaults from a templated class instantiation.
For example:
.. code-block:: c++
std::vector< int, std::allocator< int > >
will become:
.. code-block:: c++
std::vector< int >
"""
name = type_or_string
if not utils.is_str(type_or_string):
name = self.class_declaration(type_or_string).name
if not self.remove_defaults_impl:
return name
no_defaults = self.remove_defaults_impl(name)
if not no_defaults:
return name
return no_defaults
|
python
|
def remove_defaults(self, type_or_string):
name = type_or_string
if not utils.is_str(type_or_string):
name = self.class_declaration(type_or_string).name
if not self.remove_defaults_impl:
return name
no_defaults = self.remove_defaults_impl(name)
if not no_defaults:
return name
return no_defaults
|
[
"def",
"remove_defaults",
"(",
"self",
",",
"type_or_string",
")",
":",
"name",
"=",
"type_or_string",
"if",
"not",
"utils",
".",
"is_str",
"(",
"type_or_string",
")",
":",
"name",
"=",
"self",
".",
"class_declaration",
"(",
"type_or_string",
")",
".",
"name",
"if",
"not",
"self",
".",
"remove_defaults_impl",
":",
"return",
"name",
"no_defaults",
"=",
"self",
".",
"remove_defaults_impl",
"(",
"name",
")",
"if",
"not",
"no_defaults",
":",
"return",
"name",
"return",
"no_defaults"
] |
Removes template defaults from a templated class instantiation.
For example:
.. code-block:: c++
std::vector< int, std::allocator< int > >
will become:
.. code-block:: c++
std::vector< int >
|
[
"Removes",
"template",
"defaults",
"from",
"a",
"templated",
"class",
"instantiation",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/container_traits.py#L508-L532
|
gccxml/pygccxml
|
pygccxml/declarations/namespace.py
|
get_global_namespace
|
def get_global_namespace(decls):
"""
Get the global namespace (::) from a declaration tree.
Args:
decls (list[declaration_t]): a list of declarations
Returns:
namespace_t: the global namespace_t object (::)
"""
found = [
decl for decl in scopedef.make_flatten(decls) if decl.name == '::' and
isinstance(decl, namespace_t)]
if len(found) == 1:
return found[0]
raise RuntimeError("Unable to find global namespace.")
|
python
|
def get_global_namespace(decls):
found = [
decl for decl in scopedef.make_flatten(decls) if decl.name == '::' and
isinstance(decl, namespace_t)]
if len(found) == 1:
return found[0]
raise RuntimeError("Unable to find global namespace.")
|
[
"def",
"get_global_namespace",
"(",
"decls",
")",
":",
"found",
"=",
"[",
"decl",
"for",
"decl",
"in",
"scopedef",
".",
"make_flatten",
"(",
"decls",
")",
"if",
"decl",
".",
"name",
"==",
"'::'",
"and",
"isinstance",
"(",
"decl",
",",
"namespace_t",
")",
"]",
"if",
"len",
"(",
"found",
")",
"==",
"1",
":",
"return",
"found",
"[",
"0",
"]",
"raise",
"RuntimeError",
"(",
"\"Unable to find global namespace.\"",
")"
] |
Get the global namespace (::) from a declaration tree.
Args:
decls (list[declaration_t]): a list of declarations
Returns:
namespace_t: the global namespace_t object (::)
|
[
"Get",
"the",
"global",
"namespace",
"(",
"::",
")",
"from",
"a",
"declaration",
"tree",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/namespace.py#L273-L289
|
gccxml/pygccxml
|
pygccxml/declarations/namespace.py
|
namespace_t.take_parenting
|
def take_parenting(self, inst):
"""
Takes parenting from inst and transfers it to self.
Args:
inst (namespace_t): a namespace declaration
"""
if self is inst:
return
for decl in inst.declarations:
decl.parent = self
self.declarations.append(decl)
inst.declarations = []
|
python
|
def take_parenting(self, inst):
if self is inst:
return
for decl in inst.declarations:
decl.parent = self
self.declarations.append(decl)
inst.declarations = []
|
[
"def",
"take_parenting",
"(",
"self",
",",
"inst",
")",
":",
"if",
"self",
"is",
"inst",
":",
"return",
"for",
"decl",
"in",
"inst",
".",
"declarations",
":",
"decl",
".",
"parent",
"=",
"self",
"self",
".",
"declarations",
".",
"append",
"(",
"decl",
")",
"inst",
".",
"declarations",
"=",
"[",
"]"
] |
Takes parenting from inst and transfers it to self.
Args:
inst (namespace_t): a namespace declaration
|
[
"Takes",
"parenting",
"from",
"inst",
"and",
"transfers",
"it",
"to",
"self",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/namespace.py#L73-L87
|
gccxml/pygccxml
|
pygccxml/declarations/namespace.py
|
namespace_t.remove_declaration
|
def remove_declaration(self, decl):
"""
Removes declaration from members list.
:param decl: declaration to be removed
:type decl: :class:`declaration_t`
"""
del self.declarations[self.declarations.index(decl)]
decl.cache.reset()
|
python
|
def remove_declaration(self, decl):
del self.declarations[self.declarations.index(decl)]
decl.cache.reset()
|
[
"def",
"remove_declaration",
"(",
"self",
",",
"decl",
")",
":",
"del",
"self",
".",
"declarations",
"[",
"self",
".",
"declarations",
".",
"index",
"(",
"decl",
")",
"]",
"decl",
".",
"cache",
".",
"reset",
"(",
")"
] |
Removes declaration from members list.
:param decl: declaration to be removed
:type decl: :class:`declaration_t`
|
[
"Removes",
"declaration",
"from",
"members",
"list",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/namespace.py#L94-L104
|
gccxml/pygccxml
|
pygccxml/declarations/namespace.py
|
namespace_t.namespace
|
def namespace(self, name=None, function=None, recursive=None):
"""
Returns reference to namespace declaration that matches
a defined criteria.
"""
return (
self._find_single(
scopedef.scopedef_t._impl_matchers[namespace_t.namespace],
name=name,
function=function,
recursive=recursive)
)
|
python
|
def namespace(self, name=None, function=None, recursive=None):
return (
self._find_single(
scopedef.scopedef_t._impl_matchers[namespace_t.namespace],
name=name,
function=function,
recursive=recursive)
)
|
[
"def",
"namespace",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"recursive",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_single",
"(",
"scopedef",
".",
"scopedef_t",
".",
"_impl_matchers",
"[",
"namespace_t",
".",
"namespace",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"recursive",
"=",
"recursive",
")",
")"
] |
Returns reference to namespace declaration that matches
a defined criteria.
|
[
"Returns",
"reference",
"to",
"namespace",
"declaration",
"that",
"matches",
"a",
"defined",
"criteria",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/namespace.py#L109-L122
|
gccxml/pygccxml
|
pygccxml/declarations/namespace.py
|
namespace_t.namespaces
|
def namespaces(
self,
name=None,
function=None,
recursive=None,
allow_empty=None):
"""
Returns a set of namespace declarations that match
a defined criteria.
"""
return (
self._find_multiple(
scopedef.scopedef_t._impl_matchers[namespace_t.namespace],
name=name,
function=function,
recursive=recursive,
allow_empty=allow_empty)
)
|
python
|
def namespaces(
self,
name=None,
function=None,
recursive=None,
allow_empty=None):
return (
self._find_multiple(
scopedef.scopedef_t._impl_matchers[namespace_t.namespace],
name=name,
function=function,
recursive=recursive,
allow_empty=allow_empty)
)
|
[
"def",
"namespaces",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"recursive",
"=",
"None",
",",
"allow_empty",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_multiple",
"(",
"scopedef",
".",
"scopedef_t",
".",
"_impl_matchers",
"[",
"namespace_t",
".",
"namespace",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"recursive",
"=",
"recursive",
",",
"allow_empty",
"=",
"allow_empty",
")",
")"
] |
Returns a set of namespace declarations that match
a defined criteria.
|
[
"Returns",
"a",
"set",
"of",
"namespace",
"declarations",
"that",
"match",
"a",
"defined",
"criteria",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/namespace.py#L124-L143
|
gccxml/pygccxml
|
pygccxml/declarations/namespace.py
|
namespace_t.free_function
|
def free_function(
self,
name=None,
function=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None):
"""
Returns reference to free function declaration that matches
a defined criteria.
"""
return (
self._find_single(
scopedef.scopedef_t._impl_matchers[namespace_t.free_function],
name=name,
function=function,
decl_type=self._impl_decl_types[namespace_t.free_function],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive)
)
|
python
|
def free_function(
self,
name=None,
function=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None):
return (
self._find_single(
scopedef.scopedef_t._impl_matchers[namespace_t.free_function],
name=name,
function=function,
decl_type=self._impl_decl_types[namespace_t.free_function],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive)
)
|
[
"def",
"free_function",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"return_type",
"=",
"None",
",",
"arg_types",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_single",
"(",
"scopedef",
".",
"scopedef_t",
".",
"_impl_matchers",
"[",
"namespace_t",
".",
"free_function",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"decl_type",
"=",
"self",
".",
"_impl_decl_types",
"[",
"namespace_t",
".",
"free_function",
"]",
",",
"return_type",
"=",
"return_type",
",",
"arg_types",
"=",
"arg_types",
",",
"header_dir",
"=",
"header_dir",
",",
"header_file",
"=",
"header_file",
",",
"recursive",
"=",
"recursive",
")",
")"
] |
Returns reference to free function declaration that matches
a defined criteria.
|
[
"Returns",
"reference",
"to",
"free",
"function",
"declaration",
"that",
"matches",
"a",
"defined",
"criteria",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/namespace.py#L145-L171
|
gccxml/pygccxml
|
pygccxml/declarations/namespace.py
|
namespace_t.free_functions
|
def free_functions(
self,
name=None,
function=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
"""
Returns a set of free function declarations that match
a defined criteria.
"""
return (
self._find_multiple(
scopedef.scopedef_t._impl_matchers[namespace_t.free_function],
name=name,
function=function,
decl_type=self._impl_decl_types[namespace_t.free_function],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
python
|
def free_functions(
self,
name=None,
function=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
return (
self._find_multiple(
scopedef.scopedef_t._impl_matchers[namespace_t.free_function],
name=name,
function=function,
decl_type=self._impl_decl_types[namespace_t.free_function],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
[
"def",
"free_functions",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"return_type",
"=",
"None",
",",
"arg_types",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
",",
"allow_empty",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_multiple",
"(",
"scopedef",
".",
"scopedef_t",
".",
"_impl_matchers",
"[",
"namespace_t",
".",
"free_function",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"decl_type",
"=",
"self",
".",
"_impl_decl_types",
"[",
"namespace_t",
".",
"free_function",
"]",
",",
"return_type",
"=",
"return_type",
",",
"arg_types",
"=",
"arg_types",
",",
"header_dir",
"=",
"header_dir",
",",
"header_file",
"=",
"header_file",
",",
"recursive",
"=",
"recursive",
",",
"allow_empty",
"=",
"allow_empty",
")",
")"
] |
Returns a set of free function declarations that match
a defined criteria.
|
[
"Returns",
"a",
"set",
"of",
"free",
"function",
"declarations",
"that",
"match",
"a",
"defined",
"criteria",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/namespace.py#L173-L201
|
gccxml/pygccxml
|
pygccxml/declarations/namespace.py
|
namespace_t.free_operator
|
def free_operator(
self,
name=None,
function=None,
symbol=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None):
"""
Returns reference to free operator declaration that matches
a defined criteria.
"""
return (
self._find_single(
scopedef.scopedef_t._impl_matchers[namespace_t.free_operator],
name=self._build_operator_name(name, function, symbol),
symbol=symbol,
function=self._build_operator_function(name, function),
decl_type=self._impl_decl_types[namespace_t.free_operator],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive)
)
|
python
|
def free_operator(
self,
name=None,
function=None,
symbol=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None):
return (
self._find_single(
scopedef.scopedef_t._impl_matchers[namespace_t.free_operator],
name=self._build_operator_name(name, function, symbol),
symbol=symbol,
function=self._build_operator_function(name, function),
decl_type=self._impl_decl_types[namespace_t.free_operator],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive)
)
|
[
"def",
"free_operator",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"symbol",
"=",
"None",
",",
"return_type",
"=",
"None",
",",
"arg_types",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_single",
"(",
"scopedef",
".",
"scopedef_t",
".",
"_impl_matchers",
"[",
"namespace_t",
".",
"free_operator",
"]",
",",
"name",
"=",
"self",
".",
"_build_operator_name",
"(",
"name",
",",
"function",
",",
"symbol",
")",
",",
"symbol",
"=",
"symbol",
",",
"function",
"=",
"self",
".",
"_build_operator_function",
"(",
"name",
",",
"function",
")",
",",
"decl_type",
"=",
"self",
".",
"_impl_decl_types",
"[",
"namespace_t",
".",
"free_operator",
"]",
",",
"return_type",
"=",
"return_type",
",",
"arg_types",
"=",
"arg_types",
",",
"header_dir",
"=",
"header_dir",
",",
"header_file",
"=",
"header_file",
",",
"recursive",
"=",
"recursive",
")",
")"
] |
Returns reference to free operator declaration that matches
a defined criteria.
|
[
"Returns",
"reference",
"to",
"free",
"operator",
"declaration",
"that",
"matches",
"a",
"defined",
"criteria",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/namespace.py#L203-L230
|
gccxml/pygccxml
|
pygccxml/declarations/calldef_types.py
|
CALLING_CONVENTION_TYPES.extract
|
def extract(text, default=UNKNOWN):
"""extracts calling convention from the text. If the calling convention
could not be found, the "default"is used"""
if not text:
return default
found = CALLING_CONVENTION_TYPES.pattern.match(text)
if found:
return found.group('cc')
return default
|
python
|
def extract(text, default=UNKNOWN):
if not text:
return default
found = CALLING_CONVENTION_TYPES.pattern.match(text)
if found:
return found.group('cc')
return default
|
[
"def",
"extract",
"(",
"text",
",",
"default",
"=",
"UNKNOWN",
")",
":",
"if",
"not",
"text",
":",
"return",
"default",
"found",
"=",
"CALLING_CONVENTION_TYPES",
".",
"pattern",
".",
"match",
"(",
"text",
")",
"if",
"found",
":",
"return",
"found",
".",
"group",
"(",
"'cc'",
")",
"return",
"default"
] |
extracts calling convention from the text. If the calling convention
could not be found, the "default"is used
|
[
"extracts",
"calling",
"convention",
"from",
"the",
"text",
".",
"If",
"the",
"calling",
"convention",
"could",
"not",
"be",
"found",
"the",
"default",
"is",
"used"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/calldef_types.py#L38-L47
|
gccxml/pygccxml
|
pygccxml/declarations/function_traits.py
|
is_same_function
|
def is_same_function(f1, f2):
"""returns true if f1 and f2 is same function
Use case: sometimes when user defines some virtual function in base class,
it overrides it in a derived one. Sometimes we need to know whether two
member functions is actually same function.
"""
if f1 is f2:
return True
if f1.__class__ is not f2.__class__:
return False
if isinstance(f1, calldef_members.member_calldef_t) and \
f1.has_const != f2.has_const:
return False
if f1.name != f2.name:
return False
if not is_same_return_type(f1, f2):
return False
if len(f1.arguments) != len(f2.arguments):
return False
for f1_arg, f2_arg in zip(f1.arguments, f2.arguments):
if not type_traits.is_same(f1_arg.decl_type, f2_arg.decl_type):
return False
return True
|
python
|
def is_same_function(f1, f2):
if f1 is f2:
return True
if f1.__class__ is not f2.__class__:
return False
if isinstance(f1, calldef_members.member_calldef_t) and \
f1.has_const != f2.has_const:
return False
if f1.name != f2.name:
return False
if not is_same_return_type(f1, f2):
return False
if len(f1.arguments) != len(f2.arguments):
return False
for f1_arg, f2_arg in zip(f1.arguments, f2.arguments):
if not type_traits.is_same(f1_arg.decl_type, f2_arg.decl_type):
return False
return True
|
[
"def",
"is_same_function",
"(",
"f1",
",",
"f2",
")",
":",
"if",
"f1",
"is",
"f2",
":",
"return",
"True",
"if",
"f1",
".",
"__class__",
"is",
"not",
"f2",
".",
"__class__",
":",
"return",
"False",
"if",
"isinstance",
"(",
"f1",
",",
"calldef_members",
".",
"member_calldef_t",
")",
"and",
"f1",
".",
"has_const",
"!=",
"f2",
".",
"has_const",
":",
"return",
"False",
"if",
"f1",
".",
"name",
"!=",
"f2",
".",
"name",
":",
"return",
"False",
"if",
"not",
"is_same_return_type",
"(",
"f1",
",",
"f2",
")",
":",
"return",
"False",
"if",
"len",
"(",
"f1",
".",
"arguments",
")",
"!=",
"len",
"(",
"f2",
".",
"arguments",
")",
":",
"return",
"False",
"for",
"f1_arg",
",",
"f2_arg",
"in",
"zip",
"(",
"f1",
".",
"arguments",
",",
"f2",
".",
"arguments",
")",
":",
"if",
"not",
"type_traits",
".",
"is_same",
"(",
"f1_arg",
".",
"decl_type",
",",
"f2_arg",
".",
"decl_type",
")",
":",
"return",
"False",
"return",
"True"
] |
returns true if f1 and f2 is same function
Use case: sometimes when user defines some virtual function in base class,
it overrides it in a derived one. Sometimes we need to know whether two
member functions is actually same function.
|
[
"returns",
"true",
"if",
"f1",
"and",
"f2",
"is",
"same",
"function"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/function_traits.py#L73-L96
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
make_flatten
|
def make_flatten(decl_or_decls):
"""
Converts tree representation of declarations to flatten one.
:param decl_or_decls: reference to list of declaration's or single
declaration
:type decl_or_decls: :class:`declaration_t` or [ :class:`declaration_t` ]
:rtype: [ all internal declarations ]
"""
def proceed_single(decl):
answer = [decl]
if not isinstance(decl, scopedef_t):
return answer
for elem in decl.declarations:
if isinstance(elem, scopedef_t):
answer.extend(proceed_single(elem))
else:
answer.append(elem)
return answer
decls = []
if isinstance(decl_or_decls, list):
decls.extend(decl_or_decls)
else:
decls.append(decl_or_decls)
answer = []
for decl in decls:
answer.extend(proceed_single(decl))
return answer
|
python
|
def make_flatten(decl_or_decls):
def proceed_single(decl):
answer = [decl]
if not isinstance(decl, scopedef_t):
return answer
for elem in decl.declarations:
if isinstance(elem, scopedef_t):
answer.extend(proceed_single(elem))
else:
answer.append(elem)
return answer
decls = []
if isinstance(decl_or_decls, list):
decls.extend(decl_or_decls)
else:
decls.append(decl_or_decls)
answer = []
for decl in decls:
answer.extend(proceed_single(decl))
return answer
|
[
"def",
"make_flatten",
"(",
"decl_or_decls",
")",
":",
"def",
"proceed_single",
"(",
"decl",
")",
":",
"answer",
"=",
"[",
"decl",
"]",
"if",
"not",
"isinstance",
"(",
"decl",
",",
"scopedef_t",
")",
":",
"return",
"answer",
"for",
"elem",
"in",
"decl",
".",
"declarations",
":",
"if",
"isinstance",
"(",
"elem",
",",
"scopedef_t",
")",
":",
"answer",
".",
"extend",
"(",
"proceed_single",
"(",
"elem",
")",
")",
"else",
":",
"answer",
".",
"append",
"(",
"elem",
")",
"return",
"answer",
"decls",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"decl_or_decls",
",",
"list",
")",
":",
"decls",
".",
"extend",
"(",
"decl_or_decls",
")",
"else",
":",
"decls",
".",
"append",
"(",
"decl_or_decls",
")",
"answer",
"=",
"[",
"]",
"for",
"decl",
"in",
"decls",
":",
"answer",
".",
"extend",
"(",
"proceed_single",
"(",
"decl",
")",
")",
"return",
"answer"
] |
Converts tree representation of declarations to flatten one.
:param decl_or_decls: reference to list of declaration's or single
declaration
:type decl_or_decls: :class:`declaration_t` or [ :class:`declaration_t` ]
:rtype: [ all internal declarations ]
|
[
"Converts",
"tree",
"representation",
"of",
"declarations",
"to",
"flatten",
"one",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L1058-L1088
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
find_all_declarations
|
def find_all_declarations(
declarations,
decl_type=None,
name=None,
parent=None,
recursive=True,
fullname=None):
"""
Returns a list of all declarations that match criteria, defined by
developer.
For more information about arguments see :class:`match_declaration_t`
class.
:rtype: [ matched declarations ]
"""
if recursive:
decls = make_flatten(declarations)
else:
decls = declarations
return list(
filter(
algorithm.match_declaration_t(
decl_type=decl_type,
name=name,
fullname=fullname,
parent=parent),
decls))
|
python
|
def find_all_declarations(
declarations,
decl_type=None,
name=None,
parent=None,
recursive=True,
fullname=None):
if recursive:
decls = make_flatten(declarations)
else:
decls = declarations
return list(
filter(
algorithm.match_declaration_t(
decl_type=decl_type,
name=name,
fullname=fullname,
parent=parent),
decls))
|
[
"def",
"find_all_declarations",
"(",
"declarations",
",",
"decl_type",
"=",
"None",
",",
"name",
"=",
"None",
",",
"parent",
"=",
"None",
",",
"recursive",
"=",
"True",
",",
"fullname",
"=",
"None",
")",
":",
"if",
"recursive",
":",
"decls",
"=",
"make_flatten",
"(",
"declarations",
")",
"else",
":",
"decls",
"=",
"declarations",
"return",
"list",
"(",
"filter",
"(",
"algorithm",
".",
"match_declaration_t",
"(",
"decl_type",
"=",
"decl_type",
",",
"name",
"=",
"name",
",",
"fullname",
"=",
"fullname",
",",
"parent",
"=",
"parent",
")",
",",
"decls",
")",
")"
] |
Returns a list of all declarations that match criteria, defined by
developer.
For more information about arguments see :class:`match_declaration_t`
class.
:rtype: [ matched declarations ]
|
[
"Returns",
"a",
"list",
"of",
"all",
"declarations",
"that",
"match",
"criteria",
"defined",
"by",
"developer",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L1091-L1121
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
find_declaration
|
def find_declaration(
declarations,
decl_type=None,
name=None,
parent=None,
recursive=True,
fullname=None):
"""
Returns single declaration that match criteria, defined by developer.
If more the one declaration was found None will be returned.
For more information about arguments see :class:`match_declaration_t`
class.
:rtype: matched declaration :class:`declaration_t` or None
"""
decl = find_all_declarations(
declarations,
decl_type=decl_type,
name=name,
parent=parent,
recursive=recursive,
fullname=fullname)
if len(decl) == 1:
return decl[0]
|
python
|
def find_declaration(
declarations,
decl_type=None,
name=None,
parent=None,
recursive=True,
fullname=None):
decl = find_all_declarations(
declarations,
decl_type=decl_type,
name=name,
parent=parent,
recursive=recursive,
fullname=fullname)
if len(decl) == 1:
return decl[0]
|
[
"def",
"find_declaration",
"(",
"declarations",
",",
"decl_type",
"=",
"None",
",",
"name",
"=",
"None",
",",
"parent",
"=",
"None",
",",
"recursive",
"=",
"True",
",",
"fullname",
"=",
"None",
")",
":",
"decl",
"=",
"find_all_declarations",
"(",
"declarations",
",",
"decl_type",
"=",
"decl_type",
",",
"name",
"=",
"name",
",",
"parent",
"=",
"parent",
",",
"recursive",
"=",
"recursive",
",",
"fullname",
"=",
"fullname",
")",
"if",
"len",
"(",
"decl",
")",
"==",
"1",
":",
"return",
"decl",
"[",
"0",
"]"
] |
Returns single declaration that match criteria, defined by developer.
If more the one declaration was found None will be returned.
For more information about arguments see :class:`match_declaration_t`
class.
:rtype: matched declaration :class:`declaration_t` or None
|
[
"Returns",
"single",
"declaration",
"that",
"match",
"criteria",
"defined",
"by",
"developer",
".",
"If",
"more",
"the",
"one",
"declaration",
"was",
"found",
"None",
"will",
"be",
"returned",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L1124-L1150
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
find_first_declaration
|
def find_first_declaration(
declarations,
decl_type=None,
name=None,
parent=None,
recursive=True,
fullname=None):
"""
Returns first declaration that match criteria, defined by developer.
For more information about arguments see :class:`match_declaration_t`
class.
:rtype: matched declaration :class:`declaration_t` or None
"""
decl_matcher = algorithm.match_declaration_t(
decl_type=decl_type,
name=name,
fullname=fullname,
parent=parent)
if recursive:
decls = make_flatten(declarations)
else:
decls = declarations
for decl in decls:
if decl_matcher(decl):
return decl
return None
|
python
|
def find_first_declaration(
declarations,
decl_type=None,
name=None,
parent=None,
recursive=True,
fullname=None):
decl_matcher = algorithm.match_declaration_t(
decl_type=decl_type,
name=name,
fullname=fullname,
parent=parent)
if recursive:
decls = make_flatten(declarations)
else:
decls = declarations
for decl in decls:
if decl_matcher(decl):
return decl
return None
|
[
"def",
"find_first_declaration",
"(",
"declarations",
",",
"decl_type",
"=",
"None",
",",
"name",
"=",
"None",
",",
"parent",
"=",
"None",
",",
"recursive",
"=",
"True",
",",
"fullname",
"=",
"None",
")",
":",
"decl_matcher",
"=",
"algorithm",
".",
"match_declaration_t",
"(",
"decl_type",
"=",
"decl_type",
",",
"name",
"=",
"name",
",",
"fullname",
"=",
"fullname",
",",
"parent",
"=",
"parent",
")",
"if",
"recursive",
":",
"decls",
"=",
"make_flatten",
"(",
"declarations",
")",
"else",
":",
"decls",
"=",
"declarations",
"for",
"decl",
"in",
"decls",
":",
"if",
"decl_matcher",
"(",
"decl",
")",
":",
"return",
"decl",
"return",
"None"
] |
Returns first declaration that match criteria, defined by developer.
For more information about arguments see :class:`match_declaration_t`
class.
:rtype: matched declaration :class:`declaration_t` or None
|
[
"Returns",
"first",
"declaration",
"that",
"match",
"criteria",
"defined",
"by",
"developer",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L1153-L1182
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
declaration_files
|
def declaration_files(decl_or_decls):
"""
Returns set of files
Every declaration is declared in some file. This function returns set, that
contains all file names of declarations.
:param decl_or_decls: reference to list of declaration's or single
declaration
:type decl_or_decls: :class:`declaration_t` or [:class:`declaration_t`]
:rtype: set(declaration file names)
"""
files = set()
decls = make_flatten(decl_or_decls)
for decl in decls:
if decl.location:
files.add(decl.location.file_name)
return files
|
python
|
def declaration_files(decl_or_decls):
files = set()
decls = make_flatten(decl_or_decls)
for decl in decls:
if decl.location:
files.add(decl.location.file_name)
return files
|
[
"def",
"declaration_files",
"(",
"decl_or_decls",
")",
":",
"files",
"=",
"set",
"(",
")",
"decls",
"=",
"make_flatten",
"(",
"decl_or_decls",
")",
"for",
"decl",
"in",
"decls",
":",
"if",
"decl",
".",
"location",
":",
"files",
".",
"add",
"(",
"decl",
".",
"location",
".",
"file_name",
")",
"return",
"files"
] |
Returns set of files
Every declaration is declared in some file. This function returns set, that
contains all file names of declarations.
:param decl_or_decls: reference to list of declaration's or single
declaration
:type decl_or_decls: :class:`declaration_t` or [:class:`declaration_t`]
:rtype: set(declaration file names)
|
[
"Returns",
"set",
"of",
"files"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L1185-L1204
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
matcher.find
|
def find(decl_matcher, decls, recursive=True):
"""
Returns a list of declarations that match `decl_matcher` defined
criteria or None
:param decl_matcher: Python callable object, that takes one argument -
reference to a declaration
:param decls: the search scope, :class:declaration_t object or
:class:declaration_t objects list t
:param recursive: boolean, if True, the method will run `decl_matcher`
on the internal declarations too
"""
where = []
if isinstance(decls, list):
where.extend(decls)
else:
where.append(decls)
if recursive:
where = make_flatten(where)
return list(filter(decl_matcher, where))
|
python
|
def find(decl_matcher, decls, recursive=True):
where = []
if isinstance(decls, list):
where.extend(decls)
else:
where.append(decls)
if recursive:
where = make_flatten(where)
return list(filter(decl_matcher, where))
|
[
"def",
"find",
"(",
"decl_matcher",
",",
"decls",
",",
"recursive",
"=",
"True",
")",
":",
"where",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"decls",
",",
"list",
")",
":",
"where",
".",
"extend",
"(",
"decls",
")",
"else",
":",
"where",
".",
"append",
"(",
"decls",
")",
"if",
"recursive",
":",
"where",
"=",
"make_flatten",
"(",
"where",
")",
"return",
"list",
"(",
"filter",
"(",
"decl_matcher",
",",
"where",
")",
")"
] |
Returns a list of declarations that match `decl_matcher` defined
criteria or None
:param decl_matcher: Python callable object, that takes one argument -
reference to a declaration
:param decls: the search scope, :class:declaration_t object or
:class:declaration_t objects list t
:param recursive: boolean, if True, the method will run `decl_matcher`
on the internal declarations too
|
[
"Returns",
"a",
"list",
"of",
"declarations",
"that",
"match",
"decl_matcher",
"defined",
"criteria",
"or",
"None"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L29-L49
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
matcher.find_single
|
def find_single(decl_matcher, decls, recursive=True):
"""
Returns a reference to the declaration, that match `decl_matcher`
defined criteria.
if a unique declaration could not be found the method will return None.
:param decl_matcher: Python callable object, that takes one argument -
reference to a declaration
:param decls: the search scope, :class:declaration_t object or
:class:declaration_t objects list t
:param recursive: boolean, if True, the method will run `decl_matcher`
on the internal declarations too
"""
answer = matcher.find(decl_matcher, decls, recursive)
if len(answer) == 1:
return answer[0]
|
python
|
def find_single(decl_matcher, decls, recursive=True):
answer = matcher.find(decl_matcher, decls, recursive)
if len(answer) == 1:
return answer[0]
|
[
"def",
"find_single",
"(",
"decl_matcher",
",",
"decls",
",",
"recursive",
"=",
"True",
")",
":",
"answer",
"=",
"matcher",
".",
"find",
"(",
"decl_matcher",
",",
"decls",
",",
"recursive",
")",
"if",
"len",
"(",
"answer",
")",
"==",
"1",
":",
"return",
"answer",
"[",
"0",
"]"
] |
Returns a reference to the declaration, that match `decl_matcher`
defined criteria.
if a unique declaration could not be found the method will return None.
:param decl_matcher: Python callable object, that takes one argument -
reference to a declaration
:param decls: the search scope, :class:declaration_t object or
:class:declaration_t objects list t
:param recursive: boolean, if True, the method will run `decl_matcher`
on the internal declarations too
|
[
"Returns",
"a",
"reference",
"to",
"the",
"declaration",
"that",
"match",
"decl_matcher",
"defined",
"criteria",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L52-L68
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
matcher.get_single
|
def get_single(decl_matcher, decls, recursive=True):
"""
Returns a reference to declaration, that match `decl_matcher` defined
criteria.
If a unique declaration could not be found, an appropriate exception
will be raised.
:param decl_matcher: Python callable object, that takes one argument -
reference to a declaration
:param decls: the search scope, :class:declaration_t object or
:class:declaration_t objects list t
:param recursive: boolean, if True, the method will run `decl_matcher`
on the internal declarations too
"""
answer = matcher.find(decl_matcher, decls, recursive)
if len(answer) == 1:
return answer[0]
elif not answer:
raise runtime_errors.declaration_not_found_t(decl_matcher)
else:
raise runtime_errors.multiple_declarations_found_t(decl_matcher)
|
python
|
def get_single(decl_matcher, decls, recursive=True):
answer = matcher.find(decl_matcher, decls, recursive)
if len(answer) == 1:
return answer[0]
elif not answer:
raise runtime_errors.declaration_not_found_t(decl_matcher)
else:
raise runtime_errors.multiple_declarations_found_t(decl_matcher)
|
[
"def",
"get_single",
"(",
"decl_matcher",
",",
"decls",
",",
"recursive",
"=",
"True",
")",
":",
"answer",
"=",
"matcher",
".",
"find",
"(",
"decl_matcher",
",",
"decls",
",",
"recursive",
")",
"if",
"len",
"(",
"answer",
")",
"==",
"1",
":",
"return",
"answer",
"[",
"0",
"]",
"elif",
"not",
"answer",
":",
"raise",
"runtime_errors",
".",
"declaration_not_found_t",
"(",
"decl_matcher",
")",
"else",
":",
"raise",
"runtime_errors",
".",
"multiple_declarations_found_t",
"(",
"decl_matcher",
")"
] |
Returns a reference to declaration, that match `decl_matcher` defined
criteria.
If a unique declaration could not be found, an appropriate exception
will be raised.
:param decl_matcher: Python callable object, that takes one argument -
reference to a declaration
:param decls: the search scope, :class:declaration_t object or
:class:declaration_t objects list t
:param recursive: boolean, if True, the method will run `decl_matcher`
on the internal declarations too
|
[
"Returns",
"a",
"reference",
"to",
"declaration",
"that",
"match",
"decl_matcher",
"defined",
"criteria",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L71-L92
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.__decl_types
|
def __decl_types(decl):
"""implementation details"""
types = []
bases = list(decl.__class__.__bases__)
if 'pygccxml' in decl.__class__.__module__:
types.append(decl.__class__)
while bases:
base = bases.pop()
if base is declaration.declaration_t:
continue
if base is byte_info.byte_info:
continue
if base is elaborated_info.elaborated_info:
continue
if 'pygccxml' not in base.__module__:
continue
types.append(base)
bases.extend(base.__bases__)
return types
|
python
|
def __decl_types(decl):
types = []
bases = list(decl.__class__.__bases__)
if 'pygccxml' in decl.__class__.__module__:
types.append(decl.__class__)
while bases:
base = bases.pop()
if base is declaration.declaration_t:
continue
if base is byte_info.byte_info:
continue
if base is elaborated_info.elaborated_info:
continue
if 'pygccxml' not in base.__module__:
continue
types.append(base)
bases.extend(base.__bases__)
return types
|
[
"def",
"__decl_types",
"(",
"decl",
")",
":",
"types",
"=",
"[",
"]",
"bases",
"=",
"list",
"(",
"decl",
".",
"__class__",
".",
"__bases__",
")",
"if",
"'pygccxml'",
"in",
"decl",
".",
"__class__",
".",
"__module__",
":",
"types",
".",
"append",
"(",
"decl",
".",
"__class__",
")",
"while",
"bases",
":",
"base",
"=",
"bases",
".",
"pop",
"(",
")",
"if",
"base",
"is",
"declaration",
".",
"declaration_t",
":",
"continue",
"if",
"base",
"is",
"byte_info",
".",
"byte_info",
":",
"continue",
"if",
"base",
"is",
"elaborated_info",
".",
"elaborated_info",
":",
"continue",
"if",
"'pygccxml'",
"not",
"in",
"base",
".",
"__module__",
":",
"continue",
"types",
".",
"append",
"(",
"base",
")",
"bases",
".",
"extend",
"(",
"base",
".",
"__bases__",
")",
"return",
"types"
] |
implementation details
|
[
"implementation",
"details"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L228-L246
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.clear_optimizer
|
def clear_optimizer(self):
"""Cleans query optimizer state"""
self._optimized = False
self._type2decls = {}
self._type2name2decls = {}
self._type2decls_nr = {}
self._type2name2decls_nr = {}
self._all_decls = None
self._all_decls_not_recursive = None
for decl in self.declarations:
if isinstance(decl, scopedef_t):
decl.clear_optimizer()
|
python
|
def clear_optimizer(self):
self._optimized = False
self._type2decls = {}
self._type2name2decls = {}
self._type2decls_nr = {}
self._type2name2decls_nr = {}
self._all_decls = None
self._all_decls_not_recursive = None
for decl in self.declarations:
if isinstance(decl, scopedef_t):
decl.clear_optimizer()
|
[
"def",
"clear_optimizer",
"(",
"self",
")",
":",
"self",
".",
"_optimized",
"=",
"False",
"self",
".",
"_type2decls",
"=",
"{",
"}",
"self",
".",
"_type2name2decls",
"=",
"{",
"}",
"self",
".",
"_type2decls_nr",
"=",
"{",
"}",
"self",
".",
"_type2name2decls_nr",
"=",
"{",
"}",
"self",
".",
"_all_decls",
"=",
"None",
"self",
".",
"_all_decls_not_recursive",
"=",
"None",
"for",
"decl",
"in",
"self",
".",
"declarations",
":",
"if",
"isinstance",
"(",
"decl",
",",
"scopedef_t",
")",
":",
"decl",
".",
"clear_optimizer",
"(",
")"
] |
Cleans query optimizer state
|
[
"Cleans",
"query",
"optimizer",
"state"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L248-L260
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.init_optimizer
|
def init_optimizer(self):
"""
Initializes query optimizer state.
There are 4 internals hash tables:
1. from type to declarations
2. from type to declarations for non-recursive queries
3. from type to name to declarations
4. from type to name to declarations for non-recursive queries
Almost every query includes declaration type information. Also very
common query is to search some declaration(s) by name or full name.
Those hash tables allows to search declaration very quick.
"""
if self.name == '::':
self._logger.debug(
"preparing data structures for query optimizer - started")
start_time = timeit.default_timer()
self.clear_optimizer()
for dtype in scopedef_t._impl_all_decl_types:
self._type2decls[dtype] = []
self._type2decls_nr[dtype] = []
self._type2name2decls[dtype] = {}
self._type2name2decls_nr[dtype] = {}
self._all_decls_not_recursive = self.declarations
self._all_decls = make_flatten(
self._all_decls_not_recursive)
for decl in self._all_decls:
types = self.__decl_types(decl)
for type_ in types:
self._type2decls[type_].append(decl)
name2decls = self._type2name2decls[type_]
if decl.name not in name2decls:
name2decls[decl.name] = []
name2decls[decl.name].append(decl)
if self is decl.parent:
self._type2decls_nr[type_].append(decl)
name2decls_nr = self._type2name2decls_nr[type_]
if decl.name not in name2decls_nr:
name2decls_nr[decl.name] = []
name2decls_nr[decl.name].append(decl)
for decl in self._all_decls_not_recursive:
if isinstance(decl, scopedef_t):
decl.init_optimizer()
if self.name == '::':
self._logger.debug((
"preparing data structures for query optimizer - " +
"done( %f seconds ). "), (timeit.default_timer() - start_time))
self._optimized = True
|
python
|
def init_optimizer(self):
if self.name == '::':
self._logger.debug(
"preparing data structures for query optimizer - started")
start_time = timeit.default_timer()
self.clear_optimizer()
for dtype in scopedef_t._impl_all_decl_types:
self._type2decls[dtype] = []
self._type2decls_nr[dtype] = []
self._type2name2decls[dtype] = {}
self._type2name2decls_nr[dtype] = {}
self._all_decls_not_recursive = self.declarations
self._all_decls = make_flatten(
self._all_decls_not_recursive)
for decl in self._all_decls:
types = self.__decl_types(decl)
for type_ in types:
self._type2decls[type_].append(decl)
name2decls = self._type2name2decls[type_]
if decl.name not in name2decls:
name2decls[decl.name] = []
name2decls[decl.name].append(decl)
if self is decl.parent:
self._type2decls_nr[type_].append(decl)
name2decls_nr = self._type2name2decls_nr[type_]
if decl.name not in name2decls_nr:
name2decls_nr[decl.name] = []
name2decls_nr[decl.name].append(decl)
for decl in self._all_decls_not_recursive:
if isinstance(decl, scopedef_t):
decl.init_optimizer()
if self.name == '::':
self._logger.debug((
"preparing data structures for query optimizer - " +
"done( %f seconds ). "), (timeit.default_timer() - start_time))
self._optimized = True
|
[
"def",
"init_optimizer",
"(",
"self",
")",
":",
"if",
"self",
".",
"name",
"==",
"'::'",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"preparing data structures for query optimizer - started\"",
")",
"start_time",
"=",
"timeit",
".",
"default_timer",
"(",
")",
"self",
".",
"clear_optimizer",
"(",
")",
"for",
"dtype",
"in",
"scopedef_t",
".",
"_impl_all_decl_types",
":",
"self",
".",
"_type2decls",
"[",
"dtype",
"]",
"=",
"[",
"]",
"self",
".",
"_type2decls_nr",
"[",
"dtype",
"]",
"=",
"[",
"]",
"self",
".",
"_type2name2decls",
"[",
"dtype",
"]",
"=",
"{",
"}",
"self",
".",
"_type2name2decls_nr",
"[",
"dtype",
"]",
"=",
"{",
"}",
"self",
".",
"_all_decls_not_recursive",
"=",
"self",
".",
"declarations",
"self",
".",
"_all_decls",
"=",
"make_flatten",
"(",
"self",
".",
"_all_decls_not_recursive",
")",
"for",
"decl",
"in",
"self",
".",
"_all_decls",
":",
"types",
"=",
"self",
".",
"__decl_types",
"(",
"decl",
")",
"for",
"type_",
"in",
"types",
":",
"self",
".",
"_type2decls",
"[",
"type_",
"]",
".",
"append",
"(",
"decl",
")",
"name2decls",
"=",
"self",
".",
"_type2name2decls",
"[",
"type_",
"]",
"if",
"decl",
".",
"name",
"not",
"in",
"name2decls",
":",
"name2decls",
"[",
"decl",
".",
"name",
"]",
"=",
"[",
"]",
"name2decls",
"[",
"decl",
".",
"name",
"]",
".",
"append",
"(",
"decl",
")",
"if",
"self",
"is",
"decl",
".",
"parent",
":",
"self",
".",
"_type2decls_nr",
"[",
"type_",
"]",
".",
"append",
"(",
"decl",
")",
"name2decls_nr",
"=",
"self",
".",
"_type2name2decls_nr",
"[",
"type_",
"]",
"if",
"decl",
".",
"name",
"not",
"in",
"name2decls_nr",
":",
"name2decls_nr",
"[",
"decl",
".",
"name",
"]",
"=",
"[",
"]",
"name2decls_nr",
"[",
"decl",
".",
"name",
"]",
".",
"append",
"(",
"decl",
")",
"for",
"decl",
"in",
"self",
".",
"_all_decls_not_recursive",
":",
"if",
"isinstance",
"(",
"decl",
",",
"scopedef_t",
")",
":",
"decl",
".",
"init_optimizer",
"(",
")",
"if",
"self",
".",
"name",
"==",
"'::'",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"(",
"\"preparing data structures for query optimizer - \"",
"+",
"\"done( %f seconds ). \"",
")",
",",
"(",
"timeit",
".",
"default_timer",
"(",
")",
"-",
"start_time",
")",
")",
"self",
".",
"_optimized",
"=",
"True"
] |
Initializes query optimizer state.
There are 4 internals hash tables:
1. from type to declarations
2. from type to declarations for non-recursive queries
3. from type to name to declarations
4. from type to name to declarations for non-recursive queries
Almost every query includes declaration type information. Also very
common query is to search some declaration(s) by name or full name.
Those hash tables allows to search declaration very quick.
|
[
"Initializes",
"query",
"optimizer",
"state",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L262-L314
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t._build_operator_name
|
def _build_operator_name(name, function, symbol):
"""implementation details"""
def add_operator(sym):
if 'new' in sym or 'delete' in sym:
return 'operator ' + sym
return 'operator' + sym
if isinstance(name, Callable) and None is function:
name = None
if name:
if 'operator' not in name:
name = add_operator(name)
return name
elif symbol:
return add_operator(symbol)
return name
|
python
|
def _build_operator_name(name, function, symbol):
def add_operator(sym):
if 'new' in sym or 'delete' in sym:
return 'operator ' + sym
return 'operator' + sym
if isinstance(name, Callable) and None is function:
name = None
if name:
if 'operator' not in name:
name = add_operator(name)
return name
elif symbol:
return add_operator(symbol)
return name
|
[
"def",
"_build_operator_name",
"(",
"name",
",",
"function",
",",
"symbol",
")",
":",
"def",
"add_operator",
"(",
"sym",
")",
":",
"if",
"'new'",
"in",
"sym",
"or",
"'delete'",
"in",
"sym",
":",
"return",
"'operator '",
"+",
"sym",
"return",
"'operator'",
"+",
"sym",
"if",
"isinstance",
"(",
"name",
",",
"Callable",
")",
"and",
"None",
"is",
"function",
":",
"name",
"=",
"None",
"if",
"name",
":",
"if",
"'operator'",
"not",
"in",
"name",
":",
"name",
"=",
"add_operator",
"(",
"name",
")",
"return",
"name",
"elif",
"symbol",
":",
"return",
"add_operator",
"(",
"symbol",
")",
"return",
"name"
] |
implementation details
|
[
"implementation",
"details"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L324-L338
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.__normalize_args
|
def __normalize_args(**keywds):
"""implementation details"""
if isinstance(keywds['name'], Callable) and \
None is keywds['function']:
keywds['function'] = keywds['name']
keywds['name'] = None
return keywds
|
python
|
def __normalize_args(**keywds):
if isinstance(keywds['name'], Callable) and \
None is keywds['function']:
keywds['function'] = keywds['name']
keywds['name'] = None
return keywds
|
[
"def",
"__normalize_args",
"(",
"*",
"*",
"keywds",
")",
":",
"if",
"isinstance",
"(",
"keywds",
"[",
"'name'",
"]",
",",
"Callable",
")",
"and",
"None",
"is",
"keywds",
"[",
"'function'",
"]",
":",
"keywds",
"[",
"'function'",
"]",
"=",
"keywds",
"[",
"'name'",
"]",
"keywds",
"[",
"'name'",
"]",
"=",
"None",
"return",
"keywds"
] |
implementation details
|
[
"implementation",
"details"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L351-L357
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.__findout_decl_type
|
def __findout_decl_type(match_class, **keywds):
"""implementation details"""
if 'decl_type' in keywds:
return keywds['decl_type']
matcher_args = keywds.copy()
del matcher_args['function']
del matcher_args['recursive']
if 'allow_empty' in matcher_args:
del matcher_args['allow_empty']
decl_matcher = match_class(**matcher_args)
if decl_matcher.decl_type:
return decl_matcher.decl_type
return None
|
python
|
def __findout_decl_type(match_class, **keywds):
if 'decl_type' in keywds:
return keywds['decl_type']
matcher_args = keywds.copy()
del matcher_args['function']
del matcher_args['recursive']
if 'allow_empty' in matcher_args:
del matcher_args['allow_empty']
decl_matcher = match_class(**matcher_args)
if decl_matcher.decl_type:
return decl_matcher.decl_type
return None
|
[
"def",
"__findout_decl_type",
"(",
"match_class",
",",
"*",
"*",
"keywds",
")",
":",
"if",
"'decl_type'",
"in",
"keywds",
":",
"return",
"keywds",
"[",
"'decl_type'",
"]",
"matcher_args",
"=",
"keywds",
".",
"copy",
"(",
")",
"del",
"matcher_args",
"[",
"'function'",
"]",
"del",
"matcher_args",
"[",
"'recursive'",
"]",
"if",
"'allow_empty'",
"in",
"matcher_args",
":",
"del",
"matcher_args",
"[",
"'allow_empty'",
"]",
"decl_matcher",
"=",
"match_class",
"(",
"*",
"*",
"matcher_args",
")",
"if",
"decl_matcher",
".",
"decl_type",
":",
"return",
"decl_matcher",
".",
"decl_type",
"return",
"None"
] |
implementation details
|
[
"implementation",
"details"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L374-L388
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.__create_matcher
|
def __create_matcher(self, match_class, **keywds):
"""implementation details"""
matcher_args = keywds.copy()
del matcher_args['function']
del matcher_args['recursive']
if 'allow_empty' in matcher_args:
del matcher_args['allow_empty']
decl_matcher = decl_matcher = match_class(**matcher_args)
if keywds['function']:
self._logger.debug(
'running query: %s and <user defined function>',
str(decl_matcher))
return lambda decl: decl_matcher(decl) and keywds['function'](decl)
self._logger.debug('running query: %s', str(decl_matcher))
return decl_matcher
|
python
|
def __create_matcher(self, match_class, **keywds):
matcher_args = keywds.copy()
del matcher_args['function']
del matcher_args['recursive']
if 'allow_empty' in matcher_args:
del matcher_args['allow_empty']
decl_matcher = decl_matcher = match_class(**matcher_args)
if keywds['function']:
self._logger.debug(
'running query: %s and <user defined function>',
str(decl_matcher))
return lambda decl: decl_matcher(decl) and keywds['function'](decl)
self._logger.debug('running query: %s', str(decl_matcher))
return decl_matcher
|
[
"def",
"__create_matcher",
"(",
"self",
",",
"match_class",
",",
"*",
"*",
"keywds",
")",
":",
"matcher_args",
"=",
"keywds",
".",
"copy",
"(",
")",
"del",
"matcher_args",
"[",
"'function'",
"]",
"del",
"matcher_args",
"[",
"'recursive'",
"]",
"if",
"'allow_empty'",
"in",
"matcher_args",
":",
"del",
"matcher_args",
"[",
"'allow_empty'",
"]",
"decl_matcher",
"=",
"decl_matcher",
"=",
"match_class",
"(",
"*",
"*",
"matcher_args",
")",
"if",
"keywds",
"[",
"'function'",
"]",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"'running query: %s and <user defined function>'",
",",
"str",
"(",
"decl_matcher",
")",
")",
"return",
"lambda",
"decl",
":",
"decl_matcher",
"(",
"decl",
")",
"and",
"keywds",
"[",
"'function'",
"]",
"(",
"decl",
")",
"self",
".",
"_logger",
".",
"debug",
"(",
"'running query: %s'",
",",
"str",
"(",
"decl_matcher",
")",
")",
"return",
"decl_matcher"
] |
implementation details
|
[
"implementation",
"details"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L390-L406
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.__findout_range
|
def __findout_range(self, name, decl_type, recursive):
"""implementation details"""
if not self._optimized:
self._logger.debug(
'running non optimized query - optimization has not been done')
decls = self.declarations
if recursive:
decls = make_flatten(self.declarations)
if decl_type:
decls = [d for d in decls if isinstance(d, decl_type)]
return decls
if name and templates.is_instantiation(name):
# templates has tricky mode to compare them, so lets check the
# whole range
name = None
if name and decl_type:
impl_match = scopedef_t._impl_matchers[scopedef_t.decl](name=name)
if impl_match.is_full_name():
name = impl_match.decl_name_only
if recursive:
self._logger.debug(
'query has been optimized on type and name')
return self._type2name2decls[decl_type].get(name, [])
self._logger.debug(
'non recursive query has been optimized on type and name')
return self._type2name2decls_nr[decl_type].get(name, [])
elif decl_type:
if recursive:
self._logger.debug('query has been optimized on type')
return self._type2decls[decl_type]
self._logger.debug(
'non recursive query has been optimized on type')
return self._type2decls_nr[decl_type]
else:
if recursive:
self._logger.debug((
'query has not been optimized ( hint: query does not ' +
'contain type and/or name )'))
return self._all_decls
self._logger.debug((
'non recursive query has not been optimized ( hint: ' +
'query does not contain type and/or name )'))
return self._all_decls_not_recursive
|
python
|
def __findout_range(self, name, decl_type, recursive):
if not self._optimized:
self._logger.debug(
'running non optimized query - optimization has not been done')
decls = self.declarations
if recursive:
decls = make_flatten(self.declarations)
if decl_type:
decls = [d for d in decls if isinstance(d, decl_type)]
return decls
if name and templates.is_instantiation(name):
name = None
if name and decl_type:
impl_match = scopedef_t._impl_matchers[scopedef_t.decl](name=name)
if impl_match.is_full_name():
name = impl_match.decl_name_only
if recursive:
self._logger.debug(
'query has been optimized on type and name')
return self._type2name2decls[decl_type].get(name, [])
self._logger.debug(
'non recursive query has been optimized on type and name')
return self._type2name2decls_nr[decl_type].get(name, [])
elif decl_type:
if recursive:
self._logger.debug('query has been optimized on type')
return self._type2decls[decl_type]
self._logger.debug(
'non recursive query has been optimized on type')
return self._type2decls_nr[decl_type]
else:
if recursive:
self._logger.debug((
'query has not been optimized ( hint: query does not ' +
'contain type and/or name )'))
return self._all_decls
self._logger.debug((
'non recursive query has not been optimized ( hint: ' +
'query does not contain type and/or name )'))
return self._all_decls_not_recursive
|
[
"def",
"__findout_range",
"(",
"self",
",",
"name",
",",
"decl_type",
",",
"recursive",
")",
":",
"if",
"not",
"self",
".",
"_optimized",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"'running non optimized query - optimization has not been done'",
")",
"decls",
"=",
"self",
".",
"declarations",
"if",
"recursive",
":",
"decls",
"=",
"make_flatten",
"(",
"self",
".",
"declarations",
")",
"if",
"decl_type",
":",
"decls",
"=",
"[",
"d",
"for",
"d",
"in",
"decls",
"if",
"isinstance",
"(",
"d",
",",
"decl_type",
")",
"]",
"return",
"decls",
"if",
"name",
"and",
"templates",
".",
"is_instantiation",
"(",
"name",
")",
":",
"# templates has tricky mode to compare them, so lets check the",
"# whole range",
"name",
"=",
"None",
"if",
"name",
"and",
"decl_type",
":",
"impl_match",
"=",
"scopedef_t",
".",
"_impl_matchers",
"[",
"scopedef_t",
".",
"decl",
"]",
"(",
"name",
"=",
"name",
")",
"if",
"impl_match",
".",
"is_full_name",
"(",
")",
":",
"name",
"=",
"impl_match",
".",
"decl_name_only",
"if",
"recursive",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"'query has been optimized on type and name'",
")",
"return",
"self",
".",
"_type2name2decls",
"[",
"decl_type",
"]",
".",
"get",
"(",
"name",
",",
"[",
"]",
")",
"self",
".",
"_logger",
".",
"debug",
"(",
"'non recursive query has been optimized on type and name'",
")",
"return",
"self",
".",
"_type2name2decls_nr",
"[",
"decl_type",
"]",
".",
"get",
"(",
"name",
",",
"[",
"]",
")",
"elif",
"decl_type",
":",
"if",
"recursive",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"'query has been optimized on type'",
")",
"return",
"self",
".",
"_type2decls",
"[",
"decl_type",
"]",
"self",
".",
"_logger",
".",
"debug",
"(",
"'non recursive query has been optimized on type'",
")",
"return",
"self",
".",
"_type2decls_nr",
"[",
"decl_type",
"]",
"else",
":",
"if",
"recursive",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"(",
"'query has not been optimized ( hint: query does not '",
"+",
"'contain type and/or name )'",
")",
")",
"return",
"self",
".",
"_all_decls",
"self",
".",
"_logger",
".",
"debug",
"(",
"(",
"'non recursive query has not been optimized ( hint: '",
"+",
"'query does not contain type and/or name )'",
")",
")",
"return",
"self",
".",
"_all_decls_not_recursive"
] |
implementation details
|
[
"implementation",
"details"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L408-L455
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t._find_single
|
def _find_single(self, match_class, **keywds):
"""implementation details"""
self._logger.debug('find single query execution - started')
start_time = timeit.default_timer()
norm_keywds = self.__normalize_args(**keywds)
decl_matcher = self.__create_matcher(match_class, **norm_keywds)
dtype = self.__findout_decl_type(match_class, **norm_keywds)
recursive_ = self.__findout_recursive(**norm_keywds)
decls = self.__findout_range(norm_keywds['name'], dtype, recursive_)
found = matcher.get_single(decl_matcher, decls, False)
self._logger.debug(
'find single query execution - done( %f seconds )',
(timeit.default_timer() - start_time))
return found
|
python
|
def _find_single(self, match_class, **keywds):
self._logger.debug('find single query execution - started')
start_time = timeit.default_timer()
norm_keywds = self.__normalize_args(**keywds)
decl_matcher = self.__create_matcher(match_class, **norm_keywds)
dtype = self.__findout_decl_type(match_class, **norm_keywds)
recursive_ = self.__findout_recursive(**norm_keywds)
decls = self.__findout_range(norm_keywds['name'], dtype, recursive_)
found = matcher.get_single(decl_matcher, decls, False)
self._logger.debug(
'find single query execution - done( %f seconds )',
(timeit.default_timer() - start_time))
return found
|
[
"def",
"_find_single",
"(",
"self",
",",
"match_class",
",",
"*",
"*",
"keywds",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"'find single query execution - started'",
")",
"start_time",
"=",
"timeit",
".",
"default_timer",
"(",
")",
"norm_keywds",
"=",
"self",
".",
"__normalize_args",
"(",
"*",
"*",
"keywds",
")",
"decl_matcher",
"=",
"self",
".",
"__create_matcher",
"(",
"match_class",
",",
"*",
"*",
"norm_keywds",
")",
"dtype",
"=",
"self",
".",
"__findout_decl_type",
"(",
"match_class",
",",
"*",
"*",
"norm_keywds",
")",
"recursive_",
"=",
"self",
".",
"__findout_recursive",
"(",
"*",
"*",
"norm_keywds",
")",
"decls",
"=",
"self",
".",
"__findout_range",
"(",
"norm_keywds",
"[",
"'name'",
"]",
",",
"dtype",
",",
"recursive_",
")",
"found",
"=",
"matcher",
".",
"get_single",
"(",
"decl_matcher",
",",
"decls",
",",
"False",
")",
"self",
".",
"_logger",
".",
"debug",
"(",
"'find single query execution - done( %f seconds )'",
",",
"(",
"timeit",
".",
"default_timer",
"(",
")",
"-",
"start_time",
")",
")",
"return",
"found"
] |
implementation details
|
[
"implementation",
"details"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L457-L470
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t._find_multiple
|
def _find_multiple(self, match_class, **keywds):
"""implementation details"""
self._logger.debug('find all query execution - started')
start_time = timeit.default_timer()
norm_keywds = self.__normalize_args(**keywds)
decl_matcher = self.__create_matcher(match_class, **norm_keywds)
dtype = self.__findout_decl_type(match_class, **norm_keywds)
recursive_ = self.__findout_recursive(**norm_keywds)
allow_empty = self.__findout_allow_empty(**norm_keywds)
decls = self.__findout_range(norm_keywds['name'], dtype, recursive_)
found = matcher.find(decl_matcher, decls, False)
mfound = mdecl_wrapper.mdecl_wrapper_t(found)
self._logger.debug('%d declaration(s) that match query', len(mfound))
self._logger.debug(
'find single query execution - done( %f seconds )',
(timeit.default_timer() - start_time))
if not mfound and not allow_empty:
raise RuntimeError(
"Multi declaration query returned 0 declarations.")
return mfound
|
python
|
def _find_multiple(self, match_class, **keywds):
self._logger.debug('find all query execution - started')
start_time = timeit.default_timer()
norm_keywds = self.__normalize_args(**keywds)
decl_matcher = self.__create_matcher(match_class, **norm_keywds)
dtype = self.__findout_decl_type(match_class, **norm_keywds)
recursive_ = self.__findout_recursive(**norm_keywds)
allow_empty = self.__findout_allow_empty(**norm_keywds)
decls = self.__findout_range(norm_keywds['name'], dtype, recursive_)
found = matcher.find(decl_matcher, decls, False)
mfound = mdecl_wrapper.mdecl_wrapper_t(found)
self._logger.debug('%d declaration(s) that match query', len(mfound))
self._logger.debug(
'find single query execution - done( %f seconds )',
(timeit.default_timer() - start_time))
if not mfound and not allow_empty:
raise RuntimeError(
"Multi declaration query returned 0 declarations.")
return mfound
|
[
"def",
"_find_multiple",
"(",
"self",
",",
"match_class",
",",
"*",
"*",
"keywds",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"'find all query execution - started'",
")",
"start_time",
"=",
"timeit",
".",
"default_timer",
"(",
")",
"norm_keywds",
"=",
"self",
".",
"__normalize_args",
"(",
"*",
"*",
"keywds",
")",
"decl_matcher",
"=",
"self",
".",
"__create_matcher",
"(",
"match_class",
",",
"*",
"*",
"norm_keywds",
")",
"dtype",
"=",
"self",
".",
"__findout_decl_type",
"(",
"match_class",
",",
"*",
"*",
"norm_keywds",
")",
"recursive_",
"=",
"self",
".",
"__findout_recursive",
"(",
"*",
"*",
"norm_keywds",
")",
"allow_empty",
"=",
"self",
".",
"__findout_allow_empty",
"(",
"*",
"*",
"norm_keywds",
")",
"decls",
"=",
"self",
".",
"__findout_range",
"(",
"norm_keywds",
"[",
"'name'",
"]",
",",
"dtype",
",",
"recursive_",
")",
"found",
"=",
"matcher",
".",
"find",
"(",
"decl_matcher",
",",
"decls",
",",
"False",
")",
"mfound",
"=",
"mdecl_wrapper",
".",
"mdecl_wrapper_t",
"(",
"found",
")",
"self",
".",
"_logger",
".",
"debug",
"(",
"'%d declaration(s) that match query'",
",",
"len",
"(",
"mfound",
")",
")",
"self",
".",
"_logger",
".",
"debug",
"(",
"'find single query execution - done( %f seconds )'",
",",
"(",
"timeit",
".",
"default_timer",
"(",
")",
"-",
"start_time",
")",
")",
"if",
"not",
"mfound",
"and",
"not",
"allow_empty",
":",
"raise",
"RuntimeError",
"(",
"\"Multi declaration query returned 0 declarations.\"",
")",
"return",
"mfound"
] |
implementation details
|
[
"implementation",
"details"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L472-L491
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.decls
|
def decls(
self,
name=None,
function=None,
decl_type=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
"""returns a set of declarations, that are matched defined criteria"""
return (
self._find_multiple(
self._impl_matchers[
scopedef_t.decl],
name=name,
function=function,
decl_type=decl_type,
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
python
|
def decls(
self,
name=None,
function=None,
decl_type=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
return (
self._find_multiple(
self._impl_matchers[
scopedef_t.decl],
name=name,
function=function,
decl_type=decl_type,
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
[
"def",
"decls",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"decl_type",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
",",
"allow_empty",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_multiple",
"(",
"self",
".",
"_impl_matchers",
"[",
"scopedef_t",
".",
"decl",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"decl_type",
"=",
"decl_type",
",",
"header_dir",
"=",
"header_dir",
",",
"header_file",
"=",
"header_file",
",",
"recursive",
"=",
"recursive",
",",
"allow_empty",
"=",
"allow_empty",
")",
")"
] |
returns a set of declarations, that are matched defined criteria
|
[
"returns",
"a",
"set",
"of",
"declarations",
"that",
"are",
"matched",
"defined",
"criteria"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L515-L536
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.classes
|
def classes(
self,
name=None,
function=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
"""returns a set of class declarations, that are matched defined
criteria"""
return (
self._find_multiple(
self._impl_matchers[scopedef_t.class_],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.class_],
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
python
|
def classes(
self,
name=None,
function=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
return (
self._find_multiple(
self._impl_matchers[scopedef_t.class_],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.class_],
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
[
"def",
"classes",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
",",
"allow_empty",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_multiple",
"(",
"self",
".",
"_impl_matchers",
"[",
"scopedef_t",
".",
"class_",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"decl_type",
"=",
"self",
".",
"_impl_decl_types",
"[",
"scopedef_t",
".",
"class_",
"]",
",",
"header_dir",
"=",
"header_dir",
",",
"header_file",
"=",
"header_file",
",",
"recursive",
"=",
"recursive",
",",
"allow_empty",
"=",
"allow_empty",
")",
")"
] |
returns a set of class declarations, that are matched defined
criteria
|
[
"returns",
"a",
"set",
"of",
"class",
"declarations",
"that",
"are",
"matched",
"defined",
"criteria"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L559-L580
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.variable
|
def variable(
self,
name=None,
function=None,
decl_type=None,
header_dir=None,
header_file=None,
recursive=None):
"""returns reference to variable declaration, that is matched defined
criteria"""
return (
self._find_single(
self._impl_matchers[
scopedef_t.variable],
name=name,
function=function,
decl_type=decl_type,
header_dir=header_dir,
header_file=header_file,
recursive=recursive)
)
|
python
|
def variable(
self,
name=None,
function=None,
decl_type=None,
header_dir=None,
header_file=None,
recursive=None):
return (
self._find_single(
self._impl_matchers[
scopedef_t.variable],
name=name,
function=function,
decl_type=decl_type,
header_dir=header_dir,
header_file=header_file,
recursive=recursive)
)
|
[
"def",
"variable",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"decl_type",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_single",
"(",
"self",
".",
"_impl_matchers",
"[",
"scopedef_t",
".",
"variable",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"decl_type",
"=",
"decl_type",
",",
"header_dir",
"=",
"header_dir",
",",
"header_file",
"=",
"header_file",
",",
"recursive",
"=",
"recursive",
")",
")"
] |
returns reference to variable declaration, that is matched defined
criteria
|
[
"returns",
"reference",
"to",
"variable",
"declaration",
"that",
"is",
"matched",
"defined",
"criteria"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L582-L603
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.variables
|
def variables(
self,
name=None,
function=None,
decl_type=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
"""returns a set of variable declarations, that are matched defined
criteria"""
return (
self._find_multiple(
self._impl_matchers[
scopedef_t.variable],
name=name,
function=function,
decl_type=decl_type,
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
python
|
def variables(
self,
name=None,
function=None,
decl_type=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
return (
self._find_multiple(
self._impl_matchers[
scopedef_t.variable],
name=name,
function=function,
decl_type=decl_type,
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
[
"def",
"variables",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"decl_type",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
",",
"allow_empty",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_multiple",
"(",
"self",
".",
"_impl_matchers",
"[",
"scopedef_t",
".",
"variable",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"decl_type",
"=",
"decl_type",
",",
"header_dir",
"=",
"header_dir",
",",
"header_file",
"=",
"header_file",
",",
"recursive",
"=",
"recursive",
",",
"allow_empty",
"=",
"allow_empty",
")",
")"
] |
returns a set of variable declarations, that are matched defined
criteria
|
[
"returns",
"a",
"set",
"of",
"variable",
"declarations",
"that",
"are",
"matched",
"defined",
"criteria"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L605-L628
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.calldefs
|
def calldefs(
self,
name=None,
function=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
"""returns a set of :class:`calldef_t` declarations, that are matched
defined criteria"""
return (
self._find_multiple(
self._impl_matchers[scopedef_t.calldef],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.calldef],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
python
|
def calldefs(
self,
name=None,
function=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
return (
self._find_multiple(
self._impl_matchers[scopedef_t.calldef],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.calldef],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
[
"def",
"calldefs",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"return_type",
"=",
"None",
",",
"arg_types",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
",",
"allow_empty",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_multiple",
"(",
"self",
".",
"_impl_matchers",
"[",
"scopedef_t",
".",
"calldef",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"decl_type",
"=",
"self",
".",
"_impl_decl_types",
"[",
"scopedef_t",
".",
"calldef",
"]",
",",
"return_type",
"=",
"return_type",
",",
"arg_types",
"=",
"arg_types",
",",
"header_dir",
"=",
"header_dir",
",",
"header_file",
"=",
"header_file",
",",
"recursive",
"=",
"recursive",
",",
"allow_empty",
"=",
"allow_empty",
")",
")"
] |
returns a set of :class:`calldef_t` declarations, that are matched
defined criteria
|
[
"returns",
"a",
"set",
"of",
":",
"class",
":",
"calldef_t",
"declarations",
"that",
"are",
"matched",
"defined",
"criteria"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L655-L680
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.member_functions
|
def member_functions(
self,
name=None,
function=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
"""returns a set of member function declarations, that are matched
defined criteria"""
return (
self._find_multiple(
self._impl_matchers[scopedef_t.member_function],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.member_function],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
python
|
def member_functions(
self,
name=None,
function=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
return (
self._find_multiple(
self._impl_matchers[scopedef_t.member_function],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.member_function],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
[
"def",
"member_functions",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"return_type",
"=",
"None",
",",
"arg_types",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
",",
"allow_empty",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_multiple",
"(",
"self",
".",
"_impl_matchers",
"[",
"scopedef_t",
".",
"member_function",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"decl_type",
"=",
"self",
".",
"_impl_decl_types",
"[",
"scopedef_t",
".",
"member_function",
"]",
",",
"return_type",
"=",
"return_type",
",",
"arg_types",
"=",
"arg_types",
",",
"header_dir",
"=",
"header_dir",
",",
"header_file",
"=",
"header_file",
",",
"recursive",
"=",
"recursive",
",",
"allow_empty",
"=",
"allow_empty",
")",
")"
] |
returns a set of member function declarations, that are matched
defined criteria
|
[
"returns",
"a",
"set",
"of",
"member",
"function",
"declarations",
"that",
"are",
"matched",
"defined",
"criteria"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L767-L792
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.constructor
|
def constructor(
self,
name=None,
function=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None):
"""returns reference to constructor declaration, that is matched
defined criteria"""
return (
self._find_single(
self._impl_matchers[scopedef_t.constructor],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.constructor],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive)
)
|
python
|
def constructor(
self,
name=None,
function=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None):
return (
self._find_single(
self._impl_matchers[scopedef_t.constructor],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.constructor],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive)
)
|
[
"def",
"constructor",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"return_type",
"=",
"None",
",",
"arg_types",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_single",
"(",
"self",
".",
"_impl_matchers",
"[",
"scopedef_t",
".",
"constructor",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"decl_type",
"=",
"self",
".",
"_impl_decl_types",
"[",
"scopedef_t",
".",
"constructor",
"]",
",",
"return_type",
"=",
"return_type",
",",
"arg_types",
"=",
"arg_types",
",",
"header_dir",
"=",
"header_dir",
",",
"header_file",
"=",
"header_file",
",",
"recursive",
"=",
"recursive",
")",
")"
] |
returns reference to constructor declaration, that is matched
defined criteria
|
[
"returns",
"reference",
"to",
"constructor",
"declaration",
"that",
"is",
"matched",
"defined",
"criteria"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L794-L817
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.constructors
|
def constructors(
self,
name=None,
function=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
"""returns a set of constructor declarations, that are matched
defined criteria"""
return (
self._find_multiple(
self._impl_matchers[scopedef_t.constructor],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.constructor],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
python
|
def constructors(
self,
name=None,
function=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
return (
self._find_multiple(
self._impl_matchers[scopedef_t.constructor],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.constructor],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
[
"def",
"constructors",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"return_type",
"=",
"None",
",",
"arg_types",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
",",
"allow_empty",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_multiple",
"(",
"self",
".",
"_impl_matchers",
"[",
"scopedef_t",
".",
"constructor",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"decl_type",
"=",
"self",
".",
"_impl_decl_types",
"[",
"scopedef_t",
".",
"constructor",
"]",
",",
"return_type",
"=",
"return_type",
",",
"arg_types",
"=",
"arg_types",
",",
"header_dir",
"=",
"header_dir",
",",
"header_file",
"=",
"header_file",
",",
"recursive",
"=",
"recursive",
",",
"allow_empty",
"=",
"allow_empty",
")",
")"
] |
returns a set of constructor declarations, that are matched
defined criteria
|
[
"returns",
"a",
"set",
"of",
"constructor",
"declarations",
"that",
"are",
"matched",
"defined",
"criteria"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L819-L844
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.casting_operators
|
def casting_operators(
self,
name=None,
function=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
"""returns a set of casting operator declarations, that are matched
defined criteria"""
return (
self._find_multiple(
self._impl_matchers[scopedef_t.casting_operator],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.casting_operator],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
python
|
def casting_operators(
self,
name=None,
function=None,
return_type=None,
arg_types=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
return (
self._find_multiple(
self._impl_matchers[scopedef_t.casting_operator],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.casting_operator],
return_type=return_type,
arg_types=arg_types,
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
[
"def",
"casting_operators",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"return_type",
"=",
"None",
",",
"arg_types",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
",",
"allow_empty",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_multiple",
"(",
"self",
".",
"_impl_matchers",
"[",
"scopedef_t",
".",
"casting_operator",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"decl_type",
"=",
"self",
".",
"_impl_decl_types",
"[",
"scopedef_t",
".",
"casting_operator",
"]",
",",
"return_type",
"=",
"return_type",
",",
"arg_types",
"=",
"arg_types",
",",
"header_dir",
"=",
"header_dir",
",",
"header_file",
"=",
"header_file",
",",
"recursive",
"=",
"recursive",
",",
"allow_empty",
"=",
"allow_empty",
")",
")"
] |
returns a set of casting operator declarations, that are matched
defined criteria
|
[
"returns",
"a",
"set",
"of",
"casting",
"operator",
"declarations",
"that",
"are",
"matched",
"defined",
"criteria"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L931-L956
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.enumerations
|
def enumerations(
self,
name=None,
function=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
"""returns a set of enumeration declarations, that are matched
defined criteria"""
return (
self._find_multiple(
self._impl_matchers[scopedef_t.enumeration],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.enumeration],
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
python
|
def enumerations(
self,
name=None,
function=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
return (
self._find_multiple(
self._impl_matchers[scopedef_t.enumeration],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.enumeration],
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
[
"def",
"enumerations",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
",",
"allow_empty",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_multiple",
"(",
"self",
".",
"_impl_matchers",
"[",
"scopedef_t",
".",
"enumeration",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"decl_type",
"=",
"self",
".",
"_impl_decl_types",
"[",
"scopedef_t",
".",
"enumeration",
"]",
",",
"header_dir",
"=",
"header_dir",
",",
"header_file",
"=",
"header_file",
",",
"recursive",
"=",
"recursive",
",",
"allow_empty",
"=",
"allow_empty",
")",
")"
] |
returns a set of enumeration declarations, that are matched
defined criteria
|
[
"returns",
"a",
"set",
"of",
"enumeration",
"declarations",
"that",
"are",
"matched",
"defined",
"criteria"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L979-L1000
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.typedef
|
def typedef(
self,
name=None,
function=None,
header_dir=None,
header_file=None,
recursive=None):
"""returns reference to typedef declaration, that is matched
defined criteria"""
return (
self._find_single(
self._impl_matchers[scopedef_t.typedef],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.typedef],
header_dir=header_dir,
header_file=header_file,
recursive=recursive)
)
|
python
|
def typedef(
self,
name=None,
function=None,
header_dir=None,
header_file=None,
recursive=None):
return (
self._find_single(
self._impl_matchers[scopedef_t.typedef],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.typedef],
header_dir=header_dir,
header_file=header_file,
recursive=recursive)
)
|
[
"def",
"typedef",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_single",
"(",
"self",
".",
"_impl_matchers",
"[",
"scopedef_t",
".",
"typedef",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"decl_type",
"=",
"self",
".",
"_impl_decl_types",
"[",
"scopedef_t",
".",
"typedef",
"]",
",",
"header_dir",
"=",
"header_dir",
",",
"header_file",
"=",
"header_file",
",",
"recursive",
"=",
"recursive",
")",
")"
] |
returns reference to typedef declaration, that is matched
defined criteria
|
[
"returns",
"reference",
"to",
"typedef",
"declaration",
"that",
"is",
"matched",
"defined",
"criteria"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L1002-L1021
|
gccxml/pygccxml
|
pygccxml/declarations/scopedef.py
|
scopedef_t.typedefs
|
def typedefs(
self,
name=None,
function=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
"""returns a set of typedef declarations, that are matched
defined criteria"""
return (
self._find_multiple(
self._impl_matchers[scopedef_t.typedef],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.typedef],
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
python
|
def typedefs(
self,
name=None,
function=None,
header_dir=None,
header_file=None,
recursive=None,
allow_empty=None):
return (
self._find_multiple(
self._impl_matchers[scopedef_t.typedef],
name=name,
function=function,
decl_type=self._impl_decl_types[
scopedef_t.typedef],
header_dir=header_dir,
header_file=header_file,
recursive=recursive,
allow_empty=allow_empty)
)
|
[
"def",
"typedefs",
"(",
"self",
",",
"name",
"=",
"None",
",",
"function",
"=",
"None",
",",
"header_dir",
"=",
"None",
",",
"header_file",
"=",
"None",
",",
"recursive",
"=",
"None",
",",
"allow_empty",
"=",
"None",
")",
":",
"return",
"(",
"self",
".",
"_find_multiple",
"(",
"self",
".",
"_impl_matchers",
"[",
"scopedef_t",
".",
"typedef",
"]",
",",
"name",
"=",
"name",
",",
"function",
"=",
"function",
",",
"decl_type",
"=",
"self",
".",
"_impl_decl_types",
"[",
"scopedef_t",
".",
"typedef",
"]",
",",
"header_dir",
"=",
"header_dir",
",",
"header_file",
"=",
"header_file",
",",
"recursive",
"=",
"recursive",
",",
"allow_empty",
"=",
"allow_empty",
")",
")"
] |
returns a set of typedef declarations, that are matched
defined criteria
|
[
"returns",
"a",
"set",
"of",
"typedef",
"declarations",
"that",
"are",
"matched",
"defined",
"criteria"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/scopedef.py#L1023-L1044
|
gccxml/pygccxml
|
pygccxml/parser/config.py
|
load_xml_generator_configuration
|
def load_xml_generator_configuration(configuration, **defaults):
"""
Loads CastXML or GCC-XML configuration.
Args:
configuration (string|configparser.ConfigParser): can be
a string (file path to a configuration file) or
instance of :class:`configparser.ConfigParser`.
defaults: can be used to override single configuration values.
Returns:
:class:`.xml_generator_configuration_t`: a configuration object
The file passed needs to be in a format that can be parsed by
:class:`configparser.ConfigParser`.
An example configuration file skeleton can be found
`here <https://github.com/gccxml/pygccxml/blob/develop/
unittests/xml_generator.cfg>`_.
"""
parser = configuration
if utils.is_str(configuration):
parser = ConfigParser()
parser.read(configuration)
# Create a new empty configuration
cfg = xml_generator_configuration_t()
values = defaults
if not values:
values = {}
if parser.has_section('xml_generator'):
for name, value in parser.items('xml_generator'):
if value.strip():
values[name] = value
for name, value in values.items():
if isinstance(value, str):
value = value.strip()
if name == 'gccxml_path':
cfg.gccxml_path = value
if name == 'xml_generator_path':
cfg.xml_generator_path = value
elif name == 'working_directory':
cfg.working_directory = value
elif name == 'include_paths':
for p in value.split(';'):
p = p.strip()
if p:
cfg.include_paths.append(os.path.normpath(p))
elif name == 'compiler':
cfg.compiler = value
elif name == 'xml_generator':
cfg.xml_generator = value
elif name == 'castxml_epic_version':
cfg.castxml_epic_version = int(value)
elif name == 'keep_xml':
cfg.keep_xml = value
elif name == 'cflags':
cfg.cflags = value
elif name == 'flags':
cfg.flags = value
elif name == 'compiler_path':
cfg.compiler_path = value
else:
print('\n%s entry was ignored' % name)
# If no compiler path was set and we are using castxml, set the path
# Here we overwrite the default configuration done in the cfg because
# the xml_generator was set through the setter after the creation of a new
# emppty configuration object.
cfg.compiler_path = create_compiler_path(
cfg.xml_generator, cfg.compiler_path)
return cfg
|
python
|
def load_xml_generator_configuration(configuration, **defaults):
parser = configuration
if utils.is_str(configuration):
parser = ConfigParser()
parser.read(configuration)
cfg = xml_generator_configuration_t()
values = defaults
if not values:
values = {}
if parser.has_section('xml_generator'):
for name, value in parser.items('xml_generator'):
if value.strip():
values[name] = value
for name, value in values.items():
if isinstance(value, str):
value = value.strip()
if name == 'gccxml_path':
cfg.gccxml_path = value
if name == 'xml_generator_path':
cfg.xml_generator_path = value
elif name == 'working_directory':
cfg.working_directory = value
elif name == 'include_paths':
for p in value.split(';'):
p = p.strip()
if p:
cfg.include_paths.append(os.path.normpath(p))
elif name == 'compiler':
cfg.compiler = value
elif name == 'xml_generator':
cfg.xml_generator = value
elif name == 'castxml_epic_version':
cfg.castxml_epic_version = int(value)
elif name == 'keep_xml':
cfg.keep_xml = value
elif name == 'cflags':
cfg.cflags = value
elif name == 'flags':
cfg.flags = value
elif name == 'compiler_path':
cfg.compiler_path = value
else:
print('\n%s entry was ignored' % name)
cfg.compiler_path = create_compiler_path(
cfg.xml_generator, cfg.compiler_path)
return cfg
|
[
"def",
"load_xml_generator_configuration",
"(",
"configuration",
",",
"*",
"*",
"defaults",
")",
":",
"parser",
"=",
"configuration",
"if",
"utils",
".",
"is_str",
"(",
"configuration",
")",
":",
"parser",
"=",
"ConfigParser",
"(",
")",
"parser",
".",
"read",
"(",
"configuration",
")",
"# Create a new empty configuration",
"cfg",
"=",
"xml_generator_configuration_t",
"(",
")",
"values",
"=",
"defaults",
"if",
"not",
"values",
":",
"values",
"=",
"{",
"}",
"if",
"parser",
".",
"has_section",
"(",
"'xml_generator'",
")",
":",
"for",
"name",
",",
"value",
"in",
"parser",
".",
"items",
"(",
"'xml_generator'",
")",
":",
"if",
"value",
".",
"strip",
"(",
")",
":",
"values",
"[",
"name",
"]",
"=",
"value",
"for",
"name",
",",
"value",
"in",
"values",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"value",
"=",
"value",
".",
"strip",
"(",
")",
"if",
"name",
"==",
"'gccxml_path'",
":",
"cfg",
".",
"gccxml_path",
"=",
"value",
"if",
"name",
"==",
"'xml_generator_path'",
":",
"cfg",
".",
"xml_generator_path",
"=",
"value",
"elif",
"name",
"==",
"'working_directory'",
":",
"cfg",
".",
"working_directory",
"=",
"value",
"elif",
"name",
"==",
"'include_paths'",
":",
"for",
"p",
"in",
"value",
".",
"split",
"(",
"';'",
")",
":",
"p",
"=",
"p",
".",
"strip",
"(",
")",
"if",
"p",
":",
"cfg",
".",
"include_paths",
".",
"append",
"(",
"os",
".",
"path",
".",
"normpath",
"(",
"p",
")",
")",
"elif",
"name",
"==",
"'compiler'",
":",
"cfg",
".",
"compiler",
"=",
"value",
"elif",
"name",
"==",
"'xml_generator'",
":",
"cfg",
".",
"xml_generator",
"=",
"value",
"elif",
"name",
"==",
"'castxml_epic_version'",
":",
"cfg",
".",
"castxml_epic_version",
"=",
"int",
"(",
"value",
")",
"elif",
"name",
"==",
"'keep_xml'",
":",
"cfg",
".",
"keep_xml",
"=",
"value",
"elif",
"name",
"==",
"'cflags'",
":",
"cfg",
".",
"cflags",
"=",
"value",
"elif",
"name",
"==",
"'flags'",
":",
"cfg",
".",
"flags",
"=",
"value",
"elif",
"name",
"==",
"'compiler_path'",
":",
"cfg",
".",
"compiler_path",
"=",
"value",
"else",
":",
"print",
"(",
"'\\n%s entry was ignored'",
"%",
"name",
")",
"# If no compiler path was set and we are using castxml, set the path",
"# Here we overwrite the default configuration done in the cfg because",
"# the xml_generator was set through the setter after the creation of a new",
"# emppty configuration object.",
"cfg",
".",
"compiler_path",
"=",
"create_compiler_path",
"(",
"cfg",
".",
"xml_generator",
",",
"cfg",
".",
"compiler_path",
")",
"return",
"cfg"
] |
Loads CastXML or GCC-XML configuration.
Args:
configuration (string|configparser.ConfigParser): can be
a string (file path to a configuration file) or
instance of :class:`configparser.ConfigParser`.
defaults: can be used to override single configuration values.
Returns:
:class:`.xml_generator_configuration_t`: a configuration object
The file passed needs to be in a format that can be parsed by
:class:`configparser.ConfigParser`.
An example configuration file skeleton can be found
`here <https://github.com/gccxml/pygccxml/blob/develop/
unittests/xml_generator.cfg>`_.
|
[
"Loads",
"CastXML",
"or",
"GCC",
"-",
"XML",
"configuration",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/config.py#L333-L410
|
gccxml/pygccxml
|
pygccxml/parser/config.py
|
create_compiler_path
|
def create_compiler_path(xml_generator, compiler_path):
"""
Try to guess a path for the compiler.
If you want ot use a specific compiler, please provide the compiler
path manually, as the guess may not be what you are expecting.
Providing the path can be done by passing it as an argument (compiler_path)
to the xml_generator_configuration_t() or by defining it in your pygccxml
configuration file.
"""
if xml_generator == 'castxml' and compiler_path is None:
if platform.system() == 'Windows':
# Look for msvc
p = subprocess.Popen(
['where', 'cl'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
compiler_path = p.stdout.read().decode("utf-8").rstrip()
p.wait()
p.stdout.close()
p.stderr.close()
# No msvc found; look for mingw
if compiler_path == '':
p = subprocess.Popen(
['where', 'mingw'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
compiler_path = p.stdout.read().decode("utf-8").rstrip()
p.wait()
p.stdout.close()
p.stderr.close()
else:
# OS X or Linux
# Look for clang first, then gcc
p = subprocess.Popen(
['which', 'clang++'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
compiler_path = p.stdout.read().decode("utf-8").rstrip()
p.wait()
p.stdout.close()
p.stderr.close()
# No clang found; use gcc
if compiler_path == '':
p = subprocess.Popen(
['which', 'c++'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
compiler_path = p.stdout.read().decode("utf-8").rstrip()
p.wait()
p.stdout.close()
p.stderr.close()
if compiler_path == "":
compiler_path = None
return compiler_path
|
python
|
def create_compiler_path(xml_generator, compiler_path):
if xml_generator == 'castxml' and compiler_path is None:
if platform.system() == 'Windows':
p = subprocess.Popen(
['where', 'cl'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
compiler_path = p.stdout.read().decode("utf-8").rstrip()
p.wait()
p.stdout.close()
p.stderr.close()
if compiler_path == '':
p = subprocess.Popen(
['where', 'mingw'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
compiler_path = p.stdout.read().decode("utf-8").rstrip()
p.wait()
p.stdout.close()
p.stderr.close()
else:
p = subprocess.Popen(
['which', 'clang++'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
compiler_path = p.stdout.read().decode("utf-8").rstrip()
p.wait()
p.stdout.close()
p.stderr.close()
if compiler_path == '':
p = subprocess.Popen(
['which', 'c++'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
compiler_path = p.stdout.read().decode("utf-8").rstrip()
p.wait()
p.stdout.close()
p.stderr.close()
if compiler_path == "":
compiler_path = None
return compiler_path
|
[
"def",
"create_compiler_path",
"(",
"xml_generator",
",",
"compiler_path",
")",
":",
"if",
"xml_generator",
"==",
"'castxml'",
"and",
"compiler_path",
"is",
"None",
":",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"'Windows'",
":",
"# Look for msvc",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"'where'",
",",
"'cl'",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",
"PIPE",
")",
"compiler_path",
"=",
"p",
".",
"stdout",
".",
"read",
"(",
")",
".",
"decode",
"(",
"\"utf-8\"",
")",
".",
"rstrip",
"(",
")",
"p",
".",
"wait",
"(",
")",
"p",
".",
"stdout",
".",
"close",
"(",
")",
"p",
".",
"stderr",
".",
"close",
"(",
")",
"# No msvc found; look for mingw",
"if",
"compiler_path",
"==",
"''",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"'where'",
",",
"'mingw'",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",
"PIPE",
")",
"compiler_path",
"=",
"p",
".",
"stdout",
".",
"read",
"(",
")",
".",
"decode",
"(",
"\"utf-8\"",
")",
".",
"rstrip",
"(",
")",
"p",
".",
"wait",
"(",
")",
"p",
".",
"stdout",
".",
"close",
"(",
")",
"p",
".",
"stderr",
".",
"close",
"(",
")",
"else",
":",
"# OS X or Linux",
"# Look for clang first, then gcc",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"'which'",
",",
"'clang++'",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",
"PIPE",
")",
"compiler_path",
"=",
"p",
".",
"stdout",
".",
"read",
"(",
")",
".",
"decode",
"(",
"\"utf-8\"",
")",
".",
"rstrip",
"(",
")",
"p",
".",
"wait",
"(",
")",
"p",
".",
"stdout",
".",
"close",
"(",
")",
"p",
".",
"stderr",
".",
"close",
"(",
")",
"# No clang found; use gcc",
"if",
"compiler_path",
"==",
"''",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"'which'",
",",
"'c++'",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",
"PIPE",
")",
"compiler_path",
"=",
"p",
".",
"stdout",
".",
"read",
"(",
")",
".",
"decode",
"(",
"\"utf-8\"",
")",
".",
"rstrip",
"(",
")",
"p",
".",
"wait",
"(",
")",
"p",
".",
"stdout",
".",
"close",
"(",
")",
"p",
".",
"stderr",
".",
"close",
"(",
")",
"if",
"compiler_path",
"==",
"\"\"",
":",
"compiler_path",
"=",
"None",
"return",
"compiler_path"
] |
Try to guess a path for the compiler.
If you want ot use a specific compiler, please provide the compiler
path manually, as the guess may not be what you are expecting.
Providing the path can be done by passing it as an argument (compiler_path)
to the xml_generator_configuration_t() or by defining it in your pygccxml
configuration file.
|
[
"Try",
"to",
"guess",
"a",
"path",
"for",
"the",
"compiler",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/config.py#L413-L471
|
gccxml/pygccxml
|
pygccxml/parser/config.py
|
parser_configuration_t.raise_on_wrong_settings
|
def raise_on_wrong_settings(self):
"""
Validates the configuration settings and raises RuntimeError on error
"""
self.__ensure_dir_exists(self.working_directory, 'working directory')
for idir in self.include_paths:
self.__ensure_dir_exists(idir, 'include directory')
if self.__xml_generator not in ["castxml", "gccxml"]:
msg = ('xml_generator("%s") should either be ' +
'"castxml" or "gccxml".') % self.xml_generator
raise RuntimeError(msg)
|
python
|
def raise_on_wrong_settings(self):
self.__ensure_dir_exists(self.working_directory, 'working directory')
for idir in self.include_paths:
self.__ensure_dir_exists(idir, 'include directory')
if self.__xml_generator not in ["castxml", "gccxml"]:
msg = ('xml_generator("%s") should either be ' +
'"castxml" or "gccxml".') % self.xml_generator
raise RuntimeError(msg)
|
[
"def",
"raise_on_wrong_settings",
"(",
"self",
")",
":",
"self",
".",
"__ensure_dir_exists",
"(",
"self",
".",
"working_directory",
",",
"'working directory'",
")",
"for",
"idir",
"in",
"self",
".",
"include_paths",
":",
"self",
".",
"__ensure_dir_exists",
"(",
"idir",
",",
"'include directory'",
")",
"if",
"self",
".",
"__xml_generator",
"not",
"in",
"[",
"\"castxml\"",
",",
"\"gccxml\"",
"]",
":",
"msg",
"=",
"(",
"'xml_generator(\"%s\") should either be '",
"+",
"'\"castxml\" or \"gccxml\".'",
")",
"%",
"self",
".",
"xml_generator",
"raise",
"RuntimeError",
"(",
"msg",
")"
] |
Validates the configuration settings and raises RuntimeError on error
|
[
"Validates",
"the",
"configuration",
"settings",
"and",
"raises",
"RuntimeError",
"on",
"error"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/config.py#L210-L220
|
gccxml/pygccxml
|
pygccxml/declarations/calldef_members.py
|
member_calldef_t.function_type
|
def function_type(self):
"""returns function type. See :class:`type_t` hierarchy"""
if self.has_static:
return cpptypes.free_function_type_t(
return_type=self.return_type,
arguments_types=[arg.decl_type for arg in self.arguments])
return cpptypes.member_function_type_t(
class_inst=self.parent,
return_type=self.return_type,
arguments_types=[arg.decl_type for arg in self.arguments],
has_const=self.has_const)
|
python
|
def function_type(self):
if self.has_static:
return cpptypes.free_function_type_t(
return_type=self.return_type,
arguments_types=[arg.decl_type for arg in self.arguments])
return cpptypes.member_function_type_t(
class_inst=self.parent,
return_type=self.return_type,
arguments_types=[arg.decl_type for arg in self.arguments],
has_const=self.has_const)
|
[
"def",
"function_type",
"(",
"self",
")",
":",
"if",
"self",
".",
"has_static",
":",
"return",
"cpptypes",
".",
"free_function_type_t",
"(",
"return_type",
"=",
"self",
".",
"return_type",
",",
"arguments_types",
"=",
"[",
"arg",
".",
"decl_type",
"for",
"arg",
"in",
"self",
".",
"arguments",
"]",
")",
"return",
"cpptypes",
".",
"member_function_type_t",
"(",
"class_inst",
"=",
"self",
".",
"parent",
",",
"return_type",
"=",
"self",
".",
"return_type",
",",
"arguments_types",
"=",
"[",
"arg",
".",
"decl_type",
"for",
"arg",
"in",
"self",
".",
"arguments",
"]",
",",
"has_const",
"=",
"self",
".",
"has_const",
")"
] |
returns function type. See :class:`type_t` hierarchy
|
[
"returns",
"function",
"type",
".",
"See",
":",
"class",
":",
"type_t",
"hierarchy"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/calldef_members.py#L104-L115
|
gccxml/pygccxml
|
pygccxml/declarations/declaration_utils.py
|
declaration_path
|
def declaration_path(decl):
"""
Returns a list of parent declarations names.
Args:
decl (declaration_t): declaration for which declaration path
should be calculated.
Returns:
list[(str | basestring)]: list of names, where first item is the top
parent name and last item the inputted
declaration name.
"""
if not decl:
return []
if not decl.cache.declaration_path:
result = [decl.name]
parent = decl.parent
while parent:
if parent.cache.declaration_path:
result.reverse()
decl.cache.declaration_path = parent.cache.declaration_path + \
result
return decl.cache.declaration_path
else:
result.append(parent.name)
parent = parent.parent
result.reverse()
decl.cache.declaration_path = result
return result
return decl.cache.declaration_path
|
python
|
def declaration_path(decl):
if not decl:
return []
if not decl.cache.declaration_path:
result = [decl.name]
parent = decl.parent
while parent:
if parent.cache.declaration_path:
result.reverse()
decl.cache.declaration_path = parent.cache.declaration_path + \
result
return decl.cache.declaration_path
else:
result.append(parent.name)
parent = parent.parent
result.reverse()
decl.cache.declaration_path = result
return result
return decl.cache.declaration_path
|
[
"def",
"declaration_path",
"(",
"decl",
")",
":",
"if",
"not",
"decl",
":",
"return",
"[",
"]",
"if",
"not",
"decl",
".",
"cache",
".",
"declaration_path",
":",
"result",
"=",
"[",
"decl",
".",
"name",
"]",
"parent",
"=",
"decl",
".",
"parent",
"while",
"parent",
":",
"if",
"parent",
".",
"cache",
".",
"declaration_path",
":",
"result",
".",
"reverse",
"(",
")",
"decl",
".",
"cache",
".",
"declaration_path",
"=",
"parent",
".",
"cache",
".",
"declaration_path",
"+",
"result",
"return",
"decl",
".",
"cache",
".",
"declaration_path",
"else",
":",
"result",
".",
"append",
"(",
"parent",
".",
"name",
")",
"parent",
"=",
"parent",
".",
"parent",
"result",
".",
"reverse",
"(",
")",
"decl",
".",
"cache",
".",
"declaration_path",
"=",
"result",
"return",
"result",
"return",
"decl",
".",
"cache",
".",
"declaration_path"
] |
Returns a list of parent declarations names.
Args:
decl (declaration_t): declaration for which declaration path
should be calculated.
Returns:
list[(str | basestring)]: list of names, where first item is the top
parent name and last item the inputted
declaration name.
|
[
"Returns",
"a",
"list",
"of",
"parent",
"declarations",
"names",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/declaration_utils.py#L7-L39
|
gccxml/pygccxml
|
pygccxml/declarations/declaration_utils.py
|
partial_declaration_path
|
def partial_declaration_path(decl):
"""
Returns a list of parent declarations names without template arguments that
have default value.
Args:
decl (declaration_t): declaration for which the partial declaration
path should be calculated.
Returns:
list[(str | basestring)]: list of names, where first item is the top
parent name and last item the inputted
declaration name.
"""
# TODO:
# If parent declaration cache already has declaration_path, reuse it for
# calculation.
if not decl:
return []
if not decl.cache.partial_declaration_path:
result = [decl.partial_name]
parent = decl.parent
while parent:
if parent.cache.partial_declaration_path:
result.reverse()
decl.cache.partial_declaration_path \
= parent.cache.partial_declaration_path + result
return decl.cache.partial_declaration_path
else:
result.append(parent.partial_name)
parent = parent.parent
result.reverse()
decl.cache.partial_declaration_path = result
return result
return decl.cache.partial_declaration_path
|
python
|
def partial_declaration_path(decl):
if not decl:
return []
if not decl.cache.partial_declaration_path:
result = [decl.partial_name]
parent = decl.parent
while parent:
if parent.cache.partial_declaration_path:
result.reverse()
decl.cache.partial_declaration_path \
= parent.cache.partial_declaration_path + result
return decl.cache.partial_declaration_path
else:
result.append(parent.partial_name)
parent = parent.parent
result.reverse()
decl.cache.partial_declaration_path = result
return result
return decl.cache.partial_declaration_path
|
[
"def",
"partial_declaration_path",
"(",
"decl",
")",
":",
"# TODO:",
"# If parent declaration cache already has declaration_path, reuse it for",
"# calculation.",
"if",
"not",
"decl",
":",
"return",
"[",
"]",
"if",
"not",
"decl",
".",
"cache",
".",
"partial_declaration_path",
":",
"result",
"=",
"[",
"decl",
".",
"partial_name",
"]",
"parent",
"=",
"decl",
".",
"parent",
"while",
"parent",
":",
"if",
"parent",
".",
"cache",
".",
"partial_declaration_path",
":",
"result",
".",
"reverse",
"(",
")",
"decl",
".",
"cache",
".",
"partial_declaration_path",
"=",
"parent",
".",
"cache",
".",
"partial_declaration_path",
"+",
"result",
"return",
"decl",
".",
"cache",
".",
"partial_declaration_path",
"else",
":",
"result",
".",
"append",
"(",
"parent",
".",
"partial_name",
")",
"parent",
"=",
"parent",
".",
"parent",
"result",
".",
"reverse",
"(",
")",
"decl",
".",
"cache",
".",
"partial_declaration_path",
"=",
"result",
"return",
"result",
"return",
"decl",
".",
"cache",
".",
"partial_declaration_path"
] |
Returns a list of parent declarations names without template arguments that
have default value.
Args:
decl (declaration_t): declaration for which the partial declaration
path should be calculated.
Returns:
list[(str | basestring)]: list of names, where first item is the top
parent name and last item the inputted
declaration name.
|
[
"Returns",
"a",
"list",
"of",
"parent",
"declarations",
"names",
"without",
"template",
"arguments",
"that",
"have",
"default",
"value",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/declaration_utils.py#L42-L78
|
gccxml/pygccxml
|
pygccxml/declarations/declaration_utils.py
|
full_name
|
def full_name(decl, with_defaults=True):
"""
Returns declaration full qualified name.
If `decl` belongs to anonymous namespace or class, the function will return
C++ illegal qualified name.
Args:
decl (declaration_t): declaration for which the full qualified name
should be calculated.
Returns:
list[(str | basestring)]: full name of the declaration.
"""
if None is decl:
raise RuntimeError("Unable to generate full name for None object!")
if with_defaults:
if not decl.cache.full_name:
path = declaration_path(decl)
if path == [""]:
# Declarations without names are allowed (for examples class
# or struct instances). In this case set an empty name..
decl.cache.full_name = ""
else:
decl.cache.full_name = full_name_from_declaration_path(path)
return decl.cache.full_name
else:
if not decl.cache.full_partial_name:
path = partial_declaration_path(decl)
if path == [""]:
# Declarations without names are allowed (for examples class
# or struct instances). In this case set an empty name.
decl.cache.full_partial_name = ""
else:
decl.cache.full_partial_name = \
full_name_from_declaration_path(path)
return decl.cache.full_partial_name
|
python
|
def full_name(decl, with_defaults=True):
if None is decl:
raise RuntimeError("Unable to generate full name for None object!")
if with_defaults:
if not decl.cache.full_name:
path = declaration_path(decl)
if path == [""]:
decl.cache.full_name = ""
else:
decl.cache.full_name = full_name_from_declaration_path(path)
return decl.cache.full_name
else:
if not decl.cache.full_partial_name:
path = partial_declaration_path(decl)
if path == [""]:
decl.cache.full_partial_name = ""
else:
decl.cache.full_partial_name = \
full_name_from_declaration_path(path)
return decl.cache.full_partial_name
|
[
"def",
"full_name",
"(",
"decl",
",",
"with_defaults",
"=",
"True",
")",
":",
"if",
"None",
"is",
"decl",
":",
"raise",
"RuntimeError",
"(",
"\"Unable to generate full name for None object!\"",
")",
"if",
"with_defaults",
":",
"if",
"not",
"decl",
".",
"cache",
".",
"full_name",
":",
"path",
"=",
"declaration_path",
"(",
"decl",
")",
"if",
"path",
"==",
"[",
"\"\"",
"]",
":",
"# Declarations without names are allowed (for examples class",
"# or struct instances). In this case set an empty name..",
"decl",
".",
"cache",
".",
"full_name",
"=",
"\"\"",
"else",
":",
"decl",
".",
"cache",
".",
"full_name",
"=",
"full_name_from_declaration_path",
"(",
"path",
")",
"return",
"decl",
".",
"cache",
".",
"full_name",
"else",
":",
"if",
"not",
"decl",
".",
"cache",
".",
"full_partial_name",
":",
"path",
"=",
"partial_declaration_path",
"(",
"decl",
")",
"if",
"path",
"==",
"[",
"\"\"",
"]",
":",
"# Declarations without names are allowed (for examples class",
"# or struct instances). In this case set an empty name.",
"decl",
".",
"cache",
".",
"full_partial_name",
"=",
"\"\"",
"else",
":",
"decl",
".",
"cache",
".",
"full_partial_name",
"=",
"full_name_from_declaration_path",
"(",
"path",
")",
"return",
"decl",
".",
"cache",
".",
"full_partial_name"
] |
Returns declaration full qualified name.
If `decl` belongs to anonymous namespace or class, the function will return
C++ illegal qualified name.
Args:
decl (declaration_t): declaration for which the full qualified name
should be calculated.
Returns:
list[(str | basestring)]: full name of the declaration.
|
[
"Returns",
"declaration",
"full",
"qualified",
"name",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/declaration_utils.py#L90-L128
|
gccxml/pygccxml
|
pygccxml/declarations/declaration_utils.py
|
get_named_parent
|
def get_named_parent(decl):
"""
Returns a reference to a named parent declaration.
Args:
decl (declaration_t): the child declaration
Returns:
declaration_t: the declaration or None if not found.
"""
if not decl:
return None
parent = decl.parent
while parent and (not parent.name or parent.name == '::'):
parent = parent.parent
return parent
|
python
|
def get_named_parent(decl):
if not decl:
return None
parent = decl.parent
while parent and (not parent.name or parent.name == '::'):
parent = parent.parent
return parent
|
[
"def",
"get_named_parent",
"(",
"decl",
")",
":",
"if",
"not",
"decl",
":",
"return",
"None",
"parent",
"=",
"decl",
".",
"parent",
"while",
"parent",
"and",
"(",
"not",
"parent",
".",
"name",
"or",
"parent",
".",
"name",
"==",
"'::'",
")",
":",
"parent",
"=",
"parent",
".",
"parent",
"return",
"parent"
] |
Returns a reference to a named parent declaration.
Args:
decl (declaration_t): the child declaration
Returns:
declaration_t: the declaration or None if not found.
|
[
"Returns",
"a",
"reference",
"to",
"a",
"named",
"parent",
"declaration",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/declaration_utils.py#L131-L149
|
gccxml/pygccxml
|
pygccxml/declarations/decl_printer.py
|
print_declarations
|
def print_declarations(
decls,
detailed=True,
recursive=True,
writer=lambda x: sys.stdout.write(x + os.linesep),
verbose=True):
"""
print declarations tree rooted at each of the included nodes.
:param decls: either a single :class:declaration_t object or list
of :class:declaration_t objects
"""
prn = decl_printer_t(0, detailed, recursive, writer, verbose=verbose)
if not isinstance(decls, list):
decls = [decls]
for d in decls:
prn.level = 0
prn.instance = d
algorithm.apply_visitor(prn, d)
|
python
|
def print_declarations(
decls,
detailed=True,
recursive=True,
writer=lambda x: sys.stdout.write(x + os.linesep),
verbose=True):
prn = decl_printer_t(0, detailed, recursive, writer, verbose=verbose)
if not isinstance(decls, list):
decls = [decls]
for d in decls:
prn.level = 0
prn.instance = d
algorithm.apply_visitor(prn, d)
|
[
"def",
"print_declarations",
"(",
"decls",
",",
"detailed",
"=",
"True",
",",
"recursive",
"=",
"True",
",",
"writer",
"=",
"lambda",
"x",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"x",
"+",
"os",
".",
"linesep",
")",
",",
"verbose",
"=",
"True",
")",
":",
"prn",
"=",
"decl_printer_t",
"(",
"0",
",",
"detailed",
",",
"recursive",
",",
"writer",
",",
"verbose",
"=",
"verbose",
")",
"if",
"not",
"isinstance",
"(",
"decls",
",",
"list",
")",
":",
"decls",
"=",
"[",
"decls",
"]",
"for",
"d",
"in",
"decls",
":",
"prn",
".",
"level",
"=",
"0",
"prn",
".",
"instance",
"=",
"d",
"algorithm",
".",
"apply_visitor",
"(",
"prn",
",",
"d",
")"
] |
print declarations tree rooted at each of the included nodes.
:param decls: either a single :class:declaration_t object or list
of :class:declaration_t objects
|
[
"print",
"declarations",
"tree",
"rooted",
"at",
"each",
"of",
"the",
"included",
"nodes",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/decl_printer.py#L434-L452
|
gccxml/pygccxml
|
pygccxml/declarations/decl_printer.py
|
dump_declarations
|
def dump_declarations(declarations, file_path):
"""
Dump declarations tree rooted at each of the included nodes to the file
:param declarations: either a single :class:declaration_t object or a list
of :class:declaration_t objects
:param file_path: path to a file
"""
with open(file_path, "w+") as f:
print_declarations(declarations, writer=f.write)
|
python
|
def dump_declarations(declarations, file_path):
with open(file_path, "w+") as f:
print_declarations(declarations, writer=f.write)
|
[
"def",
"dump_declarations",
"(",
"declarations",
",",
"file_path",
")",
":",
"with",
"open",
"(",
"file_path",
",",
"\"w+\"",
")",
"as",
"f",
":",
"print_declarations",
"(",
"declarations",
",",
"writer",
"=",
"f",
".",
"write",
")"
] |
Dump declarations tree rooted at each of the included nodes to the file
:param declarations: either a single :class:declaration_t object or a list
of :class:declaration_t objects
:param file_path: path to a file
|
[
"Dump",
"declarations",
"tree",
"rooted",
"at",
"each",
"of",
"the",
"included",
"nodes",
"to",
"the",
"file"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/decl_printer.py#L455-L466
|
gccxml/pygccxml
|
pygccxml/parser/source_reader.py
|
source_reader_t.__add_symbols
|
def __add_symbols(self, cmd):
"""
Add all additional defined and undefined symbols.
"""
if self.__config.define_symbols:
symbols = self.__config.define_symbols
cmd.append(''.join(
[' -D"%s"' % def_symbol for def_symbol in symbols]))
if self.__config.undefine_symbols:
un_symbols = self.__config.undefine_symbols
cmd.append(''.join(
[' -U"%s"' % undef_symbol for undef_symbol in un_symbols]))
return cmd
|
python
|
def __add_symbols(self, cmd):
if self.__config.define_symbols:
symbols = self.__config.define_symbols
cmd.append(''.join(
[' -D"%s"' % def_symbol for def_symbol in symbols]))
if self.__config.undefine_symbols:
un_symbols = self.__config.undefine_symbols
cmd.append(''.join(
[' -U"%s"' % undef_symbol for undef_symbol in un_symbols]))
return cmd
|
[
"def",
"__add_symbols",
"(",
"self",
",",
"cmd",
")",
":",
"if",
"self",
".",
"__config",
".",
"define_symbols",
":",
"symbols",
"=",
"self",
".",
"__config",
".",
"define_symbols",
"cmd",
".",
"append",
"(",
"''",
".",
"join",
"(",
"[",
"' -D\"%s\"'",
"%",
"def_symbol",
"for",
"def_symbol",
"in",
"symbols",
"]",
")",
")",
"if",
"self",
".",
"__config",
".",
"undefine_symbols",
":",
"un_symbols",
"=",
"self",
".",
"__config",
".",
"undefine_symbols",
"cmd",
".",
"append",
"(",
"''",
".",
"join",
"(",
"[",
"' -U\"%s\"'",
"%",
"undef_symbol",
"for",
"undef_symbol",
"in",
"un_symbols",
"]",
")",
")",
"return",
"cmd"
] |
Add all additional defined and undefined symbols.
|
[
"Add",
"all",
"additional",
"defined",
"and",
"undefined",
"symbols",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/source_reader.py#L183-L199
|
gccxml/pygccxml
|
pygccxml/parser/source_reader.py
|
source_reader_t.create_xml_file
|
def create_xml_file(self, source_file, destination=None):
"""
This method will generate a xml file using an external tool.
The method will return the file path of the generated xml file.
:param source_file: path to the source file that should be parsed.
:type source_file: str
:param destination: if given, will be used as target file path for
the xml generator.
:type destination: str
:rtype: path to xml file.
"""
xml_file = destination
# If file specified, remove it to start else create new file name
if xml_file:
utils.remove_file_no_raise(xml_file, self.__config)
else:
xml_file = utils.create_temp_file_name(suffix='.xml')
ffname = source_file
if not os.path.isabs(ffname):
ffname = self.__file_full_name(source_file)
command_line = self.__create_command_line(ffname, xml_file)
process = subprocess.Popen(
args=command_line,
shell=True,
stdout=subprocess.PIPE)
try:
results = []
while process.poll() is None:
line = process.stdout.readline()
if line.strip():
results.append(line.rstrip())
for line in process.stdout.readlines():
if line.strip():
results.append(line.rstrip())
exit_status = process.returncode
msg = os.linesep.join([str(s) for s in results])
if self.__config.ignore_gccxml_output:
if not os.path.isfile(xml_file):
raise RuntimeError(
"Error occurred while running " +
self.__config.xml_generator.upper() +
": %s status:%s" %
(msg, exit_status))
else:
if msg or exit_status or not \
os.path.isfile(xml_file):
if not os.path.isfile(xml_file):
raise RuntimeError(
"Error occurred while running " +
self.__config.xml_generator.upper() +
" xml file does not exist")
else:
raise RuntimeError(
"Error occurred while running " +
self.__config.xml_generator.upper() +
": %s status:%s" % (msg, exit_status))
except Exception:
utils.remove_file_no_raise(xml_file, self.__config)
raise
finally:
process.wait()
process.stdout.close()
return xml_file
|
python
|
def create_xml_file(self, source_file, destination=None):
xml_file = destination
if xml_file:
utils.remove_file_no_raise(xml_file, self.__config)
else:
xml_file = utils.create_temp_file_name(suffix='.xml')
ffname = source_file
if not os.path.isabs(ffname):
ffname = self.__file_full_name(source_file)
command_line = self.__create_command_line(ffname, xml_file)
process = subprocess.Popen(
args=command_line,
shell=True,
stdout=subprocess.PIPE)
try:
results = []
while process.poll() is None:
line = process.stdout.readline()
if line.strip():
results.append(line.rstrip())
for line in process.stdout.readlines():
if line.strip():
results.append(line.rstrip())
exit_status = process.returncode
msg = os.linesep.join([str(s) for s in results])
if self.__config.ignore_gccxml_output:
if not os.path.isfile(xml_file):
raise RuntimeError(
"Error occurred while running " +
self.__config.xml_generator.upper() +
": %s status:%s" %
(msg, exit_status))
else:
if msg or exit_status or not \
os.path.isfile(xml_file):
if not os.path.isfile(xml_file):
raise RuntimeError(
"Error occurred while running " +
self.__config.xml_generator.upper() +
" xml file does not exist")
else:
raise RuntimeError(
"Error occurred while running " +
self.__config.xml_generator.upper() +
": %s status:%s" % (msg, exit_status))
except Exception:
utils.remove_file_no_raise(xml_file, self.__config)
raise
finally:
process.wait()
process.stdout.close()
return xml_file
|
[
"def",
"create_xml_file",
"(",
"self",
",",
"source_file",
",",
"destination",
"=",
"None",
")",
":",
"xml_file",
"=",
"destination",
"# If file specified, remove it to start else create new file name",
"if",
"xml_file",
":",
"utils",
".",
"remove_file_no_raise",
"(",
"xml_file",
",",
"self",
".",
"__config",
")",
"else",
":",
"xml_file",
"=",
"utils",
".",
"create_temp_file_name",
"(",
"suffix",
"=",
"'.xml'",
")",
"ffname",
"=",
"source_file",
"if",
"not",
"os",
".",
"path",
".",
"isabs",
"(",
"ffname",
")",
":",
"ffname",
"=",
"self",
".",
"__file_full_name",
"(",
"source_file",
")",
"command_line",
"=",
"self",
".",
"__create_command_line",
"(",
"ffname",
",",
"xml_file",
")",
"process",
"=",
"subprocess",
".",
"Popen",
"(",
"args",
"=",
"command_line",
",",
"shell",
"=",
"True",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
"try",
":",
"results",
"=",
"[",
"]",
"while",
"process",
".",
"poll",
"(",
")",
"is",
"None",
":",
"line",
"=",
"process",
".",
"stdout",
".",
"readline",
"(",
")",
"if",
"line",
".",
"strip",
"(",
")",
":",
"results",
".",
"append",
"(",
"line",
".",
"rstrip",
"(",
")",
")",
"for",
"line",
"in",
"process",
".",
"stdout",
".",
"readlines",
"(",
")",
":",
"if",
"line",
".",
"strip",
"(",
")",
":",
"results",
".",
"append",
"(",
"line",
".",
"rstrip",
"(",
")",
")",
"exit_status",
"=",
"process",
".",
"returncode",
"msg",
"=",
"os",
".",
"linesep",
".",
"join",
"(",
"[",
"str",
"(",
"s",
")",
"for",
"s",
"in",
"results",
"]",
")",
"if",
"self",
".",
"__config",
".",
"ignore_gccxml_output",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"xml_file",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Error occurred while running \"",
"+",
"self",
".",
"__config",
".",
"xml_generator",
".",
"upper",
"(",
")",
"+",
"\": %s status:%s\"",
"%",
"(",
"msg",
",",
"exit_status",
")",
")",
"else",
":",
"if",
"msg",
"or",
"exit_status",
"or",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"xml_file",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"xml_file",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Error occurred while running \"",
"+",
"self",
".",
"__config",
".",
"xml_generator",
".",
"upper",
"(",
")",
"+",
"\" xml file does not exist\"",
")",
"else",
":",
"raise",
"RuntimeError",
"(",
"\"Error occurred while running \"",
"+",
"self",
".",
"__config",
".",
"xml_generator",
".",
"upper",
"(",
")",
"+",
"\": %s status:%s\"",
"%",
"(",
"msg",
",",
"exit_status",
")",
")",
"except",
"Exception",
":",
"utils",
".",
"remove_file_no_raise",
"(",
"xml_file",
",",
"self",
".",
"__config",
")",
"raise",
"finally",
":",
"process",
".",
"wait",
"(",
")",
"process",
".",
"stdout",
".",
"close",
"(",
")",
"return",
"xml_file"
] |
This method will generate a xml file using an external tool.
The method will return the file path of the generated xml file.
:param source_file: path to the source file that should be parsed.
:type source_file: str
:param destination: if given, will be used as target file path for
the xml generator.
:type destination: str
:rtype: path to xml file.
|
[
"This",
"method",
"will",
"generate",
"a",
"xml",
"file",
"using",
"an",
"external",
"tool",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/source_reader.py#L201-L273
|
gccxml/pygccxml
|
pygccxml/parser/source_reader.py
|
source_reader_t.create_xml_file_from_string
|
def create_xml_file_from_string(self, content, destination=None):
"""
Creates XML file from text.
:param content: C++ source code
:type content: str
:param destination: file name for xml file
:type destination: str
:rtype: returns file name of xml file
"""
header_file = utils.create_temp_file_name(suffix='.h')
try:
with open(header_file, "w+") as header:
header.write(content)
xml_file = self.create_xml_file(header_file, destination)
finally:
utils.remove_file_no_raise(header_file, self.__config)
return xml_file
|
python
|
def create_xml_file_from_string(self, content, destination=None):
header_file = utils.create_temp_file_name(suffix='.h')
try:
with open(header_file, "w+") as header:
header.write(content)
xml_file = self.create_xml_file(header_file, destination)
finally:
utils.remove_file_no_raise(header_file, self.__config)
return xml_file
|
[
"def",
"create_xml_file_from_string",
"(",
"self",
",",
"content",
",",
"destination",
"=",
"None",
")",
":",
"header_file",
"=",
"utils",
".",
"create_temp_file_name",
"(",
"suffix",
"=",
"'.h'",
")",
"try",
":",
"with",
"open",
"(",
"header_file",
",",
"\"w+\"",
")",
"as",
"header",
":",
"header",
".",
"write",
"(",
"content",
")",
"xml_file",
"=",
"self",
".",
"create_xml_file",
"(",
"header_file",
",",
"destination",
")",
"finally",
":",
"utils",
".",
"remove_file_no_raise",
"(",
"header_file",
",",
"self",
".",
"__config",
")",
"return",
"xml_file"
] |
Creates XML file from text.
:param content: C++ source code
:type content: str
:param destination: file name for xml file
:type destination: str
:rtype: returns file name of xml file
|
[
"Creates",
"XML",
"file",
"from",
"text",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/source_reader.py#L275-L295
|
gccxml/pygccxml
|
pygccxml/parser/source_reader.py
|
source_reader_t.read_cpp_source_file
|
def read_cpp_source_file(self, source_file):
"""
Reads C++ source file and returns declarations tree
:param source_file: path to C++ source file
:type source_file: str
"""
xml_file = ''
try:
ffname = self.__file_full_name(source_file)
self.logger.debug("Reading source file: [%s].", ffname)
decls = self.__dcache.cached_value(ffname, self.__config)
if not decls:
self.logger.debug(
"File has not been found in cache, parsing...")
xml_file = self.create_xml_file(ffname)
decls, files = self.__parse_xml_file(xml_file)
self.__dcache.update(
ffname, self.__config, decls, files)
else:
self.logger.debug((
"File has not been changed, reading declarations " +
"from cache."))
except Exception:
if xml_file:
utils.remove_file_no_raise(xml_file, self.__config)
raise
if xml_file:
utils.remove_file_no_raise(xml_file, self.__config)
return decls
|
python
|
def read_cpp_source_file(self, source_file):
xml_file = ''
try:
ffname = self.__file_full_name(source_file)
self.logger.debug("Reading source file: [%s].", ffname)
decls = self.__dcache.cached_value(ffname, self.__config)
if not decls:
self.logger.debug(
"File has not been found in cache, parsing...")
xml_file = self.create_xml_file(ffname)
decls, files = self.__parse_xml_file(xml_file)
self.__dcache.update(
ffname, self.__config, decls, files)
else:
self.logger.debug((
"File has not been changed, reading declarations " +
"from cache."))
except Exception:
if xml_file:
utils.remove_file_no_raise(xml_file, self.__config)
raise
if xml_file:
utils.remove_file_no_raise(xml_file, self.__config)
return decls
|
[
"def",
"read_cpp_source_file",
"(",
"self",
",",
"source_file",
")",
":",
"xml_file",
"=",
"''",
"try",
":",
"ffname",
"=",
"self",
".",
"__file_full_name",
"(",
"source_file",
")",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Reading source file: [%s].\"",
",",
"ffname",
")",
"decls",
"=",
"self",
".",
"__dcache",
".",
"cached_value",
"(",
"ffname",
",",
"self",
".",
"__config",
")",
"if",
"not",
"decls",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"File has not been found in cache, parsing...\"",
")",
"xml_file",
"=",
"self",
".",
"create_xml_file",
"(",
"ffname",
")",
"decls",
",",
"files",
"=",
"self",
".",
"__parse_xml_file",
"(",
"xml_file",
")",
"self",
".",
"__dcache",
".",
"update",
"(",
"ffname",
",",
"self",
".",
"__config",
",",
"decls",
",",
"files",
")",
"else",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"(",
"\"File has not been changed, reading declarations \"",
"+",
"\"from cache.\"",
")",
")",
"except",
"Exception",
":",
"if",
"xml_file",
":",
"utils",
".",
"remove_file_no_raise",
"(",
"xml_file",
",",
"self",
".",
"__config",
")",
"raise",
"if",
"xml_file",
":",
"utils",
".",
"remove_file_no_raise",
"(",
"xml_file",
",",
"self",
".",
"__config",
")",
"return",
"decls"
] |
Reads C++ source file and returns declarations tree
:param source_file: path to C++ source file
:type source_file: str
|
[
"Reads",
"C",
"++",
"source",
"file",
"and",
"returns",
"declarations",
"tree"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/source_reader.py#L300-L332
|
gccxml/pygccxml
|
pygccxml/parser/source_reader.py
|
source_reader_t.read_xml_file
|
def read_xml_file(self, xml_file):
"""
Read generated XML file.
:param xml_file: path to xml file
:type xml_file: str
:rtype: declarations tree
"""
assert self.__config is not None
ffname = self.__file_full_name(xml_file)
self.logger.debug("Reading xml file: [%s]", xml_file)
decls = self.__dcache.cached_value(ffname, self.__config)
if not decls:
self.logger.debug("File has not been found in cache, parsing...")
decls, _ = self.__parse_xml_file(ffname)
self.__dcache.update(ffname, self.__config, decls, [])
else:
self.logger.debug(
"File has not been changed, reading declarations from cache.")
return decls
|
python
|
def read_xml_file(self, xml_file):
assert self.__config is not None
ffname = self.__file_full_name(xml_file)
self.logger.debug("Reading xml file: [%s]", xml_file)
decls = self.__dcache.cached_value(ffname, self.__config)
if not decls:
self.logger.debug("File has not been found in cache, parsing...")
decls, _ = self.__parse_xml_file(ffname)
self.__dcache.update(ffname, self.__config, decls, [])
else:
self.logger.debug(
"File has not been changed, reading declarations from cache.")
return decls
|
[
"def",
"read_xml_file",
"(",
"self",
",",
"xml_file",
")",
":",
"assert",
"self",
".",
"__config",
"is",
"not",
"None",
"ffname",
"=",
"self",
".",
"__file_full_name",
"(",
"xml_file",
")",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Reading xml file: [%s]\"",
",",
"xml_file",
")",
"decls",
"=",
"self",
".",
"__dcache",
".",
"cached_value",
"(",
"ffname",
",",
"self",
".",
"__config",
")",
"if",
"not",
"decls",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"File has not been found in cache, parsing...\"",
")",
"decls",
",",
"_",
"=",
"self",
".",
"__parse_xml_file",
"(",
"ffname",
")",
"self",
".",
"__dcache",
".",
"update",
"(",
"ffname",
",",
"self",
".",
"__config",
",",
"decls",
",",
"[",
"]",
")",
"else",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"File has not been changed, reading declarations from cache.\"",
")",
"return",
"decls"
] |
Read generated XML file.
:param xml_file: path to xml file
:type xml_file: str
:rtype: declarations tree
|
[
"Read",
"generated",
"XML",
"file",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/source_reader.py#L334-L358
|
gccxml/pygccxml
|
pygccxml/parser/source_reader.py
|
source_reader_t.read_string
|
def read_string(self, content):
"""
Reads a Python string that contains C++ code, and return
the declarations tree.
"""
header_file = utils.create_temp_file_name(suffix='.h')
with open(header_file, "w+") as f:
f.write(content)
try:
decls = self.read_file(header_file)
except Exception:
utils.remove_file_no_raise(header_file, self.__config)
raise
utils.remove_file_no_raise(header_file, self.__config)
return decls
|
python
|
def read_string(self, content):
header_file = utils.create_temp_file_name(suffix='.h')
with open(header_file, "w+") as f:
f.write(content)
try:
decls = self.read_file(header_file)
except Exception:
utils.remove_file_no_raise(header_file, self.__config)
raise
utils.remove_file_no_raise(header_file, self.__config)
return decls
|
[
"def",
"read_string",
"(",
"self",
",",
"content",
")",
":",
"header_file",
"=",
"utils",
".",
"create_temp_file_name",
"(",
"suffix",
"=",
"'.h'",
")",
"with",
"open",
"(",
"header_file",
",",
"\"w+\"",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"content",
")",
"try",
":",
"decls",
"=",
"self",
".",
"read_file",
"(",
"header_file",
")",
"except",
"Exception",
":",
"utils",
".",
"remove_file_no_raise",
"(",
"header_file",
",",
"self",
".",
"__config",
")",
"raise",
"utils",
".",
"remove_file_no_raise",
"(",
"header_file",
",",
"self",
".",
"__config",
")",
"return",
"decls"
] |
Reads a Python string that contains C++ code, and return
the declarations tree.
|
[
"Reads",
"a",
"Python",
"string",
"that",
"contains",
"C",
"++",
"code",
"and",
"return",
"the",
"declarations",
"tree",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/source_reader.py#L360-L378
|
gccxml/pygccxml
|
pygccxml/declarations/algorithm.py
|
apply_visitor
|
def apply_visitor(visitor, decl_inst):
"""
Applies a visitor on declaration instance.
:param visitor: instance
:type visitor: :class:`type_visitor_t` or :class:`decl_visitor_t`
"""
fname = 'visit_' + \
decl_inst.__class__.__name__[:-2] # removing '_t' from class name
if not hasattr(visitor, fname):
raise runtime_errors.visit_function_has_not_been_found_t(
visitor, decl_inst)
return getattr(visitor, fname)()
|
python
|
def apply_visitor(visitor, decl_inst):
fname = 'visit_' + \
decl_inst.__class__.__name__[:-2]
if not hasattr(visitor, fname):
raise runtime_errors.visit_function_has_not_been_found_t(
visitor, decl_inst)
return getattr(visitor, fname)()
|
[
"def",
"apply_visitor",
"(",
"visitor",
",",
"decl_inst",
")",
":",
"fname",
"=",
"'visit_'",
"+",
"decl_inst",
".",
"__class__",
".",
"__name__",
"[",
":",
"-",
"2",
"]",
"# removing '_t' from class name",
"if",
"not",
"hasattr",
"(",
"visitor",
",",
"fname",
")",
":",
"raise",
"runtime_errors",
".",
"visit_function_has_not_been_found_t",
"(",
"visitor",
",",
"decl_inst",
")",
"return",
"getattr",
"(",
"visitor",
",",
"fname",
")",
"(",
")"
] |
Applies a visitor on declaration instance.
:param visitor: instance
:type visitor: :class:`type_visitor_t` or :class:`decl_visitor_t`
|
[
"Applies",
"a",
"visitor",
"on",
"declaration",
"instance",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/algorithm.py#L73-L87
|
gccxml/pygccxml
|
pygccxml/declarations/algorithm.py
|
match_declaration_t.does_match_exist
|
def does_match_exist(self, inst):
"""
Returns True if inst does match one of specified criteria.
:param inst: declaration instance
:type inst: :class:`declaration_t`
:rtype: bool
"""
answer = True
if self._decl_type is not None:
answer &= isinstance(inst, self._decl_type)
if self.name is not None:
answer &= inst.name == self.name
if self.parent is not None:
answer &= self.parent is inst.parent
if self.fullname is not None:
if inst.name:
answer &= self.fullname == declaration_utils.full_name(inst)
else:
answer = False
return answer
|
python
|
def does_match_exist(self, inst):
answer = True
if self._decl_type is not None:
answer &= isinstance(inst, self._decl_type)
if self.name is not None:
answer &= inst.name == self.name
if self.parent is not None:
answer &= self.parent is inst.parent
if self.fullname is not None:
if inst.name:
answer &= self.fullname == declaration_utils.full_name(inst)
else:
answer = False
return answer
|
[
"def",
"does_match_exist",
"(",
"self",
",",
"inst",
")",
":",
"answer",
"=",
"True",
"if",
"self",
".",
"_decl_type",
"is",
"not",
"None",
":",
"answer",
"&=",
"isinstance",
"(",
"inst",
",",
"self",
".",
"_decl_type",
")",
"if",
"self",
".",
"name",
"is",
"not",
"None",
":",
"answer",
"&=",
"inst",
".",
"name",
"==",
"self",
".",
"name",
"if",
"self",
".",
"parent",
"is",
"not",
"None",
":",
"answer",
"&=",
"self",
".",
"parent",
"is",
"inst",
".",
"parent",
"if",
"self",
".",
"fullname",
"is",
"not",
"None",
":",
"if",
"inst",
".",
"name",
":",
"answer",
"&=",
"self",
".",
"fullname",
"==",
"declaration_utils",
".",
"full_name",
"(",
"inst",
")",
"else",
":",
"answer",
"=",
"False",
"return",
"answer"
] |
Returns True if inst does match one of specified criteria.
:param inst: declaration instance
:type inst: :class:`declaration_t`
:rtype: bool
|
[
"Returns",
"True",
"if",
"inst",
"does",
"match",
"one",
"of",
"specified",
"criteria",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/algorithm.py#L37-L60
|
gccxml/pygccxml
|
pygccxml/declarations/declaration.py
|
declaration_t.partial_name
|
def partial_name(self):
"""
Declaration name, without template default arguments.
Right now std containers is the only classes that support this
functionality.
"""
if None is self._partial_name:
self._partial_name = self._get_partial_name_impl()
return self._partial_name
|
python
|
def partial_name(self):
if None is self._partial_name:
self._partial_name = self._get_partial_name_impl()
return self._partial_name
|
[
"def",
"partial_name",
"(",
"self",
")",
":",
"if",
"None",
"is",
"self",
".",
"_partial_name",
":",
"self",
".",
"_partial_name",
"=",
"self",
".",
"_get_partial_name_impl",
"(",
")",
"return",
"self",
".",
"_partial_name"
] |
Declaration name, without template default arguments.
Right now std containers is the only classes that support this
functionality.
|
[
"Declaration",
"name",
"without",
"template",
"default",
"arguments",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/declaration.py#L175-L187
|
gccxml/pygccxml
|
pygccxml/declarations/declaration.py
|
declaration_t.top_parent
|
def top_parent(self):
"""
Reference to top parent declaration.
@type: declaration_t
"""
parent = self.parent
while parent is not None:
if parent.parent is None:
return parent
else:
parent = parent.parent
return self
|
python
|
def top_parent(self):
parent = self.parent
while parent is not None:
if parent.parent is None:
return parent
else:
parent = parent.parent
return self
|
[
"def",
"top_parent",
"(",
"self",
")",
":",
"parent",
"=",
"self",
".",
"parent",
"while",
"parent",
"is",
"not",
"None",
":",
"if",
"parent",
".",
"parent",
"is",
"None",
":",
"return",
"parent",
"else",
":",
"parent",
"=",
"parent",
".",
"parent",
"return",
"self"
] |
Reference to top parent declaration.
@type: declaration_t
|
[
"Reference",
"to",
"top",
"parent",
"declaration",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/declaration.py#L208-L221
|
gccxml/pygccxml
|
pygccxml/declarations/calldef.py
|
argument_t.clone
|
def clone(self, **keywd):
"""constructs new argument_t instance
return argument_t(
name=keywd.get('name', self.name),
decl_type=keywd.get('decl_type', self.decl_type),
default_value=keywd.get('default_value', self.default_value),
attributes=keywd.get('attributes', self.attributes ))
"""
return argument_t(
name=keywd.get('name', self.name),
decl_type=keywd.get('decl_type', self.decl_type),
default_value=keywd.get('default_value', self.default_value),
attributes=keywd.get('attributes', self.attributes))
|
python
|
def clone(self, **keywd):
return argument_t(
name=keywd.get('name', self.name),
decl_type=keywd.get('decl_type', self.decl_type),
default_value=keywd.get('default_value', self.default_value),
attributes=keywd.get('attributes', self.attributes))
|
[
"def",
"clone",
"(",
"self",
",",
"*",
"*",
"keywd",
")",
":",
"return",
"argument_t",
"(",
"name",
"=",
"keywd",
".",
"get",
"(",
"'name'",
",",
"self",
".",
"name",
")",
",",
"decl_type",
"=",
"keywd",
".",
"get",
"(",
"'decl_type'",
",",
"self",
".",
"decl_type",
")",
",",
"default_value",
"=",
"keywd",
".",
"get",
"(",
"'default_value'",
",",
"self",
".",
"default_value",
")",
",",
"attributes",
"=",
"keywd",
".",
"get",
"(",
"'attributes'",
",",
"self",
".",
"attributes",
")",
")"
] |
constructs new argument_t instance
return argument_t(
name=keywd.get('name', self.name),
decl_type=keywd.get('decl_type', self.decl_type),
default_value=keywd.get('default_value', self.default_value),
attributes=keywd.get('attributes', self.attributes ))
|
[
"constructs",
"new",
"argument_t",
"instance"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/calldef.py#L44-L58
|
gccxml/pygccxml
|
pygccxml/declarations/calldef.py
|
calldef_t.required_args
|
def required_args(self):
"""list of all required arguments"""
r_args = []
for arg in self.arguments:
if not arg.default_value:
r_args.append(arg)
else:
break
return r_args
|
python
|
def required_args(self):
r_args = []
for arg in self.arguments:
if not arg.default_value:
r_args.append(arg)
else:
break
return r_args
|
[
"def",
"required_args",
"(",
"self",
")",
":",
"r_args",
"=",
"[",
"]",
"for",
"arg",
"in",
"self",
".",
"arguments",
":",
"if",
"not",
"arg",
".",
"default_value",
":",
"r_args",
".",
"append",
"(",
"arg",
")",
"else",
":",
"break",
"return",
"r_args"
] |
list of all required arguments
|
[
"list",
"of",
"all",
"required",
"arguments"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/calldef.py#L224-L232
|
gccxml/pygccxml
|
pygccxml/declarations/calldef.py
|
calldef_t.overloads
|
def overloads(self):
"""A list of overloaded "callables" (i.e. other callables with the
same name within the same scope.
@type: list of :class:`calldef_t`
"""
if not self.parent:
return []
# finding all functions with the same name
return self.parent.calldefs(
name=self.name,
function=lambda decl: decl is not self,
allow_empty=True,
recursive=False)
|
python
|
def overloads(self):
if not self.parent:
return []
return self.parent.calldefs(
name=self.name,
function=lambda decl: decl is not self,
allow_empty=True,
recursive=False)
|
[
"def",
"overloads",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"parent",
":",
"return",
"[",
"]",
"# finding all functions with the same name",
"return",
"self",
".",
"parent",
".",
"calldefs",
"(",
"name",
"=",
"self",
".",
"name",
",",
"function",
"=",
"lambda",
"decl",
":",
"decl",
"is",
"not",
"self",
",",
"allow_empty",
"=",
"True",
",",
"recursive",
"=",
"False",
")"
] |
A list of overloaded "callables" (i.e. other callables with the
same name within the same scope.
@type: list of :class:`calldef_t`
|
[
"A",
"list",
"of",
"overloaded",
"callables",
"(",
"i",
".",
"e",
".",
"other",
"callables",
"with",
"the",
"same",
"name",
"within",
"the",
"same",
"scope",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/calldef.py#L273-L286
|
gccxml/pygccxml
|
pygccxml/declarations/calldef.py
|
calldef_t.calling_convention
|
def calling_convention(self):
"""function calling convention. See
:class:CALLING_CONVENTION_TYPES class for possible values"""
if self._calling_convention is None:
self._calling_convention = \
calldef_types.CALLING_CONVENTION_TYPES.extract(self.attributes)
if not self._calling_convention:
self._calling_convention = self.guess_calling_convention()
return self._calling_convention
|
python
|
def calling_convention(self):
if self._calling_convention is None:
self._calling_convention = \
calldef_types.CALLING_CONVENTION_TYPES.extract(self.attributes)
if not self._calling_convention:
self._calling_convention = self.guess_calling_convention()
return self._calling_convention
|
[
"def",
"calling_convention",
"(",
"self",
")",
":",
"if",
"self",
".",
"_calling_convention",
"is",
"None",
":",
"self",
".",
"_calling_convention",
"=",
"calldef_types",
".",
"CALLING_CONVENTION_TYPES",
".",
"extract",
"(",
"self",
".",
"attributes",
")",
"if",
"not",
"self",
".",
"_calling_convention",
":",
"self",
".",
"_calling_convention",
"=",
"self",
".",
"guess_calling_convention",
"(",
")",
"return",
"self",
".",
"_calling_convention"
] |
function calling convention. See
:class:CALLING_CONVENTION_TYPES class for possible values
|
[
"function",
"calling",
"convention",
".",
"See",
":",
"class",
":",
"CALLING_CONVENTION_TYPES",
"class",
"for",
"possible",
"values"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/calldef.py#L333-L341
|
gccxml/pygccxml
|
pygccxml/declarations/free_calldef.py
|
free_calldef_t.function_type
|
def function_type(self):
"""returns function type. See :class:`type_t` hierarchy"""
return cpptypes.free_function_type_t(
return_type=self.return_type,
arguments_types=[
arg.decl_type for arg in self.arguments])
|
python
|
def function_type(self):
return cpptypes.free_function_type_t(
return_type=self.return_type,
arguments_types=[
arg.decl_type for arg in self.arguments])
|
[
"def",
"function_type",
"(",
"self",
")",
":",
"return",
"cpptypes",
".",
"free_function_type_t",
"(",
"return_type",
"=",
"self",
".",
"return_type",
",",
"arguments_types",
"=",
"[",
"arg",
".",
"decl_type",
"for",
"arg",
"in",
"self",
".",
"arguments",
"]",
")"
] |
returns function type. See :class:`type_t` hierarchy
|
[
"returns",
"function",
"type",
".",
"See",
":",
"class",
":",
"type_t",
"hierarchy"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/free_calldef.py#L48-L53
|
gccxml/pygccxml
|
pygccxml/declarations/free_calldef.py
|
free_operator_t.class_types
|
def class_types(self):
"""list of class/class declaration types, extracted from the
operator arguments"""
if None is self.__class_types:
self.__class_types = []
for type_ in self.argument_types:
decl = None
type_ = type_traits.remove_reference(type_)
if type_traits_classes.is_class(type_):
decl = type_traits_classes.class_traits.get_declaration(
type_)
elif type_traits_classes.is_class_declaration(type_):
tt = type_traits_classes.class_declaration_traits
decl = tt.get_declaration(type_)
else:
pass
if decl:
self.__class_types.append(decl)
return self.__class_types
|
python
|
def class_types(self):
if None is self.__class_types:
self.__class_types = []
for type_ in self.argument_types:
decl = None
type_ = type_traits.remove_reference(type_)
if type_traits_classes.is_class(type_):
decl = type_traits_classes.class_traits.get_declaration(
type_)
elif type_traits_classes.is_class_declaration(type_):
tt = type_traits_classes.class_declaration_traits
decl = tt.get_declaration(type_)
else:
pass
if decl:
self.__class_types.append(decl)
return self.__class_types
|
[
"def",
"class_types",
"(",
"self",
")",
":",
"if",
"None",
"is",
"self",
".",
"__class_types",
":",
"self",
".",
"__class_types",
"=",
"[",
"]",
"for",
"type_",
"in",
"self",
".",
"argument_types",
":",
"decl",
"=",
"None",
"type_",
"=",
"type_traits",
".",
"remove_reference",
"(",
"type_",
")",
"if",
"type_traits_classes",
".",
"is_class",
"(",
"type_",
")",
":",
"decl",
"=",
"type_traits_classes",
".",
"class_traits",
".",
"get_declaration",
"(",
"type_",
")",
"elif",
"type_traits_classes",
".",
"is_class_declaration",
"(",
"type_",
")",
":",
"tt",
"=",
"type_traits_classes",
".",
"class_declaration_traits",
"decl",
"=",
"tt",
".",
"get_declaration",
"(",
"type_",
")",
"else",
":",
"pass",
"if",
"decl",
":",
"self",
".",
"__class_types",
".",
"append",
"(",
"decl",
")",
"return",
"self",
".",
"__class_types"
] |
list of class/class declaration types, extracted from the
operator arguments
|
[
"list",
"of",
"class",
"/",
"class",
"declaration",
"types",
"extracted",
"from",
"the",
"operator",
"arguments"
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/free_calldef.py#L95-L114
|
gccxml/pygccxml
|
pygccxml/parser/declarations_cache.py
|
file_signature
|
def file_signature(filename):
"""
Return a signature for a file.
"""
if not os.path.isfile(filename):
return None
if not os.path.exists(filename):
return None
# Duplicate auto-generated files can be recognized with the sha1 hash.
sig = hashlib.sha1()
with open(filename, "rb") as f:
buf = f.read()
sig.update(buf)
return sig.hexdigest()
|
python
|
def file_signature(filename):
if not os.path.isfile(filename):
return None
if not os.path.exists(filename):
return None
sig = hashlib.sha1()
with open(filename, "rb") as f:
buf = f.read()
sig.update(buf)
return sig.hexdigest()
|
[
"def",
"file_signature",
"(",
"filename",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"return",
"None",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"return",
"None",
"# Duplicate auto-generated files can be recognized with the sha1 hash.",
"sig",
"=",
"hashlib",
".",
"sha1",
"(",
")",
"with",
"open",
"(",
"filename",
",",
"\"rb\"",
")",
"as",
"f",
":",
"buf",
"=",
"f",
".",
"read",
"(",
")",
"sig",
".",
"update",
"(",
"buf",
")",
"return",
"sig",
".",
"hexdigest",
"(",
")"
] |
Return a signature for a file.
|
[
"Return",
"a",
"signature",
"for",
"a",
"file",
"."
] |
train
|
https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/declarations_cache.py#L17-L34
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.