bt2: use SWIG_AppendOutput (fix for SWIG 4.3.0)
authorJitka Plesnikova <jplesnik@redhat.com>
Mon, 14 Oct 2024 12:17:10 +0000 (12:17 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 17 Oct 2024 04:02:41 +0000 (00:02 -0400)
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 <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/13345
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
src/bindings/python/bt2/bt2/native_bt.i
src/bindings/python/bt2/bt2/native_bt_component.i
src/bindings/python/bt2/bt2/native_bt_event_class.i
src/bindings/python/bt2/bt2/native_bt_field_class.i
src/bindings/python/bt2/bt2/native_bt_graph.i
src/bindings/python/bt2/bt2/native_bt_message.i
src/bindings/python/bt2/bt2/native_bt_message_iterator.i
src/bindings/python/bt2/bt2/native_bt_plugin.i

index b4b5e9048c14bfccce02deed98666c1f6084bb2d..5914f7025bd0f824088363fc574eda47555ec68f 100644 (file)
@@ -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));
 }
 
index e0fc247d7e705a7be3bf894dcecf4594372f0762..cc2419ce1faaffe83632a8ada1fd7f4be242da6f 100644 (file)
 
 %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);
        }
 }
 
 
 %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);
        }
 }
 
index 9531b350f16850eda3fe018a870b4eb65684248a..b7f05bb8715b79be2e45c0d7c7715fd9fd013efa 100644 (file)
@@ -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 <babeltrace2/trace-ir/event-class.h>
index ad9fb58459f345991cd49ffe3b692aaf50efb4b3..72aaa9ca29ba118dd16ccb311bad7d824cf9189c 100644 (file)
                        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);
        }
 }
 
index 3fda915eb3e396b39bf20772e3e8f123c12477b0..d559b252b17bd1f45f5953e44d612b6e3735b169 100644 (file)
 %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);
        }
 }
 
 
 %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);
        }
 }
 
index e983cc9c09605c08ab6c755c2c11d767fa1303c0..99a976760d50e6aa625dfe161b17b97d6883077c 100644 (file)
 %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);
        }
 }
 
index 531274ecfae3cdbf4fe49758e0f447aa3cc1c91b..d54b8e1d339fda023e20514e84d9f8e2f5283b2e 100644 (file)
 %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);
        }
 }
 
index e15dcdbce6402baa0b49a1a8d30c832bfcf98582..dc4f44800e738235662af8e4e1ec26db79c36f49 100644 (file)
 %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);
        }
 }
 
 %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);
        }
 }
 
This page took 0.032964 seconds and 4 git commands to generate.