The Gaudi Framework  master (2c9e87c2)
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  _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 = 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 446 of file semantics.py.

446def extract_template_args(cpp_type):
447 """
448 Return an iterator over the list of template arguments in a C++ type
449 string.
450
451 >>> t = 'map<string, vector<int, allocator<int> >, allocator<v<i>, a<i>> >'
452 >>> list(extract_template_args(t))
453 ['string', 'vector<int, allocator<int> >', 'allocator<v<i>, a<i>>']
454 >>> list(extract_template_args('int'))
455 []
456 """
457 template_level = 0
458 arg_start = -1
459 for p, c in enumerate(cpp_type):
460 if c == ",":
461 if template_level == 1:
462 yield cpp_type[arg_start:p].strip()
463 arg_start = p + 1
464 elif c == "<":
465 template_level += 1
466 if template_level == 1:
467 arg_start = p + 1
468 elif c == ">":
469 template_level -= 1
470 if template_level == 0:
471 yield cpp_type[arg_start:p].strip()
472
473

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

833def getSemanticsFor(cpp_type, strict=False):
834 """Return semantics for given type. If no type-specific semantics can be found
835 return DefaultSemantics. In strict mode, raise a TypeError instead.
836 """
837
838 for semantics in SEMANTICS:
839 try:
840 return semantics(cpp_type)
841 except TypeError:
842 pass
843
844 if strict:
845 raise TypeError(f"No semantics found for {cpp_type}")
846
847 return DefaultSemantics(cpp_type)

Variable Documentation

◆ _COMMA_SEPARATION_RE

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

Definition at line 254 of file semantics.py.

◆ _IDENTIFIER_RE

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

Definition at line 252 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 = r"{ident}(::{ident})*".format(ident=_IDENTIFIER_RE)
protected

Definition at line 253 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:
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 824 of file semantics.py.