diff options
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. |