diff options
author | Med Ismail Bennani <medismail.bennani@gmail.com> | 2022-11-19 13:20:11 -0800 |
---|---|---|
committer | Med Ismail Bennani <medismail.bennani@gmail.com> | 2022-11-19 13:24:47 -0800 |
commit | 41f3e6b74df173198c67f46f223b9815334d42a2 (patch) | |
tree | 1eb0d663ce28be06ce53f37ba4d9df49a172a96f /lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h | |
parent | 2baa99b2a8e43ecb3c43056a964c89f4ee6651d2 (diff) | |
download | llvm-41f3e6b74df173198c67f46f223b9815334d42a2.zip llvm-41f3e6b74df173198c67f46f223b9815334d42a2.tar.gz llvm-41f3e6b74df173198c67f46f223b9815334d42a2.tar.bz2 |
[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 <medismail.bennani@gmail.com>
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h')
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h | 40 |
1 files changed, 15 insertions, 25 deletions
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 <typename T> struct transformation { using type = T; }; - template <typename T, typename U> 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<Status> { - using type = python::PythonObject; - }; - template <typename T> struct reverse_transformation<T, python::PythonObject> { - static void Apply(ScriptedPythonInterface &obj, T &original_arg, - python::PythonObject transformed_arg, Status &error) { - original_arg = - obj.ExtractValueFromPythonObject<T>(transformed_arg, error); - } - }; - - template <typename T> typename transformation<T>::type Transform(T object) { + template <typename T> T Transform(T object) { // No Transformation for generic usage return {object}; } - template <> typename transformation<Status>::type Transform(Status arg) { - // Call SWIG Wrapper function + python::PythonObject Transform(Status arg) { return python::ToSWIGWrapper(arg); } + template <typename T, typename U> + void ReverseTransform(T &original_arg, U transformed_arg, Status &error) { + // If U is not a PythonObject, don't touch it! + return; + } + + template <typename T> + void ReverseTransform(T &original_arg, python::PythonObject transformed_arg, + Status &error) { + original_arg = ExtractValueFromPythonObject<T>(transformed_arg, error); + } + template <std::size_t... I, typename... Args> auto TransformTuple(const std::tuple<Args...> &args, std::index_sequence<I...>) { @@ -146,8 +137,7 @@ protected: template <typename T, typename U> void TransformBack(T &original_arg, U transformed_arg, Status &error) { - reverse_transformation<T, U>::Apply(*this, original_arg, transformed_arg, - error); + ReverseTransform(original_arg, transformed_arg, error); } template <std::size_t... I, typename... Ts, typename... Us> |