X-Git-Url: https://git.efficios.com/?a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fnative_bt_trace.i;h=0868055cfaefea34a462197f8e41805c56def67f;hb=7704a0af9f2275321f8294df8c02f8a299b3134e;hp=f771ef45c4e10a7e8ffb54dab31d35bc321a2c6e;hpb=8d6ef9dfa268f6f31f5996e363cafb3a2005d862;p=babeltrace.git diff --git a/src/bindings/python/bt2/bt2/native_bt_trace.i b/src/bindings/python/bt2/bt2/native_bt_trace.i index f771ef45..0868055c 100644 --- a/src/bindings/python/bt2/bt2/native_bt_trace.i +++ b/src/bindings/python/bt2/bt2/native_bt_trace.i @@ -22,50 +22,10 @@ * THE SOFTWARE. */ -%include %include %{ -static void -trace_destroyed_listener(const bt_trace *trace, void *py_callable) -{ - PyObject *py_trace_ptr = NULL; - PyObject *py_res = NULL; - - py_trace_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(trace), - SWIGTYPE_p_bt_trace, 0); - if (!py_trace_ptr) { - BT_LOGF_STR("Failed to create a SWIG pointer object."); - abort(); - } - - py_res = PyObject_CallFunction(py_callable, "(O)", py_trace_ptr); - if (py_res) { - BT_ASSERT(py_res == Py_None); - } else { - loge_exception("Trace's destruction listener (Python)", - BT_LOG_OUTPUT_LEVEL); - } - - Py_DECREF(py_trace_ptr); - Py_XDECREF(py_res); -} - -int bt_bt2_trace_add_destruction_listener(bt_trace *trace, - PyObject *py_callable, bt_listener_id *id) -{ - bt_trace_add_listener_status status; - - BT_ASSERT(trace); - BT_ASSERT(py_callable); - status = bt_trace_add_destruction_listener( - trace, trace_destroyed_listener, py_callable, id); - if (status == __BT_FUNC_STATUS_OK) { - Py_INCREF(py_callable); - } - - return status; -} +#include "native_bt_trace.i.h" %} int bt_bt2_trace_add_destruction_listener(bt_trace *trace,