[glibmm] VaraintBase: Use output parameters instead of returning values.
- From: José Alburquerque <jaalburqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] VaraintBase: Use output parameters instead of returning values.
- Date: Fri, 30 Jul 2010 05:35:05 +0000 (UTC)
commit 43d45475398cd9c0ef651d2c746ce539214a691b
Author: José Alburquerque <jaalburqu svn gnome org>
Date: Fri Jul 30 01:21:51 2010 -0400
VaraintBase: Use output parameters instead of returning values.
* glib/src/variant.{ccg,hg}: get_normal_form(), byteswap(): Handwrote
these methods so that output parameters can be used instead of
returning the result.
ChangeLog | 8 ++++++++
glib/src/variant.ccg | 12 ++++++++++++
glib/src/variant.hg | 44 +++++++++++++++++++++++++++++++++++++++++---
3 files changed, 61 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3bb31a0..a04b1ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-07-30 José Alburquerque <jaalburqu svn gnome org>
+
+ VaraintBase: Use output parameters instead of returning values.
+
+ * glib/src/variant.{ccg,hg}: get_normal_form(), byteswap(): Handwrote
+ these methods so that output parameters can be used instead of
+ returning the result.
+
2010-07-29 Murray Cumming <murrayc murrayc com>
Variant: Added some methods.
diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg
index 6f1a683..90bb010 100644
--- a/glib/src/variant.ccg
+++ b/glib/src/variant.ccg
@@ -22,6 +22,18 @@
namespace Glib
{
+void VariantBase::get_normal_form(VariantBase& result) const
+{
+ GVariant* g_value = g_variant_get_normal_form(const_cast<GVariant*>(gobj()));
+ result.init(g_value); // g_value is already referenced.
+}
+
+void VariantBase::byteswap(VariantBase& result) const
+{
+ GVariant* g_value = g_variant_byteswap(const_cast<GVariant*>(gobj()));
+ result.init(g_value); // g_value is already referenced.
+}
+
/****************** Specializations ***********************************/
diff --git a/glib/src/variant.hg b/glib/src/variant.hg
index c0d5219..3b14da7 100644
--- a/glib/src/variant.hg
+++ b/glib/src/variant.hg
@@ -67,10 +67,48 @@ public:
_WRAP_METHOD(guint hash() const, g_variant_hash)
_WRAP_METHOD(bool equal(const VariantBase& other) const, g_variant_equal)
- //TODO: Use VariantBase as an output parameter:
- _WRAP_METHOD(VariantBase get_normal_form() const, g_variant_get_normal_form)
+ /** Gets a VariantBase instance that has the same value as this variant and
+ * is trusted to be in normal form.
+ *
+ * If this variant is already trusted to be in normal form then a new
+ * reference to the variant is returned.
+ *
+ * If this variant is not already trusted, then it is scanned to check if it
+ * is in normal form. If it is found to be in normal form then it is marked
+ * as trusted and a new reference to it is returned.
+ *
+ * If this variant is found not to be in normal form then a new trusted
+ * VariantBase is created with the same value as this variant.
+ *
+ * It makes sense to call this function if you've received variant data from
+ * untrusted sources and you want to ensure your serialised output is
+ * definitely in normal form.
+ *
+ * @param result A Location in which to store the trusted VariantBase.
+ * @newin{2,24}
+ */
+ void get_normal_form(VariantBase& result) const;
+ _IGNORE(g_variant_get_normal_form)
+
_WRAP_METHOD(bool is_normal_form() const, g_variant_is_normal_form)
- _WRAP_METHOD(VariantBase byteswap() const, g_variant_byteswap)
+
+ /** Performs a byteswapping operation on the contents of this variant. The
+ * result is that all multi-byte numeric data contained in the variant is
+ * byteswapped. That includes 16, 32, and 64bit signed and unsigned integers
+ * as well as file handles and double precision floating point values.
+ *
+ * This function is an identity mapping on any value that does not contain
+ * multi-byte numeric data. That include strings, booleans, bytes and
+ * containers containing only these things (recursively).
+ *
+ * The returned value is always in normal form and is marked as trusted.
+ *
+ * @param result : A Location in which to store the byteswapped form of this
+ * variant.
+ * @newin{2,24}
+ */
+ void byteswap(VariantBase& result) const;
+ _IGNORE(g_variant_byteswap)
};
/** Template class from which other Glib::Variant<> specializations derive.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]