Skip to content

Commit bc9d862

Browse files
authored
Merge pull request #3228 from medismailben/stable/20210726
[lldb/Plugins] Move member template specialization out of class
2 parents 7e4b309 + 08ec0e2 commit bc9d862

File tree

2 files changed

+37
-27
lines changed

2 files changed

+37
-27
lines changed

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,31 @@ ScriptedPythonInterface::GetStatusFromMethod(llvm::StringRef method_name) {
3535
return error;
3636
}
3737

38+
template <>
39+
Status ScriptedPythonInterface::ExtractValueFromPythonObject<Status>(
40+
python::PythonObject &p, Status &error) {
41+
if (lldb::SBError *sb_error = reinterpret_cast<lldb::SBError *>(
42+
LLDBSWIGPython_CastPyObjectToSBError(p.get())))
43+
error = m_interpreter.GetStatusFromSBError(*sb_error);
44+
else
45+
error.SetErrorString("Couldn't cast lldb::SBError to lldb::Status.");
46+
47+
return error;
48+
}
49+
50+
template <>
51+
lldb::DataExtractorSP
52+
ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DataExtractorSP>(
53+
python::PythonObject &p, Status &error) {
54+
lldb::SBData *sb_data = reinterpret_cast<lldb::SBData *>(
55+
LLDBSWIGPython_CastPyObjectToSBData(p.get()));
56+
57+
if (!sb_data) {
58+
error.SetErrorString("Couldn't cast lldb::SBError to lldb::Status.");
59+
return nullptr;
60+
}
61+
62+
return m_interpreter.GetDataExtractorFromSBData(*sb_data);
63+
}
64+
3865
#endif

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,33 +33,6 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
3333
return p.CreateStructuredObject();
3434
}
3535

36-
template <>
37-
Status ExtractValueFromPythonObject<Status>(python::PythonObject &p,
38-
Status &error) {
39-
if (lldb::SBError *sb_error = reinterpret_cast<lldb::SBError *>(
40-
LLDBSWIGPython_CastPyObjectToSBError(p.get())))
41-
error = m_interpreter.GetStatusFromSBError(*sb_error);
42-
else
43-
error.SetErrorString("Couldn't cast lldb::SBError to lldb::Status.");
44-
45-
return error;
46-
}
47-
48-
template <>
49-
lldb::DataExtractorSP
50-
ExtractValueFromPythonObject<lldb::DataExtractorSP>(python::PythonObject &p,
51-
Status &error) {
52-
lldb::SBData *sb_data = reinterpret_cast<lldb::SBData *>(
53-
LLDBSWIGPython_CastPyObjectToSBData(p.get()));
54-
55-
if (!sb_data) {
56-
error.SetErrorString("Couldn't cast lldb::SBError to lldb::Status.");
57-
return nullptr;
58-
}
59-
60-
return m_interpreter.GetDataExtractorFromSBData(*sb_data);
61-
}
62-
6336
template <typename T = StructuredData::ObjectSP, typename... Args>
6437
T Dispatch(llvm::StringRef method_name, Status &error, Args... args) {
6538
using namespace python;
@@ -149,6 +122,16 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
149122
// The lifetime is managed by the ScriptInterpreter
150123
ScriptInterpreterPythonImpl &m_interpreter;
151124
};
125+
126+
template <>
127+
Status ScriptedPythonInterface::ExtractValueFromPythonObject<Status>(
128+
python::PythonObject &p, Status &error);
129+
130+
template <>
131+
lldb::DataExtractorSP
132+
ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::DataExtractorSP>(
133+
python::PythonObject &p, Status &error);
134+
152135
} // namespace lldb_private
153136

154137
#endif // LLDB_ENABLE_PYTHON

0 commit comments

Comments
 (0)