no message

This commit is contained in:
gem
2025-02-18 15:21:31 +08:00
commit 2d133e56d7
1980 changed files with 465595 additions and 0 deletions

View File

@@ -0,0 +1,295 @@
// generated code
#define DECLARE_BUS_EVENT_ARG0(BusEventClass, EventBusClass) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast() { \
cc::event::broadcast<BusEventClass>(); \
} \
};
#define DECLARE_BUS_EVENT_ARG1(BusEventClass, EventBusClass, ArgType0) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0) { \
cc::event::broadcast<BusEventClass>(arg0); \
} \
};
#define DECLARE_BUS_EVENT_ARG2(BusEventClass, EventBusClass, ArgType0, ArgType1) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1) { \
cc::event::broadcast<BusEventClass>(arg0, arg1); \
} \
};
#define DECLARE_BUS_EVENT_ARG3(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2); \
} \
};
#define DECLARE_BUS_EVENT_ARG4(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3); \
} \
};
#define DECLARE_BUS_EVENT_ARG5(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4); \
} \
};
#define DECLARE_BUS_EVENT_ARG6(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4, ArgType5 arg5) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4, arg5); \
} \
};
#define DECLARE_BUS_EVENT_ARG7(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4, ArgType5 arg5, ArgType6 arg6) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4, arg5, arg6); \
} \
};
#define DECLARE_BUS_EVENT_ARG8(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4, ArgType5 arg5, ArgType6 arg6, ArgType7 arg7) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); \
} \
};
#define DECLARE_BUS_EVENT_ARG9(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4, ArgType5 arg5, ArgType6 arg6, ArgType7 arg7, ArgType8 arg8) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); \
} \
};
#define DECLARE_BUS_EVENT_ARG10(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4, ArgType5 arg5, ArgType6 arg6, ArgType7 arg7, ArgType8 arg8, ArgType9 arg9) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); \
} \
};
#define DECLARE_BUS_EVENT_ARG11(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4, ArgType5 arg5, ArgType6 arg6, ArgType7 arg7, ArgType8 arg8, ArgType9 arg9, ArgType10 arg10) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); \
} \
};
#define DECLARE_BUS_EVENT_ARG12(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4, ArgType5 arg5, ArgType6 arg6, ArgType7 arg7, ArgType8 arg8, ArgType9 arg9, ArgType10 arg10, ArgType11 arg11) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); \
} \
};
#define DECLARE_BUS_EVENT_ARG13(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4, ArgType5 arg5, ArgType6 arg6, ArgType7 arg7, ArgType8 arg8, ArgType9 arg9, ArgType10 arg10, ArgType11 arg11, ArgType12 arg12) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); \
} \
};
#define DECLARE_BUS_EVENT_ARG14(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4, ArgType5 arg5, ArgType6 arg6, ArgType7 arg7, ArgType8 arg8, ArgType9 arg9, ArgType10 arg10, ArgType11 arg11, ArgType12 arg12, ArgType13 arg13) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13); \
} \
};
#define DECLARE_BUS_EVENT_ARG15(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4, ArgType5 arg5, ArgType6 arg6, ArgType7 arg7, ArgType8 arg8, ArgType9 arg9, ArgType10 arg10, ArgType11 arg11, ArgType12 arg12, ArgType13 arg13, ArgType14 arg14) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); \
} \
};
#define DECLARE_BUS_EVENT_ARG16(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4, ArgType5 arg5, ArgType6 arg6, ArgType7 arg7, ArgType8 arg8, ArgType9 arg9, ArgType10 arg10, ArgType11 arg11, ArgType12 arg12, ArgType13 arg13, ArgType14 arg14, ArgType15 arg15) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); \
} \
};
#define DECLARE_BUS_EVENT_ARG17(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4, ArgType5 arg5, ArgType6 arg6, ArgType7 arg7, ArgType8 arg8, ArgType9 arg9, ArgType10 arg10, ArgType11 arg11, ArgType12 arg12, ArgType13 arg13, ArgType14 arg14, ArgType15 arg15, ArgType16 arg16) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16); \
} \
};
#define DECLARE_BUS_EVENT_ARG18(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16, ArgType17) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16, ArgType17> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4, ArgType5 arg5, ArgType6 arg6, ArgType7 arg7, ArgType8 arg8, ArgType9 arg9, ArgType10 arg10, ArgType11 arg11, ArgType12 arg12, ArgType13 arg13, ArgType14 arg14, ArgType15 arg15, ArgType16 arg16, ArgType17 arg17) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17); \
} \
};
#define DECLARE_BUS_EVENT_ARG19(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16, ArgType17, ArgType18) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16, ArgType17, ArgType18> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4, ArgType5 arg5, ArgType6 arg6, ArgType7 arg7, ArgType8 arg8, ArgType9 arg9, ArgType10 arg10, ArgType11 arg11, ArgType12 arg12, ArgType13 arg13, ArgType14 arg14, ArgType15 arg15, ArgType16 arg16, ArgType17 arg17, ArgType18 arg18) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18); \
} \
};
#define DECLARE_BUS_EVENT_ARG20(BusEventClass, EventBusClass, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16, ArgType17, ArgType18, ArgType19) \
struct BusEventClass final : cc::event::BusEventTrait<EventBusName_(EventBusClass), void, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16, ArgType17, ArgType18, ArgType19> { \
using BusType = EventBusName_(EventBusClass); \
using Listener = cc::event::Listener<BusEventClass>; \
constexpr static const char *BUS_NAME = EventBusName_(EventBusClass)::BUS_NAME; \
constexpr static const char *HANDLE_CLASS = #BusEventClass; \
constexpr static size_t TypeID() { \
return cc::event::intl::hash(#BusEventClass); \
} \
static inline void broadcast(ArgType0 arg0, ArgType1 arg1, ArgType2 arg2, ArgType3 arg3, ArgType4 arg4, ArgType5 arg5, ArgType6 arg6, ArgType7 arg7, ArgType8 arg8, ArgType9 arg9, ArgType10 arg10, ArgType11 arg11, ArgType12 arg12, ArgType13 arg13, ArgType14 arg14, ArgType15 arg15, ArgType16 arg16, ArgType17 arg17, ArgType18 arg18, ArgType19 arg19) { \
cc::event::broadcast<BusEventClass>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19); \
} \
};

