pygccxml.declarations.scopedef module¶
Defines scopedef_t
class
-
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.
Parameters: decl_or_decls ( declaration_t
or [declaration_t
]) – reference to list of declaration’s or single declarationReturn type: set(declaration file names)
-
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
match_declaration_t
class.Return type: [ matched declarations ]
-
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
match_declaration_t
class.Return type: matched declaration declaration_t
or None
-
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
match_declaration_t
class.Return type: matched declaration declaration_t
or None
-
make_flatten
(decl_or_decls)¶ Converts tree representation of declarations to flatten one.
Parameters: decl_or_decls ( declaration_t
or [declaration_t
]) – reference to list of declaration’s or single declarationReturn type: [ all internal declarations ]
-
class
matcher
¶ Bases:
object
Class-namespace, contains implementation of a few “find” algorithms
-
static
find
(decl_matcher, decls, recursive=True)¶ Returns a list of declarations that match decl_matcher defined criteria or None
Parameters: - decl_matcher – Python callable object, that takes one argument - reference to a declaration
- decls – the search scope, :class:declaration_t object or :class:declaration_t objects list t
- recursive – boolean, if True, the method will run decl_matcher on the internal declarations too
-
static
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.
Parameters: - decl_matcher – Python callable object, that takes one argument - reference to a declaration
- decls – the search scope, :class:declaration_t object or :class:declaration_t objects list t
- recursive – boolean, if True, the method will run decl_matcher on the internal declarations too
-
static
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.
Parameters: - decl_matcher – Python callable object, that takes one argument - reference to a declaration
- decls – the search scope, :class:declaration_t object or :class:declaration_t objects list t
- recursive – boolean, if True, the method will run decl_matcher on the internal declarations too
-
static
-
class
scopedef_t
(name='')¶ Bases:
pygccxml.declarations.declaration.declaration_t
Base class for
namespace_t
andclass_t
classes.This is the base class for all declaration classes that may have children nodes. The children can be accessed via the
scopedef_t.declarations
property.Also this class provides “get/select/find” interface. Using this class you can get instance or instances of internal declaration(s).
You can find declaration(s) using next criteria:
- name - declaration name, could be full qualified name
- header_dir - directory, to which belongs file, that the
- declaration was declared in. header_dir should be absolute path.
- header_file - file that the declaration was declared in.
- function - user ( your ) custom criteria. The interesting thing
- is that this function will be joined with other arguments (criteria).
- recursive - the search declaration range, if True will be search
- in internal declarations too.
Every “”query”” API, takes name or function as the first argument.
global_namespace.member_function("do_something)
the statement returns reference to member function named “do_something”. If there the function doesn’t exist or more than one function exists, an exception is raised.
If you want to query for many declarations, use other function(s):
do_something = global_namespace.member_functions("do_something")
the statement returns
mdecl_wrapper_t
instance. That object will save you writing for loops. For more information seethe class
documentation.-
ALLOW_EMPTY_MDECL_WRAPPER
= False¶
-
RECURSIVE_DEFAULT
= True¶
-
attributes
¶ GCCXML attributes, set using __attribute__((gccxml(“…”)))
@type: str
-
cache
¶ Implementation detail.
Reference to instance of
algorithms_cache_t
class.
-
calldef
(name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None)¶ returns reference to “calldef” declaration, that is matched defined criteria
-
calldefs
(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
calldef_t
declarations, that are matched defined criteria
-
casting_operator
(name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None)¶ returns reference to casting operator declaration, that is matched defined criteria
-
casting_operators
(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
-
class_
(name=None, function=None, header_dir=None, header_file=None, recursive=None)¶ returns reference to class declaration, that is matched defined criteria
-
classes
(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
-
clear_optimizer
()¶ Cleans query optimizer state
-
constructor
(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
-
constructors
(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
-
create_decl_string
(with_defaults=True)¶
-
decl
(name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None)¶ returns reference to declaration, that is matched defined criteria
-
decl_string
¶ Declaration full name.
-
declarations
¶ List of children declarations.
Returns: List[declarations.declaration_t]
-
decls
(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
-
enumeration
(name=None, function=None, header_dir=None, header_file=None, recursive=None)¶ returns reference to enumeration declaration, that is matched defined criteria
-
enumerations
(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
-
get_mangled_name
()¶
-
i_depend_on_them
(recursive=True)¶ Return list of all types and declarations the declaration depends on
-
init_optimizer
()¶ Initializes query optimizer state.
- There are 4 internals hash tables:
- from type to declarations
- from type to declarations for non-recursive queries
- from type to name to declarations
- 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.
-
is_artificial
¶ Describes whether declaration is compiler generated or not
@type: bool
-
location
¶ Location of the declaration within source file
@type:
location_t
-
mangled
¶ Unique declaration name generated by the compiler.
For GCCXML, you can get the mangled name for all the declarations. When using CastXML, calling mangled is only allowed on functions and variables. For other declarations it will raise an exception.
Returns: the mangled name Return type: str
-
member_function
(name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None)¶ returns reference to member declaration, that is matched defined criteria
-
member_functions
(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
-
member_operator
(name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None)¶ returns reference to member operator declaration, that is matched defined criteria
-
member_operators
(name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None)¶ returns a set of member operator declarations, that are matched defined criteria
-
name
¶ Declaration name @type: str
-
operator
(name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None)¶ returns reference to operator declaration, that is matched defined criteria
-
operators
(name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None)¶ returns a set of operator declarations, that are matched defined criteria
-
parent
¶ Reference to parent declaration.
@type: declaration_t
-
partial_decl_string
¶ Declaration full name.
-
partial_name
¶ Declaration name, without template default arguments.
Right now std containers is the only classes that support this functionality.
-
remove_declaration
(decl)¶
-
top_parent
¶ Reference to top parent declaration.
@type: declaration_t
-
typedef
(name=None, function=None, header_dir=None, header_file=None, recursive=None)¶ returns reference to typedef declaration, that is matched defined criteria
-
typedefs
(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
-
variable
(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
-
variables
(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