void-packages/srcpkgs/fcitx5/patches/0002-connectableobject-introduce-FCITX_DECLARE_SIGNAL_WIT.patch
2021-07-08 18:01:26 +07:00

44 lines
1.9 KiB
Diff

From 7134470f681304d40d1756c31f20013a3911bf33 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
<congdanhqx@gmail.com>
Date: Wed, 7 Jul 2021 19:12:54 +0700
Subject: [PATCH 2/5] connectableobject: introduce
FCITX_DECLARE_SIGNAL_WITH_COMBINER
In order to correctly downcast SignalBase, in the next step,
we will switch all initialisation of SignalAdaptor to use
SignalType::combinerType.
Let's introduce a new macro to ease to initialisation of those
signals which employs custom combiner.
Arguably, the custom combiner is an implementation detail,
thus it'll be put in source files. Hence, the macro is intended
to be used outside of class declaration.
---
src/lib/fcitx-utils/connectableobject.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/lib/fcitx-utils/connectableobject.h b/src/lib/fcitx-utils/connectableobject.h
index 1b0343d..1c318bf 100644
--- a/src/lib/fcitx-utils/connectableobject.h
+++ b/src/lib/fcitx-utils/connectableobject.h
@@ -27,6 +27,18 @@
using signature = fcitxMakeMetaString(#CLASS_NAME "::" #NAME); \
}
+/// \brief Declare signal by type with combiner.
+///
+/// This macro is intended to be used outside of class declaration,
+/// because the custom combiner is an implementation detail,
+/// thus it'll be put in source files.
+#define FCITX_DECLARE_SIGNAL_WITH_COMBINER(CLASS_NAME, NAME, COMBINER, ...) \
+ struct CLASS_NAME::NAME { \
+ using signalType = __VA_ARGS__; \
+ using combinerType = COMBINER; \
+ using signature = fcitxMakeMetaString(#CLASS_NAME "::" #NAME); \
+ }
+
/// \brief Declare a signal.
#define FCITX_DEFINE_SIGNAL(CLASS_NAME, NAME) \
::fcitx::SignalAdaptor<CLASS_NAME::NAME> CLASS_NAME##NAME##Adaptor { this }