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

Classes

class  PropertySemantics
class  DefaultSemantics
class  _JSONValue
class  _JSONOption
class  JSONSemantics
class  StringSemantics
class  BoolSemantics
class  FloatSemantics
class  IntSemantics
class  ComponentSemantics
class  ComponentHandleSemantics
class  _GaudiHandleArrayOptionValue
class  GaudiHandleArraySemantics
class  DataHandleSemantics
class  _ListHelper
class  SequenceSemantics
class  DataHandleVectorSemantics
class  _SetHelper
class  SetSemantics
class  OrderedSetSemantics
class  _DictHelper
class  MappingSemantics

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 = rf"{_IDENTIFIER_RE}(::{_IDENTIFIER_RE})*"
str _COMMA_SEPARATION_RE = r"{exp}(,{exp})*"
list SEMANTICS

Function Documentation

◆ extract_template_args()

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

434def extract_template_args(cpp_type):
435 """
436 Return an iterator over the list of template arguments in a C++ type
437 string.
438
439 >>> t = 'map<string, vector<int, allocator<int> >, allocator<v<i>, a<i>> >'
440 >>> list(extract_template_args(t))
441 ['string', 'vector<int, allocator<int> >', 'allocator<v<i>, a<i>>']
442 >>> list(extract_template_args('int'))
443 []
444 """
445 template_level = 0
446 arg_start = -1
447 for p, c in enumerate(cpp_type):
448 if c == ",":
449 if template_level == 1:
450 yield cpp_type[arg_start:p].strip()
451 arg_start = p + 1
452 elif c == "<":
453 template_level += 1
454 if template_level == 1:
455 arg_start = p + 1
456 elif c == ">":
457 template_level -= 1
458 if template_level == 0:
459 yield cpp_type[arg_start:p].strip()
460
461

◆ getSemanticsFor()

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

858def getSemanticsFor(cpp_type, strict=False):
859 """Return semantics for given type. If no type-specific semantics can be found
860 return DefaultSemantics. In strict mode, raise a TypeError instead.
861 """
862
863 for semantics in SEMANTICS:
864 try:
865 return semantics(cpp_type)
866 except TypeError:
867 pass
868
869 if strict:
870 raise TypeError(f"No semantics found for {cpp_type}")
871
872 return DefaultSemantics(cpp_type)

Variable Documentation

◆ _COMMA_SEPARATION_RE

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

Definition at line 252 of file semantics.py.

◆ _IDENTIFIER_RE

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

Definition at line 250 of file semantics.py.

◆ _log

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

Definition at line 24 of file semantics.py.

◆ _NS_IDENT_RE

str GaudiConfig2.semantics._NS_IDENT_RE = rf"{_IDENTIFIER_RE}(::{_IDENTIFIER_RE})*"
protected

Definition at line 251 of file semantics.py.

◆ is_64bits

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

Definition at line 25 of file semantics.py.

◆ SEMANTICS

list GaudiConfig2.semantics.SEMANTICS
Initial value:
= [
c
for c in globals().values()
if isinstance(c, type)
and issubclass(c, PropertySemantics)
and c not in (PropertySemantics, DefaultSemantics)
]

Definition at line 849 of file semantics.py.