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

Classes

class  _DictHelper
 
class  _ListHelper
 
class  _SetHelper
 
class  BoolSemantics
 
class  ComponentHandleSemantics
 
class  ComponentSemantics
 
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 351 of file semantics.py.

351def extract_template_args(cpp_type):
352 """
353 Return an iterator over the list of template arguments in a C++ type
354 string.
355
356 >>> t = 'map<string, vector<int, allocator<int> >, allocator<v<i>, a<i>> >'
357 >>> list(extract_template_args(t))
358 ['string', 'vector<int, allocator<int> >', 'allocator<v<i>, a<i>>']
359 >>> list(extract_template_args('int'))
360 []
361 """
362 template_level = 0
363 arg_start = -1
364 for p, c in enumerate(cpp_type):
365 if c == ",":
366 if template_level == 1:
367 yield cpp_type[arg_start:p].strip()
368 arg_start = p + 1
369 elif c == "<":
370 template_level += 1
371 if template_level == 1:
372 arg_start = p + 1
373 elif c == ">":
374 template_level -= 1
375 if template_level == 0:
376 yield cpp_type[arg_start:p].strip()
377
378

◆ 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 738 of file semantics.py.

738def getSemanticsFor(cpp_type, strict=False):
739 """Return semantics for given type. If no type-specific semantics can be found
740 return DefaultSemantics. In strict mode, raise a TypeError instead.
741 """
742
743 for semantics in SEMANTICS:
744 try:
745 return semantics(cpp_type)
746 except TypeError:
747 pass
748
749 if strict:
750 raise TypeError(f"No semantics found for {cpp_type}")
751
752 return DefaultSemantics(cpp_type)

Variable Documentation

◆ _COMMA_SEPARATION_RE

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

Definition at line 204 of file semantics.py.

◆ _IDENTIFIER_RE

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

Definition at line 202 of file semantics.py.

◆ _log

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

Definition at line 22 of file semantics.py.

◆ _NS_IDENT_RE

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

Definition at line 203 of file semantics.py.

◆ is_64bits

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

Definition at line 23 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 729 of file semantics.py.