bt2: Add `Const` suffix to `_*Port` classes and adapt tests
[babeltrace.git] / src / bindings / python / bt2 / bt2 / component.py
index a0d29e272f43d5286cad50f47ff400c68eb33a2f..142cd26933c333e9104dbefc2eb4d3b01e1dbf4e 100644 (file)
@@ -247,7 +247,7 @@ class _GenericSourceComponent(object._SharedObject, _SourceComponent):
             native_bt.component_source_borrow_output_port_by_name_const,
             native_bt.component_source_borrow_output_port_by_index_const,
             native_bt.component_source_get_output_port_count,
-            bt2_port._OutputPort,
+            bt2_port._OutputPortConst,
         )
 
 
@@ -264,7 +264,7 @@ class _GenericFilterComponent(object._SharedObject, _FilterComponent):
             native_bt.component_filter_borrow_output_port_by_name_const,
             native_bt.component_filter_borrow_output_port_by_index_const,
             native_bt.component_filter_get_output_port_count,
-            bt2_port._OutputPort,
+            bt2_port._OutputPortConst,
         )
 
     @property
@@ -274,7 +274,7 @@ class _GenericFilterComponent(object._SharedObject, _FilterComponent):
             native_bt.component_filter_borrow_input_port_by_name_const,
             native_bt.component_filter_borrow_input_port_by_index_const,
             native_bt.component_filter_get_input_port_count,
-            bt2_port._InputPort,
+            bt2_port._InputPortConst,
         )
 
 
@@ -291,7 +291,7 @@ class _GenericSinkComponent(object._SharedObject, _SinkComponent):
             native_bt.component_sink_borrow_input_port_by_name_const,
             native_bt.component_sink_borrow_input_port_by_index_const,
             native_bt.component_sink_get_input_port_count,
-            bt2_port._InputPort,
+            bt2_port._InputPortConst,
         )
 
 
@@ -515,7 +515,7 @@ class _UserComponentType(type):
 
         # call user's __init__() method
         if params_ptr is not None:
-            params = bt2_value._create_from_ptr_and_get_ref(params_ptr)
+            params = bt2_value._create_from_const_ptr_and_get_ref(params_ptr)
         else:
             params = None
 
@@ -574,7 +574,7 @@ class _UserComponentType(type):
     def _bt_get_supported_mip_versions_from_native(cls, params_ptr, obj, log_level):
         # this can raise, but the native side checks the exception
         if params_ptr is not None:
-            params = bt2_value._create_from_ptr_and_get_ref(params_ptr)
+            params = bt2_value._create_from_const_ptr_and_get_ref(params_ptr)
         else:
             params = None
 
@@ -595,7 +595,7 @@ class _UserComponentType(type):
     def _bt_query_from_native(cls, priv_query_exec_ptr, object, params_ptr, method_obj):
         # this can raise, but the native side checks the exception
         if params_ptr is not None:
-            params = bt2_value._create_from_ptr_and_get_ref(params_ptr)
+            params = bt2_value._create_from_const_ptr_and_get_ref(params_ptr)
         else:
             params = None
 
@@ -701,7 +701,7 @@ class _UserComponent(metaclass=_UserComponentType):
         else:
             other_port_type = native_bt.PORT_TYPE_OUTPUT
 
-        other_port = bt2_port._create_from_ptr_and_get_ref(
+        other_port = bt2_port._create_from_const_ptr_and_get_ref(
             other_port_ptr, other_port_type
         )
         self._user_port_connected(port, other_port)
@@ -899,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.026638 seconds and 4 git commands to generate.