[glibmm] VariantBase: Added a byte/guchar specialization.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] VariantBase: Added a byte/guchar specialization.
- Date: Mon, 13 Sep 2010 08:00:40 +0000 (UTC)
commit 4c2b7814ce8fac368680d404cf05d4998e98c301
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Sep 13 10:00:33 2010 +0200
VariantBase: Added a byte/guchar specialization.
* glib/src/variant_basictypes.cc.m4:
* glib/src/variant_basictypes.h.m4: Add an extra argument to the macro,
so we can handle g_variant_get_byte(), whose function/macro type name is not
the same as its C type name. Each macro only uses 2 arguments, but it is
clearer if both are the same, I think.
* glib/src/variant.hg: Mark g_variant_get_byte() as handled.
ChangeLog | 11 +++++++++++
glib/src/variant.hg | 1 +
glib/src/variant_basictypes.cc.m4 | 34 ++++++++++++++++++++--------------
glib/src/variant_basictypes.h.m4 | 28 ++++++++++++++++------------
4 files changed, 48 insertions(+), 26 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 39579de..adda0ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2010-09-13 Murray Cumming <murrayc murrayc com>
+ VariantBase: Added a byte/guchar specialization.
+
+ * glib/src/variant_basictypes.cc.m4:
+ * glib/src/variant_basictypes.h.m4: Add an extra argument to the macro,
+ so we can handle g_variant_get_byte(), whose function/macro type name is not
+ the same as its C type name. Each macro only uses 2 arguments, but it is
+ clearer if both are the same, I think.
+ * glib/src/variant.hg: Mark g_variant_get_byte() as handled.
+
+2010-09-13 Murray Cumming <murrayc murrayc com>
+
Variant: Added some methods.
* glib/src/variant.[hg|ccg]: Added get_maybe(), get_size(), get_data(),
diff --git a/glib/src/variant.hg b/glib/src/variant.hg
index 7ee6d23..3f0cf56 100644
--- a/glib/src/variant.hg
+++ b/glib/src/variant.hg
@@ -198,6 +198,7 @@ public:
//We ignore g_variant_get_*() methods that are wrapped by Variant<> specializations, such as in variant_basictypes.h.m4.
_IGNORE(
g_variant_get_boolean,
+ g_variant_get_byte,
g_variant_get_uint16,
g_variant_get_int64,
g_variant_get_int32,
diff --git a/glib/src/variant_basictypes.cc.m4 b/glib/src/variant_basictypes.cc.m4
index dc345d8..eb70222 100644
--- a/glib/src/variant_basictypes.cc.m4
+++ b/glib/src/variant_basictypes.cc.m4
@@ -23,7 +23,11 @@ dnl Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include(template.macros.m4)
dnl
-dnl GLIB_VARIANT_BASIC(bool, boolean)
+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
define([GLIB_VARIANT_BASIC],[dnl
LINE(]__line__[)dnl
@@ -34,17 +38,17 @@ dnl Please ignore the format stuff. I was just tired and played a little.
// static
const GVariantType* Variant<$1>::variant_type()
{
- return G_VARIANT_TYPE_[]UPPER($2);
+ return G_VARIANT_TYPE_[]UPPER($3);
}
Variant<$1> Variant<$1>::create($1 data)
{
- return Variant<$1>(g_variant_new_$2(data));
+ return Variant<$1>(g_variant_new_$3(data));
}
$1 Variant<$1>::get() const
{
- return g_variant_get_$2(gobject_);
+ return g_variant_get_$3(gobject_);
}
])
@@ -55,14 +59,16 @@ divert[]dnl
namespace Glib
{
-GLIB_VARIANT_BASIC(bool, boolean)
-dnl GLIB_VARIANT_BASIC(unsigned char, byte)
-GLIB_VARIANT_BASIC(gint16, int16)
-GLIB_VARIANT_BASIC(guint16, uint16)
-GLIB_VARIANT_BASIC(gint32, int32)
-GLIB_VARIANT_BASIC(guint32, uint32)
-GLIB_VARIANT_BASIC(gint64, int64)
-GLIB_VARIANT_BASIC(guint64, uint64)
-dnl GLIB_VARIANT_BASIC(gint32, handle)
-GLIB_VARIANT_BASIC(double, double)
+
+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(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
diff --git a/glib/src/variant_basictypes.h.m4 b/glib/src/variant_basictypes.h.m4
index 84847e9..ee0662d 100644
--- a/glib/src/variant_basictypes.h.m4
+++ b/glib/src/variant_basictypes.h.m4
@@ -23,7 +23,11 @@ dnl Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include(template.macros.m4)
dnl
-dnl GLIB_VARIANT_BASIC(bool, boolean)
+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
define([GLIB_VARIANT_BASIC],[dnl
LINE(]__line__[)dnl
@@ -36,7 +40,7 @@ template <>
class Variant<$1> : public VariantBase
{
public:
- typedef g$2 CType;
+ typedef $2 CType;
/// Default constructor.
Variant<$1>()
@@ -79,14 +83,14 @@ divert[]dnl
namespace Glib
{
-GLIB_VARIANT_BASIC(bool, boolean)
-dnl GLIB_VARIANT_BASIC(unsigned char, byte)
-GLIB_VARIANT_BASIC(gint16, int16)
-GLIB_VARIANT_BASIC(guint16, uint16)
-GLIB_VARIANT_BASIC(gint32, int32)
-GLIB_VARIANT_BASIC(guint32, uint32)
-GLIB_VARIANT_BASIC(gint64, int64)
-GLIB_VARIANT_BASIC(guint64, uint64)
-dnl GLIB_VARIANT_BASIC(gint32, handle)
-GLIB_VARIANT_BASIC(double, double)
+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(guint32, guint32, uint32)
+GLIB_VARIANT_BASIC(gint64, gint64, int64)
+GLIB_VARIANT_BASIC(guint64, guint64, uint64)
+dnl This would redeclare the <int> specialization: GLIB_VARIANT_BASIC(gint32, guint32, handle)
+GLIB_VARIANT_BASIC(double, gdouble, double)
} // namespace Glib
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]