summaryrefslogtreecommitdiff
path: root/glib/src/variant_basictypes.cc.m4
diff options
context:
space:
mode:
Diffstat (limited to 'glib/src/variant_basictypes.cc.m4')
-rw-r--r--glib/src/variant_basictypes.cc.m432
1 files changed, 24 insertions, 8 deletions
diff --git a/glib/src/variant_basictypes.cc.m4 b/glib/src/variant_basictypes.cc.m4
index ba79a204..4247da88 100644
--- a/glib/src/variant_basictypes.cc.m4
+++ b/glib/src/variant_basictypes.cc.m4
@@ -23,11 +23,14 @@ dnl Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include(template.macros.m4)
dnl
-dnl For instance, GLIB_VARIANT_BASIC(c++ type, c type, c type name)
-dnl parameters:
-dnl c++ type: The C++ type for the specialization, such as bool
-dnl c type: The C type used by the C API, such as gboolean.
-dnl c type name: The text used in the C API functions and macros, such as boolean, in g_variant_get_boolean() and G_VARIANT_TYPE_BOOLEAN.
+dnl For instance, GLIB_VARIANT_BASIC(C++ type, C type, C type name [,C type name 2])
+dnl Parameters:
+dnl C++ type: The C++ type for the specialization, such as bool.
+dnl C type: The C type used by the C API, such as gboolean.
+dnl C type name: The text used in the C API functions and macros, such as boolean
+dnl in g_variant_get_boolean() and G_VARIANT_TYPE_BOOLEAN.
+dnl C type name 2: Optional second text, such as handle in g_variant_get_handle()
+dnl and G_VARIANT_TYPE_HANDLE.
dnl
define([GLIB_VARIANT_BASIC],[dnl
LINE(]__line__[)dnl
@@ -44,13 +47,27 @@ const VariantType& Variant<$1>::variant_type()
Variant<$1> Variant<$1>::create($1 data)
{
- Variant<$1> result = Variant<$1>(g_variant_new_$3(data));
+ auto result = Variant<$1>(g_variant_new_$3(data));
return result;
}
+ifelse($4,,,[
+Variant<$1> Variant<$1>::create_$4($1 data)
+{
+ auto result = Variant<$1>(g_variant_new_$4(data));
+ return result;
+}
+])dnl
$1 Variant<$1>::get() const
{
+ifelse($4,,[dnl
return g_variant_get_$3(gobject_);
+],[dnl
+ if (get_type().equal(VARIANT_TYPE_[]UPPER($3)))
+ return g_variant_get_$3(gobject_);
+ else
+ return g_variant_get_$4(gobject_);
+])dnl
}
])
@@ -66,11 +83,10 @@ GLIB_VARIANT_BASIC(bool, gboolean, boolean)
GLIB_VARIANT_BASIC(unsigned char, guchar, byte)
GLIB_VARIANT_BASIC(gint16, gint16, int16)
GLIB_VARIANT_BASIC(guint16, guint16, uint16)
-GLIB_VARIANT_BASIC(gint32, gint32, int32)
+GLIB_VARIANT_BASIC(gint32, gint32, int32, handle)
GLIB_VARIANT_BASIC(guint32, guint32, uint32)
GLIB_VARIANT_BASIC(gint64, gint64, int64)
GLIB_VARIANT_BASIC(guint64, guint64, uint64)
-dnl This would redeclare the <int> GLIB_VARIANT_BASIC(gint32, guint32, handle)
GLIB_VARIANT_BASIC(double, gdouble, double)
} // namespace Glib