[glibmm/gmmproc-refactor] Implement custom ctor cast for VariantBase.



commit 208cb7c905afe6b5e37dfb49cc1f07064c39f46e
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Sun Jul 22 19:55:42 2012 +0200

    Implement custom ctor cast for VariantBase.

 glib/src/variant.ccg |   17 +++++++++++++++++
 glib/src/variant.hg  |    3 +++
 2 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg
index c002c14..8dc5ad8 100644
--- a/glib/src/variant.ccg
+++ b/glib/src/variant.ccg
@@ -23,6 +23,23 @@
 namespace Glib
 {
 
+VariantBase::VariantBase(GVariant* castitem, bool make_a_copy /* = false */)
+{
+  if (castitem)
+  {
+    if (g_variant_is_floating(castitem))
+    {
+      g_variant_ref_sink (castitem);
+    }
+    if (make_a_copy)
+    {
+      g_variant_ref (castitem);
+    }
+  }
+
+  gobject_ = castitem;
+}
+
 void VariantBase::get_normal_form(VariantBase& result) const
 {
   GVariant* const g_value =
diff --git a/glib/src/variant.hg b/glib/src/variant.hg
index d1892cc..1433fe3 100644
--- a/glib/src/variant.hg
+++ b/glib/src/variant.hg
@@ -82,10 +82,13 @@ namespace Glib
 class VariantBase
 {
   _CLASS_OPAQUE_COPYABLE(VariantBase, GVariant, NONE, g_variant_ref_sink, g_variant_unref)
+  _CUSTOM_CTOR_CAST
   _IGNORE(g_variant_ref, g_variant_ref_sink, g_variant_unref,
     g_variant_get, g_variant_get_va)
 public:
 
+  VariantBase(GVariant* castitem, bool make_a_copy = false);
+
   /** Replace the underlying GVariant.
    * This is for use by methods that take a VariantBase& as an output
    * parameter.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]