tap-driver.sh: flush stdout after each test result
[babeltrace.git] / bindings / python / bt2 / bt2 / native_bt_trace.i
CommitLineData
6945df9a
SM
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/* From trace-const.h */
26
27typedef enum bt_trace_status {
28 BT_TRACE_STATUS_OK = 0,
29 BT_TRACE_STATUS_NOMEM = -12,
30} bt_trace_status;
31
32typedef void (* bt_trace_destruction_listener_func)(
33 const bt_trace *trace, void *data);
34
35extern const bt_trace_class *bt_trace_borrow_class_const(
36 const bt_trace *trace);
37
38extern const char *bt_trace_get_name(const bt_trace *trace);
39
40extern uint64_t bt_trace_get_stream_count(const bt_trace *trace);
41
42extern const bt_stream *bt_trace_borrow_stream_by_index_const(
43 const bt_trace *trace, uint64_t index);
44
45extern const bt_stream *bt_trace_borrow_stream_by_id_const(
46 const bt_trace *trace, uint64_t id);
47
48extern bt_trace_status bt_trace_add_destruction_listener(
49 const bt_trace *trace,
50 bt_trace_destruction_listener_func listener,
51 void *data, uint64_t *listener_id);
52
53extern bt_trace_status bt_trace_remove_destruction_listener(
54 const bt_trace *trace, uint64_t listener_id);
55
56extern void bt_trace_get_ref(const bt_trace *trace);
57
58extern void bt_trace_put_ref(const bt_trace *trace);
59
60/* From trace.h */
61
62extern bt_trace_class *bt_trace_borrow_class(bt_trace *trace);
63
64extern bt_trace *bt_trace_create(bt_trace_class *trace_class);
65
66extern bt_trace_status bt_trace_set_name(bt_trace *trace,
67 const char *name);
68
69extern bt_stream *bt_trace_borrow_stream_by_index(bt_trace *trace,
70 uint64_t index);
71
72extern bt_stream *bt_trace_borrow_stream_by_id(bt_trace *trace,
73 uint64_t id);
74
75%{
76static void
77trace_destroyed_listener(const bt_trace *trace, void *py_callable)
78{
79 PyObject *py_trace_ptr = NULL;
80 PyObject *py_res = NULL;
81
82 py_trace_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(trace),
83 SWIGTYPE_p_bt_trace, 0);
84 if (!py_trace_ptr) {
85 BT_LOGF_STR("Failed to create a SWIG pointer object.");
86 abort();
87 }
88
89 py_res = PyObject_CallFunction(py_callable, "(O)", py_trace_ptr);
90 if (py_res != NULL) {
91 BT_ASSERT(py_res == Py_None);
92 } else {
93 bt2_py_loge_exception();
94 }
95
96 Py_DECREF(py_trace_ptr);
97 Py_XDECREF(py_res);
98}
99
100uint64_t bt_py3_trace_add_destruction_listener(bt_trace *trace, PyObject *py_callable)
101{
102 uint64_t id = UINT64_C(-1);
103 bt_trace_status status;
104
105 BT_ASSERT(trace);
106 BT_ASSERT(py_callable);
107
108 status = bt_trace_add_destruction_listener(
109 trace, trace_destroyed_listener, py_callable, &id);
110 if (status != BT_TRACE_STATUS_OK) {
111 BT_LOGF_STR("Failed to add trace destruction listener.");
112 abort();
113 }
114
115 Py_INCREF(py_callable);
116
117 return id;
118}
119%}
120
121uint64_t bt_py3_trace_add_destruction_listener(bt_trace *trace,
122 PyObject *py_callable);
This page took 0.029301 seconds and 4 git commands to generate.