Skip to content

Commit 0350943

Browse files
committed
[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 <[email protected]>
1 parent 084faa0 commit 0350943

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

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

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -101,36 +101,27 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
101101

102102
Status GetStatusFromMethod(llvm::StringRef method_name);
103103

104-
template <typename T> struct transformation { using type = T; };
105-
template <typename T, typename U> struct reverse_transformation {
106-
static void Apply(ScriptedPythonInterface &obj, T &original_arg,
107-
U transformed_arg, Status &error) {
108-
// If U is not a PythonObject, don't touch it!
109-
return;
110-
}
111-
};
112-
113-
template <> struct transformation<Status> {
114-
using type = python::PythonObject;
115-
};
116-
template <typename T> struct reverse_transformation<T, python::PythonObject> {
117-
static void Apply(ScriptedPythonInterface &obj, T &original_arg,
118-
python::PythonObject transformed_arg, Status &error) {
119-
original_arg =
120-
obj.ExtractValueFromPythonObject<T>(transformed_arg, error);
121-
}
122-
};
123-
124-
template <typename T> typename transformation<T>::type Transform(T object) {
104+
template <typename T> T Transform(T object) {
125105
// No Transformation for generic usage
126106
return {object};
127107
}
128108

129-
template <> typename transformation<Status>::type Transform(Status arg) {
130-
// Call SWIG Wrapper function
109+
python::PythonObject Transform(Status arg) {
131110
return python::ToSWIGWrapper(arg);
132111
}
133112

113+
template <typename T, typename U>
114+
void ReverseTransform(T &original_arg, U transformed_arg, Status &error) {
115+
// If U is not a PythonObject, don't touch it!
116+
return;
117+
}
118+
119+
template <typename T>
120+
void ReverseTransform(T &original_arg, python::PythonObject transformed_arg,
121+
Status &error) {
122+
original_arg = ExtractValueFromPythonObject<T>(transformed_arg, error);
123+
}
124+
134125
template <std::size_t... I, typename... Args>
135126
auto TransformTuple(const std::tuple<Args...> &args,
136127
std::index_sequence<I...>) {
@@ -146,8 +137,7 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
146137

147138
template <typename T, typename U>
148139
void TransformBack(T &original_arg, U transformed_arg, Status &error) {
149-
reverse_transformation<T, U>::Apply(*this, original_arg, transformed_arg,
150-
error);
140+
ReverseTransform(original_arg, transformed_arg, error);
151141
}
152142

153143
template <std::size_t... I, typename... Ts, typename... Us>

0 commit comments

Comments
 (0)