From: Jitka Plesnikova Date: Mon, 14 Oct 2024 12:17:10 +0000 (+0000) Subject: bt2: use SWIG_AppendOutput (fix for SWIG 4.3.0) X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=ba49ae6bb3646e7b257abbb85067a27885ad21a3;p=babeltrace.git bt2: use SWIG_AppendOutput (fix for SWIG 4.3.0) From the SWIG release notes: [Python] #2907 Fix returning null from functions with output parameters. Ensures OUTPUT and INOUT typemaps are handled consistently wrt return type. New declaration of SWIG_Python_AppendOutput is now: SWIG_Python_AppendOutput(PyObject* result, PyObject* obj, int is_void); The 3rd parameter is new and the new $isvoid special variable should be passed to it, indicating whether or not the wrapped function returns void. If SWIG_Python_AppendOutput is currently being used and a completely backwards compatible (but technically incorrect) solution is required, then pass 1 for the is_void parameter. Also consider replacing with: SWIG_AppendOutput(PyObject* result, PyObject* obj); which calls SWIG_Python_AppendOutput with same parameters but adding $isvoid for final parameter. Change-Id: I0944116fa40e024785d48e0b172ab30f359f505c Signed-off-by: Michael Jeanson Reviewed-on: https://review.lttng.org/c/babeltrace/+/13345 CI-Build: Simon Marchi Tested-by: jenkins Reviewed-by: Simon Marchi --- diff --git a/src/bindings/python/bt2/bt2/native_bt.i b/src/bindings/python/bt2/bt2/native_bt.i index b4b5e904..5914f702 100644 --- a/src/bindings/python/bt2/bt2/native_bt.i +++ b/src/bindings/python/bt2/bt2/native_bt.i @@ -65,12 +65,12 @@ typedef uint64_t bt_listener_id; %typemap(argout) (const char **) { if (*$1) { - /* SWIG_Python_AppendOutput() steals the created object */ - $result = SWIG_Python_AppendOutput($result, SWIG_Python_str_FromChar(*$1)); + /* SWIG_AppendOutput() steals the created object */ + $result = SWIG_AppendOutput($result, SWIG_Python_str_FromChar(*$1)); } else { - /* SWIG_Python_AppendOutput() steals Py_None */ + /* SWIG_AppendOutput() steals Py_None */ Py_INCREF(Py_None); - $result = SWIG_Python_AppendOutput($result, Py_None); + $result = SWIG_AppendOutput($result, Py_None); } } @@ -81,14 +81,14 @@ typedef uint64_t bt_listener_id; %typemap(argout) (bt_value **) { if (*$1) { - /* SWIG_Python_AppendOutput() steals the created object */ - $result = SWIG_Python_AppendOutput($result, + /* SWIG_AppendOutput() steals the created object */ + $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_value, 0)); } else { - /* SWIG_Python_AppendOutput() steals Py_None */ + /* SWIG_AppendOutput() steals Py_None */ Py_INCREF(Py_None); - $result = SWIG_Python_AppendOutput($result, Py_None); + $result = SWIG_AppendOutput($result, Py_None); } } @@ -98,7 +98,7 @@ typedef uint64_t bt_listener_id; } %typemap(argout) uint64_t * { - $result = SWIG_Python_AppendOutput(resultobj, + $result = SWIG_AppendOutput(resultobj, SWIG_From_unsigned_SS_long_SS_long((*$1))); } @@ -108,7 +108,7 @@ typedef uint64_t bt_listener_id; } %typemap(argout) (int64_t *) { - $result = SWIG_Python_AppendOutput(resultobj, SWIG_From_long_SS_long((*$1))); + $result = SWIG_AppendOutput(resultobj, SWIG_From_long_SS_long((*$1))); } /* Output argument typemap for initialized unsigned int output parameter (always appends) */ @@ -117,7 +117,7 @@ typedef uint64_t bt_listener_id; } %typemap(argout) (unsigned int *) { - $result = SWIG_Python_AppendOutput(resultobj, + $result = SWIG_AppendOutput(resultobj, SWIG_From_unsigned_SS_long_SS_long((uint64_t) (*$1))); } @@ -127,7 +127,7 @@ typedef uint64_t bt_listener_id; } %typemap(argout) bt_bool * { - $result = SWIG_Python_AppendOutput(resultobj, + $result = SWIG_AppendOutput(resultobj, SWIG_From_bool(*$1)); } diff --git a/src/bindings/python/bt2/bt2/native_bt_component.i b/src/bindings/python/bt2/bt2/native_bt_component.i index e0fc247d..cc2419ce 100644 --- a/src/bindings/python/bt2/bt2/native_bt_component.i +++ b/src/bindings/python/bt2/bt2/native_bt_component.i @@ -13,14 +13,14 @@ %typemap(argout) bt_self_component_port_input ** { if (*$1) { - /* SWIG_Python_AppendOutput() steals the created object */ - $result = SWIG_Python_AppendOutput($result, + /* SWIG_AppendOutput() steals the created object */ + $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_self_component_port_input, 0)); } else { - /* SWIG_Python_AppendOutput() steals Py_None */ + /* SWIG_AppendOutput() steals Py_None */ Py_INCREF(Py_None); - $result = SWIG_Python_AppendOutput($result, Py_None); + $result = SWIG_AppendOutput($result, Py_None); } } @@ -33,14 +33,14 @@ %typemap(argout) (bt_self_component_port_output **) { if (*$1) { - /* SWIG_Python_AppendOutput() steals the created object */ - $result = SWIG_Python_AppendOutput($result, + /* SWIG_AppendOutput() steals the created object */ + $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_self_component_port_output, 0)); } else { - /* SWIG_Python_AppendOutput() steals Py_None */ + /* SWIG_AppendOutput() steals Py_None */ Py_INCREF(Py_None); - $result = SWIG_Python_AppendOutput($result, Py_None); + $result = SWIG_AppendOutput($result, Py_None); } } diff --git a/src/bindings/python/bt2/bt2/native_bt_event_class.i b/src/bindings/python/bt2/bt2/native_bt_event_class.i index 9531b350..b7f05bb8 100644 --- a/src/bindings/python/bt2/bt2/native_bt_event_class.i +++ b/src/bindings/python/bt2/bt2/native_bt_event_class.i @@ -14,8 +14,8 @@ } %typemap(argout) bt_event_class_log_level * { - /* SWIG_Python_AppendOutput() steals the created object */ - $result = SWIG_Python_AppendOutput($result, SWIG_From_int(*$1)); + /* SWIG_AppendOutput() steals the created object */ + $result = SWIG_AppendOutput($result, SWIG_From_int(*$1)); } %include diff --git a/src/bindings/python/bt2/bt2/native_bt_field_class.i b/src/bindings/python/bt2/bt2/native_bt_field_class.i index ad9fb584..72aaa9ca 100644 --- a/src/bindings/python/bt2/bt2/native_bt_field_class.i +++ b/src/bindings/python/bt2/bt2/native_bt_field_class.i @@ -22,10 +22,10 @@ PyList_SET_ITEM(py_label_list, i, PyUnicode_FromString((*$1)[i])); } - $result = SWIG_Python_AppendOutput($result, py_label_list); + $result = SWIG_AppendOutput($result, py_label_list); } else { Py_INCREF(Py_None); - $result = SWIG_Python_AppendOutput($result, Py_None); + $result = SWIG_AppendOutput($result, Py_None); } } diff --git a/src/bindings/python/bt2/bt2/native_bt_graph.i b/src/bindings/python/bt2/bt2/native_bt_graph.i index 3fda915e..d559b252 100644 --- a/src/bindings/python/bt2/bt2/native_bt_graph.i +++ b/src/bindings/python/bt2/bt2/native_bt_graph.i @@ -14,14 +14,14 @@ %typemap(argout) (const bt_connection **) { if (*$1) { - /* SWIG_Python_AppendOutput() steals the created object */ - $result = SWIG_Python_AppendOutput($result, + /* SWIG_AppendOutput() steals the created object */ + $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_connection, 0)); } else { - /* SWIG_Python_AppendOutput() steals Py_None */ + /* SWIG_AppendOutput() steals Py_None */ Py_INCREF(Py_None); - $result = SWIG_Python_AppendOutput($result, Py_None); + $result = SWIG_AppendOutput($result, Py_None); } } @@ -46,40 +46,40 @@ %typemap(argout) (const bt_component_source **) { if (*$1) { - /* SWIG_Python_AppendOutput() steals the created object */ - $result = SWIG_Python_AppendOutput($result, + /* SWIG_AppendOutput() steals the created object */ + $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_component_source, 0)); } else { - /* SWIG_Python_AppendOutput() steals Py_None */ + /* SWIG_AppendOutput() steals Py_None */ Py_INCREF(Py_None); - $result = SWIG_Python_AppendOutput($result, Py_None); + $result = SWIG_AppendOutput($result, Py_None); } } %typemap(argout) (const bt_component_filter **) { if (*$1) { - /* SWIG_Python_AppendOutput() steals the created object */ - $result = SWIG_Python_AppendOutput($result, + /* SWIG_AppendOutput() steals the created object */ + $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_component_filter, 0)); } else { - /* SWIG_Python_AppendOutput() steals Py_None */ + /* SWIG_AppendOutput() steals Py_None */ Py_INCREF(Py_None); - $result = SWIG_Python_AppendOutput($result, Py_None); + $result = SWIG_AppendOutput($result, Py_None); } } %typemap(argout) (const bt_component_sink **) { if (*$1) { - /* SWIG_Python_AppendOutput() steals the created object */ - $result = SWIG_Python_AppendOutput($result, + /* SWIG_AppendOutput() steals the created object */ + $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_component_sink, 0)); } else { - /* SWIG_Python_AppendOutput() steals Py_None */ + /* SWIG_AppendOutput() steals Py_None */ Py_INCREF(Py_None); - $result = SWIG_Python_AppendOutput($result, Py_None); + $result = SWIG_AppendOutput($result, Py_None); } } diff --git a/src/bindings/python/bt2/bt2/native_bt_message.i b/src/bindings/python/bt2/bt2/native_bt_message.i index e983cc9c..99a97676 100644 --- a/src/bindings/python/bt2/bt2/native_bt_message.i +++ b/src/bindings/python/bt2/bt2/native_bt_message.i @@ -15,14 +15,14 @@ %typemap(argout) (const bt_clock_snapshot **) { if (*$1) { - /* SWIG_Python_AppendOutput() steals the created object */ - $result = SWIG_Python_AppendOutput($result, + /* SWIG_AppendOutput() steals the created object */ + $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_clock_snapshot, 0)); } else { - /* SWIG_Python_AppendOutput() steals Py_None */ + /* SWIG_AppendOutput() steals Py_None */ Py_INCREF(Py_None); - $result = SWIG_Python_AppendOutput($result, Py_None); + $result = SWIG_AppendOutput($result, Py_None); } } diff --git a/src/bindings/python/bt2/bt2/native_bt_message_iterator.i b/src/bindings/python/bt2/bt2/native_bt_message_iterator.i index 531274ec..d54b8e1d 100644 --- a/src/bindings/python/bt2/bt2/native_bt_message_iterator.i +++ b/src/bindings/python/bt2/bt2/native_bt_message_iterator.i @@ -14,14 +14,14 @@ %typemap(argout) (bt_message_iterator **) { if (*$1) { - /* SWIG_Python_AppendOutput() steals the created object */ - $result = SWIG_Python_AppendOutput($result, + /* SWIG_AppendOutput() steals the created object */ + $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_message_iterator, 0)); } else { - /* SWIG_Python_AppendOutput() steals Py_None */ + /* SWIG_AppendOutput() steals Py_None */ Py_INCREF(Py_None); - $result = SWIG_Python_AppendOutput($result, Py_None); + $result = SWIG_AppendOutput($result, Py_None); } } diff --git a/src/bindings/python/bt2/bt2/native_bt_plugin.i b/src/bindings/python/bt2/bt2/native_bt_plugin.i index e15dcdbc..dc4f4480 100644 --- a/src/bindings/python/bt2/bt2/native_bt_plugin.i +++ b/src/bindings/python/bt2/bt2/native_bt_plugin.i @@ -14,14 +14,14 @@ %typemap(argout) (const bt_plugin **) { if (*$1) { - /* SWIG_Python_AppendOutput() steals the created object */ - $result = SWIG_Python_AppendOutput($result, + /* SWIG_AppendOutput() steals the created object */ + $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_plugin, 0)); } else { - /* SWIG_Python_AppendOutput() steals Py_None */ + /* SWIG_AppendOutput() steals Py_None */ Py_INCREF(Py_None); - $result = SWIG_Python_AppendOutput($result, Py_None); + $result = SWIG_AppendOutput($result, Py_None); } } @@ -35,14 +35,14 @@ %typemap(argout) (const bt_plugin_set **) { if (*$1) { - /* SWIG_Python_AppendOutput() steals the created object */ - $result = SWIG_Python_AppendOutput($result, + /* SWIG_AppendOutput() steals the created object */ + $result = SWIG_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(*$1), SWIGTYPE_p_bt_plugin_set, 0)); } else { - /* SWIG_Python_AppendOutput() steals Py_None */ + /* SWIG_AppendOutput() steals Py_None */ Py_INCREF(Py_None); - $result = SWIG_Python_AppendOutput($result, Py_None); + $result = SWIG_AppendOutput($result, Py_None); } }