bt2: replace copy of headers for SWIG with includes
[babeltrace.git] / src / bindings / python / bt2 / bt2 / native_bt_field_class.i
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 /* Parameter names seem to be required for multi-argument typemaps to match. */
26 %typemap(in, numinputs=0)
27 (bt_field_class_enumeration_mapping_label_array *label_array, uint64_t *count)
28 (bt_field_class_enumeration_mapping_label_array temp_array, uint64_t temp_label_count = 0) {
29 $1 = &temp_array;
30 $2 = &temp_label_count;
31 }
32
33 %typemap(argout)
34 (bt_field_class_enumeration_mapping_label_array *label_array, uint64_t *count) {
35 if (*$1) {
36 PyObject *py_label_list = PyList_New(*$2);
37 for (int i = 0; i < *$2; i++) {
38 PyList_SET_ITEM(py_label_list, i, PyUnicode_FromString((*$1)[i]));
39 }
40
41 $result = SWIG_Python_AppendOutput($result, py_label_list);
42 } else {
43 Py_INCREF(Py_None);
44 $result = SWIG_Python_AppendOutput($result, Py_None);
45 }
46 }
47
48 /* Output argument typemap for value output (always appends) */
49 %typemap(in, numinputs=0)
50 (const bt_field_class_signed_enumeration_mapping_ranges **)
51 (bt_field_class_signed_enumeration_mapping_ranges *temp_value = NULL) {
52 $1 = &temp_value;
53 }
54
55 %typemap(argout)
56 (const bt_field_class_signed_enumeration_mapping_ranges **) {
57 if (*$1) {
58 /* SWIG_Python_AppendOutput() steals the created object */
59 $result = SWIG_Python_AppendOutput($result,
60 SWIG_NewPointerObj(SWIG_as_voidptr(*$1),
61 SWIGTYPE_p_bt_field_class_signed_enumeration_mapping_ranges, 0));
62 } else {
63 /* SWIG_Python_AppendOutput() steals Py_None */
64 Py_INCREF(Py_None);
65 $result = SWIG_Python_AppendOutput($result, Py_None);
66 }
67 }
68
69 /* Output argument typemap for value output (always appends) */
70 %typemap(in, numinputs=0)
71 (const bt_field_class_unsigned_enumeration_mapping_ranges **)
72 (bt_field_class_unsigned_enumeration_mapping_ranges *temp_value = NULL) {
73 $1 = &temp_value;
74 }
75
76 %typemap(argout)
77 (const bt_field_class_unsigned_enumeration_mapping_ranges **) {
78 if (*$1) {
79 /* SWIG_Python_AppendOutput() steals the created object */
80 $result = SWIG_Python_AppendOutput($result,
81 SWIG_NewPointerObj(SWIG_as_voidptr(*$1),
82 SWIGTYPE_p_bt_field_class_unsigned_enumeration_mapping_ranges, 0));
83 } else {
84 /* SWIG_Python_AppendOutput() steals Py_None */
85 Py_INCREF(Py_None);
86 $result = SWIG_Python_AppendOutput($result, Py_None);
87 }
88 }
89
90 %include <babeltrace2/trace-ir/field-class-const.h>
91 %include <babeltrace2/trace-ir/field-class.h>
This page took 0.032433 seconds and 5 git commands to generate.