Commit d82c7ae4 authored by Marco Trevisan's avatar Marco Trevisan 🎺 Committed by Philip Chimento

arg: Add template specialization for boolean

Ensure that native boolean type is saved as we expect to be in gboolean
world.
parent cacc79b3
Pipeline #193857 passed with stages
in 5 minutes and 50 seconds
......@@ -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);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment