tap-driver.sh: flush stdout after each test result
[babeltrace.git] / bindings / python / bt2 / bt2 / native_bt_component_class.i
index b9c7b13a06414de184c98b34fdde606a98d83b79..1dfa0110886fa05a225e1d018155d11b67829142 100644 (file)
@@ -520,7 +520,7 @@ static PyObject *py_mod_bt2_exc_error_type = NULL;
 static PyObject *py_mod_bt2_exc_try_again_type = NULL;
 static PyObject *py_mod_bt2_exc_stop_type = NULL;
 static PyObject *py_mod_bt2_exc_port_connection_refused_type = NULL;
-static PyObject *py_mod_bt2_exc_notif_iter_canceled_type = NULL;
+static PyObject *py_mod_bt2_exc_msg_iter_canceled_type = NULL;
 static PyObject *py_mod_bt2_exc_invalid_query_object_type = NULL;
 static PyObject *py_mod_bt2_exc_invalid_query_params_type = NULL;
 
@@ -576,7 +576,7 @@ static void bt_py3_cc_exit_handler(void)
        Py_XDECREF(py_mod_bt2_exc_try_again_type);
        Py_XDECREF(py_mod_bt2_exc_stop_type);
        Py_XDECREF(py_mod_bt2_exc_port_connection_refused_type);
-       Py_XDECREF(py_mod_bt2_exc_notif_iter_canceled_type);
+       Py_XDECREF(py_mod_bt2_exc_msg_iter_canceled_type);
        Py_XDECREF(py_mod_bt2_exc_invalid_query_object_type);
        Py_XDECREF(py_mod_bt2_exc_invalid_query_params_type);
 }
@@ -719,12 +719,12 @@ bt_py3_exc_to_self_message_iterator_status(void)
        }
 
        if (PyErr_GivenExceptionMatches(exc, py_mod_bt2_exc_stop_type)) {
-               status = BT_MESSAGE_ITERATOR_STATUS_END;
+               status = BT_SELF_MESSAGE_ITERATOR_STATUS_END;
        } else if (PyErr_GivenExceptionMatches(exc, py_mod_bt2_exc_try_again_type)) {
-               status = BT_MESSAGE_ITERATOR_STATUS_AGAIN;
+               status = BT_SELF_MESSAGE_ITERATOR_STATUS_AGAIN;
        } else {
                bt2_py_loge_exception();
-               status = BT_MESSAGE_ITERATOR_STATUS_ERROR;
+               status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
        }
 
 end:
