Commit | Line | Data |
---|---|---|
81447b5b PP |
1 | /* |
2 | * The MIT License (MIT) | |
3 | * | |
4 | * Copyright (c) 2016 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 | %{ | |
26 | typedef const unsigned char *BTUUID; | |
27 | %} | |
28 | ||
29 | #ifndef SWIGPYTHON | |
30 | # error Unsupported output language | |
31 | #endif | |
32 | ||
33 | /* For uint*_t/int*_t */ | |
34 | %include "stdint.i" | |
35 | ||
36 | /* Remove `bt_` and `BT_` prefixes from function names and enumeration items */ | |
37 | %rename("%(strip:[bt_])s", %$isfunction) ""; | |
38 | %rename("%(strip:[BT_])s", %$isenumitem) ""; | |
39 | ||
40 | /* Output argument typemap for string output (always appends) */ | |
41 | %typemap(in, numinputs=0) const char **BTOUTSTR (char *temp_value = NULL) { | |
42 | $1 = &temp_value; | |
43 | } | |
44 | ||
45 | %typemap(argout) const char **BTOUTSTR { | |
46 | if (*$1) { | |
47 | /* SWIG_Python_AppendOutput() steals the created object */ | |
48 | $result = SWIG_Python_AppendOutput($result, SWIG_Python_str_FromChar(*$1)); | |
49 | } else { | |
50 | /* SWIG_Python_AppendOutput() steals Py_None */ | |
51 | Py_INCREF(Py_None); | |
52 | $result = SWIG_Python_AppendOutput($result, Py_None); | |
53 | } | |
54 | } | |
55 | ||
56 | /* Output argument typemap for field type output (always appends) */ | |
57 | %typemap(in, numinputs=0) struct bt_ctf_field_type **BTOUTFT (struct bt_ctf_field_type *temp_ft = NULL) { | |
58 | $1 = &temp_ft; | |
59 | } | |
60 | ||
61 | %typemap(argout) struct bt_ctf_field_type **BTOUTFT { | |
62 | if (*$1) { | |
63 | /* SWIG_Python_AppendOutput() steals the created object */ | |
64 | $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_ctf_field_type, 0)); | |
65 | } else { | |
66 | /* SWIG_Python_AppendOutput() steals Py_None */ | |
67 | Py_INCREF(Py_None); | |
68 | $result = SWIG_Python_AppendOutput($result, Py_None); | |
69 | } | |
70 | } | |
71 | ||
72 | /* Input argument typemap for UUID bytes */ | |
73 | %typemap(in) BTUUID { | |
74 | $1 = (unsigned char *) PyBytes_AsString($input); | |
75 | } | |
76 | ||
77 | /* Output argument typemap for UUID bytes */ | |
78 | %typemap(out) BTUUID { | |
79 | if (!$1) { | |
80 | Py_INCREF(Py_None); | |
81 | $result = Py_None; | |
82 | } else { | |
83 | $result = PyBytes_FromStringAndSize((const char *) $1, 16); | |
84 | } | |
85 | } | |
86 | ||
87 | /* | |
88 | * Input and output argument typemaps for raw Python objects (direct). | |
89 | * | |
90 | * Those typemaps honor the convention of Python C function calls with | |
91 | * respect to reference counting: parameters are passed as borrowed | |
92 | * references, and objects are returned as new references. The wrapped | |
93 | * C function must ensure that the return value is always a new | |
94 | * reference, and never steal parameter references. | |
95 | */ | |
96 | %typemap(in) PyObject * { | |
97 | $1 = $input; | |
98 | } | |
99 | ||
100 | %typemap(out) PyObject * { | |
101 | $result = $1; | |
102 | } | |
103 | ||
104 | /* Per-module interface files */ | |
105 | %include "native_btclockclass.i" | |
106 | %include "native_btevent.i" | |
107 | %include "native_bteventclass.i" | |
108 | %include "native_btfields.i" | |
109 | %include "native_btft.i" | |
110 | %include "native_btpacket.i" | |
111 | %include "native_btref.i" | |
112 | %include "native_btstream.i" | |
113 | %include "native_btstreamclass.i" | |
114 | %include "native_bttrace.i" | |
115 | %include "native_btvalues.i" | |
116 | %include "native_btctfwriter.i" | |
117 | %include "native_btcomponentclass.i" | |
118 | %include "native_btcomponent.i" | |
119 | %include "native_btnotifiter.i" | |
120 | %include "native_btnotification.i" | |
121 | %include "native_btplugin.i" |