X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Ffield_class.py;h=4268bbf732ef67065db130ee3b689ea49f339753;hb=0aa006b7775f9578e37c0f006df795e903d25acc;hp=9bab66278a0025288b6c3c919d94fd9cf69e89b1;hpb=70a79f650b35364b233fbefbc822db2c206ef86c;p=babeltrace.git diff --git a/src/bindings/python/bt2/bt2/field_class.py b/src/bindings/python/bt2/bt2/field_class.py index 9bab6627..4268bbf7 100644 --- a/src/bindings/python/bt2/bt2/field_class.py +++ b/src/bindings/python/bt2/bt2/field_class.py @@ -172,23 +172,27 @@ class _SignedIntegerFieldClass( class _RealFieldClassConst(_FieldClassConst): - _NAME = 'Const real' + pass - @property - def is_single_precision(self): - return native_bt.field_class_real_is_single_precision(self._ptr) + +class _SinglePrecisionRealFieldClassConst(_RealFieldClassConst): + _NAME = 'Const single-precision real' + + +class _DoublePrecisionRealFieldClassConst(_RealFieldClassConst): + _NAME = 'Const double-precision real' class _RealFieldClass(_FieldClass, _RealFieldClassConst): - _NAME = 'Real' + pass - 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 _SinglePrecisionRealFieldClass(_RealFieldClass): + _NAME = 'Single-precision real' + + +class _DoublePrecisionRealFieldClass(_RealFieldClass): + _NAME = 'Double-precision real' # an enumeration field class mapping does not have a reference count, so @@ -214,7 +218,7 @@ class _EnumerationFieldClassMapping: class _UnsignedEnumerationFieldClassMappingConst(_EnumerationFieldClassMapping): - _range_set_pycls = 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 +228,7 @@ class _UnsignedEnumerationFieldClassMappingConst(_EnumerationFieldClassMapping): class _SignedEnumerationFieldClassMappingConst(_EnumerationFieldClassMapping): - _range_set_pycls = 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 ) @@ -286,8 +290,7 @@ class _EnumerationFieldClass(_EnumerationFieldClassConst, _IntegerFieldClass): class _UnsignedEnumerationFieldClassConst( _EnumerationFieldClassConst, _UnsignedIntegerFieldClassConst ): - _NAME = 'Const nsigned enumeration' - _range_set_pycls = 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 ) @@ -307,6 +310,7 @@ class _UnsignedEnumerationFieldClass( _UnsignedIntegerFieldClass, ): _NAME = 'Unsigned enumeration' + _range_set_pycls = bt2_integer_range_set.UnsignedIntegerRangeSet _add_mapping = staticmethod(native_bt.field_class_enumeration_unsigned_add_mapping) @@ -314,7 +318,6 @@ class _SignedEnumerationFieldClassConst( _EnumerationFieldClassConst, _SignedIntegerFieldClassConst ): _NAME = 'Const signed enumeration' - _range_set_pycls = bt2_integer_range_set.SignedIntegerRangeSet _borrow_mapping_ptr_by_label = staticmethod( native_bt.field_class_enumeration_signed_borrow_mapping_by_label_const ) @@ -332,6 +335,7 @@ class _SignedEnumerationFieldClass( _SignedEnumerationFieldClassConst, _EnumerationFieldClass, _SignedIntegerFieldClass ): _NAME = 'Signed enumeration' + _range_set_pycls = bt2_integer_range_set.SignedIntegerRangeSet _add_mapping = staticmethod(native_bt.field_class_enumeration_signed_add_mapping) @@ -501,22 +505,67 @@ class _OptionFieldClassConst(_FieldClassConst): _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_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_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_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_integer_signed_borrow_selector_ranges_const + ) class _OptionFieldClass(_OptionFieldClassConst, _FieldClass): @@ -529,6 +578,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_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 @@ -617,7 +706,7 @@ class _VariantFieldClassWithSignedSelectorOptionConst( _borrow_ranges_ptr = staticmethod( native_bt.field_class_variant_with_selector_signed_option_borrow_ranges_const ) - _range_set_pycls = bt2_integer_range_set.SignedIntegerRangeSet + _range_set_pycls = bt2_integer_range_set._SignedIntegerRangeSetConst class _VariantFieldClassWithSignedSelectorOption( @@ -636,7 +725,7 @@ class _VariantFieldClassWithUnsignedSelectorOptionConst( _borrow_ranges_ptr = staticmethod( native_bt.field_class_variant_with_selector_unsigned_option_borrow_ranges_const ) - _range_set_pycls = bt2_integer_range_set.UnsignedIntegerRangeSet + _range_set_pycls = bt2_integer_range_set._UnsignedIntegerRangeSetConst class _VariantFieldClassWithUnsignedSelectorOption( @@ -761,7 +850,7 @@ class _VariantFieldClassWithSelectorConst(_VariantFieldClassConst): 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( @@ -811,9 +900,6 @@ class _VariantFieldClassWithUnsignedSelectorConst(_VariantFieldClassWithSelector _borrow_option_ptr_by_index = staticmethod( native_bt.field_class_variant_with_selector_unsigned_borrow_option_by_index_const ) - _append_option = staticmethod( - native_bt.field_class_variant_with_selector_unsigned_append_option - ) _variant_option_pycls = _VariantFieldClassWithUnsignedSelectorOptionConst _as_option_ptr = staticmethod(_variant_option_pycls._as_option_ptr) @@ -824,6 +910,9 @@ class _VariantFieldClassWithUnsignedSelector( _NAME = 'Variant (with unsigned selector)' _variant_option_pycls = _VariantFieldClassWithUnsignedSelectorOption _as_option_ptr = staticmethod(_variant_option_pycls._as_option_ptr) + _append_option = staticmethod( + native_bt.field_class_variant_with_selector_unsigned_append_option + ) class _VariantFieldClassWithSignedSelectorConst(_VariantFieldClassWithSelectorConst): @@ -834,9 +923,6 @@ class _VariantFieldClassWithSignedSelectorConst(_VariantFieldClassWithSelectorCo _borrow_option_ptr_by_index = staticmethod( native_bt.field_class_variant_with_selector_signed_borrow_option_by_index_const ) - _append_option = staticmethod( - native_bt.field_class_variant_with_selector_signed_append_option - ) _variant_option_pycls = _VariantFieldClassWithSignedSelectorOptionConst _as_option_ptr = staticmethod(_variant_option_pycls._as_option_ptr) @@ -847,6 +933,9 @@ class _VariantFieldClassWithSignedSelector( _NAME = 'Variant (with signed selector)' _variant_option_pycls = _VariantFieldClassWithSignedSelectorOption _as_option_ptr = staticmethod(_variant_option_pycls._as_option_ptr) + _append_option = staticmethod( + native_bt.field_class_variant_with_selector_signed_append_option + ) class _ArrayFieldClassConst(_FieldClassConst): @@ -895,7 +984,7 @@ class _DynamicArrayFieldClassConst(_ArrayFieldClassConst): 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): @@ -907,14 +996,18 @@ _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_OPTION_WITHOUT_SELECTOR: _OptionFieldClassConst, + native_bt.FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR: _OptionWithBoolSelectorFieldClassConst, + native_bt.FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR: _OptionWithUnsignedIntegerSelectorFieldClassConst, + native_bt.FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR: _OptionWithSignedIntegerSelectorFieldClassConst, 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, @@ -925,14 +1018,18 @@ _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_OPTION_WITHOUT_SELECTOR: _OptionFieldClass, + native_bt.FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR: _OptionWithBoolSelectorFieldClass, + native_bt.FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR: _OptionWithUnsignedIntegerSelectorFieldClass, + native_bt.FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR: _OptionWithSignedIntegerSelectorFieldClass, 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,