6#error Do not include qobjectdefs_impl.h directly
7#include <QtCore/qnamespace.h>
11#pragma qt_sync_skip_header_check
12#pragma qt_sync_stop_processing
15#include <QtCore/qfunctionaltools_impl.h>
32
33
34
35
36
38 template <
typename... Ts>
struct List {
static constexpr size_t size =
sizeof...(Ts); };
42 template <
typename Head,
typename... Tail>
struct List<Head, Tail...> {
46 template <
typename,
typename>
struct List_Append;
47 template <
typename... L1,
typename...L2>
struct List_Append<
List<L1...>,
List<L2...>> {
typedef List<L1..., L2...>
Value; };
54
55
56
57
60 template <
typename R,
typename Lambda>
64 if constexpr (std::is_void_v<R> || std::is_void_v<std::invoke_result_t<Lambda>>) {
65 std::forward<Lambda>(fn)();
68 *
reinterpret_cast<R *>(args[0]) =
std::forward<Lambda>(fn)();
70 [[maybe_unused]]
auto r =
std::forward<Lambda>(fn)();
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
93 template<
typename ObjPrivate>
inline void assertObjectType(QObjectPrivate *d);
97 [[maybe_unused]]
auto staticcast = [](QObject *obj) {
return static_cast<Obj *>(obj); };
98 [[maybe_unused]]
auto qobjcast = [](QObject *obj) {
return Obj::staticMetaObject.cast(obj); };
100 [[maybe_unused]]
auto dyncast = [](QObject *obj) {
return dynamic_cast<Obj *>(obj); };
103 auto cast = qobjcast;
105 Q_ASSERT_X(cast(o), Obj::staticMetaObject.className(),
106 "Called object is not of the correct type (class destructor may have already run)");
109 template <
typename,
typename,
typename,
typename>
struct FunctorCall;
170 typedef Ret (Obj::*Function) (Args...);
172 template <
typename SignalArgs,
typename R>
173 static void call(Function f, Obj *o,
void **arg) {
174 FunctorCall<std::index_sequence_for<Args...>, SignalArgs, R, Function>::call(f, o, arg);
177 template<
class Obj,
typename Ret,
typename... Args>
struct FunctionPointer<Ret (
Obj::*) (Args...)
const>
182 typedef Ret (Obj::*Function) (Args...)
const;
184 template <
typename SignalArgs,
typename R>
185 static void call(Function f, Obj *o,
void **arg) {
186 FunctorCall<std::index_sequence_for<Args...>, SignalArgs, R, Function>::call(f, o, arg);
194 typedef Ret (*Function) (Args...);
196 template <
typename SignalArgs,
typename R>
197 static void call(Function f,
void *,
void **arg) {
198 FunctorCall<std::index_sequence_for<Args...>, SignalArgs, R, Function>::call(f, arg);
202 template<
class Obj,
typename Ret,
typename... Args>
struct FunctionPointer<Ret (
Obj::*) (Args...)
noexcept>
207 typedef Ret (Obj::*Function) (Args...)
noexcept;
209 template <
typename SignalArgs,
typename R>
210 static void call(Function f, Obj *o,
void **arg) {
211 FunctorCall<std::index_sequence_for<Args...>, SignalArgs, R, Function>::call(f, o, arg);
214 template<
class Obj,
typename Ret,
typename... Args>
struct FunctionPointer<Ret (
Obj::*) (Args...)
const noexcept>
219 typedef Ret (Obj::*Function) (Args...)
const noexcept;
221 template <
typename SignalArgs,
typename R>
222 static void call(Function f, Obj *o,
void **arg) {
223 FunctorCall<std::index_sequence_for<Args...>, SignalArgs, R, Function>::call(f, o, arg);
227 template<
typename Ret,
typename... Args>
struct FunctionPointer<Ret (*) (Args...)
noexcept>
231 typedef Ret (*Function) (Args...)
noexcept;
233 template <
typename SignalArgs,
typename R>
234 static void call(Function f,
void *,
void **arg) {
235 FunctorCall<std::index_sequence_for<Args...>, SignalArgs, R, Function>::call(f, arg);
241 template <
typename T>
244 template <
typename From,
typename To,
typename Enable =
void>
247 template <
typename From,
typename To>
256 template <
typename From,
typename To,
typename Enable =
void>
259 template <
typename From,
typename To>
267
268
269
270
272 static int test(
const std::remove_reference_t<A2>&);
274 enum {
value =
sizeof(test(std::declval<std::remove_reference_t<A1>>())) ==
sizeof(
int) };
275#ifdef QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
290 template <
typename Arg1,
typename Arg2,
typename... Tail1,
typename... Tail2>
298
299
300
301
302 template <
typename Functor,
typename ArgList>
struct ComputeFunctorArgumentCount;
306 template <
typename Functor,
typename First,
typename... ArgList>
308 : ComputeFunctorArgumentCount<Functor,
309 typename List_Left<
List<First, ArgList...>,
sizeof...(ArgList)>::Value> {};
311 template <
typename Functor,
typename... ArgList>
struct ComputeFunctorArgumentCount<Functor,
List<ArgList...>>
313 template <
typename F>
static auto test(F f) ->
decltype(((f.operator()((
std::declval<ArgList>())...)),
int()));
316 Ok =
sizeof(test(
std::declval<Functor>())) ==
sizeof(
int),
322 template <
typename Functor,
typename ArgList>
struct FunctorReturnType;
323 template <
typename Functor,
typename... ArgList>
struct FunctorReturnType<Functor,
List<ArgList...>>
324 :
std::invoke_result<Functor, ArgList...>
327 template<
typename Func,
typename... Args>
335 template <
typename SignalArgs,
typename R>
336 static void call(Func &f,
void *,
void **arg) {
337 FunctorCall<std::index_sequence_for<Args...>, SignalArgs, R, Func>::call(f, arg);
341 template <
typename Functor,
typename... Args>
345 template <
typename F,
typename =
void>
346 struct Test : std::false_type
350 template <
typename F>
365 template <
typename Func,
typename... Args>
371 static auto Resolve(std::true_type CallOperator) ->
FunctorCallable<Func, Args...>;
372 static auto Resolve(std::false_type CallOperator) -> FunctionPointer<std::decay_t<Func>>;
379 template<
typename Func,
typename... Args>
382 template<
typename Func,
typename... Args>
387
388
389
390
424#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
429 using ImplFn =
void (*)(
QSlotObjectBase* this_, QObject *receiver,
void **args,
int which,
bool *ret);
431 QAtomicInt m_ref = 1;
455 bool ref()
noexcept {
return m_ref.ref(); }
456#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
464 {
if (!m_ref.deref()) m_impl(
this,
nullptr,
nullptr,
Destroy,
nullptr); }
469 m_impl(
this,
nullptr, a,
Compare, &ret);
472 inline void call(QObject *r,
void **a) { m_impl(
this, r, a,
Call,
nullptr); }
474 bool isImpl(ImplFn f)
const {
return m_impl == f; }
483 inline SlotObjUniquePtr
copy(
const SlotObjUniquePtr &other)
noexcept
487 return SlotObjUniquePtr{other.get()};
491 SlotObjUniquePtr obj;
512 auto get()
const noexcept {
return obj.get(); }
515 explicit operator bool()
const noexcept {
return bool(obj); }
521 template <
typename Func,
typename Args,
typename R>
527 using FuncType =
Callable<Func, Args>;
529#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
535 Q_DECL_HIDDEN
static void impl(
QSlotObjectBase *this_, QObject *r,
void **a,
int which,
bool *ret)
544 if constexpr (std::is_member_function_pointer_v<FunctorValue>)
545 FuncType::
template call<Args, R>(that->object(),
static_cast<
typename FuncType::Object *>(r), a);
547 FuncType::
template call<Args, R>(that->object(), r, a);
550 if constexpr (std::is_member_function_pointer_v<FunctorValue>) {
551 *ret = *
reinterpret_cast<FunctorValue *>(a) == that->object();
570 template <
typename Func,
typename =
void>
573 template <
typename Func>
583 template <
typename Func>
596
597
598
599
600
615 "Functor requires more arguments than what can be provided.");
621 template<
typename Prototype,
typename Functor,
typename =
void>
629 template<
typename Prototype,
typename Functor>
631 static_assert(AreFunctionsCompatible<Prototype, Functor>::value,
632 "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
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)
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