[glibmm/gmmproc-refactor] Add Glib::unwrap() for references.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/gmmproc-refactor] Add Glib::unwrap() for references.
- Date: Wed, 6 Jun 2012 07:12:02 +0000 (UTC)
commit 97df5a85816c6278b667e7d6cd2afb5e2116d82d
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Sun May 6 05:55:49 2012 +0200
Add Glib::unwrap() for references.
glib/glibmm/wrap.h: While Glib::unwrap() for pointers (be them smart
or plain C) makes sense, because it does checking for NULL pointers,
then Glib::unwrap() for references is just a convenience addition,
so I do not have to differentiate much when generating code basing
on whether passed value is a reference or a pointer.
glib/glibmm/wrap.h | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/glib/glibmm/wrap.h b/glib/glibmm/wrap.h
index a65bcf6..3d4eb74 100644
--- a/glib/glibmm/wrap.h
+++ b/glib/glibmm/wrap.h
@@ -116,6 +116,14 @@ typename T::BaseObjectType* unwrap(T* ptr)
return (ptr) ? ptr->gobj() : 0;
}
+/** Get the underlying C instance from the C++ instance.
+ */
+template <class T> inline
+typename T::BaseObjectType* unwrap(T& ref)
+{
+ return ref.gobj();
+}
+
/** Get the underlying C instance from the C++ instance. This is just
* like calling gobj(), but it does its own check for a NULL pointer.
*/
@@ -125,6 +133,14 @@ const typename T::BaseObjectType* unwrap(const T* ptr)
return (ptr) ? ptr->gobj() : 0;
}
+/** Get the underlying C instance from the C++ instance.
+ */
+template <class T> inline
+const typename T::BaseObjectType* unwrap(const T& ref)
+{
+ return ref.gobj();
+}
+
/** Get the underlying C instance from the C++ instance. This is just
* like calling gobj(), but it does its own check for a NULL pointer.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]