doc/api/libbabeltrace2/DoxygenLayout.xml: use `topics` tab
[babeltrace.git] / src / python-plugin-provider / python-plugin-provider.c
index c6b606564ced4e564eebdda8e0e58009defb409e..4df648527d93afc824e64cd8e675969f3a7b2a88 100644 (file)
@@ -1,27 +1,9 @@
 /*
- * python-plugin-provider.c
- *
- * Babeltrace Python plugin provider
+ * SPDX-License-Identifier: MIT
  *
  * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Babeltrace Python plugin provider
  */
 
 #define BT_LOG_TAG "LIB/PLUGIN-PY"
 
 #include "common/macros.h"
 #include "compat/compiler.h"
-#include <babeltrace2/plugin/plugin-const.h>
+#include <babeltrace2/plugin/plugin-loading.h>
 #include "lib/plugin/plugin.h"
 #include <babeltrace2/graph/component-class.h>
-#include <babeltrace2/current-thread.h>
+#include <babeltrace2/error-reporting.h>
 #include "lib/graph/component-class.h"
 #include "py-common/py-common.h"
 #include <stdbool.h>
 #include <signal.h>
 #include <Python.h>
 #include <glib.h>
-#include <gmodule.h>
 
 #define PYTHON_PLUGIN_FILE_PREFIX      "bt_plugin_"
 #define PYTHON_PLUGIN_FILE_PREFIX_LEN  (sizeof(PYTHON_PLUGIN_FILE_PREFIX) - 1)
 #define PYTHON_PLUGIN_FILE_EXT         ".py"
 #define PYTHON_PLUGIN_FILE_EXT_LEN     (sizeof(PYTHON_PLUGIN_FILE_EXT) - 1)
 
-enum python_state {
+static enum python_state {
        /* init_python() not called yet */
        PYTHON_STATE_NOT_INITED,
 
@@ -82,7 +63,7 @@ void append_python_traceback_error_cause(void)
                }
 
                (void) BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(
-                       "Babeltrace library", "%s", exc->str);
+                       BT_LIB_LOG_LIBBABELTRACE2_NAME, "%s", exc->str);
        }
 
 end:
@@ -103,8 +84,8 @@ void log_python_traceback(int log_level)
                        goto end;
                }
 
-               BT_LOG_WRITE(log_level, BT_LOG_TAG,
-                       "Exception occured: Python traceback:\n%s", exc->str);
+               BT_LOG_WRITE_PRINTF(log_level, BT_LOG_TAG,
+                       "Exception occurred: Python traceback:\n%s", exc->str);
        }
 
 end:
@@ -143,7 +124,7 @@ int init_python(void)
                ret = BT_FUNC_STATUS_ERROR;
                goto end;
        default:
-               abort();
+               bt_common_abort();
        }
 
        /*
@@ -589,7 +570,7 @@ int bt_plugin_from_python_plugin_info(PyObject *plugin_info,
                                        bt_plugin_get_name(*plugin_out),
                                        comp_class,
                                        bt_component_class_get_name(comp_class),
-                                       bt_component_class_type_string(
+                                       bt_common_component_class_type_string(
                                                bt_component_class_get_type(comp_class)));
                                goto error;
                        }
@@ -614,7 +595,7 @@ end:
        return status;
 }
 
-G_MODULE_EXPORT
+BT_EXPORT
 int bt_plugin_python_create_all_from_file(const char *path,
                bool fail_on_load_error, struct bt_plugin_set **plugin_set_out)
 {
@@ -682,7 +663,7 @@ int bt_plugin_python_create_all_from_file(const char *path,
        /*
         * Initialize Python now.
         *
-        * This is not done in the library contructor because the
+        * This is not done in the library constructor because the
         * interpreter is somewhat slow to initialize. If you don't
         * have any potential Python plugins, you don't need to endure
         * this waiting time everytime you load the library.
This page took 0.025475 seconds and 4 git commands to generate.