lib: make message iterator creation functions return a status
[babeltrace.git] / src / bindings / python / bt2 / bt2 / component.py
index 2d0cd922a1a07730b830ca35c0aeecef5deaf881..a4f80c613d98fb6dfe5239e332c92e9ce23634d5 100644 (file)
@@ -677,6 +677,11 @@ class _UserComponent(metaclass=_UserComponentType):
     def addr(self):
         return int(self._bt_ptr)
 
+    @property
+    def _graph_mip_version(self):
+        ptr = self._bt_as_self_component_ptr(self._bt_ptr)
+        return native_bt.self_component_get_graph_mip_version(ptr)
+
     def __init__(self, params=None, obj=None):
         pass
 
@@ -701,7 +706,9 @@ class _UserComponent(metaclass=_UserComponentType):
         )
         self._user_port_connected(port, other_port)
 
-    def _create_trace_class(self, assigns_automatic_stream_class_id=True):
+    def _create_trace_class(
+        self, user_attributes=None, assigns_automatic_stream_class_id=True
+    ):
         ptr = self._bt_as_self_component_ptr(self._bt_ptr)
         tc_ptr = native_bt.trace_class_create(ptr)
 
@@ -711,12 +718,16 @@ class _UserComponent(metaclass=_UserComponentType):
         tc = bt2_trace_class._TraceClass._create_from_ptr(tc_ptr)
         tc._assigns_automatic_stream_class_id = assigns_automatic_stream_class_id
 
+        if user_attributes is not None:
+            tc._user_attributes = user_attributes
+
         return tc
 
     def _create_clock_class(
         self,
         frequency=None,
         name=None,
+        user_attributes=None,
         description=None,
         precision=None,
         offset=None,
@@ -737,6 +748,9 @@ class _UserComponent(metaclass=_UserComponentType):
         if name is not None:
             cc._name = name
 
+        if user_attributes is not None:
+            cc._user_attributes = user_attributes
+
         if description is not None:
             cc._description = description
 
@@ -885,12 +899,11 @@ class _UserSinkComponent(_UserComponent, _SinkComponent):
     def _create_input_port_message_iterator(self, input_port):
         utils._check_type(input_port, bt2_port._UserComponentInputPort)
 
-        msg_iter_ptr = native_bt.self_component_port_input_message_iterator_create_from_sink_component(
+        status, msg_iter_ptr = native_bt.bt2_self_component_port_input_message_iterator_create_from_sink_component(
             self._bt_ptr, input_port._ptr
         )
-
-        if msg_iter_ptr is None:
-            raise bt2._MemoryError('cannot create message iterator object')
+        utils._handle_func_status(status, 'cannot create message iterator object')
+        assert msg_iter_ptr is not None
 
         return bt2_message_iterator._UserComponentInputPortMessageIterator(msg_iter_ptr)
 
This page took 0.025345 seconds and 4 git commands to generate.