Document libbabeltrace2's C API
[babeltrace.git] / src / bindings / python / bt2 / bt2 / native_bt_component.i
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 **)
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 ** {
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 **)
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 **) {
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
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 *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 *user_data {
80 if (PyLong_AsLong($result) == __BT_FUNC_STATUS_OK) {
81 Py_INCREF($1);
82 }
83 }
84
85 %include <babeltrace2/graph/component.h>
86 %include <babeltrace2/graph/self-component.h>
87
88 /*
89 * This type map relies on the rather common "user_data" name, so don't pollute
90 * the typemap namespace.
91 */
92 %clear void *user_data;
This page took 0.031615 seconds and 4 git commands to generate.