diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2019-01-30 13:08:13 +0100 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2019-01-30 13:08:13 +0100 |
commit | be00e91381e43f3cdd69200cf5398eab53479dfc (patch) | |
tree | 008c168eeeb0ceba191bbdfa68a8ecf52174dbe4 /glib/glibmm | |
parent | d7109095e88073daf7f05393fd0cbc323f651b7c (diff) | |
download | glibmm-be00e91381e43f3cdd69200cf5398eab53479dfc.tar.gz |
gmmproc: Add _IS_REFCOUNTED_BOXEDTYPE
* glib/glibmm/value.h: Add Value_RefPtrBoxed<>.
* tools/m4/class_opaque_refcounted.m4: Add _IS_REFCOUNTED_BOXEDTYPE, which can
be used together with _CLASS_OPAQUE_REFCOUNTED. It generates a *_get_type()
function and a Glib::Value specialization. A Glib::Value specialization is
required, if the C++ class is used in _WRAP_PROPERTY.
Diffstat (limited to 'glib/glibmm')
-rw-r--r-- | glib/glibmm/value.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/glib/glibmm/value.h b/glib/glibmm/value.h index b5a435b7..8afc5bfb 100644 --- a/glib/glibmm/value.h +++ b/glib/glibmm/value.h @@ -221,6 +221,7 @@ namespace Glib template <class T> class Value_Boxed : public ValueBase_Boxed { +// Used by _CLASS_BOXEDTYPE and _CLASS_BOXEDTYPE_STATIC public: using CppType = T; @@ -230,6 +231,26 @@ public: CppType get() const { return CppType(static_cast<typename T::BaseObjectType*>(get_boxed())); } }; +/** + * @ingroup glibmmValue + */ +template <class T> +class Value_RefPtrBoxed : public ValueBase_Boxed +{ +// Used by _CLASS_OPAQUE_REFCOUNTED with _IS_REFCOUNTED_BOXEDTYPE +public: + using CppType = Glib::RefPtr<T>; + + static GType value_type() { return T::get_type(); } + + // Equivalent to set_boxed(Glib::unwrap(data)) without including wrap.h. + void set(const CppType& data) { set_boxed(data ? data->gobj() : nullptr); } + + // get() is defined in the Value<> specializations. It requires the declaration + // of Glib::wrap(T::BaseObjectType*, bool) to be visible. + // CppType get() const { return Glib::wrap(static_cast<typename T::BaseObjectType*>(get_boxed()), true); } +}; + // More spec-compliant compilers (such as Tru64) need this to be near Glib::Object instead. #ifdef GLIBMM_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION |