summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2011-03-16 11:45:35 +0100
committerMurray Cumming <murrayc@murrayc.com>2011-03-16 11:45:35 +0100
commitd6393a161a0d0f7d63a33d8bad8505e916f8fd8e (patch)
treea8050c0c74009b6776b150edd3096a3dd98c5c81
parent2f2de9f5802bb722c86951398ca3ff501c990282 (diff)
downloadglibmm-d6393a161a0d0f7d63a33d8bad8505e916f8fd8e.tar.gz
Gio::Variant: Use _WRAP_METHOD() instead of hand-coding.
* glib/src/variant.[hg|ccg]: Use _WRAP_METHOD() for two hand-coded methods.
-rw-r--r--ChangeLog6
-rw-r--r--glib/src/variant.ccg12
-rw-r--r--glib/src/variant.hg24
3 files changed, 22 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index a8352953..4dfdeb44 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 f1c30ac1..07cc5186 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 f9606d3e..9cb1a9e9 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