+ if len(ranges) == 0:
+ raise ValueError('range set is empty')
+
+ # TODO: check overlaps (precondition of self._append_option())
+
+ 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'
+ )
+
+ def __iadd__(self, options):
+ for name, field_class, ranges in options:
+ self.append_option(name, field_class, ranges)
+
+ return self
+
+
+class _VariantFieldClassWithUnsignedSelector(_VariantFieldClassWithSelector):
+ _NAME = 'Variant (with unsigned selector)'
+ _borrow_option_by_name_ptr = staticmethod(
+ native_bt.field_class_variant_with_selector_unsigned_borrow_option_by_name_const
+ )
+ _borrow_member_by_index_ptr = staticmethod(
+ native_bt.field_class_variant_with_selector_unsigned_borrow_option_by_index_const
+ )
+ _as_option_ptr = staticmethod(
+ native_bt.field_class_variant_with_selector_unsigned_option_as_option_const
+ )
+ _append_option = staticmethod(
+ native_bt.field_class_variant_with_selector_unsigned_append_option
+ )
+ _option_borrow_ranges_ptr = staticmethod(
+ native_bt.field_class_variant_with_selector_unsigned_option_borrow_ranges_const
+ )
+ _range_set_type = bt2_integer_range_set.UnsignedIntegerRangeSet
+
+
+class _VariantFieldClassWithSignedSelector(_VariantFieldClassWithSelector):
+ _NAME = 'Variant (with signed selector)'
+ _borrow_option_by_name_ptr = staticmethod(
+ native_bt.field_class_variant_with_selector_signed_borrow_option_by_name_const
+ )
+ _borrow_member_by_index_ptr = staticmethod(
+ native_bt.field_class_variant_with_selector_signed_borrow_option_by_index_const
+ )
+ _as_option_ptr = staticmethod(
+ native_bt.field_class_variant_with_selector_signed_option_as_option_const
+ )
+ _append_option = staticmethod(
+ native_bt.field_class_variant_with_selector_signed_append_option
+ )
+ _option_borrow_ranges_ptr = staticmethod(
+ native_bt.field_class_variant_with_selector_signed_option_borrow_ranges_const
+ )
+ _range_set_type = bt2_integer_range_set.SignedIntegerRangeSet