summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2024-01-30 15:19:23 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2024-01-31 21:18:48 +0100
commit76cf922980cf0cde7cb03f4bec8f17eab94a5767 (patch)
treefaf43c5e14fef1d62f0251e92b147648c2e06c1b /src/corelib/kernel
parent72f5b35b3d7704db6ef16e4c60751ed8444363be (diff)
JNI: simplify implementation of native function wrappers
When declaring native callback functions with the JNI type system, then we actually register a helper function with variadic arguments, and implement that to forward the arguments to the declared function, which then might use higher-level types as arguments. We deduce those higher-level types through a variadic template, and use std::tuple as well as std::apply to generate the calls. Simplify the implementation by using std::make_tuple, and replace q20:remove_cvref_t with std::decay_t; this is what std::make_tuple uses, and we don't need to maintain functions and arrays as such. Found during 6.7 header review. Pick-to: 6.7 Task-number: QTBUG-119952 Change-Id: I7cd206c6b372c2ec62a10feb5f9253f5607f01a9 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qjnitypes.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/corelib/kernel/qjnitypes.h b/src/corelib/kernel/qjnitypes.h
index 56af657fa3..71c4db670c 100644
--- a/src/corelib/kernel/qjnitypes.h
+++ b/src/corelib/kernel/qjnitypes.h
@@ -96,20 +96,18 @@ struct JNITypeForArgImpl<QString>
};
template <typename Arg>
-using JNITypeForArg = typename JNITypeForArgImpl<q20::remove_cvref_t<Arg>>::Type;
+using JNITypeForArg = typename JNITypeForArgImpl<std::decay_t<Arg>>::Type;
template <typename Arg, typename Type>
static inline auto methodArgFromVarArg(Type &&t)
{
- return JNITypeForArgImpl<q20::remove_cvref_t<Arg>>::fromVarArg(std::move(t));
+ return JNITypeForArgImpl<std::decay_t<Arg>>::fromVarArg(std::move(t));
}
// Turn a va_list into a tuple of typed arguments
template <typename ...Args>
static constexpr auto makeTupleFromArgsHelper(va_list args)
{
- return std::tuple<q20::remove_cvref_t<Args>...>{
- methodArgFromVarArg<q20::remove_cvref_t<Args>>(va_arg(args, JNITypeForArg<Args>))...
- };
+ return std::tuple(methodArgFromVarArg<Args>(va_arg(args, JNITypeForArg<Args>))...);
}
template <typename Ret, typename ...Args>