The Gaudi Framework  master (3415b466)
Loading...
Searching...
No Matches
GaudiConfig2.semantics Namespace Reference

Classes

class  _DictHelper
 
class  _ListHelper
 
class  _SetHelper
 
class  BoolSemantics
 
class  ComponentHandleSemantics
 
class  ComponentSemantics
 
class  DataHandleSemantics
 
class  DefaultSemantics
 
class  FloatSemantics
 
class  GaudiHandleArraySemantics
 
class  IntSemantics
 
class  MappingSemantics
 
class  OrderedSetSemantics
 
class  PropertySemantics
 
class  SequenceSemantics
 
class  SetSemantics
 
class  StringSemantics
 

Functions

 extract_template_args (cpp_type)
 
 getSemanticsFor (cpp_type, strict=False)
 

Variables

 _log = logging.getLogger(__name__)
 
int is_64bits = sys.maxsize > 2**32
 
str _IDENTIFIER_RE = r"[a-zA-Z_][a-zA-Z0-9_]*"
 
str _NS_IDENT_RE = r"{ident}(::{ident})*".format(ident=_IDENTIFIER_RE)
 
str _COMMA_SEPARATION_RE = r"{exp}(,{exp})*"
 
list SEMANTICS
 

Function Documentation

◆ extract_template_args()

GaudiConfig2.semantics.extract_template_args ( cpp_type)
Return an iterator over the list of template arguments in a C++ type
string.

>>> t = 'map<string, vector<int, allocator<int> >, allocator<v<i>, a<i>> >'
>>> list(extract_template_args(t))
['string', 'vector<int, allocator<int> >', 'allocator<v<i>, a<i>>']
>>> list(extract_template_args('int'))
[]

Definition at line 387 of file semantics.py.

387def extract_template_args(cpp_type):
388 """
389 Return an iterator over the list of template arguments in a C++ type
390 string.
391
392 >>> t = 'map<string, vector<int, allocator<int> >, allocator<v<i>, a<i>> >'
393 >>> list(extract_template_args(t))
394 ['string', 'vector<int, allocator<int> >', 'allocator<v<i>, a<i>>']
395 >>> list(extract_template_args('int'))
396 []
397 """
398 template_level = 0
399 arg_start = -1
400 for p, c in enumerate(cpp_type):
401 if c == ",":
402 if template_level == 1:
403 yield cpp_type[arg_start:p].strip()
404 arg_start = p + 1
405 elif c == "<":
406 template_level += 1
407 if template_level == 1:
408 arg_start = p + 1
409 elif c == ">":
410 template_level -= 1
411 if template_level == 0:
412 yield cpp_type[arg_start:p].strip()
413
414

◆ getSemanticsFor()

GaudiConfig2.semantics.getSemanticsFor ( cpp_type,
strict = False )
Return semantics for given type. If no type-specific semantics can be found
return DefaultSemantics. In strict mode, raise a TypeError instead.

Definition at line 774 of file semantics.py.

774def getSemanticsFor(cpp_type, strict=False):
775 """Return semantics for given type. If no type-specific semantics can be found
776 return DefaultSemantics. In strict mode, raise a TypeError instead.
777 """
778
779 for semantics in SEMANTICS:
780 try:
781 return semantics(cpp_type)
782 except TypeError:
783 pass
784
785 if strict:
786 raise TypeError(f"No semantics found for {cpp_type}")
787
788 return DefaultSemantics(cpp_type)

Variable Documentation

◆ _COMMA_SEPARATION_RE

str GaudiConfig2.semantics._COMMA_SEPARATION_RE = r"{exp}(,{exp})*"
protected

Definition at line 205 of file semantics.py.

◆ _IDENTIFIER_RE

str GaudiConfig2.semantics._IDENTIFIER_RE = r"[a-zA-Z_][a-zA-Z0-9_]*"
protected

Definition at line 203 of file semantics.py.

◆ _log

GaudiConfig2.semantics._log = logging.getLogger(__name__)
protected

Definition at line 23 of file semantics.py.

◆ _NS_IDENT_RE

str GaudiConfig2.semantics._NS_IDENT_RE = r"{ident}(::{ident})*".format(ident=_IDENTIFIER_RE)
protected

Definition at line 204 of file semantics.py.

◆ is_64bits

int GaudiConfig2.semantics.is_64bits = sys.maxsize > 2**32

Definition at line 24 of file semantics.py.

◆ SEMANTICS

list GaudiConfig2.semantics.SEMANTICS
Initial value:
1= [
2 c
3 for c in globals().values()
4 if isinstance(c, type)
5 and issubclass(c, PropertySemantics)
6 and c not in (PropertySemantics, DefaultSemantics)
7]

Definition at line 765 of file semantics.py.