Move to kernel style SPDX license identifiers
[babeltrace.git] / src / bindings / python / bt2 / bt2 / native_bt_component.i
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
5 */
6
7 /* Output argument typemap for self port output (always appends) */
8 %typemap(in, numinputs=0)
9 (bt_self_component_port_input **)
10 (bt_self_component_port_input *temp_self_port = NULL) {
11 $1 = &temp_self_port;
12 }
13
14 %typemap(argout) bt_self_component_port_input ** {
15 if (*$1) {
16 /* SWIG_Python_AppendOutput() steals the created object */
17 $result = SWIG_Python_AppendOutput($result,
18 SWIG_NewPointerObj(SWIG_as_voidptr(*$1),
19 SWIGTYPE_p_bt_self_component_port_input, 0));
20 } else {
21 /* SWIG_Python_AppendOutput() steals Py_None */
22 Py_INCREF(Py_None);
23 $result = SWIG_Python_AppendOutput($result, Py_None);
24 }
25 }
26
27 /* Output argument typemap for self port output (always appends) */
28 %typemap(in, numinputs=0)
29 (bt_self_component_port_output **)
30 (bt_self_component_port_output *temp_self_port = NULL) {
31 $1 = &temp_self_port;
32 }
33
34 %typemap(argout) (bt_self_component_port_output **) {
35 if (*$1) {
36 /* SWIG_Python_AppendOutput() steals the created object */
37 $result = SWIG_Python_AppendOutput($result,
38 SWIG_NewPointerObj(SWIG_as_voidptr(*$1),
39 SWIGTYPE_p_bt_self_component_port_output, 0));
40 } else {
41 /* SWIG_Python_AppendOutput() steals Py_None */
42 Py_INCREF(Py_None);
43 $result = SWIG_Python_AppendOutput($result, Py_None);
44 }
45 }
46
47 /* Typemaps used for user data attached to self component ports. */
48
49 /*
50 * The user data Python object is kept as the user data of the port, we pass
51 * the PyObject pointer directly to the port creation function.
52 */
53 %typemap(in) void *user_data {
54 $1 = $input;
55 }
56
57 /*
58 * The port, if created successfully, now owns a reference to the Python object,
59 * we reflect that here.
60 */
61 %typemap(argout) void *user_data {
62 if (PyLong_AsLong($result) == __BT_FUNC_STATUS_OK) {
63 Py_INCREF($1);
64 }
65 }
66
67 %include <babeltrace2/graph/component.h>
68 %include <babeltrace2/graph/self-component.h>
69
70 /*
71 * This type map relies on the rather common "user_data" name, so don't pollute
72 * the typemap namespace.
73 */
74 %clear void *user_data;
This page took 0.030787 seconds and 4 git commands to generate.