Fix: add missing void param to bt_clock_class_priority_map_create
[babeltrace.git] / bindings / python / bt2 / native_btconnection.i
1 /*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2017 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 /* Type */
26 struct bt_connection;
27 struct bt_private_connection;
28
29 /* Status */
30 enum bt_connection_status {
31 BT_CONNECTION_STATUS_GRAPH_IS_CANCELED = 125,
32 BT_CONNECTION_STATUS_OK = 0,
33 BT_CONNECTION_STATUS_INVALID = -22,
34 BT_CONNECTION_STATUS_ERROR = -1,
35 BT_CONNECTION_STATUS_NOMEM = -12,
36 BT_CONNECTION_STATUS_IS_ENDED = 104,
37 };
38
39 /* Functions (public) */
40 struct bt_port *bt_connection_get_downstream_port(
41 struct bt_connection *connection);
42 struct bt_port *bt_connection_get_upstream_port(
43 struct bt_connection *connection);
44 int bt_connection_is_ended(struct bt_connection *connection);
45
46 /* Functions (private) */
47 struct bt_connection *bt_connection_from_private_connection(
48 struct bt_private_connection *private_connection);
49
50 /* Helper functions for Python */
51 %typemap(out) struct bt_py3_create_notif_iter_ret {
52 $result = PyTuple_New(2);
53 PyObject *py_notif_iter_ptr = SWIG_NewPointerObj(
54 SWIG_as_voidptr($1.notif_iter),
55 SWIGTYPE_p_bt_notification_iterator, 0);
56 PyObject *py_status = SWIG_From_long_SS_long($1.status);
57 PyTuple_SET_ITEM($result, 0, py_status);
58 PyTuple_SET_ITEM($result, 1, py_notif_iter_ptr);
59 }
60
61 %{
62 struct bt_py3_create_notif_iter_ret {
63 enum bt_connection_status status;
64 struct bt_notification_iterator *notif_iter;
65 };
66
67 static struct bt_py3_create_notif_iter_ret bt_py3_create_notif_iter(
68 unsigned long long priv_conn_addr, PyObject *py_notif_types)
69 {
70 struct bt_private_connection *priv_conn;
71 enum bt_notification_type *notification_types = NULL;
72 struct bt_py3_create_notif_iter_ret ret;
73
74 priv_conn = (void *) priv_conn_addr;
75 assert(!PyErr_Occurred());
76 assert(priv_conn);
77
78 if (py_notif_types != Py_None) {
79 size_t i;
80
81 assert(PyList_Check(py_notif_types));
82 notification_types = g_new0(enum bt_notification_type,
83 PyList_Size(py_notif_types) + 1);
84 assert(notification_types);
85 notification_types[PyList_Size(py_notif_types)] =
86 BT_NOTIFICATION_TYPE_SENTINEL;
87
88 for (i = 0; i < PyList_Size(py_notif_types); i++) {
89 PyObject *item = PyList_GetItem(py_notif_types, i);
90 long value;
91 int overflow;
92
93 assert(item);
94 assert(PyLong_Check(item));
95 value = PyLong_AsLongAndOverflow(item, &overflow);
96 assert(overflow == 0);
97 notification_types[i] = value;
98 }
99 }
100
101 ret.status = bt_private_connection_create_notification_iterator(
102 priv_conn, notification_types, &ret.notif_iter);
103
104 if (notification_types) {
105 g_free(notification_types);
106 }
107
108 return ret;
109 }
110 %}
111
112 struct bt_py3_create_notif_iter_ret bt_py3_create_notif_iter(
113 unsigned long long priv_conn_addr, PyObject *notif_types);
This page took 0.031598 seconds and 4 git commands to generate.