The Gaudi Framework  master (adcf1ca6)
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 384 of file semantics.py.

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

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

771def getSemanticsFor(cpp_type, strict=False):
772 """Return semantics for given type. If no type-specific semantics can be found
773 return DefaultSemantics. In strict mode, raise a TypeError instead.
774 """
775
776 for semantics in SEMANTICS:
777 try:
778 return semantics(cpp_type)
779 except TypeError:
780 pass
781
782 if strict:
783 raise TypeError(f"No semantics found for {cpp_type}")
784
785 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 762 of file semantics.py.