View File

@@ -0,0 +1,481 @@
/****************************************************************************
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#pragma once
#include <cstddef>
#include <cstdint>
#include <functional>
#include <type_traits>
namespace cc {
namespace event {
namespace intl {
template <size_t N, size_t I = 0>
struct hash_calc { // NOLINT
static constexpr size_t apply(const char (&str)[N]) {
return (hash_calc<N, I + 1>::apply(str) ^ str[I]) * 16777619U;
};
};
template <size_t N>
struct hash_calc<N, N> { // NOLINT
static constexpr size_t apply(const char (&/*used*/)[N]) {
return 2166136261U;
};
};
template <size_t N>
constexpr size_t hash(const char (&str)[N]) {
return hash_calc<N>::apply(str);
}
template <typename... TYPES>
struct HeadType;
template <typename Head, typename... Tails>
struct HeadType<Head, Tails...> {
using head = Head;
using remain = HeadType<Tails...>;
};
template <typename Head>
struct HeadType<Head> {
using head = Head;
using remain = HeadType<>;
};
template <>
struct HeadType<> {
using head = void;
using remain = HeadType<>;
};
template <int idx, typename EHandler>
constexpr bool validateParameters() {
return true;
}
template <int idx, typename EHandler, typename Head>
constexpr bool validateParameters(Head && /*unused*/) {
using element_t = std::remove_reference_t<std::tuple_element_t<idx, typename EHandler::_argument_tuple_types>>;
using head = std::remove_reference_t<Head>;
constexpr bool assignable = std::is_assignable_v<head, element_t> || std::is_convertible_v<head, element_t>;
constexpr bool ret = assignable;
static_assert(ret, "Parameter type incorrect");
return ret;
}
template <int idx, typename EHandler, typename Head, typename... ARGS>
constexpr bool validateParameters(Head &&head, ARGS &&...remain) {
return validateParameters<idx, EHandler, Head>(std::forward<Head>(head)) && validateParameters<idx + 1, EHandler, ARGS...>(std::forward<ARGS>(remain)...);
}
template <typename T>
struct TupleExtractor {
using func_type = void();
};
template <typename... ARGS>
struct TupleExtractor<std::tuple<ARGS...>> {
using func_type = void(ARGS...);
using std_func_type = std::function<void(ARGS...)>;
};
template <typename F>
struct FunctionTrait : public FunctionTrait<decltype(&F::operator())> {
constexpr static bool IS_LAMBDA = true;
};
template <typename R, typename C, typename... ARGS>
struct FunctionTrait<R (C::*)(ARGS...)> {
constexpr static bool IS_LAMBDA = false;
using function_type = R (C::*)(ARGS...);
};
template <typename R, typename C, typename... ARGS>
struct FunctionTrait<R (C::*)(ARGS...) const> {
constexpr static bool IS_LAMBDA = false;
using function_type = R (C::*)(ARGS...) const;
};
template <typename R, typename... ARGS>
struct FunctionTrait<R (*)(ARGS...)> {
using function_type = R (*)(ARGS...);
constexpr static bool IS_LAMBDA = false;
};
template <typename R, typename... ARGS>
struct FunctionTrait<R(ARGS...)> {
using function_type = R(ARGS...);
constexpr static bool IS_LAMBDA = false;
};
template <typename R, typename... ARGS>
struct FunctionTrait<std::function<R(ARGS...)>> {
using function_type = std::function<R(ARGS...)>;
constexpr static bool IS_LAMBDA = false;
};
template <typename T>
struct RemoveClass {
using type = T;
};
template <typename C, typename R, typename... ARGS>
struct RemoveClass<R (C::*)(ARGS...)> {
using type = std::function<R(ARGS...)>;
};
template <typename C, typename R, typename... ARGS>
struct RemoveClass<R (C::*)(ARGS...) const> {
using type = std::function<R(ARGS...)>;
};
template <typename F>
using function_type_t = typename FunctionTrait<F>::function_type;
template <typename F>
using lambda_without_class_t = typename RemoveClass<function_type_t<F>>::type;
template <typename F>
inline auto convertLambda(F &&lambda) {
if constexpr (FunctionTrait<F>::IS_LAMBDA) {
return static_cast<lambda_without_class_t<F>>(std::forward<F>(lambda));
} else {
return static_cast<function_type_t<F>>(std::forward<F>(lambda));
}
}
template <typename T>
struct TgtEvtFnTrait;
template <typename C, typename R, typename... ARGS>
struct TgtEvtFnTrait<R(C *, ARGS...)> {
using param0_type = C;
using src_func_type = R(C *, ARGS...);
constexpr static bool IS_MEMBER_FUNC = false;
template <typename TgtEvent>
static constexpr bool accept() {
if constexpr (sizeof...(ARGS) == 0) {
using event_type = typename TgtEvent::EventType;
return std::is_same_v<param0_type, event_type>;
} else {
return false;
}
}
template <typename TgtEvent>
static auto wrap(src_func_type func) {
using event_type = typename TgtEvent::EventType;
using persist_function_type = typename TgtEvent::_persist_function_type;
using emitter_type = typename TgtEvent::_emitter_type;
persist_function_type ret;
if constexpr (accept<TgtEvent>()) {
ret = [&func](emitter_type * /*self*/, event_type *event) {
func(event);
};
} else {
static_assert(std::is_same_v<param0_type, emitter_type>, "mismatch emitter type");
ret = [func](emitter_type *self, event_type *event) {
return std::apply([self, func](auto &&...args) { func(self, args...); }, event->args);
};
}
return ret;
}
};
template <typename C, typename R, typename... ARGS>
struct TgtEvtFnTrait<R(const C *, ARGS...)> {
using param0_type = C;
using src_func_type = R(const C *, ARGS...);
constexpr static bool IS_MEMBER_FUNC = false;
template <typename TgtEvent>
static constexpr bool accept() {
if constexpr (sizeof...(ARGS) == 0) {
using event_type = typename TgtEvent::EventType;
return std::is_same_v<param0_type, event_type>;
} else {
return false;
}
}
template <typename TgtEvent>
static auto wrap(src_func_type func) {
using event_type = typename TgtEvent::EventType;
using emitter_type = typename TgtEvent::_emitter_type;
using persist_function_type = typename TgtEvent::_persist_function_type;
persist_function_type ret;
if constexpr (accept<TgtEvent>()) {
ret = [func](emitter_type * /*self*/, event_type *event) {
func(event);
};
} else {
static_assert(std::is_same_v<param0_type, emitter_type>, "mismatch emitter type");
ret = [func](emitter_type *self, event_type *event) { return std::apply([self, func](auto &&...args) { func(self, args...); }, event->args); };
}
return ret;
}
};
template <typename C, typename R, typename... ARGS>
struct TgtEvtFnTrait<R (*)(C *, ARGS...)> {
using param0_type = C;
using src_func_type = R (*)(C *, ARGS...);
constexpr static bool IS_MEMBER_FUNC = false;
template <typename TgtEvent>
static constexpr bool accept() {
if constexpr (sizeof...(ARGS) == 0) {
using event_type = typename TgtEvent::EventType;
return std::is_same_v<param0_type, event_type>;
} else {
return false;
}
}
template <typename TgtEvent>
static auto wrap(src_func_type func) {
using EventType = typename TgtEvent::EventType;
using persist_function_type = typename TgtEvent::_persist_function_type;
using emitter_type = typename TgtEvent::_emitter_type;
persist_function_type ret;
if constexpr (accept<TgtEvent>()) {
auto ret2 = [func](emitter_type * /*self*/, EventType *event) {
func(event);
};
ret = ret2;
} else {
static_assert(std::is_same_v<emitter_type, param0_type>, "mismatch emitter type");
ret = [func](emitter_type *self, EventType *event) {
return std::apply([self, func](auto &&...args) { func(self, args...); }, event->args);
};
}
return ret;
}
};
template <typename C, typename R, typename... ARGS>
struct TgtEvtFnTrait<R (*)(const C *, ARGS...)> {
using src_func_type = R (*)(const C *, ARGS...);
using param0_type = C;
constexpr static bool IS_MEMBER_FUNC = false;
template <typename TgtEvent>
static constexpr bool accept() {
if constexpr (sizeof...(ARGS) == 0) {
using event_type = typename TgtEvent::EventType;
return std::is_same_v<param0_type, event_type>;
} else {
return false;
}
}
template <typename TgtEvent>
static auto wrap(src_func_type func) {
using event_type = typename TgtEvent::EventType;
using emitter_type = typename TgtEvent::_emitter_type;
using persist_function_type = typename TgtEvent::_persist_function_type;
persist_function_type ret;
if constexpr (accept<TgtEvent>()) {
ret = [&func](emitter_type * /*self*/, event_type *event) {
func(event);
};
return ret;
} else {
static_assert(std::is_same_v<emitter_type, param0_type>, "mismatch emitter type");
ret = [func](emitter_type *self, event_type *event) {
return std::apply([self, func](auto &&...args) { func(self, args...); }, event->args);
};
}
return ret;
}
};
template <typename C, typename R, typename... ARGS>
struct TgtEvtFnTrait<std::function<R(const C *, ARGS...)>> {
using src_func_type = std::function<R(const C *, ARGS...)>;
using param0_type = C;
constexpr static bool IS_MEMBER_FUNC = false;
template <typename TgtEvent>
static constexpr bool accept() {
if constexpr (sizeof...(ARGS) == 0) {
using event_type = typename TgtEvent::EventType;
return std::is_same_v<param0_type, event_type>;
} else {
return false;
}
}
template <typename TgtEvent>
static auto wrap(src_func_type func) {
using event_type = typename TgtEvent::EventType;
using emitter_type = typename TgtEvent::_emitter_type;
using persist_function_type = typename TgtEvent::_persist_function_type;
persist_function_type ret;
if constexpr (accept<TgtEvent>()) {
ret = [&func](emitter_type * /*self*/, event_type *event) {
func(event);
};
} else {
static_assert(std::is_same_v<emitter_type, param0_type>, "mismatch emitter type");
ret = [func](emitter_type *self, event_type *event) {
return std::apply([self, func](auto &&...args) { func(self, args...); }, event->args);
};
}
return ret;
}
};
template <typename C, typename R, typename... ARGS>
struct TgtEvtFnTrait<std::function<R(C *, ARGS...)>> {
using param0_type = C;
using src_func_type = std::function<R(C *, ARGS...)>;
constexpr static bool IS_MEMBER_FUNC = false;
template <typename TgtEvent>
static constexpr bool accept() {
if constexpr (sizeof...(ARGS) == 0) {
using EventType = typename TgtEvent::EventType;
return std::is_same_v<param0_type, EventType>;
} else {
return false;
}
}
template <typename TgtEvent>
static auto wrap(src_func_type func) {
using event_type = typename TgtEvent::EventType;
using emitter_type = typename TgtEvent::_emitter_type;
using persist_function_type = typename TgtEvent::_persist_function_type;
persist_function_type ret;
if constexpr (accept<TgtEvent>()) {
ret = [func](emitter_type * /*self*/, event_type *event) {
func(event);
};
} else {
static_assert(std::is_same_v<emitter_type, param0_type>, "mismatch emitter type");
ret = [func](emitter_type *self, event_type *event) {
return std::apply([self, func](auto &&...args) { func(self, args...); }, event->args);
};
}
return ret;
}
};
template <typename C, typename R, typename... ARGS>
struct TgtEvtFnTrait<R (C::*)(ARGS...)> {
using src_func_type = R (C::*)(ARGS...);
using context_type = C;
using param0_type = typename intl::HeadType<ARGS...>::head;
constexpr static bool IS_MEMBER_FUNC = true;
template <typename TgtEvent>
static constexpr bool accept() {
if constexpr (sizeof...(ARGS) == 1) {
using event_type = typename TgtEvent::EventType;
return std::is_same_v<param0_type, event_type *>;
} else {
return false;
}
}
template <typename TgtEvent>
static auto wrap(src_func_type func) {
using event_type = typename TgtEvent::EventType;
using emitter_type = typename TgtEvent::_emitter_type;
using persist_function_type = typename TgtEvent::_persist_function_type;
persist_function_type ret;
static_assert(std::is_same_v<emitter_type, context_type>, "mismatch emitter type");
if constexpr (accept<TgtEvent>()) {
ret = [&func](emitter_type *self, event_type *event) {
(self->*func)(event);
};
} else {
ret = [func](emitter_type *self, event_type *event) {
return std::apply([&self, func](auto &&...args) { (self->*func)(args...); }, event->args);
};
}
return ret;
}
template <typename TgtEvent>
static auto wrapWithContext(src_func_type func, context_type *ctx) {
using emitter_type = typename TgtEvent::_emitter_type;
using event_type = typename TgtEvent::EventType;
using persist_function_type = typename TgtEvent::_persist_function_type;
persist_function_type ret;
if constexpr (accept<TgtEvent>()) {
ret = [func, ctx](emitter_type * /*self*/, event_type *event) {
(ctx->*func)(event);
};
} else {
ret = [func, ctx](emitter_type * /*self*/, event_type *event) {
return std::apply([ctx, func](auto... args) { (ctx->*func)(args...); }, event->args);
};
}
return ret;
}
};
template <typename C, typename R, typename... ARGS>
struct TgtEvtFnTrait<R (C::*)(ARGS...) const> {
using src_func_type = R (C::*)(ARGS...) const;
using context_type = C;
using param0_type = typename intl::HeadType<ARGS...>::head;
constexpr static bool IS_MEMBER_FUNC = true;
template <typename TgtEvent>
static constexpr bool accept() {
if constexpr (sizeof...(ARGS) == 1) {
using event_type = typename TgtEvent::EventType;
return std::is_same_v<param0_type, event_type *>;
} else {
return false;
}
}
template <typename TgtEvent>
static auto wrap(src_func_type func) {
using EventType = typename TgtEvent::EventType;
using persist_function_type = typename TgtEvent::_persist_function_type;
using emitter_type = typename TgtEvent::_emitter_type;
persist_function_type ret;
static_assert(std::is_same_v<emitter_type, context_type>, "mismatch emitter type");
if constexpr (accept<TgtEvent>()) {
ret = [&func](context_type *self, EventType *event) {
(self->*func)(event);
};
} else {
ret = [&func](context_type *self, EventType *event) {
return std::apply([self, func](auto &&...args) { (self->*func)(args...); }, event->args);
};
}
return ret;
}
template <typename TgtEvent>
static auto wrapWithContext(src_func_type func, context_type *ctx) {
using emitter_type = typename TgtEvent::_emitter_type;
using event_type = typename TgtEvent::EventType;
using persist_function_type = typename TgtEvent::_persist_function_type;
persist_function_type ret = [func, ctx](emitter_type * /*self*/, event_type *event) {
return std::apply([ctx, func](auto &&...args) { (ctx->*func)(args...); }, event->args);
};
return ret;
}
};
template <typename T>
constexpr T addAll(T first) {
return first;
}
template <typename T, typename... Others>
constexpr T addAll(T first, Others... others) {
return first + addAll(others...);
}
template <typename... Parents>
constexpr int TotalEvents = addAll(Parents::getEventCount()...); // NOLINT
} // namespace intl
} // namespace event
} // namespace cc

