[glibmm] Resolver: Add lookup_records() and lookup_records_finish().



commit afaa0cfa2335de6900a207e82272c34133d12f83
Author: Josà Alburquerque <jaalburqu svn gnome org>
Date:   Tue Oct 30 15:10:35 2012 -0400

    Resolver: Add lookup_records() and lookup_records_finish().
    
    	* glib/glibmm/containerhandle_shared.h: Add TypeTraits specializations
    	for VariantBase (for the futre) and VariantContainerBase.
    	* gio/src/resolver.hg:  Add the new methods (mentioned above) because
    	the VariantContainerBase TypeTraits specialization allows the vector
    	utilities to convert to/from GVariants in a GList correctly.

 ChangeLog                            |   10 +++++++
 gio/src/resolver.ccg                 |    1 -
 gio/src/resolver.hg                  |    4 ---
 glib/glibmm/containerhandle_shared.h |   46 ++++++++++++++++++++++++++++++++++
 4 files changed, 56 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e2b5063..b8a248a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-10-30  Josà Alburquerque  <jaalburquerque gmail com>
+
+	Resolver: Add lookup_records() and lookup_records_finish().
+
+	* glib/glibmm/containerhandle_shared.h: Add TypeTraits specializations
+	for VariantBase (for the futre) and VariantContainerBase.
+	* gio/src/resolver.hg:  Add the new methods (mentioned above) because
+	the VariantContainerBase TypeTraits specialization allows the vector
+	utilities to convert to/from GVariants in a GList correctly.
+
 2012-10-29  Josà Alburquerque  <jaalburquerque gmail com>
 
 	Resolver: Add the lookup_records_async() methods.
diff --git a/gio/src/resolver.ccg b/gio/src/resolver.ccg
index d6b1a3c..2f5f694 100644
--- a/gio/src/resolver.ccg
+++ b/gio/src/resolver.ccg
@@ -19,7 +19,6 @@
 
 #include <gio/gio.h>
 #include <glibmm/error.h>
-#include <glibmm/variant.h>
 #include "slot_async.h"
 
 namespace Gio
diff --git a/gio/src/resolver.hg b/gio/src/resolver.hg
index a01a733..f318ba5 100644
--- a/gio/src/resolver.hg
+++ b/gio/src/resolver.hg
@@ -143,11 +143,9 @@ public:
 
   _WRAP_METHOD(ListHandle_SrvTarget lookup_service_finish(const Glib::RefPtr<AsyncResult>& result), g_resolver_lookup_service_finish, errthrow)
 
-/* TODO: Wrapping this does not work for some reason.
 #m4 _CONVERSION(`GList*',`std::vector<Glib::VariantContainerBase>',`Glib::ListHandler<Glib::VariantContainerBase>::list_to_vector($3, Glib::OWNERSHIP_DEEP)')
 
   _WRAP_METHOD(std::vector<Glib::VariantContainerBase> lookup_records(const Glib::ustring& rrname, ResolverRecordType record_type, const Glib::RefPtr<Cancellable>& cancellable{?}), g_resolver_lookup_records, errthrow)
-*/
 
   /** Begins asynchronously performing a DNS lookup for the given @a rrname,
    * and eventually calls @a slot, which must call lookup_records_finish() to
@@ -167,9 +165,7 @@ public:
   void lookup_records_async(const Glib::ustring& rrname,
     ResolverRecordType record_type, const SlotAsyncReady& slot);
 
-/* TODO: Wrapping this does not work for some reason.
   _WRAP_METHOD(std::vector<Glib::VariantContainerBase> lookup_records_finish(const Glib::RefPtr<AsyncResult>& result), g_resolver_lookup_records_finish, errthrow)
-*/
 
   //TODO: Remove no_default_handler when we can break ABI:
   _WRAP_SIGNAL(void reload(), reload, no_default_handler)
diff --git a/glib/glibmm/containerhandle_shared.h b/glib/glibmm/containerhandle_shared.h
index eb7e508..e9094c9 100644
--- a/glib/glibmm/containerhandle_shared.h
+++ b/glib/glibmm/containerhandle_shared.h
@@ -22,6 +22,7 @@
 #include <glibmmconfig.h>
 #include <glibmm/refptr.h>
 #include <glibmm/ustring.h>
+#include <glibmm/variant.h>
 #include <glibmm/wrap.h>
 #include <glibmm/debug.h>
 #include <glib-object.h>
@@ -323,6 +324,51 @@ struct TypeTraits<bool>
   static void    release_c_type (CType) {}
 };
 
+/** Specialization for Glib::VariantBase.
+ * @ingroup ContHelpers
+ */
+template <>
+struct TypeTraits<Glib::VariantBase>
+{
+  typedef Glib::VariantBase     CppType;
+  typedef GVariant *            CType;
+  typedef GVariant *            CTypeNonConst;
+
+  static CType to_c_type (const Glib::VariantBase& v)
+    { return const_cast<CTypeNonConst>(v.gobj()); }
+
+  static CType to_c_type (CType v) { return v; }
+
+  static CppType to_cpp_type(CType v)
+    { return Glib::VariantBase(v, true); }
+
+  static void release_c_type(CType v)
+    { g_variant_unref(const_cast<CTypeNonConst>(v)); }
+};
+
+/** Specialization for Glib::VariantContainerBase.
+ * @ingroup ContHelpers
+ */
+template <>
+struct TypeTraits<Glib::VariantContainerBase>
+{
+  typedef Glib::VariantContainerBase    CppType;
+  typedef GVariant *                    CType;
+  typedef GVariant *                    CTypeNonConst;
+
+  static CType to_c_type (const Glib::VariantContainerBase& v)
+    { return const_cast<CTypeNonConst>(v.gobj()); }
+
+  static CType to_c_type (CType v) { return v; }
+
+  static CppType to_cpp_type(CType v)
+    { return Glib::VariantContainerBase(v, true); }
+
+  static void release_c_type(CType v)
+    { g_variant_unref(const_cast<CTypeNonConst>(v)); }
+};
+
+
 #ifndef GLIBMM_HAVE_TEMPLATE_SEQUENCE_CTORS
 
 /* The STL containers in Sun's libCstd don't support templated sequence



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