[glibmm] Gio::Variant: Use _WRAP_METHOD() instead of hand-coding.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Gio::Variant: Use _WRAP_METHOD() instead of hand-coding.
- Date: Wed, 16 Mar 2011 10:45:43 +0000 (UTC)
commit d6393a161a0d0f7d63a33d8bad8505e916f8fd8e
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Mar 16 11:45:35 2011 +0100
Gio::Variant: Use _WRAP_METHOD() instead of hand-coding.
* glib/src/variant.[hg|ccg]: Use _WRAP_METHOD() for two hand-coded methods.
ChangeLog | 6 ++++++
glib/src/variant.ccg | 12 +-----------
glib/src/variant.hg | 24 +++++++++++++++---------
3 files changed, 22 insertions(+), 20 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a835295..4dfdeb4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-03-16 Murray Cumming <murrayc murrayc com>
+
+ Gio::Variant: Use _WRAP_METHOD() instead of hand-coding.
+
+ * glib/src/variant.[hg|ccg]: Use _WRAP_METHOD() for two hand-coded methods.
+
2011-03-16 Yannick Guesnet <Yannick Guesnet univ-rouen fr>
Variant: Added Variant<VariantBase>::get().
diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg
index f1c30ac..07cc518 100644
--- a/glib/src/variant.ccg
+++ b/glib/src/variant.ccg
@@ -100,7 +100,7 @@ throw(std::bad_cast)
return VariantContainerBase();
}
if(v.get_type().is_container())
- {
+ {
return VariantContainerBase(const_cast<GVariant*>(v.gobj()), true);
}
else
@@ -152,11 +152,6 @@ Variant<VariantBase> Variant<VariantBase>::create(const VariantBase& data)
return result;
}
-VariantBase Variant<VariantBase>::get() const
-{
- return VariantBase(g_variant_get_variant(gobject_));
-}
-
// static
const VariantType& Variant<Glib::ustring>::variant_type()
{
@@ -200,11 +195,6 @@ Variant<std::string>::create(const std::string& data)
return result;
}
-std::string Variant<std::string>::get() const
-{
- return std::string(g_variant_get_bytestring(gobject_));
-}
-
typedef std::vector<Glib::ustring> type_vec_ustring;
// static
diff --git a/glib/src/variant.hg b/glib/src/variant.hg
index f9606d3..9cb1a9e 100644
--- a/glib/src/variant.hg
+++ b/glib/src/variant.hg
@@ -142,7 +142,7 @@ throw(std::bad_cast)
return V_CastTo();
}
if(v.is_of_type(V_CastTo::variant_type()))
- {
+ {
return V_CastTo(const_cast<GVariant*>(v.gobj()), true);
}
else
@@ -308,6 +308,10 @@ _IGNORE(g_variant_get_type)
template<>
class Variant<VariantBase> : public VariantContainerBase
{
+ // Trick gmmproc into thinking this is derived from GVariant to wrap a
+ // some methods.
+ _CLASS_GENERIC(Variant<VariantBase>, GVariant)
+
public:
typedef GVariant* CType;
typedef VariantBase CppType;
@@ -345,8 +349,7 @@ public:
static Variant<VariantBase> create(const Glib::VariantBase& data);
_IGNORE(g_variant_new_variant)
- VariantBase get() const;
- _IGNORE(g_variant_get_variant)
+ _WRAP_METHOD(VariantBase get() const, g_variant_get_variant)
};
/** Specialization of Glib::Variant containing a Glib::ustring.
@@ -356,6 +359,9 @@ public:
template<>
class Variant<Glib::ustring> : public VariantStringBase
{
+ // Trick gmmproc into thinking this is derived from GVariant to wrap a
+ // some methods.
+ _CLASS_GENERIC(Variant<Glib::ustring>, GVariant)
public:
typedef char* CType;
typedef Glib::ustring CppType;
@@ -389,6 +395,7 @@ public:
*/
static Variant<Glib::ustring> create(const Glib::ustring& data);
+ //We can't use WRAP_METHOD() here because g_variant_get_string() takes an extra length parameter.
/** Gets the contents of the Glib::Variant.
* @return The contents of the Glib::Variant.
* @newin{2,28}
@@ -405,6 +412,9 @@ public:
template<>
class Variant<std::string> : public VariantStringBase
{
+ // Trick gmmproc into thinking this is derived from GVariant to wrap a
+ // some methods.
+ _CLASS_GENERIC(Variant<std::string>, GVariant)
public:
typedef char* CType;
typedef std::string CppType;
@@ -438,12 +448,8 @@ public:
*/
static Variant<std::string> create(const std::string& data);
- /** Gets the contents of the Glib::Variant.
- * @return The contents of the Glib::Variant.
- * @newin{2,28}
- */
- std::string get() const;
- _IGNORE(g_variant_get_bytestring, g_variant_dup_bytestring)
+ _WRAP_METHOD(std::string get() const, g_variant_get_bytestring)
+ _IGNORE(g_variant_dup_bytestring)
};
/** Specialization of Glib::Variant containing a dictionary entry. See also
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]