2 * The MIT License (MIT)
4 * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 #include <babeltrace/plugin/plugin.h>
34 enum bt_plugin_status {
35 BT_PLUGIN_STATUS_OK = 0,
36 BT_PLUGIN_STATUS_ERROR = -1,
37 BT_PLUGIN_STATUS_NOMEM = -4,
41 const char *bt_plugin_get_name(struct bt_plugin *plugin);
42 const char *bt_plugin_get_author(struct bt_plugin *plugin);
43 const char *bt_plugin_get_license(struct bt_plugin *plugin);
44 const char *bt_plugin_get_description(struct bt_plugin *plugin);
45 const char *bt_plugin_get_path(struct bt_plugin *plugin);
46 enum bt_plugin_status bt_plugin_get_version(struct bt_plugin *plugin,
47 unsigned int *OUTPUT, unsigned int *OUTPUT, unsigned int *OUTPUT,
48 const char **BTOUTSTR);
49 int bt_plugin_get_component_class_count(struct bt_plugin *plugin);
50 struct bt_component_class *bt_plugin_get_component_class(
51 struct bt_plugin *plugin, size_t index);
52 struct bt_component_class *bt_plugin_get_component_class_by_name_and_type(
53 struct bt_plugin *plugin, const char *name,
54 enum bt_component_class_type type);
55 struct bt_plugin *bt_plugin_create_from_name(const char *plugin_name);
58 static PyObject *bt_py3_plugin_ptrs_list_from_bt_plugins(struct bt_plugin **plugins)
60 PyObject *py_plugin_ptrs = NULL;
61 struct bt_plugin **plugin_at;
67 py_plugin_ptrs = PyList_New(0);
68 if (!py_plugin_ptrs) {
75 struct bt_plugin *plugin = *plugin_at;
76 PyObject *py_plugin_ptr;
79 py_plugin_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(plugin),
80 SWIGTYPE_p_bt_plugin, 0);
85 ret = PyList_Append(py_plugin_ptrs, py_plugin_ptr);
86 Py_DECREF(py_plugin_ptr);
97 Py_XDECREF(py_plugin_ptrs);
98 py_plugin_ptrs = Py_None;
99 Py_INCREF(py_plugin_ptrs);
103 * Put existing plugin references since they are not
104 * moved to the caller.
117 return py_plugin_ptrs;
120 static PyObject *bt_py3_plugin_create_all_from_file(const char *path)
122 return bt_py3_plugin_ptrs_list_from_bt_plugins(
123 bt_plugin_create_all_from_file(path));
126 static PyObject *bt_py3_plugin_create_all_from_dir(const char *path,
129 return bt_py3_plugin_ptrs_list_from_bt_plugins(
130 bt_plugin_create_all_from_dir(path, recurse));
134 PyObject *bt_py3_plugin_create_all_from_file(const char *path);
135 PyObject *bt_py3_plugin_create_all_from_dir(const char *path,