View File

@@ -0,0 +1,64 @@
// generated code
#define TARGET_EVENT_ARG1(EventType, ArgType0) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0)
#define TARGET_EVENT_ARG2(EventType, ArgType0, ArgType1) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1)
#define TARGET_EVENT_ARG3(EventType, ArgType0, ArgType1, ArgType2) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2)
#define TARGET_EVENT_ARG4(EventType, ArgType0, ArgType1, ArgType2, ArgType3) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3)
#define TARGET_EVENT_ARG5(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4)
#define TARGET_EVENT_ARG6(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5)
#define TARGET_EVENT_ARG7(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6)
#define TARGET_EVENT_ARG8(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7)
#define TARGET_EVENT_ARG9(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8)
#define TARGET_EVENT_ARG10(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9)
#define TARGET_EVENT_ARG11(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10)
#define TARGET_EVENT_ARG12(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11)
#define TARGET_EVENT_ARG13(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12)
#define TARGET_EVENT_ARG14(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13)
#define TARGET_EVENT_ARG15(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14)
#define TARGET_EVENT_ARG16(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15)
#define TARGET_EVENT_ARG17(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16)
#define TARGET_EVENT_ARG18(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16, ArgType17) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16, ArgType17)
#define TARGET_EVENT_ARG19(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16, ArgType17, ArgType18) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16, ArgType17, ArgType18)
#define TARGET_EVENT_ARG20(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16, ArgType17, ArgType18, ArgType19) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16, ArgType17, ArgType18, ArgType19)
#define TARGET_EVENT_ARG21(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16, ArgType17, ArgType18, ArgType19, ArgType20) \
_DECLARE_TARGET_EVENT_INTER(EventType, ArgType0, ArgType1, ArgType2, ArgType3, ArgType4, ArgType5, ArgType6, ArgType7, ArgType8, ArgType9, ArgType10, ArgType11, ArgType12, ArgType13, ArgType14, ArgType15, ArgType16, ArgType17, ArgType18, ArgType19, ArgType20)

