diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp index 097cbbdb6fc7e..a38cb104c0c63 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp @@ -35,4 +35,31 @@ ScriptedPythonInterface::GetStatusFromMethod(llvm::StringRef method_name) { return error; } +template <> +Status ScriptedPythonInterface::ExtractValueFromPythonObject( + python::PythonObject &p, Status &error) { + if (lldb::SBError *sb_error = reinterpret_cast( + LLDBSWIGPython_CastPyObjectToSBError(p.get()))) + error = m_interpreter.GetStatusFromSBError(*sb_error); + else + error.SetErrorString("Couldn't cast lldb::SBError to lldb::Status."); + + return error; +} + +template <> +lldb::DataExtractorSP +ScriptedPythonInterface::ExtractValueFromPythonObject( + python::PythonObject &p, Status &error) { + lldb::SBData *sb_data = reinterpret_cast( + LLDBSWIGPython_CastPyObjectToSBData(p.get())); + + if (!sb_data) { + error.SetErrorString("Couldn't cast lldb::SBError to lldb::Status."); + return nullptr; + } + + return m_interpreter.GetDataExtractorFromSBData(*sb_data); +} + #endif diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h index 85ec167e1463f..bac4efbe76d8d 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h @@ -33,33 +33,6 @@ class ScriptedPythonInterface : virtual public ScriptedInterface { return p.CreateStructuredObject(); } - template <> - Status ExtractValueFromPythonObject(python::PythonObject &p, - Status &error) { - if (lldb::SBError *sb_error = reinterpret_cast( - LLDBSWIGPython_CastPyObjectToSBError(p.get()))) - error = m_interpreter.GetStatusFromSBError(*sb_error); - else - error.SetErrorString("Couldn't cast lldb::SBError to lldb::Status."); - - return error; - } - - template <> - lldb::DataExtractorSP - ExtractValueFromPythonObject(python::PythonObject &p, - Status &error) { - lldb::SBData *sb_data = reinterpret_cast( - LLDBSWIGPython_CastPyObjectToSBData(p.get())); - - if (!sb_data) { - error.SetErrorString("Couldn't cast lldb::SBError to lldb::Status."); - return nullptr; - } - - return m_interpreter.GetDataExtractorFromSBData(*sb_data); - } - template T Dispatch(llvm::StringRef method_name, Status &error, Args... args) { using namespace python; @@ -149,6 +122,16 @@ class ScriptedPythonInterface : virtual public ScriptedInterface { // The lifetime is managed by the ScriptInterpreter ScriptInterpreterPythonImpl &m_interpreter; }; + +template <> +Status ScriptedPythonInterface::ExtractValueFromPythonObject( + python::PythonObject &p, Status &error); + +template <> +lldb::DataExtractorSP +ScriptedPythonInterface::ExtractValueFromPythonObject( + python::PythonObject &p, Status &error); + } // namespace lldb_private #endif // LLDB_ENABLE_PYTHON