@@ -1276,7 +1276,7 @@ bt_py3_component_class_query(
         * (PyLong) containing the address of a BT value object (new
         * reference).
         */
-       *result = (void *) PyLong_AsUnsignedLongLong(py_results_addr);
+       *result = PyLong_AsVoidPtr(py_results_addr);
        BT_ASSERT(!PyErr_Occurred());
        BT_ASSERT(*result);
        goto end;
@@ -1336,17 +1336,18 @@ bt_py3_component_class_message_iterator_init(
                bt_self_component *self_component,
                bt_self_component_port_output *self_component_port_output)
 {
-       bt_self_message_iterator_status status = BT_MESSAGE_ITERATOR_STATUS_OK;
+       bt_self_message_iterator_status status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
        PyObject *py_comp_cls = NULL;
        PyObject *py_iter_cls = NULL;
        PyObject *py_iter_ptr = NULL;
+       PyObject *py_component_port_output_ptr = NULL;
        PyObject *py_init_method_result = NULL;
        PyObject *py_iter = NULL;
        PyObject *py_comp;
 
        py_comp = bt_self_component_get_data(self_component);
 
-       /* Find user's Python notification iterator class */
+       /* Find user's Python message iterator class */
        py_comp_cls = PyObject_GetAttrString(py_comp, "__class__");
        if (!py_comp_cls) {
                BT_LOGE_STR("Cannot get Python object's `__class__` attribute.");
@@ -1367,7 +1368,7 @@ bt_py3_component_class_message_iterator_init(
        }
 
        /*
-        * Create object with borrowed native notification iterator
+        * Create object with borrowed native message iterator
         * reference:
         *
         *     py_iter = py_iter_cls.__new__(py_iter_cls, py_iter_ptr)
@@ -1384,14 +1385,23 @@ bt_py3_component_class_message_iterator_init(
        /*
         * Initialize object:
         *
-        *     py_iter.__init__()
+        *     py_iter.__init__(self_output_port)
+        *
+         * through the _init_for_native helper static method.
         *
         * At this point, py_iter._ptr is set, so this initialization
         * function has access to self._component (which gives it the
         * user Python component object from which the iterator was
         * created).
         */
-       py_init_method_result = PyObject_CallMethod(py_iter, "__init__", NULL);
+        py_component_port_output_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(self_component_port_output),
+               SWIGTYPE_p_bt_self_component_port_output, 0);
+       if (!py_component_port_output_ptr) {
+               BT_LOGE_STR("Failed to create a SWIG pointer object.");
+               goto error;
+       }
+
+       py_init_method_result = PyObject_CallMethod(py_iter, "_init_from_native", "O", py_component_port_output_ptr);
        if (!py_init_method_result) {
                BT_LOGE_STR("User's __init__() method failed.");
                bt2_py_loge_exception();
@@ -1400,20 +1410,20 @@ bt_py3_component_class_message_iterator_init(
 
        /*
         * Since the Python code can never instantiate a user-defined
-        * notification iterator class, the native notification iterator
-        * object does NOT belong to a user Python notification iterator
+        * message iterator class, the native message iterator
+        * object does NOT belong to a user Python message iterator
         * object (borrowed reference). However this Python object is
-        * owned by this native notification iterator object.
+        * owned by this native message iterator object.
         *
-        * In the Python world, the lifetime of the native notification
-        * iterator is managed by a _GenericNotificationIterator
+        * In the Python world, the lifetime of the native message
+        * iterator is managed by a _GenericMessageIterator
         * instance:
         *
-        *     _GenericNotificationIterator instance:
-        *         owns a native bt_notification_iterator object (iter)
+        *     _GenericMessageIterator instance:
+        *         owns a native bt_message_iterator object (iter)
         *             owns a _UserMessageIterator instance (py_iter)
         *                 self._ptr is a borrowed reference to the
-        *                 native bt_private_connection_private_notification_iterator
+        *                 native bt_private_connection_private_message_iterator
         *                 object (iter)
         */
        bt_self_message_iterator_set_data(self_message_iterator, py_iter);
@@ -1441,6 +1451,7 @@ end:
        Py_XDECREF(py_comp_cls);
        Py_XDECREF(py_iter_cls);
        Py_XDECREF(py_iter_ptr);
+       Py_XDECREF(py_component_port_output_ptr);
        Py_XDECREF(py_init_method_result);
        Py_XDECREF(py_iter);
        return status;
@@ -1501,7 +1512,7 @@ bt_py3_component_class_message_iterator_next(
                        bt_message_array_const msgs, uint64_t capacity,
                        uint64_t *count)
 {
-       bt_self_message_iterator_status status = BT_MESSAGE_ITERATOR_STATUS_OK;
+       bt_self_message_iterator_status status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
        PyObject *py_message_iter = bt_self_message_iterator_get_data(message_iterator);
        PyObject *py_method_result = NULL;
 
@@ -1516,12 +1527,10 @@ bt_py3_component_class_message_iterator_next(
 
        /*
         * The returned object, on success, is an integer object
-        * (PyLong) containing the address of a native notification
+        * (PyLong) containing the address of a native message
         * object (which is now ours).
         */
-       msgs[0] =
-               (const bt_message *) PyLong_AsUnsignedLongLong(
-                       py_method_result);
+       msgs[0] = PyLong_AsVoidPtr(py_method_result);
        *count = 1;
 
        /* Clear potential overflow error; should never happen */
This page took 0.028277 seconds and 4 git commands to generate.