- ptr = native_bt.value_array_borrow_element_by_index(self._ptr, index)
- assert(ptr)
- return _create_from_ptr_and_get_ref(ptr)
+ ptr = self._borrow_element_by_index(self._ptr, index)
+ assert ptr
+ return self._create_value_from_ptr_and_get_ref(ptr)
+
+ def __repr__(self):
+ return '[{}]'.format(', '.join([repr(v) for v in self]))
+
+
+class ArrayValue(_ArrayValueConst, _Container, collections.abc.MutableSequence, _Value):
+ _NAME = 'Array'
+ _borrow_element_by_index = staticmethod(
+ native_bt.value_array_borrow_element_by_index
+ )
+
+ def __init__(self, value=None):
+ ptr = native_bt.value_array_create()
+ self._check_create_status(ptr)
+ super().__init__(ptr)
+
+ # Python will raise a TypeError if there's anything wrong with
+ # the iterable protocol.
+ if value is not None:
+ for elem in value:
+ self.append(elem)