/usr/share/pyshared/pygccxml/declarations/scopedef.py is in python-pygccxml 1.0.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | # Copyright 2004-2008 Roman Yakovenko.
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
"""
defines base class for L{namespace_t} and L{class_t} classes
"""
import time
import algorithm
import filtering
import templates
import declaration
import mdecl_wrapper
from pygccxml import utils
import matcher as matcher_module
class scopedef_t( declaration.declaration_t ):
"""Base class for L{namespace_t} and L{class_t} classes.
This is the base class for all declaration classes that may have
children nodes. The children can be accessed via the C{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:
1. name - declaration name, could be full qualified name
2. header_dir - directory, to which belongs file, that the declaration was declarated in.
header_dir should be absolute path.
3. header_file - file that the declaration was declarated in.
4. function - user ( your ) custom criteria. The interesting thing is that
this function will be joined with other arguments ( criteria ).
5. recursive - the search declaration range, if True will be search in
internal declarations too.
Every "select" API you can invoke and pass as first argument at declaration
name or function. This class will find out correctly what argument represents.
Example::
ns - referrers to global namespace
ns.member_function( "do_something ) - will return reference to member
function named "do_something". If there is no such function exception
will be raised. If there is more then one function exception will be
raised too.
Example 2::
ns - referers to global namespace
do_smths = ns.member_functions( "do_something ) - will return instance
of L{mdecl_wrapper_t} object. This object allows you few things:
1. To iterate on selected declarations
2. To set some property to desired value using one line of code only:
do_smths.call_policies = x
3. To call some function on every instance using one line of code:
do_smths.exclude()
Pay attention: you can not use "get" functions or properties.
"""
RECURSIVE_DEFAULT = True
ALLOW_EMPTY_MDECL_WRAPPER = False
declaration_not_found_t = matcher_module.matcher.declaration_not_found_t
multiple_declarations_found_t = matcher_module.matcher.multiple_declarations_found_t
_impl_matchers = {} #this class variable is used to prevent recursive imports
_impl_decl_types = {} #this class variable is used to prevent recursive imports
_impl_all_decl_types = [] #this class variable is used to prevent recursive imports
def __init__( self, name=''):
declaration.declaration_t.__init__( self, name )
self._optimized = False
self._type2decls = {}
self._type2name2decls = {}
self._type2decls_nr = {}
self._type2name2decls_nr = {}
self._all_decls = None
self._all_decls_not_recursive = None
def _get_logger( self ):
return utils.loggers.queries_engine
_logger = property( _get_logger, doc="reference to C{queries_engine} logger" )
def _get__cmp__scope_items(self):
"""implementation details"""
raise NotImplementedError()
def _get__cmp__items(self):
"""implementation details"""
items = []
if self._optimized:
#in this case we don't need to build class internal declarations list
items.append( self._sorted_list( self._all_decls_not_recursive ) )
else:
items.append( self._sorted_list( self.declarations ) )
items.extend( self._get__cmp__scope_items() )
return items
def __eq__(self, other):
if not declaration.declaration_t.__eq__( self, other ):
return False
return self._sorted_list( self.declarations[:] ) \
== other._sorted_list( other.declarations[:] )
#self_decls = self._all_decls_not_recursive
#if not self._optimized:
#self_decls = self._sorted_list( self.declarations[:] )
#other_decls = other._all_decls_not_recursive[:]
#if not other._optimized:
#other_decls = other._sorted_list( other.declarations[:] )
#else:
#return self_decls == other_decls
def _get_declarations_impl(self):
raise NotImplementedError()
def _get_declarations(self):
if True == self._optimized:
return self._all_decls_not_recursive
else:
return self._get_declarations_impl()
declarations = property( _get_declarations, doc="list of children L{declarations<declaration_t>}" )
def remove_declaration( self, decl ):
raise NotImplementedError()
def __decl_types( self, decl ):
"""implementation details"""
types = []
bases = list( decl.__class__.__bases__ )
visited = set()
if 'pygccxml' in decl.__class__.__module__:
types.append( decl.__class__ )
while bases:
base = bases.pop()
if base is declaration.declaration_t:
continue
if base in visited:
continue
if 'pygccxml' not in base.__module__:
continue
types.append( base )
bases.extend( base.__bases__ )
return types
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
map( lambda decl: decl.clear_optimizer()
, filter( lambda decl: isinstance( decl, scopedef_t )
, self.declarations ) )
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 hashtables allows to search declaration very quick.
"""
if self.name == '::':
self._logger.debug( "preparing data structures for query optimizer - started" )
start_time = time.clock()
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 = algorithm.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 not name2decls.has_key( decl.name ):
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 not name2decls_nr.has_key( decl.name ):
name2decls_nr[ decl.name ] = []
name2decls_nr[ decl.name ].append( decl )
map( lambda decl: decl.init_optimizer()
, filter( lambda decl: isinstance( decl, scopedef_t )
, self._all_decls_not_recursive ) )
if self.name == '::':
self._logger.debug( "preparing data structures for query optimizer - done( %f seconds ). "
% ( time.clock() - start_time ) )
self._optimized = True
def _build_operator_function( self, name, function ):
if callable( name ):
return name
else:
return function
def _build_operator_name( self, name, function, symbol ):
"""implementation details"""
def add_operator( sym ):
if 'new' in sym or 'delete' in sym:
return 'operator ' + sym
else:
return 'operator'+ sym
if callable( name ) and None is function:
name = None
if name:
if not 'operator' in name:
name = add_operator( name )
return name
elif symbol:
return add_operator( symbol )
return name #both name and symbol are None
def _on_rename( self ):
for decl in self.decls(allow_empty=True):
decl.cache.reset_name_based()
#I am not sure whether to introduce this or not?
#It could be very time consuming operation + it changes optimize query
#data structures.
#if self.parent:
# if self.parent._optimized:
# self.parent.init_optimizer()
def __normalize_args( self, **keywds ):
"""implementation details"""
if callable( keywds['name'] ) and None is keywds['function']:
keywds['function'] = keywds['name']
keywds['name'] = None
return keywds
def __findout_recursive( self, **keywds ):
"""implementation details"""
if None is keywds[ 'recursive' ]:
return self.RECURSIVE_DEFAULT
else:
return keywds[ 'recursive' ]
def __findout_allow_empty( self, **keywds ):
"""implementation details"""
if None is keywds[ 'allow_empty' ]:
return self.ALLOW_EMPTY_MDECL_WRAPPER
else:
return keywds[ 'allow_empty' ]
def __findout_decl_type( self, match_class, **keywds ):
"""implementation details"""
if keywds.has_key( 'decl_type' ):
return keywds['decl_type']
matcher_args = keywds.copy()
del matcher_args['function']
del matcher_args['recursive']
if matcher_args.has_key('allow_empty'):
del matcher_args['allow_empty']
matcher = match_class( **matcher_args )
if matcher.decl_type:
return matcher.decl_type
return None
def __create_matcher( self, match_class, **keywds ):
"""implementation details"""
matcher_args = keywds.copy()
del matcher_args['function']
del matcher_args['recursive']
if matcher_args.has_key('allow_empty'):
del matcher_args['allow_empty']
matcher = match_class( **matcher_args )
if keywds['function']:
self._logger.debug( 'running query: %s and <user defined function>' % str( matcher ) )
return lambda decl: matcher( decl ) and keywds['function'](decl)
else:
self._logger.debug( 'running query: %s' % str( matcher ) )
return matcher
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 = algorithm.make_flatten( self.declarations )
if decl_type:
decls = filter( lambda d: isinstance( d, decl_type ), decls )
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:
matcher = scopedef_t._impl_matchers[ scopedef_t.decl ]( name=name )
if matcher.is_full_name():
name = matcher.decl_name_only
if recursive:
self._logger.debug( 'query has been optimized on type and name' )
if self._type2name2decls[decl_type].has_key( name ):
return self._type2name2decls[decl_type][name]
else:
return []
else:
self._logger.debug( 'non recursive query has been optimized on type and name' )
if self._type2name2decls_nr[decl_type].has_key( name ):
return self._type2name2decls_nr[decl_type][name]
else:
return []
elif decl_type:
if recursive:
self._logger.debug( 'query has been optimized on type' )
return self._type2decls[ decl_type ]
else:
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
else:
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 _find_single( self, match_class, **keywds ):
"""implementation details"""
self._logger.debug( 'find single query execution - started' )
start_time = time.clock()
norm_keywds = self.__normalize_args( **keywds )
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_module.matcher.get_single( matcher, decls, False )
self._logger.debug( 'find single query execution - done( %f seconds )' % ( time.clock() - start_time ) )
return found
def _find_multiple( self, match_class, **keywds ):
"""implementation details"""
self._logger.debug( 'find all query execution - started' )
start_time = time.clock()
norm_keywds = self.__normalize_args( **keywds )
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_module.matcher.find( 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 )'
% ( time.clock() - start_time ) )
if not mfound and not allow_empty:
raise RuntimeError( "Multi declaration query returned 0 declarations." )
return mfound
def decl( self, name=None, function=None, decl_type=None, header_dir=None, header_file=None, recursive=None ):
"""returns reference to declaration, that is matched defined criterias"""
return self._find_single( self._impl_matchers[ scopedef_t.decl ]
, name=name
, function=function
, decl_type=decl_type
, header_dir=header_dir
, header_file=header_file
, recursive=recursive)
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 criterias"""
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 class_( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ):
"""returns reference to class declaration, that is matched defined criterias"""
return self._find_single( 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)
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 criterias"""
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 variable( self, name=None, function=None, type=None, header_dir=None, header_file=None, recursive=None ):
"""returns reference to variable declaration, that is matched defined criterias"""
return self._find_single( self._impl_matchers[ scopedef_t.variable ]
, name=name
, function=function
, type=type
, header_dir=header_dir
, header_file=header_file
, recursive=recursive)
var = variable #small alias
def variables( self, name=None, function=None, type=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ):
"""returns a set of variable declarations, that are matched defined criterias"""
return self._find_multiple( self._impl_matchers[ scopedef_t.variable ]
, name=name
, function=function
, type=type
, header_dir=header_dir
, header_file=header_file
, recursive=recursive
, allow_empty=allow_empty)
vars = variables #small alias
def calldef( self, 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 criterias"""
return self._find_single( 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 )
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 calldef declarations, that are matched defined criterias"""
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 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 operator declaration, that is matched defined criterias"""
return self._find_single( self._impl_matchers[ scopedef_t.operator ]
, name=self._build_operator_name( name, function, symbol )
, symbol=symbol
, function=self._build_operator_function( name, function )
, decl_type=self._impl_decl_types[ scopedef_t.operator ]
, return_type=return_type
, arg_types=arg_types
, header_dir=header_dir
, header_file=header_file
, recursive=recursive )
def operators( self, 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 criterias"""
return self._find_multiple( self._impl_matchers[ scopedef_t.operator ]
, name=self._build_operator_name( name, function, symbol )
, symbol=symbol
, function=self._build_operator_function( name, function )
, decl_type=self._impl_decl_types[ scopedef_t.operator ]
, return_type=return_type
, arg_types=arg_types
, header_dir=header_dir
, header_file=header_file
, recursive=recursive
, allow_empty=allow_empty)
def member_function( self, 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 criterias"""
return self._find_single( 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 )
mem_fun = member_function
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 criterias"""
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)
mem_funs = member_functions
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 criterias"""
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 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 criterias"""
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 member_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 member operator declaration, that is matched defined criterias"""
return self._find_single( self._impl_matchers[ scopedef_t.member_operator ]
, name=self._build_operator_name( name, function, symbol )
, symbol=symbol
, function=self._build_operator_function( name, function )
, decl_type=self._impl_decl_types[ scopedef_t.member_operator ]
, return_type=return_type
, arg_types=arg_types
, header_dir=header_dir
, header_file=header_file
, recursive=recursive )
mem_oper = member_operator
def member_operators( self, 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 criterias"""
return self._find_multiple( self._impl_matchers[ scopedef_t.member_operator ]
, name=self._build_operator_name( name, function, symbol )
, symbol=symbol
, function=self._build_operator_function( name, function )
, decl_type=self._impl_decl_types[ scopedef_t.member_operator ]
, return_type=return_type
, arg_types=arg_types
, header_dir=header_dir
, header_file=header_file
, recursive=recursive
, allow_empty=allow_empty)
mem_opers = member_operators
def casting_operator( self, 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 criterias"""
return self._find_single( 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 )
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 criterias"""
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 enumeration( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ):
"""returns reference to enumeration declaration, that is matched defined criterias"""
return self._find_single( 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)
enum = enumeration
"""adding small aliase to enumeration method"""
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 criterias"""
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)
#adding small aliase
enums = enumerations
def typedef( self, name=None, function=None, header_dir=None, header_file=None, recursive=None ):
"""returns reference to typedef declaration, that is matched defined criterias"""
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 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 criterias"""
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 __getitem__(self, name_or_function):
""" Allow simple name based find of decls. Internally just calls decls() method.
@param name_or_function Name of decl to lookup or finder function.
"""
return self.decls(name_or_function)
|