diff --git a/lldb/bindings/python/python-typemaps.swig b/lldb/bindings/python/python-typemaps.swig index bf3de66b91bf1..203be803d2ebd 100644 --- a/lldb/bindings/python/python-typemaps.swig +++ b/lldb/bindings/python/python-typemaps.swig @@ -18,7 +18,7 @@ if (!py_str.IsAllocated()) { PyErr_SetString(PyExc_TypeError, "list must contain strings"); free($1); - return nullptr; + SWIG_fail; } $1[i] = const_cast(py_str.GetString().data()); @@ -28,7 +28,7 @@ $1 = NULL; } else { PyErr_SetString(PyExc_TypeError, "not a list"); - return NULL; + SWIG_fail; } } @@ -70,7 +70,7 @@ PythonObject obj = Retain($input); lldb::tid_t value = unwrapOrSetPythonException(As(obj)); if (PyErr_Occurred()) - return nullptr; + SWIG_fail; $1 = value; } @@ -79,10 +79,10 @@ unsigned long long state_type_value = unwrapOrSetPythonException(As(obj)); if (PyErr_Occurred()) - return nullptr; + SWIG_fail; if (state_type_value > lldb::StateType::kLastStateType) { PyErr_SetString(PyExc_ValueError, "Not a valid StateType value"); - return nullptr; + SWIG_fail; } $1 = static_cast(state_type_value); } @@ -93,12 +93,12 @@ %typemap(in) (char *dst, size_t dst_len) { if (!PyInt_Check($input)) { PyErr_SetString(PyExc_ValueError, "Expecting an integer"); - return NULL; + SWIG_fail; } $2 = PyInt_AsLong($input); if ($2 <= 0) { PyErr_SetString(PyExc_ValueError, "Positive integer expected"); - return NULL; + SWIG_fail; } $1 = (char *)malloc($2); } @@ -129,12 +129,12 @@ %typemap(in) (char *dst_or_null, size_t dst_len) { if (!PyInt_Check($input)) { PyErr_SetString(PyExc_ValueError, "Expecting an integer"); - return NULL; + SWIG_fail; } $2 = PyInt_AsLong($input); if ($2 <= 0) { PyErr_SetString(PyExc_ValueError, "Positive integer expected"); - return NULL; + SWIG_fail; } $1 = (char *)malloc($2); } @@ -166,7 +166,7 @@ $2 = bytes.GetSize(); } else { PyErr_SetString(PyExc_ValueError, "Expecting a string"); - return NULL; + SWIG_fail; } } // For SBProcess::WriteMemory, SBTarget::GetInstructions and SBDebugger::DispatchInput. @@ -186,7 +186,7 @@ $2 = bytes.GetSize(); } else { PyErr_SetString(PyExc_ValueError, "Expecting a buffer"); - return NULL; + SWIG_fail; } } @@ -199,11 +199,11 @@ $2 = PyLong_AsLong($input); } else { PyErr_SetString(PyExc_ValueError, "Expecting an integer or long object"); - return NULL; + SWIG_fail; } if ($2 <= 0) { PyErr_SetString(PyExc_ValueError, "Positive integer expected"); - return NULL; + SWIG_fail; } $1 = (void *)malloc($2); } @@ -287,12 +287,12 @@ template <> bool SetNumberFromPyObject(double &number, PyObject *obj) { if (!SetNumberFromPyObject($1[i], o)) { PyErr_SetString(PyExc_TypeError, "list must contain numbers"); free($1); - return NULL; + SWIG_fail; } if (PyErr_Occurred()) { free($1); - return NULL; + SWIG_fail; } } } else if ($input == Py_None) { @@ -300,7 +300,7 @@ template <> bool SetNumberFromPyObject(double &number, PyObject *obj) { $2 = 0; } else { PyErr_SetString(PyExc_TypeError, "not a list"); - return NULL; + SWIG_fail; } } @@ -353,7 +353,7 @@ template <> bool SetNumberFromPyObject(double &number, PyObject *obj) { if (!($input == Py_None || PyCallable_Check(reinterpret_cast($input)))) { PyErr_SetString(PyExc_TypeError, "Need a callable object or None!"); - return NULL; + SWIG_fail; } // FIXME (filcab): We can't currently check if our callback is already @@ -377,11 +377,11 @@ template <> bool SetNumberFromPyObject(double &number, PyObject *obj) { PythonFile py_file(PyRefType::Borrowed, $input); if (!py_file) { PyErr_SetString(PyExc_TypeError, "not a file"); - return nullptr; + SWIG_fail; } auto sp = unwrapOrSetPythonException(py_file.ConvertToFile()); if (!sp) - return nullptr; + SWIG_fail; $1 = sp; } @@ -389,12 +389,12 @@ template <> bool SetNumberFromPyObject(double &number, PyObject *obj) { PythonFile py_file(PyRefType::Borrowed, $input); if (!py_file) { PyErr_SetString(PyExc_TypeError, "not a file"); - return nullptr; + SWIG_fail; } auto sp = unwrapOrSetPythonException( py_file.ConvertToFileForcingUseOfScriptingIOMethods()); if (!sp) - return nullptr; + SWIG_fail; $1 = sp; } @@ -402,12 +402,12 @@ template <> bool SetNumberFromPyObject(double &number, PyObject *obj) { PythonFile py_file(PyRefType::Borrowed, $input); if (!py_file) { PyErr_SetString(PyExc_TypeError, "not a file"); - return nullptr; + SWIG_fail; } auto sp = unwrapOrSetPythonException(py_file.ConvertToFile(/*borrowed=*/true)); if (!sp) - return nullptr; + SWIG_fail; $1 = sp; } @@ -415,12 +415,12 @@ template <> bool SetNumberFromPyObject(double &number, PyObject *obj) { PythonFile py_file(PyRefType::Borrowed, $input); if (!py_file) { PyErr_SetString(PyExc_TypeError, "not a file"); - return nullptr; + SWIG_fail; } auto sp = unwrapOrSetPythonException( py_file.ConvertToFileForcingUseOfScriptingIOMethods(/*borrowed=*/true)); if (!sp) - return nullptr; + SWIG_fail; $1 = sp; } @@ -439,7 +439,7 @@ template <> bool SetNumberFromPyObject(double &number, PyObject *obj) { if (sp) { PythonFile pyfile = unwrapOrSetPythonException(PythonFile::FromFile(*sp)); if (!pyfile.IsValid()) - return nullptr; + SWIG_fail; $result = pyfile.release(); } if (!$result) { @@ -468,7 +468,7 @@ template <> bool SetNumberFromPyObject(double &number, PyObject *obj) { py_str.release(); } else { PyErr_SetString(PyExc_TypeError, "not a string-like object"); - return NULL; + SWIG_fail; } }