diff options
author | Marcin Kolny <marcin.kolny@gmail.com> | 2015-08-08 14:45:12 +0200 |
---|---|---|
committer | Marcin Kolny <marcin.kolny@gmail.com> | 2015-08-08 14:45:59 +0200 |
commit | 0d5f63b18f5766760cf39e82ee11482984e0a938 (patch) | |
tree | e3f74b9b37e7618c92840024077dff43e6d08f0d /glib/glibmm/wrap.h | |
parent | dce7a844e48a582e42eb2b60eef5c1f2527540ac (diff) | |
parent | d94115843f38967b5e883f5f7d8057882ae364cb (diff) | |
download | glibmm-gir-gmmproc.tar.gz |
Merge branch 'master' into glibmm-gir-gmmprocglibmm-gir-gmmproc
Diffstat (limited to 'glib/glibmm/wrap.h')
-rw-r--r-- | glib/glibmm/wrap.h | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/glib/glibmm/wrap.h b/glib/glibmm/wrap.h index 5b07395b..f898785a 100644 --- a/glib/glibmm/wrap.h +++ b/glib/glibmm/wrap.h @@ -1,9 +1,6 @@ -// -*- c++ -*- #ifndef _GLIBMM_WRAP_H #define _GLIBMM_WRAP_H -/* $Id$ */ - /* Copyright (C) 1998-2002 The gtkmm Development Team * * This library is free software; you can redistribute it and/or @@ -76,7 +73,7 @@ TInterface* wrap_auto_interface(GObject* object, bool take_copy = false) //If no exact wrapper was created, //create an instance of the interface, //so we at least get the expected type: - TInterface* result = 0; + TInterface* result = nullptr; if(pCppObject) { result = dynamic_cast<TInterface*>(pCppObject); @@ -143,6 +140,20 @@ const typename T::BaseObjectType* unwrap(const Glib::RefPtr<const T>& ptr) return (ptr) ? ptr->gobj() : 0; } +// This unwrap_copy() overload is intended primarily for classes wrapped as +// _CLASS_BOXEDTYPE, _CLASS_OPAQUE_COPYABLE or _CLASS_OPAQUE_REFCOUNTED, +// where the C++ objects are not stored in Glib::RefPtr<>s. They have a const +// gobj_copy() member that returns a non-const pointer to the underlying C instance. +/** Get the underlying C instance from the C++ instance and acquire a + * reference or copy. This is just like calling gobj_copy(), but it does its own + * check for a NULL pointer to the underlying C instance. + */ +template <class T> inline +typename T::BaseObjectType* unwrap_copy(const T& obj) +{ + return obj.gobj() ? obj.gobj_copy() : 0; +} + /** Get the underlying C instance from the C++ instance and acquire a * reference. This is just like calling gobj_copy(), but it does its own * check for a NULL pointer. |