X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=bindings%2Fpython%2Fbt2%2Fbt2%2Fnative_bt_port.i;fp=bindings%2Fpython%2Fbt2%2Fbt2%2Fnative_bt_port.i;h=873c613627c35eda227e27a218d3a3d8de92763a;hp=728543783bfadb8d8692c493c444f168d437e7c2;hb=2e00bc76cf37af167c45253cfc8f8d197222d6b8;hpb=c5f330cd909f5dfbdb519546e875b4427434ba4f diff --git a/bindings/python/bt2/bt2/native_bt_port.i b/bindings/python/bt2/bt2/native_bt_port.i index 72854378..873c6136 100644 --- a/bindings/python/bt2/bt2/native_bt_port.i +++ b/bindings/python/bt2/bt2/native_bt_port.i @@ -22,6 +22,23 @@ * THE SOFTWARE. */ +/* + * Typemap for the user data attached to (and owned by) a self component port. + * The pointer saved as the port's user data is directly the PyObject *. + * + * As per the CPython calling convention, we need to return a new reference to + * the returned object, which will be transferred to the caller. The following + * typedef allows us to apply the typemap. + */ +%{ +typedef void *PY_SELF_PORT_USER_DATA; +%} + +%typemap(out) PY_SELF_PORT_USER_DATA { + Py_INCREF($1); + $result = $1; +} + /* From port-const.h */ typedef enum bt_port_type { @@ -77,7 +94,7 @@ const bt_port *bt_self_component_port_as_port( extern bt_self_component *bt_self_component_port_borrow_component( bt_self_component_port *self_port); -extern void *bt_self_component_port_get_data( +extern PY_SELF_PORT_USER_DATA bt_self_component_port_get_data( const bt_self_component_port *self_port); /* From self-component-port-output.h */