X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Ffield_class.py;h=eed50140ea3edd878b7efc4205b1a9078263a0bb;hb=f5567ea88d172767b34373bc6e402da8bfd85ef8;hp=03e6e4e3569c405dea401410da5e78f1a482a9fa;hpb=f0a42b33ac3951cd5cb2ee0f66ac04437a681621;p=babeltrace.git diff --git a/src/bindings/python/bt2/bt2/field_class.py b/src/bindings/python/bt2/bt2/field_class.py index 03e6e4e3..eed50140 100644 --- a/src/bindings/python/bt2/bt2/field_class.py +++ b/src/bindings/python/bt2/bt2/field_class.py @@ -1,24 +1,6 @@ -# The MIT License (MIT) +# SPDX-License-Identifier: MIT # # Copyright (c) 2017 Philippe Proulx -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. from bt2 import native_bt, object, utils import collections.abc @@ -28,9 +10,19 @@ from bt2 import value as bt2_value import bt2 -def _create_field_class_from_ptr_and_get_ref_template(type_map, ptr): +def _obj_type_from_field_class_ptr_template(type_map, ptr): typeid = native_bt.field_class_get_type(ptr) - return type_map[typeid]._create_from_ptr_and_get_ref(ptr) + return type_map[typeid] + + +def _obj_type_from_field_class_ptr(ptr): + return _obj_type_from_field_class_ptr_template(_FIELD_CLASS_TYPE_TO_OBJ, ptr) + + +def _create_field_class_from_ptr_and_get_ref_template(type_map, ptr): + return _obj_type_from_field_class_ptr_template( + type_map, ptr + )._create_from_ptr_and_get_ref(ptr) def _create_field_class_from_ptr_and_get_ref(ptr): @@ -65,7 +57,7 @@ class _FieldClassConst(object._SharedObject): def _check_create_status(self, ptr): if ptr is None: raise bt2._MemoryError( - 'cannot create {} field class object'.format(self._NAME.lower()) + "cannot create {} field class object".format(self._NAME.lower()) ) @property @@ -92,15 +84,15 @@ class _FieldClass(_FieldClassConst): class _BoolFieldClassConst(_FieldClassConst): - _NAME = 'Const Boolean' + _NAME = "Const boolean" class _BoolFieldClass(_BoolFieldClassConst, _FieldClass): - _NAME = 'Boolean' + _NAME = "Boolean" class _BitArrayFieldClassConst(_FieldClassConst): - _NAME = 'Const Bit array' + _NAME = "Const bit array" @property def length(self): @@ -110,7 +102,7 @@ class _BitArrayFieldClassConst(_FieldClassConst): class _BitArrayFieldClass(_BitArrayFieldClassConst, _FieldClass): - _NAME = 'Bit array' + _NAME = "Bit array" class _IntegerFieldClassConst(_FieldClassConst): @@ -152,43 +144,47 @@ class _IntegerFieldClass(_FieldClass, _IntegerFieldClassConst): class _UnsignedIntegerFieldClassConst(_IntegerFieldClassConst, _FieldClassConst): - _NAME = 'Const unsigned integer' + _NAME = "Const unsigned integer" class _UnsignedIntegerFieldClass( _UnsignedIntegerFieldClassConst, _IntegerFieldClass, _FieldClass ): - _NAME = 'Unsigned integer' + _NAME = "Unsigned integer" class _SignedIntegerFieldClassConst(_IntegerFieldClassConst, _FieldClassConst): - _NAME = 'Const signed integer' + _NAME = "Const signed integer" class _SignedIntegerFieldClass( _SignedIntegerFieldClassConst, _IntegerFieldClass, _FieldClass ): - _NAME = 'Signed integer' + _NAME = "Signed integer" class _RealFieldClassConst(_FieldClassConst): - _NAME = 'Const real' + pass + + +class _SinglePrecisionRealFieldClassConst(_RealFieldClassConst): + _NAME = "Const single-precision real" - @property - def is_single_precision(self): - return native_bt.field_class_real_is_single_precision(self._ptr) + +class _DoublePrecisionRealFieldClassConst(_RealFieldClassConst): + _NAME = "Const double-precision real" class _RealFieldClass(_FieldClass, _RealFieldClassConst): - _NAME = 'Real' + pass + + +class _SinglePrecisionRealFieldClass(_RealFieldClass): + _NAME = "Single-precision real" - def _is_single_precision(self, is_single_precision): - utils._check_bool(is_single_precision) - native_bt.field_class_real_set_is_single_precision( - self._ptr, is_single_precision - ) - _is_single_precision = property(fset=_is_single_precision) +class _DoublePrecisionRealFieldClass(_RealFieldClass): + _NAME = "Double-precision real" # an enumeration field class mapping does not have a reference count, so @@ -202,7 +198,7 @@ class _EnumerationFieldClassMapping: assert self._label is not None ranges_ptr = self._mapping_borrow_ranges_ptr(mapping_ptr) assert ranges_ptr is not None - self._ranges = self._ranges_type._create_from_ptr_and_get_ref(ranges_ptr) + self._ranges = self._range_set_pycls._create_from_ptr_and_get_ref(ranges_ptr) @property def label(self): @@ -214,7 +210,7 @@ class _EnumerationFieldClassMapping: class _UnsignedEnumerationFieldClassMappingConst(_EnumerationFieldClassMapping): - _ranges_type = bt2_integer_range_set.UnsignedIntegerRangeSet + _range_set_pycls = bt2_integer_range_set._UnsignedIntegerRangeSetConst _as_enumeration_field_class_mapping_ptr = staticmethod( native_bt.field_class_enumeration_unsigned_mapping_as_mapping_const ) @@ -224,7 +220,7 @@ class _UnsignedEnumerationFieldClassMappingConst(_EnumerationFieldClassMapping): class _SignedEnumerationFieldClassMappingConst(_EnumerationFieldClassMapping): - _ranges_type = bt2_integer_range_set.SignedIntegerRangeSet + _range_set_pycls = bt2_integer_range_set._SignedIntegerRangeSetConst _as_enumeration_field_class_mapping_ptr = staticmethod( native_bt.field_class_enumeration_signed_mapping_as_mapping_const ) @@ -244,7 +240,7 @@ class _EnumerationFieldClassConst(_IntegerFieldClassConst, collections.abc.Mappi status, labels = self._get_mapping_labels_for_value(self._ptr, value) utils._handle_func_status( - status, 'cannot get mapping labels for value {}'.format(value) + status, "cannot get mapping labels for value {}".format(value) ) return [self[label] for label in labels] @@ -266,14 +262,14 @@ class _EnumerationFieldClassConst(_IntegerFieldClassConst, collections.abc.Mappi class _EnumerationFieldClass(_EnumerationFieldClassConst, _IntegerFieldClass): def add_mapping(self, label, ranges): utils._check_str(label) - utils._check_type(ranges, self._range_set_type) + utils._check_type(ranges, self._range_set_pycls) if label in self: raise ValueError("duplicate mapping label '{}'".format(label)) status = self._add_mapping(self._ptr, label, ranges._ptr) utils._handle_func_status( - status, 'cannot add mapping to enumeration field class object' + status, "cannot add mapping to enumeration field class object" ) def __iadd__(self, mappings): @@ -286,8 +282,7 @@ class _EnumerationFieldClass(_EnumerationFieldClassConst, _IntegerFieldClass): class _UnsignedEnumerationFieldClassConst( _EnumerationFieldClassConst, _UnsignedIntegerFieldClassConst ): - _NAME = 'Const nsigned enumeration' - _range_set_type = bt2_integer_range_set.UnsignedIntegerRangeSet + _NAME = "Const unsigned enumeration" _borrow_mapping_ptr_by_label = staticmethod( native_bt.field_class_enumeration_unsigned_borrow_mapping_by_label_const ) @@ -306,15 +301,15 @@ class _UnsignedEnumerationFieldClass( _EnumerationFieldClass, _UnsignedIntegerFieldClass, ): - _NAME = 'Unsigned enumeration' + _NAME = "Unsigned enumeration" + _range_set_pycls = bt2_integer_range_set.UnsignedIntegerRangeSet _add_mapping = staticmethod(native_bt.field_class_enumeration_unsigned_add_mapping) class _SignedEnumerationFieldClassConst( _EnumerationFieldClassConst, _SignedIntegerFieldClassConst ): - _NAME = 'Const signed enumeration' - _range_set_type = bt2_integer_range_set.SignedIntegerRangeSet + _NAME = "Const signed enumeration" _borrow_mapping_ptr_by_label = staticmethod( native_bt.field_class_enumeration_signed_borrow_mapping_by_label_const ) @@ -331,16 +326,17 @@ class _SignedEnumerationFieldClassConst( class _SignedEnumerationFieldClass( _SignedEnumerationFieldClassConst, _EnumerationFieldClass, _SignedIntegerFieldClass ): - _NAME = 'Signed enumeration' + _NAME = "Signed enumeration" + _range_set_pycls = bt2_integer_range_set.SignedIntegerRangeSet _add_mapping = staticmethod(native_bt.field_class_enumeration_signed_add_mapping) class _StringFieldClassConst(_FieldClassConst): - _NAME = 'Const string' + _NAME = "Const string" class _StringFieldClass(_StringFieldClassConst, _FieldClass): - _NAME = 'String' + _NAME = "String" class _StructureFieldClassMemberConst: @@ -407,7 +403,7 @@ class _StructureFieldClassMember(_StructureFieldClassMemberConst): class _StructureFieldClassConst(_FieldClassConst, collections.abc.Mapping): - _NAME = 'Const structure' + _NAME = "Const structure" _borrow_member_ptr_by_index = staticmethod( native_bt.field_class_structure_borrow_member_by_index_const ) @@ -454,7 +450,7 @@ class _StructureFieldClassConst(_FieldClassConst, collections.abc.Mapping): class _StructureFieldClass(_StructureFieldClassConst, _FieldClass): - _NAME = 'Structure' + _NAME = "Structure" _borrow_member_by_index = staticmethod( native_bt.field_class_structure_borrow_member_by_index ) @@ -480,7 +476,7 @@ class _StructureFieldClass(_StructureFieldClassConst, _FieldClass): self._ptr, name, field_class._ptr ) utils._handle_func_status( - status, 'cannot append member to structure field class object' + status, "cannot append member to structure field class object" ) if user_attributes is not None: @@ -494,33 +490,78 @@ class _StructureFieldClass(_StructureFieldClassConst, _FieldClass): class _OptionFieldClassConst(_FieldClassConst): - _NAME = 'Const Option' + _NAME = "Const option" _create_field_class_from_ptr_and_get_ref = staticmethod( _create_field_class_from_const_ptr_and_get_ref ) _borrow_field_class_ptr = staticmethod( native_bt.field_class_option_borrow_field_class_const ) - _borrow_selector_field_path = staticmethod( - native_bt.field_class_option_borrow_selector_field_path_const - ) @property def field_class(self): elem_fc_ptr = self._borrow_field_class_ptr(self._ptr) return self._create_field_class_from_ptr_and_get_ref(elem_fc_ptr) + +class _OptionWithSelectorFieldClassConst(_OptionFieldClassConst): + _NAME = "Const option (with selector)" + @property def selector_field_path(self): - ptr = self._borrow_selector_field_path(self._ptr) + ptr = native_bt.field_class_option_with_selector_field_borrow_selector_field_path_const( + self._ptr + ) if ptr is None: return - return bt2_field_path._FieldPath._create_from_ptr_and_get_ref(ptr) + return bt2_field_path._FieldPathConst._create_from_ptr_and_get_ref(ptr) + + +class _OptionWithBoolSelectorFieldClassConst(_OptionWithSelectorFieldClassConst): + _NAME = "Const option (with boolean selector)" + + @property + def selector_is_reversed(self): + return bool( + native_bt.field_class_option_with_selector_field_bool_selector_is_reversed( + self._ptr + ) + ) + + +class _OptionWithIntegerSelectorFieldClassConst(_OptionWithSelectorFieldClassConst): + _NAME = "Const option (with integer selector)" + + @property + def ranges(self): + range_set_ptr = self._borrow_selector_ranges_ptr(self._ptr) + assert range_set_ptr is not None + return self._range_set_pycls._create_from_ptr_and_get_ref(range_set_ptr) + + +class _OptionWithUnsignedIntegerSelectorFieldClassConst( + _OptionWithIntegerSelectorFieldClassConst +): + _NAME = "Const option (with unsigned integer selector)" + _range_set_pycls = bt2_integer_range_set._UnsignedIntegerRangeSetConst + _borrow_selector_ranges_ptr = staticmethod( + native_bt.field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const + ) + + +class _OptionWithSignedIntegerSelectorFieldClassConst( + _OptionWithIntegerSelectorFieldClassConst +): + _NAME = "Const option (with signed integer selector)" + _range_set_pycls = bt2_integer_range_set._SignedIntegerRangeSetConst + _borrow_selector_ranges_ptr = staticmethod( + native_bt.field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const + ) class _OptionFieldClass(_OptionFieldClassConst, _FieldClass): - _NAME = 'Option' + _NAME = "Option" _borrow_field_class_ptr = staticmethod( native_bt.field_class_option_borrow_field_class ) @@ -529,6 +570,46 @@ class _OptionFieldClass(_OptionFieldClassConst, _FieldClass): ) +class _OptionWithSelectorFieldClass( + _OptionWithSelectorFieldClassConst, _OptionFieldClass +): + _NAME = "Option (with selector)" + + +class _OptionWithBoolSelectorFieldClass( + _OptionWithBoolSelectorFieldClassConst, _OptionWithSelectorFieldClass +): + _NAME = "Option (with boolean selector)" + + def _selector_is_reversed(self, selector_is_reversed): + utils._check_bool(selector_is_reversed) + native_bt.field_class_option_with_selector_field_bool_set_selector_is_reversed( + self._ptr, selector_is_reversed + ) + + _selector_is_reversed = property(fset=_selector_is_reversed) + + +class _OptionWithIntegerSelectorFieldClass( + _OptionWithIntegerSelectorFieldClassConst, _OptionWithSelectorFieldClass +): + _NAME = "Option (with integer selector)" + + +class _OptionWithUnsignedIntegerSelectorFieldClass( + _OptionWithUnsignedIntegerSelectorFieldClassConst, + _OptionWithIntegerSelectorFieldClass, +): + _NAME = "Option (with unsigned integer selector)" + + +class _OptionWithSignedIntegerSelectorFieldClass( + _OptionWithSignedIntegerSelectorFieldClassConst, + _OptionWithIntegerSelectorFieldClass, +): + _NAME = "Option (with signed integer selector)" + + class _VariantFieldClassOptionConst: _create_field_class_from_ptr_and_get_ref = staticmethod( _create_field_class_from_const_ptr_and_get_ref @@ -576,7 +657,7 @@ class _VariantFieldClassOption(_VariantFieldClassOptionConst): native_bt.field_class_variant_option_borrow_field_class ) _borrow_user_attributes_ptr = staticmethod( - native_bt.field_class_variant_option_borrow_user_attributes_const + native_bt.field_class_variant_option_borrow_user_attributes ) _create_value_from_ptr_and_get_ref = staticmethod( bt2_value._create_from_ptr_and_get_ref @@ -590,7 +671,7 @@ class _VariantFieldClassOption(_VariantFieldClassOptionConst): _user_attributes = property(fset=_user_attributes) -class _VariantFieldClassWithSelectorOptionConst(_VariantFieldClassOptionConst): +class _VariantFieldClassWithIntegerSelectorOptionConst(_VariantFieldClassOptionConst): def __init__(self, owning_var_fc, spec_opt_ptr): self._spec_ptr = spec_opt_ptr super().__init__(owning_var_fc, self._as_option_ptr(spec_opt_ptr)) @@ -599,55 +680,55 @@ class _VariantFieldClassWithSelectorOptionConst(_VariantFieldClassOptionConst): def ranges(self): range_set_ptr = self._borrow_ranges_ptr(self._spec_ptr) assert range_set_ptr is not None - return self._range_set_type._create_from_ptr_and_get_ref(range_set_ptr) + return self._range_set_pycls._create_from_ptr_and_get_ref(range_set_ptr) -class _VariantFieldClassWithSelectorOption( - _VariantFieldClassWithSelectorOptionConst, _VariantFieldClassOption +class _VariantFieldClassWithIntegerSelectorOption( + _VariantFieldClassWithIntegerSelectorOptionConst, _VariantFieldClassOption ): pass -class _VariantFieldClassWithSignedSelectorOptionConst( - _VariantFieldClassWithSelectorOptionConst +class _VariantFieldClassWithSignedIntegerSelectorOptionConst( + _VariantFieldClassWithIntegerSelectorOptionConst ): _as_option_ptr = staticmethod( - native_bt.field_class_variant_with_selector_signed_option_as_option_const + native_bt.field_class_variant_with_selector_field_integer_signed_option_as_option_const ) _borrow_ranges_ptr = staticmethod( - native_bt.field_class_variant_with_selector_signed_option_borrow_ranges_const + native_bt.field_class_variant_with_selector_field_integer_signed_option_borrow_ranges_const ) - _range_set_type = bt2_integer_range_set.SignedIntegerRangeSet + _range_set_pycls = bt2_integer_range_set._SignedIntegerRangeSetConst -class _VariantFieldClassWithSignedSelectorOption( - _VariantFieldClassWithSignedSelectorOptionConst, - _VariantFieldClassWithSelectorOption, +class _VariantFieldClassWithSignedIntegerSelectorOption( + _VariantFieldClassWithSignedIntegerSelectorOptionConst, + _VariantFieldClassWithIntegerSelectorOption, ): pass -class _VariantFieldClassWithUnsignedSelectorOptionConst( - _VariantFieldClassWithSelectorOptionConst +class _VariantFieldClassWithUnsignedIntegerSelectorOptionConst( + _VariantFieldClassWithIntegerSelectorOptionConst ): _as_option_ptr = staticmethod( - native_bt.field_class_variant_with_selector_unsigned_option_as_option_const + native_bt.field_class_variant_with_selector_field_integer_unsigned_option_as_option_const ) _borrow_ranges_ptr = staticmethod( - native_bt.field_class_variant_with_selector_unsigned_option_borrow_ranges_const + native_bt.field_class_variant_with_selector_field_integer_unsigned_option_borrow_ranges_const ) - _range_set_type = bt2_integer_range_set.UnsignedIntegerRangeSet + _range_set_pycls = bt2_integer_range_set._UnsignedIntegerRangeSetConst -class _VariantFieldClassWithUnsignedSelectorOption( - _VariantFieldClassWithUnsignedSelectorOptionConst, - _VariantFieldClassWithSelectorOption, +class _VariantFieldClassWithUnsignedIntegerSelectorOption( + _VariantFieldClassWithUnsignedIntegerSelectorOptionConst, + _VariantFieldClassWithIntegerSelectorOption, ): pass class _VariantFieldClassConst(_FieldClassConst, collections.abc.Mapping): - _NAME = 'Const Variant' + _NAME = "Const variant" _borrow_option_ptr_by_name = staticmethod( native_bt.field_class_variant_borrow_option_by_name_const ) @@ -700,7 +781,7 @@ class _VariantFieldClassConst(_FieldClassConst, collections.abc.Mapping): class _VariantFieldClass(_VariantFieldClassConst, _FieldClass, collections.abc.Mapping): - _NAME = 'Variant' + _NAME = "Variant" _borrow_option_ptr_by_name = staticmethod( native_bt.field_class_variant_borrow_option_by_name ) @@ -711,13 +792,13 @@ class _VariantFieldClass(_VariantFieldClassConst, _FieldClass, collections.abc.M class _VariantFieldClassWithoutSelectorConst(_VariantFieldClassConst): - _NAME = 'Const Variant (without selector)' + _NAME = "Const variant (without selector)" class _VariantFieldClassWithoutSelector( _VariantFieldClassWithoutSelectorConst, _VariantFieldClass ): - _NAME = 'Variant (without selector)' + _NAME = "Variant (without selector)" def append_option(self, name, field_class, user_attributes=None): utils._check_str(name) @@ -736,7 +817,7 @@ class _VariantFieldClassWithoutSelector( self._ptr, name, field_class._ptr ) utils._handle_func_status( - status, 'cannot append option to variant field class object' + status, "cannot append option to variant field class object" ) if user_attributes is not None: @@ -749,36 +830,36 @@ class _VariantFieldClassWithoutSelector( return self -class _VariantFieldClassWithSelectorConst(_VariantFieldClassConst): - _NAME = 'Const Variant (with selector)' +class _VariantFieldClassWithIntegerSelectorConst(_VariantFieldClassConst): + _NAME = "Const variant (with selector)" @property def selector_field_path(self): - ptr = native_bt.field_class_variant_with_selector_borrow_selector_field_path_const( + ptr = native_bt.field_class_variant_with_selector_field_borrow_selector_field_path_const( self._ptr ) if ptr is None: return - return bt2_field_path._FieldPath._create_from_ptr_and_get_ref(ptr) + return bt2_field_path._FieldPathConst._create_from_ptr_and_get_ref(ptr) -class _VariantFieldClassWithSelector( - _VariantFieldClassWithSelectorConst, _VariantFieldClass +class _VariantFieldClassWithIntegerSelector( + _VariantFieldClassWithIntegerSelectorConst, _VariantFieldClass ): - _NAME = 'Variant (with selector)' + _NAME = "Variant (with selector)" def append_option(self, name, field_class, ranges, user_attributes=None): utils._check_str(name) utils._check_type(field_class, _FieldClass) - utils._check_type(ranges, self._variant_option_pycls._range_set_type) + utils._check_type(ranges, self._variant_option_pycls._range_set_pycls) if name in self: raise ValueError("duplicate option name '{}'".format(name)) if len(ranges) == 0: - raise ValueError('range set is empty') + raise ValueError("range set is empty") user_attributes_value = None @@ -790,7 +871,7 @@ class _VariantFieldClassWithSelector( status = self._append_option(self._ptr, name, field_class._ptr, ranges._ptr) utils._handle_func_status( - status, 'cannot append option to variant field class object' + status, "cannot append option to variant field class object" ) if user_attributes is not None: @@ -803,50 +884,56 @@ class _VariantFieldClassWithSelector( return self -class _VariantFieldClassWithUnsignedSelectorConst(_VariantFieldClassWithSelectorConst): - _NAME = 'Const Variant (with unsigned selector)' +class _VariantFieldClassWithUnsignedIntegerSelectorConst( + _VariantFieldClassWithIntegerSelectorConst +): + _NAME = "Const variant (with unsigned integer selector)" _borrow_option_ptr_by_name = staticmethod( - native_bt.field_class_variant_with_selector_unsigned_borrow_option_by_name_const + native_bt.field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const ) _borrow_option_ptr_by_index = staticmethod( - native_bt.field_class_variant_with_selector_unsigned_borrow_option_by_index_const + native_bt.field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const ) - _append_option = staticmethod( - native_bt.field_class_variant_with_selector_unsigned_append_option - ) - _variant_option_pycls = _VariantFieldClassWithUnsignedSelectorOptionConst + _variant_option_pycls = _VariantFieldClassWithUnsignedIntegerSelectorOptionConst _as_option_ptr = staticmethod(_variant_option_pycls._as_option_ptr) -class _VariantFieldClassWithUnsignedSelector( - _VariantFieldClassWithUnsignedSelectorConst, _VariantFieldClassWithSelector +class _VariantFieldClassWithUnsignedIntegerSelector( + _VariantFieldClassWithUnsignedIntegerSelectorConst, + _VariantFieldClassWithIntegerSelector, ): - _NAME = 'Variant (with unsigned selector)' - _variant_option_pycls = _VariantFieldClassWithUnsignedSelectorOption + _NAME = "Variant (with unsigned integer selector)" + _variant_option_pycls = _VariantFieldClassWithUnsignedIntegerSelectorOption _as_option_ptr = staticmethod(_variant_option_pycls._as_option_ptr) + _append_option = staticmethod( + native_bt.field_class_variant_with_selector_field_integer_unsigned_append_option + ) -class _VariantFieldClassWithSignedSelectorConst(_VariantFieldClassWithSelectorConst): - _NAME = 'Const Variant (with signed selector)' +class _VariantFieldClassWithSignedIntegerSelectorConst( + _VariantFieldClassWithIntegerSelectorConst +): + _NAME = "Const variant (with signed integer selector)" _borrow_option_ptr_by_name = staticmethod( - native_bt.field_class_variant_with_selector_signed_borrow_option_by_name_const + native_bt.field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_const ) _borrow_option_ptr_by_index = staticmethod( - native_bt.field_class_variant_with_selector_signed_borrow_option_by_index_const + native_bt.field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const ) - _append_option = staticmethod( - native_bt.field_class_variant_with_selector_signed_append_option - ) - _variant_option_pycls = _VariantFieldClassWithSignedSelectorOptionConst + _variant_option_pycls = _VariantFieldClassWithSignedIntegerSelectorOptionConst _as_option_ptr = staticmethod(_variant_option_pycls._as_option_ptr) -class _VariantFieldClassWithSignedSelector( - _VariantFieldClassWithSignedSelectorConst, _VariantFieldClassWithSelector +class _VariantFieldClassWithSignedIntegerSelector( + _VariantFieldClassWithSignedIntegerSelectorConst, + _VariantFieldClassWithIntegerSelector, ): - _NAME = 'Variant (with signed selector)' - _variant_option_pycls = _VariantFieldClassWithSignedSelectorOption + _NAME = "Variant (with signed integer selector)" + _variant_option_pycls = _VariantFieldClassWithSignedIntegerSelectorOption _as_option_ptr = staticmethod(_variant_option_pycls._as_option_ptr) + _append_option = staticmethod( + native_bt.field_class_variant_with_selector_field_integer_signed_append_option + ) class _ArrayFieldClassConst(_FieldClassConst): @@ -873,7 +960,7 @@ class _ArrayFieldClass(_ArrayFieldClassConst, _FieldClass): class _StaticArrayFieldClassConst(_ArrayFieldClassConst): - _NAME = 'Const static array' + _NAME = "Const static array" @property def length(self): @@ -881,25 +968,35 @@ class _StaticArrayFieldClassConst(_ArrayFieldClassConst): class _StaticArrayFieldClass(_StaticArrayFieldClassConst, _ArrayFieldClass): - _NAME = 'Static array' + _NAME = "Static array" class _DynamicArrayFieldClassConst(_ArrayFieldClassConst): - _NAME = 'Const dynamic array' + _NAME = "Const dynamic array" + + +class _DynamicArrayWithLengthFieldFieldClassConst(_DynamicArrayFieldClassConst): + _NAME = "Const dynamic array (with length field)" @property def length_field_path(self): - ptr = native_bt.field_class_array_dynamic_borrow_length_field_path_const( + ptr = native_bt.field_class_array_dynamic_with_length_field_borrow_length_field_path_const( self._ptr ) if ptr is None: return - return bt2_field_path._FieldPath._create_from_ptr_and_get_ref(ptr) + return bt2_field_path._FieldPathConst._create_from_ptr_and_get_ref(ptr) class _DynamicArrayFieldClass(_DynamicArrayFieldClassConst, _ArrayFieldClass): - _NAME = 'Dynamic Array' + _NAME = "Dynamic array" + + +class _DynamicArrayWithLengthFieldFieldClass( + _DynamicArrayWithLengthFieldFieldClassConst, _DynamicArrayFieldClass +): + _NAME = "Dynamic array (with length field)" _FIELD_CLASS_TYPE_TO_CONST_OBJ = { @@ -907,17 +1004,22 @@ _FIELD_CLASS_TYPE_TO_CONST_OBJ = { native_bt.FIELD_CLASS_TYPE_BIT_ARRAY: _BitArrayFieldClassConst, native_bt.FIELD_CLASS_TYPE_UNSIGNED_INTEGER: _UnsignedIntegerFieldClassConst, native_bt.FIELD_CLASS_TYPE_SIGNED_INTEGER: _SignedIntegerFieldClassConst, - native_bt.FIELD_CLASS_TYPE_REAL: _RealFieldClassConst, + native_bt.FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL: _SinglePrecisionRealFieldClassConst, + native_bt.FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL: _DoublePrecisionRealFieldClassConst, native_bt.FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION: _UnsignedEnumerationFieldClassConst, native_bt.FIELD_CLASS_TYPE_SIGNED_ENUMERATION: _SignedEnumerationFieldClassConst, native_bt.FIELD_CLASS_TYPE_STRING: _StringFieldClassConst, native_bt.FIELD_CLASS_TYPE_STRUCTURE: _StructureFieldClassConst, native_bt.FIELD_CLASS_TYPE_STATIC_ARRAY: _StaticArrayFieldClassConst, - native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY: _DynamicArrayFieldClassConst, - native_bt.FIELD_CLASS_TYPE_OPTION: _OptionFieldClassConst, - native_bt.FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR: _VariantFieldClassWithoutSelectorConst, - native_bt.FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR: _VariantFieldClassWithUnsignedSelectorConst, - native_bt.FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR: _VariantFieldClassWithSignedSelectorConst, + native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD: _DynamicArrayFieldClassConst, + native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD: _DynamicArrayWithLengthFieldFieldClassConst, + native_bt.FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD: _OptionFieldClassConst, + native_bt.FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD: _OptionWithBoolSelectorFieldClassConst, + native_bt.FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD: _OptionWithUnsignedIntegerSelectorFieldClassConst, + native_bt.FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD: _OptionWithSignedIntegerSelectorFieldClassConst, + native_bt.FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD: _VariantFieldClassWithoutSelectorConst, + native_bt.FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD: _VariantFieldClassWithUnsignedIntegerSelectorConst, + native_bt.FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD: _VariantFieldClassWithSignedIntegerSelectorConst, } _FIELD_CLASS_TYPE_TO_OBJ = { @@ -925,15 +1027,20 @@ _FIELD_CLASS_TYPE_TO_OBJ = { native_bt.FIELD_CLASS_TYPE_BIT_ARRAY: _BitArrayFieldClass, native_bt.FIELD_CLASS_TYPE_UNSIGNED_INTEGER: _UnsignedIntegerFieldClass, native_bt.FIELD_CLASS_TYPE_SIGNED_INTEGER: _SignedIntegerFieldClass, - native_bt.FIELD_CLASS_TYPE_REAL: _RealFieldClass, + native_bt.FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL: _SinglePrecisionRealFieldClass, + native_bt.FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL: _DoublePrecisionRealFieldClass, native_bt.FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION: _UnsignedEnumerationFieldClass, native_bt.FIELD_CLASS_TYPE_SIGNED_ENUMERATION: _SignedEnumerationFieldClass, native_bt.FIELD_CLASS_TYPE_STRING: _StringFieldClass, native_bt.FIELD_CLASS_TYPE_STRUCTURE: _StructureFieldClass, native_bt.FIELD_CLASS_TYPE_STATIC_ARRAY: _StaticArrayFieldClass, - native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY: _DynamicArrayFieldClass, - native_bt.FIELD_CLASS_TYPE_OPTION: _OptionFieldClass, - native_bt.FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR: _VariantFieldClassWithoutSelector, - native_bt.FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR: _VariantFieldClassWithUnsignedSelector, - native_bt.FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR: _VariantFieldClassWithSignedSelector, + native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD: _DynamicArrayFieldClass, + native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD: _DynamicArrayWithLengthFieldFieldClass, + native_bt.FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD: _OptionFieldClass, + native_bt.FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD: _OptionWithBoolSelectorFieldClass, + native_bt.FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD: _OptionWithUnsignedIntegerSelectorFieldClass, + native_bt.FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD: _OptionWithSignedIntegerSelectorFieldClass, + native_bt.FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD: _VariantFieldClassWithoutSelector, + native_bt.FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD: _VariantFieldClassWithUnsignedIntegerSelector, + native_bt.FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD: _VariantFieldClassWithSignedIntegerSelector, }