mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
refactor: clang format line length
This commit is contained in:
@@ -21,7 +21,8 @@ namespace swift::misc::private_ns
|
||||
{
|
||||
//! \cond PRIVATE
|
||||
|
||||
// Like invoke() but ignores the first argument if callable is not a member function. For uniform calling of callables with slot semantics.
|
||||
// Like invoke() but ignores the first argument if callable is not a member function. For uniform calling of
|
||||
// callables with slot semantics.
|
||||
template <typename F, typename T, typename U, size_t... Is>
|
||||
decltype(auto) invokeSlotImpl(F ptr, T *object, U tuple, std::index_sequence<Is...>, std::true_type)
|
||||
{
|
||||
@@ -37,18 +38,22 @@ namespace swift::misc::private_ns
|
||||
template <typename F, typename T, typename... Ts>
|
||||
decltype(auto) invokeSlot(F &&func, T *object, Ts &&...args)
|
||||
{
|
||||
using seq = MaskSequence<std::make_index_sequence<sizeof...(Ts)>, !TIsQPrivateSignal<std::decay_t<Ts>>::value...>;
|
||||
return invokeSlotImpl(std::forward<F>(func), object, std::forward_as_tuple(std::forward<Ts>(args)...), seq(), std::is_member_pointer<std::decay_t<F>>());
|
||||
using seq =
|
||||
MaskSequence<std::make_index_sequence<sizeof...(Ts)>, !TIsQPrivateSignal<std::decay_t<Ts>>::value...>;
|
||||
return invokeSlotImpl(std::forward<F>(func), object, std::forward_as_tuple(std::forward<Ts>(args)...), seq(),
|
||||
std::is_member_pointer<std::decay_t<F>>());
|
||||
}
|
||||
|
||||
// Like QMetaObject::invokeMethod but the return value is accessed through a QFuture, and extra arguments can be provided.
|
||||
// Like QMetaObject::invokeMethod but the return value is accessed through a QFuture, and extra arguments can be
|
||||
// provided.
|
||||
template <typename T, typename F, typename... Ts>
|
||||
auto invokeMethod(T *object, F &&func, Ts &&...args)
|
||||
{
|
||||
const auto invoker = [](auto &&...x) { return private_ns::invokeSlot(std::forward<decltype(x)>(x)...); };
|
||||
auto method = std::bind(invoker, std::forward<F>(func), object, std::forward<Ts>(args)...);
|
||||
CPromise<decltype(std::move(method)())> promise;
|
||||
QMetaObject::invokeMethod(object, [promise, method = std::move(method)]() mutable { promise.setResultFrom(std::move(method)); });
|
||||
QMetaObject::invokeMethod(
|
||||
object, [promise, method = std::move(method)]() mutable { promise.setResultFrom(std::move(method)); });
|
||||
return promise.future();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user