| 1 | /* |
| 2 | * SPDX-License-Identifier: MIT |
| 3 | * |
| 4 | * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com> |
| 5 | */ |
| 6 | |
| 7 | /* Parameter names seem to be required for multi-argument typemaps to match. */ |
| 8 | %typemap(in, numinputs=0) |
| 9 | (bt_field_class_enumeration_mapping_label_array *labels, uint64_t *count) |
| 10 | (bt_field_class_enumeration_mapping_label_array temp_array, uint64_t temp_label_count = 0) { |
| 11 | $1 = &temp_array; |
| 12 | $2 = &temp_label_count; |
| 13 | } |
| 14 | |
| 15 | %typemap(argout) |
| 16 | (bt_field_class_enumeration_mapping_label_array *labels, uint64_t *count) { |
| 17 | if (*$1) { |
| 18 | PyObject *py_label_list = PyList_New(*$2); |
| 19 | uint64_t i; |
| 20 | |
| 21 | for (i = 0; i < *$2; i++) { |
| 22 | PyList_SET_ITEM(py_label_list, i, PyUnicode_FromString((*$1)[i])); |
| 23 | } |
| 24 | |
| 25 | $result = SWIG_Python_AppendOutput($result, py_label_list); |
| 26 | } else { |
| 27 | Py_INCREF(Py_None); |
| 28 | $result = SWIG_Python_AppendOutput($result, Py_None); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | %include <babeltrace2/trace-ir/field-class.h> |