[gjs] arg: Add template specialization for boolean
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] arg: Add template specialization for boolean
- Date: Sun, 5 Jul 2020 01:19:41 +0000 (UTC)
commit d82c7ae453ee4afef1e8afea19e725c8c77168ee
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Fri May 8 22:21:13 2020 +0200
arg: Add template specialization for boolean
Ensure that native boolean type is saved as we expect to be in gboolean
world.
gi/arg-inl.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
---
diff --git a/gi/arg-inl.h b/gi/arg-inl.h
index 6f20e5d7..aafee2bb 100644
--- a/gi/arg-inl.h
+++ b/gi/arg-inl.h
@@ -116,7 +116,29 @@ inline void gjs_g_argument_value_set(GIArgument* arg, T v) {
gjs_g_argument_value<T, TAG>(arg) = v;
}
+template <>
+inline void gjs_g_argument_value_set<bool>(GIArgument* arg, bool v) {
+ gjs_g_argument_value<bool>(arg) = !!v;
+}
+
+template <>
+inline void gjs_g_argument_value_set<gboolean, GI_TYPE_TAG_BOOLEAN>(
+ GIArgument* arg, gboolean v) {
+ gjs_g_argument_value<bool>(arg) = !!v;
+}
+
template <typename T, GITypeTag TAG = GI_TYPE_TAG_VOID>
GJS_USE inline T gjs_g_argument_value_get(GIArgument* arg) {
return gjs_g_argument_value<T, TAG>(arg);
}
+
+template <>
+GJS_USE inline bool gjs_g_argument_value_get<bool>(GIArgument* arg) {
+ return !!gjs_g_argument_value<bool>(arg);
+}
+
+template <>
+GJS_USE inline gboolean gjs_g_argument_value_get<gboolean, GI_TYPE_TAG_BOOLEAN>(
+ GIArgument* arg) {
+ return !!gjs_g_argument_value<bool>(arg);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]