Commit | Line | Data |
---|---|---|
6945df9a 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 | ||
2e00bc76 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 | ||
6945df9a SM |
85 | /* From component-const.h */ |
86 | ||
87 | extern const char *bt_component_get_name(const bt_component *component); | |
88 | ||
e874da19 PP |
89 | extern bt_logging_level bt_component_get_logging_level( |
90 | const bt_component *component); | |
91 | ||
6945df9a 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 | ||
752d0e47 SM |
116 | extern const bt_component_class_source * |
117 | bt_component_source_borrow_class_const( | |
118 | const bt_component_source *component); | |
119 | ||
6945df9a 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 | ||
752d0e47 SM |
142 | extern const bt_component_class_filter * |
143 | bt_component_filter_borrow_class_const( | |
144 | const bt_component_filter *component); | |
145 | ||
6945df9a 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 | ||
752d0e47 SM |
179 | extern const bt_component_class_sink * |
180 | bt_component_sink_borrow_class_const( | |
181 | const bt_component_sink *component); | |
182 | ||
6945df9a 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, | |
206 | BT_SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION = 111, | |
207 | BT_SELF_COMPONENT_STATUS_ERROR = -1, | |
208 | BT_SELF_COMPONENT_STATUS_NOMEM = -12, | |
209 | } bt_self_component_status; | |
210 | ||
211 | const bt_component *bt_self_component_as_component( | |
212 | bt_self_component *self_component); | |
213 | ||
214 | extern void *bt_self_component_get_data( | |
215 | const bt_self_component *self_component); | |
216 | ||
217 | extern void bt_self_component_set_data( | |
218 | bt_self_component *self_component, void *data); | |
219 | ||
220 | /* From self-component-source.h */ | |
221 | ||
222 | bt_self_component *bt_self_component_source_as_self_component( | |
223 | bt_self_component_source *self_comp_source); | |
224 | ||
225 | const bt_component_source * | |
226 | bt_self_component_source_as_component_source( | |
227 | bt_self_component_source *self_comp_source); | |
228 | ||
229 | extern bt_self_component_port_output * | |
230 | bt_self_component_source_borrow_output_port_by_name( | |
231 | bt_self_component_source *self_component, | |
232 | const char *name); | |
233 | ||
234 | extern bt_self_component_port_output * | |
235 | bt_self_component_source_borrow_output_port_by_index( | |
236 | bt_self_component_source *self_component, | |
237 | uint64_t index); | |
238 | ||
239 | extern bt_self_component_status | |
240 | bt_self_component_source_add_output_port( | |
241 | bt_self_component_source *self_component, | |
2e00bc76 | 242 | const char *name, void *PY_SELF_PORT_USER_DATA, |
6945df9a SM |
243 | bt_self_component_port_output **OUT); |
244 | ||
245 | /* From self-component-filter.h */ | |
246 | ||
247 | bt_self_component *bt_self_component_filter_as_self_component( | |
248 | bt_self_component_filter *self_comp_filter); | |
249 | ||
250 | const bt_component_filter * | |
251 | bt_self_component_filter_as_component_filter( | |
252 | bt_self_component_filter *self_comp_filter); | |
253 | ||
254 | extern bt_self_component_port_output * | |
255 | bt_self_component_filter_borrow_output_port_by_name( | |
256 | bt_self_component_filter *self_component, | |
257 | const char *name); | |
258 | ||
259 | extern bt_self_component_port_output * | |
260 | bt_self_component_filter_borrow_output_port_by_index( | |
261 | bt_self_component_filter *self_component, | |
262 | uint64_t index); | |
263 | ||
264 | extern bt_self_component_status | |
265 | bt_self_component_filter_add_output_port( | |
266 | bt_self_component_filter *self_component, | |
2e00bc76 | 267 | const char *name, void *PY_SELF_PORT_USER_DATA, |
6945df9a SM |
268 | bt_self_component_port_output **OUT); |
269 | ||
270 | extern bt_self_component_port_input * | |
271 | bt_self_component_filter_borrow_input_port_by_name( | |
272 | bt_self_component_filter *self_component, | |
273 | const char *name); | |
274 | ||
275 | extern bt_self_component_port_input * | |
276 | bt_self_component_filter_borrow_input_port_by_index( | |
277 | bt_self_component_filter *self_component, | |
278 | uint64_t index); | |
279 | ||
280 | extern bt_self_component_status | |
281 | bt_self_component_filter_add_input_port( | |
282 | bt_self_component_filter *self_component, | |
2e00bc76 | 283 | const char *name, void *PY_SELF_PORT_USER_DATA, |
6945df9a SM |
284 | bt_self_component_port_input **OUT); |
285 | ||
286 | /* From self-component-sink.h */ | |
287 | ||
288 | bt_self_component *bt_self_component_sink_as_self_component( | |
289 | bt_self_component_sink *self_comp_sink); | |
290 | ||
291 | const bt_component_sink * | |
292 | bt_self_component_sink_as_component_sink( | |
293 | bt_self_component_sink *self_comp_sink); | |
294 | ||
295 | extern bt_self_component_port_input * | |
296 | bt_self_component_sink_borrow_input_port_by_name( | |
297 | bt_self_component_sink *self_component, | |
298 | const char *name); | |
299 | ||
300 | extern bt_self_component_port_input * | |
301 | bt_self_component_sink_borrow_input_port_by_index( | |
302 | bt_self_component_sink *self_component, uint64_t index); | |
303 | ||
304 | extern bt_self_component_status | |
305 | bt_self_component_sink_add_input_port( | |
306 | bt_self_component_sink *self_component, | |
2e00bc76 | 307 | const char *name, void *PY_SELF_PORT_USER_DATA, |
6945df9a | 308 | bt_self_component_port_input **OUT); |