Commit | Line | Data |
---|---|---|
6fa6bfa1 SM |
1 | /* |
2 | * The MIT License (MIT) | |
3 | * | |
4 | * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com> | |
5 | * | |
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: | |
12 | * | |
13 | * The above copyright notice and this permission notice shall be included in | |
14 | * all copies or substantial portions of the Software. | |
15 | * | |
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 | |
22 | * THE SOFTWARE. | |
23 | */ | |
24 | ||
25 | /* Output argument typemap for self port output (always appends) */ | |
26 | %typemap(in, numinputs=0) | |
27 | (bt_self_component_port_input **OUT) | |
28 | (bt_self_component_port_input *temp_self_port = NULL) { | |
29 | $1 = &temp_self_port; | |
30 | } | |
31 | ||
32 | %typemap(argout) bt_self_component_port_input **OUT { | |
33 | if (*$1) { | |
34 | /* SWIG_Python_AppendOutput() steals the created object */ | |
35 | $result = SWIG_Python_AppendOutput($result, | |
36 | SWIG_NewPointerObj(SWIG_as_voidptr(*$1), | |
37 | SWIGTYPE_p_bt_self_component_port_input, 0)); | |
38 | } else { | |
39 | /* SWIG_Python_AppendOutput() steals Py_None */ | |
40 | Py_INCREF(Py_None); | |
41 | $result = SWIG_Python_AppendOutput($result, Py_None); | |
42 | } | |
43 | } | |
44 | ||
45 | /* Output argument typemap for self port output (always appends) */ | |
46 | %typemap(in, numinputs=0) | |
47 | (bt_self_component_port_output **OUT) | |
48 | (bt_self_component_port_output *temp_self_port = NULL) { | |
49 | $1 = &temp_self_port; | |
50 | } | |
51 | ||
52 | %typemap(argout) (bt_self_component_port_output **OUT) { | |
53 | if (*$1) { | |
54 | /* SWIG_Python_AppendOutput() steals the created object */ | |
55 | $result = SWIG_Python_AppendOutput($result, | |
56 | SWIG_NewPointerObj(SWIG_as_voidptr(*$1), | |
57 | SWIGTYPE_p_bt_self_component_port_output, 0)); | |
58 | } else { | |
59 | /* SWIG_Python_AppendOutput() steals Py_None */ | |
60 | Py_INCREF(Py_None); | |
61 | $result = SWIG_Python_AppendOutput($result, Py_None); | |
62 | } | |
63 | } | |
64 | ||
03ec9ebd SM |
65 | /* Typemaps used for user data attached to self component ports. */ |
66 | ||
67 | /* | |
68 | * The user data Python object is kept as the user data of the port, we pass | |
69 | * the PyObject pointer directly to the port creation function. | |
70 | */ | |
71 | %typemap(in) void *PY_SELF_PORT_USER_DATA { | |
72 | $1 = $input; | |
73 | } | |
74 | ||
75 | /* | |
76 | * The port, if created successfully, now owns a reference to the Python object, | |
77 | * we reflect that here. | |
78 | */ | |
79 | %typemap(argout) void *PY_SELF_PORT_USER_DATA { | |
80 | if (PyLong_AsLong($result) == BT_SELF_COMPONENT_STATUS_OK) { | |
81 | Py_INCREF($1); | |
82 | } | |
83 | } | |
84 | ||
6fa6bfa1 SM |
85 | /* From component-const.h */ |
86 | ||
87 | extern const char *bt_component_get_name(const bt_component *component); | |
88 | ||
cc81b5ab PP |
89 | extern bt_logging_level bt_component_get_logging_level( |
90 | const bt_component *component); | |
91 | ||
6fa6bfa1 SM |
92 | extern const bt_component_class *bt_component_borrow_class_const( |
93 | const bt_component *component); | |
94 | ||
95 | extern bt_component_class_type bt_component_get_class_type( | |
96 | const bt_component *component); | |
97 | ||
98 | bt_bool bt_component_is_source(const bt_component *component); | |
99 | ||
100 | bt_bool bt_component_is_filter(const bt_component *component); | |
101 | ||
102 | bt_bool bt_component_is_sink(const bt_component *component); | |
103 | ||
104 | extern bt_bool bt_component_graph_is_canceled( | |
105 | const bt_component *component); | |
106 | ||
107 | extern void bt_component_get_ref(const bt_component *component); | |
108 | ||
109 | extern void bt_component_put_ref(const bt_component *component); | |
110 | ||
111 | /* From component-source-const.h */ | |
112 | ||
113 | const bt_component *bt_component_source_as_component_const( | |
114 | const bt_component_source *component); | |
115 | ||
61fd44ac SM |
116 | extern const bt_component_class_source * |
117 | bt_component_source_borrow_class_const( | |
118 | const bt_component_source *component); | |
119 | ||
6fa6bfa1 SM |
120 | extern uint64_t bt_component_source_get_output_port_count( |
121 | const bt_component_source *component); | |
122 | ||
123 | extern const bt_port_output * | |
124 | bt_component_source_borrow_output_port_by_name_const( | |
125 | const bt_component_source *component, const char *name); | |
126 | ||
127 | extern const bt_port_output * | |
128 | bt_component_source_borrow_output_port_by_index_const( | |
129 | const bt_component_source *component, uint64_t index); | |
130 | ||
131 | extern void bt_component_source_get_ref( | |
132 | const bt_component_source *component_source); | |
133 | ||
134 | extern void bt_component_source_put_ref( | |
135 | const bt_component_source *component_source); | |
136 | ||
137 | /* From component-filter-const.h */ | |
138 | ||
139 | const bt_component *bt_component_filter_as_component_const( | |
140 | const bt_component_filter *component); | |
141 | ||
61fd44ac SM |
142 | extern const bt_component_class_filter * |
143 | bt_component_filter_borrow_class_const( | |
144 | const bt_component_filter *component); | |
145 | ||
6fa6bfa1 SM |
146 | extern uint64_t bt_component_filter_get_input_port_count( |
147 | const bt_component_filter *component); | |
148 | ||
149 | extern const bt_port_input * | |
150 | bt_component_filter_borrow_input_port_by_name_const( | |
151 | const bt_component_filter *component, const char *name); | |
152 | ||
153 | extern const bt_port_input * | |
154 | bt_component_filter_borrow_input_port_by_index_const( | |
155 | const bt_component_filter *component, uint64_t index); | |
156 | ||
157 | extern uint64_t bt_component_filter_get_output_port_count( | |
158 | const bt_component_filter *component); | |
159 | ||
160 | extern const bt_port_output * | |
161 | bt_component_filter_borrow_output_port_by_name_const( | |
162 | const bt_component_filter *component, const char *name); | |
163 | ||
164 | extern const bt_port_output * | |
165 | bt_component_filter_borrow_output_port_by_index_const( | |
166 | const bt_component_filter *component, uint64_t index); | |
167 | ||
168 | extern void bt_component_filter_get_ref( | |
169 | const bt_component_filter *component_filter); | |
170 | ||
171 | extern void bt_component_filter_put_ref( | |
172 | const bt_component_filter *component_filter); | |
173 | ||
174 | /* From component-sink-const.h */ | |
175 | ||
176 | const bt_component *bt_component_sink_as_component_const( | |
177 | const bt_component_sink *component); | |
178 | ||
61fd44ac SM |
179 | extern const bt_component_class_sink * |
180 | bt_component_sink_borrow_class_const( | |
181 | const bt_component_sink *component); | |
182 | ||
6fa6bfa1 SM |
183 | extern uint64_t bt_component_sink_get_input_port_count( |
184 | const bt_component_sink *component); | |
185 | ||
186 | extern const bt_port_input * | |
187 | bt_component_sink_borrow_input_port_by_name_const( | |
188 | const bt_component_sink *component, const char *name); | |
189 | ||
190 | extern const bt_port_input * | |
191 | bt_component_sink_borrow_input_port_by_index_const( | |
192 | const bt_component_sink *component, uint64_t index); | |
193 | ||
194 | extern void bt_component_sink_get_ref( | |
195 | const bt_component_sink *component_sink); | |
196 | ||
197 | extern void bt_component_sink_put_ref( | |
198 | const bt_component_sink *component_sink); | |
199 | ||
200 | /* From self-component.h */ | |
201 | ||
202 | typedef enum bt_self_component_status { | |
203 | BT_SELF_COMPONENT_STATUS_OK = 0, | |
204 | BT_SELF_COMPONENT_STATUS_END = 1, | |
205 | BT_SELF_COMPONENT_STATUS_AGAIN = 11, | |
6fa6bfa1 SM |
206 | BT_SELF_COMPONENT_STATUS_ERROR = -1, |
207 | BT_SELF_COMPONENT_STATUS_NOMEM = -12, | |
208 | } bt_self_component_status; | |
209 | ||
210 | const bt_component *bt_self_component_as_component( | |
211 | bt_self_component *self_component); | |
212 | ||
213 | extern void *bt_self_component_get_data( | |
214 | const bt_self_component *self_component); | |
215 | ||
216 | extern void bt_self_component_set_data( | |
217 | bt_self_component *self_component, void *data); | |
218 | ||
219 | /* From self-component-source.h */ | |
220 | ||
221 | bt_self_component *bt_self_component_source_as_self_component( | |
222 | bt_self_component_source *self_comp_source); | |
223 | ||
224 | const bt_component_source * | |
225 | bt_self_component_source_as_component_source( | |
226 | bt_self_component_source *self_comp_source); | |
227 | ||
228 | extern bt_self_component_port_output * | |
229 | bt_self_component_source_borrow_output_port_by_name( | |
230 | bt_self_component_source *self_component, | |
231 | const char *name); | |
232 | ||
233 | extern bt_self_component_port_output * | |
234 | bt_self_component_source_borrow_output_port_by_index( | |
235 | bt_self_component_source *self_component, | |
236 | uint64_t index); | |
237 | ||
238 | extern bt_self_component_status | |
239 | bt_self_component_source_add_output_port( | |
240 | bt_self_component_source *self_component, | |
03ec9ebd | 241 | const char *name, void *PY_SELF_PORT_USER_DATA, |
6fa6bfa1 SM |
242 | bt_self_component_port_output **OUT); |
243 | ||
244 | /* From self-component-filter.h */ | |
245 | ||
246 | bt_self_component *bt_self_component_filter_as_self_component( | |
247 | bt_self_component_filter *self_comp_filter); | |
248 | ||
249 | const bt_component_filter * | |
250 | bt_self_component_filter_as_component_filter( | |
251 | bt_self_component_filter *self_comp_filter); | |
252 | ||
253 | extern bt_self_component_port_output * | |
254 | bt_self_component_filter_borrow_output_port_by_name( | |
255 | bt_self_component_filter *self_component, | |
256 | const char *name); | |
257 | ||
258 | extern bt_self_component_port_output * | |
259 | bt_self_component_filter_borrow_output_port_by_index( | |
260 | bt_self_component_filter *self_component, | |
261 | uint64_t index); | |
262 | ||
263 | extern bt_self_component_status | |
264 | bt_self_component_filter_add_output_port( | |
265 | bt_self_component_filter *self_component, | |
03ec9ebd | 266 | const char *name, void *PY_SELF_PORT_USER_DATA, |
6fa6bfa1 SM |
267 | bt_self_component_port_output **OUT); |
268 | ||
269 | extern bt_self_component_port_input * | |
270 | bt_self_component_filter_borrow_input_port_by_name( | |
271 | bt_self_component_filter *self_component, | |
272 | const char *name); | |
273 | ||
274 | extern bt_self_component_port_input * | |
275 | bt_self_component_filter_borrow_input_port_by_index( | |
276 | bt_self_component_filter *self_component, | |
277 | uint64_t index); | |
278 | ||
279 | extern bt_self_component_status | |
280 | bt_self_component_filter_add_input_port( | |
281 | bt_self_component_filter *self_component, | |
03ec9ebd | 282 | const char *name, void *PY_SELF_PORT_USER_DATA, |
6fa6bfa1 SM |
283 | bt_self_component_port_input **OUT); |
284 | ||
285 | /* From self-component-sink.h */ | |
286 | ||
287 | bt_self_component *bt_self_component_sink_as_self_component( | |
288 | bt_self_component_sink *self_comp_sink); | |
289 | ||
290 | const bt_component_sink * | |
291 | bt_self_component_sink_as_component_sink( | |
292 | bt_self_component_sink *self_comp_sink); | |
293 | ||
294 | extern bt_self_component_port_input * | |
295 | bt_self_component_sink_borrow_input_port_by_name( | |
296 | bt_self_component_sink *self_component, | |
297 | const char *name); | |
298 | ||
299 | extern bt_self_component_port_input * | |
300 | bt_self_component_sink_borrow_input_port_by_index( | |
301 | bt_self_component_sink *self_component, uint64_t index); | |
302 | ||
303 | extern bt_self_component_status | |
304 | bt_self_component_sink_add_input_port( | |
305 | bt_self_component_sink *self_component, | |
03ec9ebd | 306 | const char *name, void *PY_SELF_PORT_USER_DATA, |
6fa6bfa1 | 307 | bt_self_component_port_input **OUT); |