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
25 /* Output argument typemap for plugin output (always appends) */
26 %typemap(in, numinputs=0)
27 (const bt_plugin **OUT)
28 (bt_plugin *temp_plugin = NULL) {
33 (const bt_plugin **OUT) {
35 /* SWIG_Python_AppendOutput() steals the created object */
36 $result = SWIG_Python_AppendOutput($result,
37 SWIG_NewPointerObj(SWIG_as_voidptr(*$1),
38 SWIGTYPE_p_bt_plugin, 0));
40 /* SWIG_Python_AppendOutput() steals Py_None */
42 $result = SWIG_Python_AppendOutput($result, Py_None);
46 /* Output argument typemap for plugin set output (always appends) */
47 %typemap(in, numinputs=0)
48 (const bt_plugin_set **OUT)
49 (bt_plugin_set *temp_plugin_set = NULL) {
50 $1 = &temp_plugin_set;
54 (const bt_plugin_set **OUT) {
56 /* SWIG_Python_AppendOutput() steals the created object */
57 $result = SWIG_Python_AppendOutput($result,
58 SWIG_NewPointerObj(SWIG_as_voidptr(*$1),
59 SWIGTYPE_p_bt_plugin_set, 0));
61 /* SWIG_Python_AppendOutput() steals Py_None */
63 $result = SWIG_Python_AppendOutput($result, Py_None);
67 /* From plugin-const.h */
69 typedef enum bt_plugin_status {
70 BT_PLUGIN_STATUS_OK = 0,
71 BT_PLUGIN_STATUS_NOT_FOUND = 2,
72 BT_PLUGIN_STATUS_ERROR = -1,
73 BT_PLUGIN_STATUS_LOADING_ERROR = -2,
74 BT_PLUGIN_STATUS_NOMEM = -12,
77 extern const char *bt_plugin_get_name(const bt_plugin *plugin);
79 extern const char *bt_plugin_get_author(const bt_plugin *plugin);
81 extern const char *bt_plugin_get_license(const bt_plugin *plugin);
83 extern const char *bt_plugin_get_description(const bt_plugin *plugin);
85 extern const char *bt_plugin_get_path(const bt_plugin *plugin);
87 extern uint64_t bt_plugin_get_source_component_class_count(
88 const bt_plugin *plugin);
90 extern uint64_t bt_plugin_get_filter_component_class_count(
91 const bt_plugin *plugin);
93 extern uint64_t bt_plugin_get_sink_component_class_count(
94 const bt_plugin *plugin);
96 extern const bt_component_class_source *
97 bt_plugin_borrow_source_component_class_by_index_const(
98 const bt_plugin *plugin, uint64_t index);
100 extern const bt_component_class_filter *
101 bt_plugin_borrow_filter_component_class_by_index_const(
102 const bt_plugin *plugin, uint64_t index);
104 extern const bt_component_class_sink *
105 bt_plugin_borrow_sink_component_class_by_index_const(
106 const bt_plugin *plugin, uint64_t index);
108 extern const bt_component_class_source *
109 bt_plugin_borrow_source_component_class_by_name_const(
110 const bt_plugin *plugin, const char *name);
112 extern const bt_component_class_filter *
113 bt_plugin_borrow_filter_component_class_by_name_const(
114 const bt_plugin *plugin, const char *name);
116 extern const bt_component_class_sink *
117 bt_plugin_borrow_sink_component_class_by_name_const(
118 const bt_plugin *plugin, const char *name);
120 extern void bt_plugin_get_ref(const bt_plugin *plugin);
122 extern void bt_plugin_put_ref(const bt_plugin *plugin);
124 /* From plugin-set-const.h */
126 extern uint64_t bt_plugin_set_get_plugin_count(
127 const bt_plugin_set *plugin_set);
129 extern const bt_plugin *bt_plugin_set_borrow_plugin_by_index_const(
130 const bt_plugin_set *plugin_set, uint64_t index);
132 extern void bt_plugin_set_get_ref(const bt_plugin_set *plugin_set);
134 extern void bt_plugin_set_put_ref(const bt_plugin_set *plugin_set);
138 bt_property_availability bt_plugin_get_version_wrapper(
139 const bt_plugin *plugin, unsigned int *OUT,
140 unsigned int *OUT, unsigned int *OUT, const char **OUT);
142 bt_plugin_status bt_plugin_find_wrapper(const char *plugin_name,
143 bt_bool fail_on_load_error, const bt_plugin **OUT);
145 bt_plugin_status bt_plugin_find_all_from_file_wrapper(
146 const char *path, bt_bool fail_on_load_error,
147 const bt_plugin_set **OUT);
149 bt_plugin_status bt_plugin_find_all_from_dir_wrapper(
150 const char *path, bt_bool recurse, bt_bool fail_on_load_error,
151 const bt_plugin_set **OUT);
156 * This *_wrapper() functions below ensure that when the API function
157 * fails, the output parameter is set to `NULL`. This is necessary
158 * because the epilogue of the `something **OUT` typemap will use that
159 * value to make a Python object. We can't rely on the initial value of
160 * `*OUT`; it could point to unreadable memory.
163 bt_property_availability bt_plugin_get_version_wrapper(
164 const bt_plugin *plugin, unsigned int *major,
165 unsigned int *minor, unsigned int *patch, const char **extra)
167 bt_property_availability ret;
169 ret = bt_plugin_get_version(plugin, major, minor, patch, extra);
171 if (ret == BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE) {
178 bt_plugin_status bt_plugin_find_wrapper(const char *plugin_name,
179 bt_bool fail_on_load_error, const bt_plugin **plugin)
181 bt_plugin_status status;
183 status = bt_plugin_find(plugin_name, fail_on_load_error,
185 if (status != BT_PLUGIN_STATUS_OK) {
192 bt_plugin_status bt_plugin_find_all_from_file_wrapper(
193 const char *path, bt_bool fail_on_load_error,
194 const bt_plugin_set **plugin_set)
196 bt_plugin_status status;
198 status = bt_plugin_find_all_from_file(path, fail_on_load_error,
200 if (status != BT_PLUGIN_STATUS_OK) {
207 bt_plugin_status bt_plugin_find_all_from_dir_wrapper(
208 const char *path, bt_bool recurse, bt_bool fail_on_load_error,
209 const bt_plugin_set **plugin_set)
211 bt_plugin_status status;
213 status = bt_plugin_find_all_from_dir(path, recurse, fail_on_load_error,
215 if (status != BT_PLUGIN_STATUS_OK) {