Commit | Line | Data |
---|---|---|
6945df9a | 1 | /* |
0235b0db | 2 | * SPDX-License-Identifier: MIT |
6945df9a SM |
3 | * |
4 | * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com> | |
6945df9a SM |
5 | */ |
6 | ||
7 | /* Output argument typemap for self port output (always appends) */ | |
8 | %typemap(in, numinputs=0) | |
d6bb425c | 9 | (bt_self_component_port_input **) |
6945df9a SM |
10 | (bt_self_component_port_input *temp_self_port = NULL) { |
11 | $1 = &temp_self_port; | |
12 | } | |
13 | ||
d6bb425c | 14 | %typemap(argout) bt_self_component_port_input ** { |
6945df9a SM |
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) | |
d6bb425c | 29 | (bt_self_component_port_output **) |
6945df9a SM |
30 | (bt_self_component_port_output *temp_self_port = NULL) { |
31 | $1 = &temp_self_port; | |
32 | } | |
33 | ||
d6bb425c | 34 | %typemap(argout) (bt_self_component_port_output **) { |
6945df9a SM |
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 | ||
2e00bc76 SM |
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 | */ | |
d6bb425c | 53 | %typemap(in) void *user_data { |
2e00bc76 SM |
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 | */ | |
d6bb425c | 61 | %typemap(argout) void *user_data { |
d24d5663 | 62 | if (PyLong_AsLong($result) == __BT_FUNC_STATUS_OK) { |
2e00bc76 SM |
63 | Py_INCREF($1); |
64 | } | |
65 | } | |
66 | ||
43c59509 | 67 | %include <babeltrace2/graph/component.h> |
d6bb425c | 68 | %include <babeltrace2/graph/self-component.h> |
6945df9a | 69 | |
d6bb425c SM |
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; |