2 * The MIT License (MIT)
4 * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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
26 # error Unsupported output language
32 #define BT_LOG_TAG "PY-NATIVE"
35 #include <babeltrace/babeltrace.h>
37 typedef const unsigned char *BTUUID;
42 /* For uint*_t/int*_t */
45 /* Remove `bt_` and `BT_` prefixes from function names and enumeration items */
46 %rename("%(strip:[bt_])s", %$isfunction) "";
47 %rename("%(strip:[BT_])s", %$isenumitem) "";
49 /* Output argument typemap for string output (always appends) */
50 %typemap(in, numinputs=0) const char **BTOUTSTR (char *temp_value = NULL) {
54 %typemap(argout) const char **BTOUTSTR {
56 /* SWIG_Python_AppendOutput() steals the created object */
57 $result = SWIG_Python_AppendOutput($result, SWIG_Python_str_FromChar(*$1));
59 /* SWIG_Python_AppendOutput() steals Py_None */
61 $result = SWIG_Python_AppendOutput($result, Py_None);
65 /* Output argument typemap for field type output (always appends) */
66 %typemap(in, numinputs=0) struct bt_ctf_field_type **BTOUTFT (struct bt_ctf_field_type *temp_ft = NULL) {
70 %typemap(argout) struct bt_ctf_field_type **BTOUTFT {
72 /* SWIG_Python_AppendOutput() steals the created object */
73 $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_ctf_field_type, 0));
75 /* SWIG_Python_AppendOutput() steals Py_None */
77 $result = SWIG_Python_AppendOutput($result, Py_None);
81 /* Output argument typemap for component output (always appends) */
82 %typemap(in, numinputs=0) struct bt_component **BTOUTCOMP (struct bt_component *temp_comp = NULL) {
86 %typemap(argout) struct bt_component **BTOUTCOMP {
88 /* SWIG_Python_AppendOutput() steals the created object */
89 $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_component, 0));
91 /* SWIG_Python_AppendOutput() steals Py_None */
93 $result = SWIG_Python_AppendOutput($result, Py_None);
97 /* Output argument typemap for connection output (always appends) */
98 %typemap(in, numinputs=0) struct bt_connection **BTOUTCONN (struct bt_connection *temp_conn = NULL) {
102 %typemap(argout) struct bt_connection **BTOUTCONN {
104 /* SWIG_Python_AppendOutput() steals the created object */
105 $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_connection, 0));
107 /* SWIG_Python_AppendOutput() steals Py_None */
109 $result = SWIG_Python_AppendOutput($result, Py_None);
113 /* Output argument typemap for private port output (always appends) */
114 %typemap(in, numinputs=0) struct bt_private_port **BTOUTPRIVPORT (struct bt_private_port *temp_priv_port = NULL) {
115 $1 = &temp_priv_port;
118 %typemap(argout) struct bt_private_port **BTOUTPRIVPORT {
120 /* SWIG_Python_AppendOutput() steals the created object */
121 $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_private_port, 0));
123 /* SWIG_Python_AppendOutput() steals Py_None */
125 $result = SWIG_Python_AppendOutput($result, Py_None);
129 /* Output argument typemap for initialized uint64_t output parameter (always appends) */
130 %typemap(in, numinputs=0) uint64_t *OUTPUTINIT (uint64_t temp = -1ULL) {
134 %typemap(argout) uint64_t *OUTPUTINIT {
135 $result = SWIG_Python_AppendOutput(resultobj, SWIG_From_unsigned_SS_long_SS_long((*$1)));
138 /* Output argument typemap for initialized unsigned int output parameter (always appends) */
139 %typemap(in, numinputs=0) unsigned int *OUTPUTINIT (unsigned int temp = -1) {
143 %typemap(argout) unsigned int *OUTPUTINIT {
144 $result = SWIG_Python_AppendOutput(resultobj, SWIG_From_unsigned_SS_long_SS_long((uint64_t) (*$1)));
147 /* Input argument typemap for UUID bytes */
148 %typemap(in) BTUUID {
149 $1 = (unsigned char *) PyBytes_AsString($input);
152 /* Output argument typemap for UUID bytes */
153 %typemap(out) BTUUID {
158 $result = PyBytes_FromStringAndSize((const char *) $1, 16);
163 * Input and output argument typemaps for raw Python objects (direct).
165 * Those typemaps honor the convention of Python C function calls with
166 * respect to reference counting: parameters are passed as borrowed
167 * references, and objects are returned as new references. The wrapped
168 * C function must ensure that the return value is always a new
169 * reference, and never steal parameter references.
171 %typemap(in) PyObject * {
175 %typemap(out) PyObject * {
179 /* Per-module interface files */
180 %include "native_btccpriomap.i"
181 %include "native_btclockclass.i"
182 %include "native_btcomponent.i"
183 %include "native_btcomponentclass.i"
184 %include "native_btconnection.i"
185 %include "native_btctfwriter.i"
186 %include "native_btevent.i"
187 %include "native_bteventclass.i"
188 %include "native_btfields.i"
189 %include "native_btft.i"
190 %include "native_btgraph.i"
191 %include "native_btlogging.i"
192 %include "native_btnotification.i"
193 %include "native_btnotifiter.i"
194 %include "native_btpacket.i"
195 %include "native_btplugin.i"
196 %include "native_btport.i"
197 %include "native_btref.i"
198 %include "native_btstream.i"
199 %include "native_btstreamclass.i"
200 %include "native_bttrace.i"
201 %include "native_btvalues.i"
202 %include "native_btversion.i"