2 * SPDX-License-Identifier: MIT
4 * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
8 trace_destroyed_listener(const bt_trace
*trace
, void *py_callable
)
10 PyObject
*py_trace_ptr
= NULL
;
11 PyObject
*py_res
= NULL
;
13 py_trace_ptr
= SWIG_NewPointerObj(SWIG_as_voidptr(trace
),
14 SWIGTYPE_p_bt_trace
, 0);
16 BT_LOGF_STR("Failed to create a SWIG pointer object.");
20 py_res
= PyObject_CallFunction(py_callable
, "(O)", py_trace_ptr
);
22 logw_exception_clear(BT_LOG_OUTPUT_LEVEL
);
26 BT_ASSERT(py_res
== Py_None
);
29 Py_DECREF(py_trace_ptr
);
34 int bt_bt2_trace_add_destruction_listener(bt_trace
*trace
,
35 PyObject
*py_callable
, bt_listener_id
*id
)
37 bt_trace_add_listener_status status
;
40 BT_ASSERT(py_callable
);
41 status
= bt_trace_add_destruction_listener(
42 trace
, trace_destroyed_listener
, py_callable
, id
);
43 if (status
== __BT_FUNC_STATUS_OK
) {
44 Py_INCREF(py_callable
);