tap-driver.sh: flush stdout after each test result
[babeltrace.git] / python-plugin-provider / python-plugin-provider.c
index 9044d8a23f1ed373e1eb343438710e30d0caf637..8e5ee08e303b50992ff1aa3efda1c1519124fb20 100644 (file)
  */
 
 #define BT_LOG_TAG "PLUGIN-PY"
-#include "logging.h"
-
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/ref.h>
-#include <babeltrace/plugin/plugin.h>
-#include <babeltrace/plugin/plugin-internal.h>
-#include <babeltrace/graph/component-class.h>
-#include <babeltrace/graph/component-class-internal.h>
+
+#include <babeltrace2/babeltrace-internal.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/plugin/plugin-const.h>
+#include <babeltrace2/plugin/plugin-internal.h>
+#include <babeltrace2/graph/component-class.h>
+#include <babeltrace2/graph/component-class-internal.h>
 #include <stdlib.h>
 #include <signal.h>
 #include <Python.h>
@@ -158,9 +156,9 @@ void fini_python(void) {
 }
 
 static
-struct bt_plugin *bt_plugin_from_python_plugin_info(PyObject *plugin_info)
+bt_plugin *bt_plugin_from_python_plugin_info(PyObject *plugin_info)
 {
-       struct bt_plugin *plugin = NULL;
+       bt_plugin *plugin = NULL;
        PyObject *py_name = NULL;
        PyObject *py_author = NULL;
        PyObject *py_description = NULL;
@@ -175,8 +173,8 @@ struct bt_plugin *bt_plugin_from_python_plugin_info(PyObject *plugin_info)
        const char *version_extra = NULL;
        int ret;
 
-       assert(plugin_info);
-       assert(python_state == PYTHON_STATE_FULLY_INITIALIZED);
+       BT_ASSERT(plugin_info);
+       BT_ASSERT(python_state == PYTHON_STATE_FULLY_INITIALIZED);
        py_name = PyObject_GetAttrString(plugin_info, "name");
        if (!py_name) {
                BT_LOGW("Cannot find `name` attribute in Python plugin info object: "
@@ -267,9 +265,9 @@ struct bt_plugin *bt_plugin_from_python_plugin_info(PyObject *plugin_info)
                        PyObject *py_minor = PyTuple_GetItem(py_version, 1);
                        PyObject *py_patch = PyTuple_GetItem(py_version, 2);
 
-                       assert(py_major);
-                       assert(py_minor);
-                       assert(py_patch);
+                       BT_ASSERT(py_major);
+                       BT_ASSERT(py_minor);
+                       BT_ASSERT(py_patch);
 
                        if (PyLong_Check(py_major)) {
                                major = PyLong_AsUnsignedLong(py_major);
@@ -294,7 +292,7 @@ struct bt_plugin *bt_plugin_from_python_plugin_info(PyObject *plugin_info)
                if (PyTuple_Size(py_version) >= 4) {
                        PyObject *py_extra = PyTuple_GetItem(py_version, 3);
 
-                       assert(py_extra);
+                       BT_ASSERT(py_extra);
 
                        if (PyUnicode_Check(py_extra)) {
                                version_extra = PyUnicode_AsUTF8(py_extra);
@@ -333,15 +331,14 @@ struct bt_plugin *bt_plugin_from_python_plugin_info(PyObject *plugin_info)
                size_t i;
 
                for (i = 0; i < PyList_Size(py_comp_class_addrs); i++) {
-                       struct bt_component_class *comp_class;
+                       bt_component_class *comp_class;
                        PyObject *py_comp_class_addr;
 
                        py_comp_class_addr =
                                PyList_GetItem(py_comp_class_addrs, i);
-                       assert(py_comp_class_addr);
+                       BT_ASSERT(py_comp_class_addr);
                        if (PyLong_Check(py_comp_class_addr)) {
-                               comp_class = (struct bt_component_class *)
-                                       PyLong_AsUnsignedLongLong(py_comp_class_addr);
+                               comp_class = PyLong_AsVoidPtr(py_comp_class_addr);
                        } else {
                                BT_LOGW("Component class address is not an integer in Python plugin info object: "
                                        "py-plugin-info-addr=%p, index=%zu",
@@ -368,14 +365,12 @@ struct bt_plugin *bt_plugin_from_python_plugin_info(PyObject *plugin_info)
                }
        }
 
-       bt_plugin_freeze(plugin);
-
        goto end;
 
 error:
        print_python_traceback_warn();
        pyerr_clear();
-       BT_PUT(plugin);
+       BT_OBJECT_PUT_REF_AND_RESET(plugin);
 
 end:
        Py_XDECREF(py_name);
@@ -388,15 +383,15 @@ end:
 }
 
 G_MODULE_EXPORT
-struct bt_plugin_set *bt_plugin_python_create_all_from_file(const char *path)
+bt_plugin_set *bt_plugin_python_create_all_from_file(const char *path)
 {
-       struct bt_plugin_set *plugin_set = NULL;
-       struct bt_plugin *plugin = NULL;
+       bt_plugin_set *plugin_set = NULL;
+       bt_plugin *plugin = NULL;
        PyObject *py_plugin_info = NULL;
        gchar *basename = NULL;
        size_t path_len;
 
-       assert(path);
+       BT_ASSERT(path);
 
        if (python_state == PYTHON_STATE_CANNOT_INITIALIZE) {
                /*
@@ -492,10 +487,10 @@ struct bt_plugin_set *bt_plugin_python_create_all_from_file(const char *path)
        goto end;
 
 error:
-       BT_PUT(plugin_set);
+       BT_OBJECT_PUT_REF_AND_RESET(plugin_set);
 
 end:
-       bt_put(plugin);
+       bt_plugin_put_ref(plugin);
        Py_XDECREF(py_plugin_info);
        g_free(basename);
        return plugin_set;
This page took 0.038112 seconds and 4 git commands to generate.