[glibmm] Implement custom cast constructor for VariantBase.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Implement custom cast constructor for VariantBase.
- Date: Sat, 28 Jul 2012 16:20:15 +0000 (UTC)
commit 74be2c624ae943a9f883c2e8befe6836332269b9
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Sun Jul 22 19:51:57 2012 +0200
Implement custom cast constructor for VariantBase.
* glib/src/variant.hg:
* glib/src/variant.ccg: Use _CUSTOM_CTOR_CAST macro and implement
cast constructor. This is needed, because we always want to sink
a GVariant.
ChangeLog | 9 +++++++++
glib/src/variant.ccg | 17 +++++++++++++++++
glib/src/variant.hg | 1 +
3 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 420883b..f0ffae0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2012-07-28 Krzesimir Nowak <qdlacz gmail com>
+ Implement custom cast constructor for VariantBase.
+
+ * glib/src/variant.hg:
+ * glib/src/variant.ccg: Use _CUSTOM_CTOR_CAST macro and implement
+ cast constructor. This is needed, because we always want to sink
+ a GVariant.
+
+2012-07-28 Krzesimir Nowak <qdlacz gmail com>
+
Add _CUSTOM_CTOR_CAST macro for _CLASS_OPAQUE_COPYABLE.
* tools/m4/class_opaque_copyable.m4: New macro.
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 87143bd..97f8e71 100644
--- a/glib/src/variant.hg
+++ b/glib/src/variant.hg
@@ -82,6 +82,7 @@ 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:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]