From 41f3e6b74df173198c67f46f223b9815334d42a2 Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Sat, 19 Nov 2022 13:20:11 -0800 Subject: [lldb/Plugins] Fix build failure with GCC in ScriptedPythonInterface::Dispatch This patch should fix the build failures following 7e01924 when building with GCC. These failures were mostly caused by GCC's poor support of C++ templates (namely, partial template specialization). To work around that problem, this patch makes use of overloading and get rid of the templated structs and specialized structs. Signed-off-by: Med Ismail Bennani --- .../Python/ScriptedPythonInterface.h | 40 ++++++++-------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h index ac1fe09..268430f 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h @@ -101,36 +101,27 @@ protected: Status GetStatusFromMethod(llvm::StringRef method_name); - template struct transformation { using type = T; }; - template struct reverse_transformation { - static void Apply(ScriptedPythonInterface &obj, T &original_arg, - U transformed_arg, Status &error) { - // If U is not a PythonObject, don't touch it! - return; - } - }; - - template <> struct transformation { - using type = python::PythonObject; - }; - template struct reverse_transformation { - static void Apply(ScriptedPythonInterface &obj, T &original_arg, - python::PythonObject transformed_arg, Status &error) { - original_arg = - obj.ExtractValueFromPythonObject(transformed_arg, error); - } - }; - - template typename transformation::type Transform(T object) { + template T Transform(T object) { // No Transformation for generic usage return {object}; } - template <> typename transformation::type Transform(Status arg) { - // Call SWIG Wrapper function + python::PythonObject Transform(Status arg) { return python::ToSWIGWrapper(arg); } + template + void ReverseTransform(T &original_arg, U transformed_arg, Status &error) { + // If U is not a PythonObject, don't touch it! + return; + } + + template + void ReverseTransform(T &original_arg, python::PythonObject transformed_arg, + Status &error) { + original_arg = ExtractValueFromPythonObject(transformed_arg, error); + } + template auto TransformTuple(const std::tuple &args, std::index_sequence) { @@ -146,8 +137,7 @@ protected: template void TransformBack(T &original_arg, U transformed_arg, Status &error) { - reverse_transformation::Apply(*this, original_arg, transformed_arg, - error); + ReverseTransform(original_arg, transformed_arg, error); } template -- cgit v1.1