7#error Do not include qobjectdefs_impl.h directly
8#include <QtCore/qnamespace.h>
12#pragma qt_sync_skip_header_check
13#pragma qt_sync_stop_processing
16#include <QtCore/qfunctionaltools_impl.h>
33
34
35
36
37
39 template <
typename... Ts>
struct List {
static constexpr size_t size =
sizeof...(Ts); };
43 template <
typename Head,
typename... Tail>
struct List<Head, Tail...> {
55
56
57
58
61 template <
typename R,
typename Lambda>
65 if constexpr (std::is_void_v<R> || std::is_void_v<std::invoke_result_t<Lambda>>) {
66 std::forward<Lambda>(fn)();
69 *
reinterpret_cast<R *>(args[0]) =
std::forward<Lambda>(fn)();
71 [[maybe_unused]]
auto r =
std::forward<Lambda>(fn)();
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
94 template<
typename ObjPrivate>
inline void assertObjectType(QObjectPrivate *d);
98 [[maybe_unused]]
auto staticcast = [](QObject *obj) {
return static_cast<Obj *>(obj); };
99 [[maybe_unused]]
auto qobjcast = [](QObject *obj) {
return Obj::staticMetaObject.cast(obj); };
101 [[maybe_unused]]
auto dyncast = [](QObject *obj) {
return dynamic_cast<Obj *>(obj); };
104 auto cast = qobjcast;
106 Q_ASSERT_X(cast(o), Obj::staticMetaObject.className(),
107 "Called object is not of the correct type (class destructor may have already run)");
110 template <
typename,
typename,
typename,
typename>
struct FunctorCall;
171 typedef Ret (Obj::*Function) (Args...);
173 template <
typename SignalArgs,
typename R>
174 static void call(Function f, Obj *o,
void **arg) {
175 FunctorCall<std::index_sequence_for<Args...>, SignalArgs, R, Function>::call(f, o, arg);
178 template<
class Obj,
typename Ret,
typename... Args>
struct FunctionPointer<Ret (
Obj::*) (Args...)
const>
183 typedef Ret (Obj::*Function) (Args...)
const;
185 template <
typename SignalArgs,
typename R>
186 static void call(Function f, Obj *o,
void **arg) {
187 FunctorCall<std::index_sequence_for<Args...>, SignalArgs, R, Function>::call(f, o, arg);
195 typedef Ret (*Function) (Args...);
197 template <
typename SignalArgs,
typename R>
198 static void call(Function f,
void *,
void **arg) {
199 FunctorCall<std::index_sequence_for<Args...>, SignalArgs, R, Function>::call(f, arg);
203 template<
class Obj,
typename Ret,
typename... Args>
struct FunctionPointer<Ret (
Obj::*) (Args...)
noexcept>
208 typedef Ret (Obj::*Function) (Args...)
noexcept;
210 template <
typename SignalArgs,
typename R>
211 static void call(Function f, Obj *o,
void **arg) {
212 FunctorCall<std::index_sequence_for<Args...>, SignalArgs, R, Function>::call(f, o, arg);
215 template<
class Obj,
typename Ret,
typename... Args>
struct FunctionPointer<Ret (
Obj::*) (Args...)
const noexcept>
220 typedef Ret (Obj::*Function) (Args...)
const noexcept;
222 template <
typename SignalArgs,
typename R>
223 static void call(Function f, Obj *o,
void **arg) {
224 FunctorCall<std::index_sequence_for<Args...>, SignalArgs, R, Function>::call(f, o, arg);
228 template<
typename Ret,
typename... Args>
struct FunctionPointer<Ret (*) (Args...)
noexcept>
232 typedef Ret (*Function) (Args...)
noexcept;
234 template <
typename SignalArgs,
typename R>
235 static void call(Function f,
void *,
void **arg) {
236 FunctorCall<std::index_sequence_for<Args...>, SignalArgs, R, Function>::call(f, arg);
242 template <
typename T>
245 template <
typename From,
typename To,
typename Enable =
void>
248 template <
typename From,
typename To>
257 template <
typename From,
typename To,
typename Enable =
void>
260 template <
typename From,
typename To>
268
269
270
271
273 static int test(
const std::remove_reference_t<A2>&);
275 enum {
value =
sizeof(
test(std::declval<std::remove_reference_t<A1>>())) ==
sizeof(
int) };
276#ifdef QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
291 template <
typename Arg1,
typename Arg2,
typename... Tail1,
typename... Tail2>
299
300
301
302
307 template <
typename Functor,
typename First,
typename... ArgList>
314 template <
typename F>
static auto test(F f) ->
decltype(((f.operator()((
std::declval<ArgList>())...)),
int()));
317 Ok =
sizeof(test(
std::declval<Functor>())) ==
sizeof(
int),
325 :
std::invoke_result<Functor, ArgList...>
328 template<
typename Func,
typename... Args>
336 template <
typename SignalArgs,
typename R>
337 static void call(Func &f,
void *,
void **arg) {
338 FunctorCall<std::index_sequence_for<Args...>, SignalArgs, R, Func>::call(f, arg);
342 template <
typename Functor,
typename... Args>
346 template <
typename F,
typename =
void>
347 struct Test : std::false_type
351 template <
typename F>
366 template <
typename Func,
typename... Args>
372 static auto Resolve(std::true_type CallOperator) ->
FunctorCallable<Func, Args...>;
373 static auto Resolve(std::false_type CallOperator) -> FunctionPointer<std::decay_t<Func>>;
380 template<
typename Func,
typename... Args>
383 template<
typename Func,
typename... Args>
388
389
390
391
425#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
430 using ImplFn =
void (*)(
QSlotObjectBase* this_, QObject *receiver,
void **args,
int which,
bool *ret);
432 QAtomicInt m_ref = 1;
456 bool ref()
noexcept {
return m_ref.ref(); }
457#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
465 {
if (!m_ref.deref()) m_impl(
this,
nullptr,
nullptr,
Destroy,
nullptr); }
470 m_impl(
this,
nullptr, a,
Compare, &ret);
473 inline void call(QObject *r,
void **a) { m_impl(
this, r, a,
Call,
nullptr); }
475 bool isImpl(ImplFn f)
const {
return m_impl == f; }
513 auto get()
const noexcept {
return obj.get(); }
516 explicit operator bool()
const noexcept {
return bool(obj); }
522 template <
typename Func,
typename Args,
typename R>
528 using FuncType =
Callable<Func, Args>;
530#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
536 Q_DECL_HIDDEN
static void impl(
QSlotObjectBase *this_, QObject *r,
void **a,
int which,
bool *ret)
545 if constexpr (std::is_member_function_pointer_v<FunctorValue>)
546 FuncType::
template call<Args, R>(that->object(),
static_cast<
typename FuncType::Object *>(r), a);
548 FuncType::
template call<Args, R>(that->object(), r, a);
551 if constexpr (std::is_member_function_pointer_v<FunctorValue>) {
552 *ret = *
reinterpret_cast<FunctorValue *>(a) == that->object();
571 template <
typename Func,
typename =
void>
574 template <
typename Func>
584 template <
typename Func>
597
598
599
600
601
616 "Functor requires more arguments than what can be provided.");
622 template<
typename Prototype,
typename Functor,
typename =
void>
630 template<
typename Prototype,
typename Functor>
632 static_assert(AreFunctionsCompatible<Prototype, Functor>::value,
633 "Functor is not compatible with expected prototype!");
QCallableObject(const Func &f)
QCallableObject(Func &&f)
void destroyIfLastRef() noexcept
bool isImpl(ImplFn f) const
void call(QObject *r, void **a)
QSlotObjectBase(ImplFn fn)
SlotObjSharedPtr & operator=(SlotObjSharedPtr &&other) noexcept=default
operator bool() const noexcept
~SlotObjSharedPtr()=default
auto operator->() const noexcept
void swap(SlotObjSharedPtr &other) noexcept
auto get() const noexcept
void assertObjectType(QObject *o)
constexpr bool HasCallOperatorAcceptingArgs_v
constexpr bool AssertCompatibleFunctions()
SlotObjUniquePtr copy(const SlotObjUniquePtr &other) noexcept
std::unique_ptr< QSlotObjectBase, QSlotObjectBase::Deleter > SlotObjUniquePtr
static int test(const std::remove_reference_t< A2 > &)
static auto test(F f) -> decltype(((f.operator()((std::declval< ArgList >())...)), int()))
static void call(Function f, Obj *o, void **arg)
List< Args... > Arguments
@ IsPointerToMemberFunction
static void call(Function f, void *, void **arg)
@ IsPointerToMemberFunction
List< Args... > Arguments
@ IsPointerToMemberFunction
static void call_internal(void **args, Lambda &&fn) noexcept(std::is_nothrow_invocable_v< Lambda >)
static void call(Func &f, void *, void **arg)
QtPrivate::List< Args... > Arguments
static constexpr bool value
static constexpr size_t size
List< L1..., L2... > Value
List_Append< List< typenameL::Car >, typenameList_Left< typenameL::Cdr, N-1 >::Value >::Value Value
static constexpr size_t size
void operator()(QSlotObjectBase *p) const noexcept
static void cleanup(QSlotObjectBase *p) noexcept
static constexpr size_t value
static constexpr size_t value
static constexpr size_t value