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>
36 #include <babeltrace/property.h>
37 #include <babeltrace/assert-internal.h>
39 typedef const uint8_t *bt_uuid;
44 /* For uint*_t/int*_t */
48 * Remove `bt_` and `BT_` prefixes from function names, global variables and
51 %rename("%(strip:[bt_])s", %$isfunction) "";
52 %rename("%(strip:[bt_])s", %$isvariable) "";
53 %rename("%(strip:[BT_])s", %$isenumitem) "";
55 /* Output argument typemap for string output (always appends) */
56 %typemap(in, numinputs=0) (const char **OUT) (char *temp_value) {
60 %typemap(argout) (const char **OUT) {
62 /* SWIG_Python_AppendOutput() steals the created object */
63 $result = SWIG_Python_AppendOutput($result, SWIG_Python_str_FromChar(*$1));
65 /* SWIG_Python_AppendOutput() steals Py_None */
67 $result = SWIG_Python_AppendOutput($result, Py_None);
71 /* Output argument typemap for value output (always appends) */
72 %typemap(in, numinputs=0) (bt_value **OUT) (struct bt_value *temp_value = NULL) {
76 %typemap(argout) (bt_value **OUT) {
78 /* SWIG_Python_AppendOutput() steals the created object */
79 $result = SWIG_Python_AppendOutput($result,
80 SWIG_NewPointerObj(SWIG_as_voidptr(*$1),
81 SWIGTYPE_p_bt_value, 0));
83 /* SWIG_Python_AppendOutput() steals Py_None */
85 $result = SWIG_Python_AppendOutput($result, Py_None);
89 /* Output argument typemap for initialized uint64_t output parameter (always appends) */
90 %typemap(in, numinputs=0) (uint64_t *OUT) (uint64_t temp) {
94 %typemap(argout) uint64_t *OUT {
95 $result = SWIG_Python_AppendOutput(resultobj,
96 SWIG_From_unsigned_SS_long_SS_long((*$1)));
99 /* Output argument typemap for initialized int64_t output parameter (always appends) */
100 %typemap(in, numinputs=0) (int64_t *OUT) (int64_t temp) {
104 %typemap(argout) (int64_t *OUT) {
105 $result = SWIG_Python_AppendOutput(resultobj, SWIG_From_long_SS_long((*$1)));
108 /* Output argument typemap for initialized unsigned int output parameter (always appends) */
109 %typemap(in, numinputs=0) (unsigned int *OUT) (unsigned int temp) {
113 %typemap(argout) (unsigned int *OUT) {
114 $result = SWIG_Python_AppendOutput(resultobj,
115 SWIG_From_unsigned_SS_long_SS_long((uint64_t) (*$1)));
117 /* Output argument typemap for initialized double output parameter (always appends) */
118 %typemap(in, numinputs=0) (double *OUT) (double temp) {
122 %typemap(argout) (double *OUT) {
123 $result = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*$1)));
126 /* Input argument typemap for UUID bytes */
127 %typemap(in) bt_uuid {
128 $1 = (unsigned char *) PyBytes_AsString($input);
131 /* Output argument typemap for UUID bytes */
132 %typemap(out) bt_uuid {
137 $result = PyBytes_FromStringAndSize((const char *) $1, 16);
141 /* Input argument typemap for bt_bool */
142 %typemap(in) bt_bool {
143 $1 = PyObject_IsTrue($input);
146 /* Output argument typemap for bt_bool */
147 %typemap(out) bt_bool {
158 * Input and output argument typemaps for raw Python objects (direct).
160 * Those typemaps honor the convention of Python C function calls with
161 * respect to reference counting: parameters are passed as borrowed
162 * references, and objects are returned as new references. The wrapped
163 * C function must ensure that the return value is always a new
164 * reference, and never steal parameter references.
166 %typemap(in) PyObject * {
170 %typemap(out) PyObject * {
174 /* From property.h */
176 typedef enum bt_property_availability {
177 BT_PROPERTY_AVAILABILITY_AVAILABLE,
178 BT_PROPERTY_AVAILABILITY_NOT_AVAILABLE,
179 } bt_property_availability;
181 /* Per-module interface files */
182 %include "native_bt_clock_class.i"
183 %include "native_bt_clock_snapshot.i"
184 %include "native_bt_component.i"
185 %include "native_bt_component_class.i"
186 %include "native_bt_connection.i"
187 %include "native_bt_event.i"
188 %include "native_bt_event_class.i"
189 %include "native_bt_field.i"
190 %include "native_bt_field_class.i"
191 %include "native_bt_field_path.i"
192 %include "native_bt_graph.i"
193 %include "native_bt_logging.i"
194 %include "native_bt_message.i"
195 %include "native_bt_notifier.i"
196 %include "native_bt_packet.i"
197 %include "native_bt_plugin.i"
198 %include "native_bt_port.i"
199 %include "native_bt_query_exec.i"
200 %include "native_bt_stream.i"
201 %include "native_bt_stream_class.i"
202 %include "native_bt_trace.i"
203 %include "native_bt_trace_class.i"
204 %include "native_bt_value.i"
205 %include "native_bt_version.i"