2 * SPDX-License-Identifier: MIT
4 * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
7 #ifndef BABELTRACE_BINDINGS_PYTHON_BT2_BT2_NATIVE_BT_TRACE_I_H
8 #define BABELTRACE_BINDINGS_PYTHON_BT2_BT2_NATIVE_BT_TRACE_I_H
11 trace_destroyed_listener(const bt_trace
*trace
, void *py_callable
)
13 PyObject
*py_trace_ptr
= NULL
;
14 PyObject
*py_res
= NULL
;
16 py_trace_ptr
= SWIG_NewPointerObj(SWIG_as_voidptr(trace
),
17 SWIGTYPE_p_bt_trace
, 0);
19 BT_LOGF_STR("Failed to create a SWIG pointer object.");
23 py_res
= PyObject_CallFunction(py_callable
, "(O)", py_trace_ptr
);
25 logw_exception_clear(BT_LOG_OUTPUT_LEVEL
);
29 BT_ASSERT(py_res
== Py_None
);
32 Py_DECREF(py_trace_ptr
);
37 int bt_bt2_trace_add_destruction_listener(bt_trace
*trace
,
38 PyObject
*py_callable
, bt_listener_id
*id
)
40 bt_trace_add_listener_status status
;
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
);
53 #endif /* BABELTRACE_BINDINGS_PYTHON_BT2_BT2_NATIVE_BT_TRACE_I_H */