.gitignore: add some more IDE / tools related file
[babeltrace.git] / src / bindings / python / bt2 / bt2 / native_bt_trace.i.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
5 */
6
7 #ifndef BABELTRACE_BINDINGS_PYTHON_BT2_BT2_NATIVE_BT_TRACE_I_H
8 #define BABELTRACE_BINDINGS_PYTHON_BT2_BT2_NATIVE_BT_TRACE_I_H
9
10 static void
11 trace_destroyed_listener(const bt_trace *trace, void *py_callable)
12 {
13 PyObject *py_trace_ptr = NULL;
14 PyObject *py_res = NULL;
15
16 py_trace_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(trace),
17 SWIGTYPE_p_bt_trace, 0);
18 if (!py_trace_ptr) {
19 BT_LOGF_STR("Failed to create a SWIG pointer object.");
20 bt_common_abort();
21 }
22
23 py_res = PyObject_CallFunction(py_callable, "(O)", py_trace_ptr);
24 if (!py_res) {
25 logw_exception_clear(BT_LOG_OUTPUT_LEVEL);
26 goto end;
27 }
28
29 BT_ASSERT(py_res == Py_None);
30
31 end:
32 Py_DECREF(py_trace_ptr);
33 Py_XDECREF(py_res);
34 }
35
36 static
37 int bt_bt2_trace_add_destruction_listener(bt_trace *trace,
38 PyObject *py_callable, bt_listener_id *id)
39 {
40 bt_trace_add_listener_status status;
41
42 BT_ASSERT(trace);
43 BT_ASSERT(py_callable);
44 status = bt_trace_add_destruction_listener(
45 trace, trace_destroyed_listener, py_callable, id);
46 if (status == __BT_FUNC_STATUS_OK) {
47 Py_INCREF(py_callable);
48 }
49
50 return status;
51 }
52
53 #endif /* BABELTRACE_BINDINGS_PYTHON_BT2_BT2_NATIVE_BT_TRACE_I_H */
This page took 0.032873 seconds and 5 git commands to generate.