View File

@@ -0,0 +1,105 @@
/****************************************************************************
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#pragma once
#include "base/Macros.h"
namespace cc {
namespace event {
namespace intl {
template <typename ListNode>
bool listAppend(ListNode **head, ListNode *newNode) {
if (newNode->next != nullptr || newNode->prev != nullptr) {
CC_ABORT();
return false;
}
if (*head == nullptr) {
newNode->next = newNode;
newNode->prev = newNode;
*head = newNode;
} else {
auto *first = *head;
auto *last = (*head)->prev;
newNode->prev = last;
newNode->next = first;
first->prev = newNode;
last->next = newNode;
}
return true;
}
template <typename ListNode>
bool detachFromList(ListNode **head, ListNode *node) {
if (*head == nullptr || node->prev == nullptr || node->next == nullptr) {
CC_ABORT();
return false;
}
if (node->prev == node && node->next == node) { // the only node
CC_ASSERT(node == *head); // should be the first
*head = nullptr;
} else {
auto *nextNode = node->next;
auto *prevNode = node->prev;
nextNode->prev = prevNode;
prevNode->next = nextNode;
if (node == *head) {
*head = nextNode;
}
}
node->prev = nullptr;
node->next = nullptr;
return true;
}
} // namespace intl
} // namespace event
} // namespace cc
#define EVENT_LIST_LOOP_BEGIN(tempVar, list) \
if (list) { \
auto *tempVar = list; \
do { \
auto *nextCopy = tempVar->next;
#define EVENT_LIST_LOOP_END(tempVar, list) \
tempVar = nextCopy; \
} \
while (tempVar != list) \
; \
}
#define EVENT_LIST_LOOP_REV_BEGIN(tempVar, list) \
if (list) { \
auto *tempVar = list->prev; \
bool isLastListNode = false; \
do { \
auto *nextCopy = tempVar->prev; \
isLastListNode = tempVar == list;
#define EVENT_LIST_LOOP_REV_END(tempVar, list) \
tempVar = nextCopy; \
} \
while (!isLastListNode) \
; \
}