summaryrefslogtreecommitdiff
path: root/glib/glibmm/object.h
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2005-01-20 16:28:17 +0000
committerMurray Cumming <murrayc@src.gnome.org>2005-01-20 16:28:17 +0000
commit5d783de9a21c0dd3e50ebbf16de41bea7a412027 (patch)
treee64865d4c9daba1733701025c27deddd71959bb2 /glib/glibmm/object.h
parentd3c5c7637ddf69bb1df177bde94b68e106d13a8b (diff)
downloadglibmm-5d783de9a21c0dd3e50ebbf16de41bea7a412027.tar.gz
Make C callacks separate extern C functions instead of static member
2005-01-20 Murray Cumming <murrayc@murrayc.com> * glib/src/iochannel.[hg|ccg], markup.[hg|ccg], optiongroup.ccg, spawn.ccg, thread.ccg: Make C callacks separate extern C functions instead of static member functions, to satisfy the IRIX MipsPro compiler. Unfortunately this means that we export some private API. * glib/src/optionentry.hg: Remove the include of value.h, because it is not used and it causes a MipsPro compile error in optioncontext.cc because its templates are included before the types that the template uses. * glib/src/optiongroup.ccg: Do not use the StringArrayHandle, because the MipsPro compiler has problems with it - see comments in code. * configure.in, scripts/cxx.m4, glibmm/glibmmconfig.h.in: Added a compiler test, because the IRIX MipsPro compiler does not allow us to define a template that uses an undefined type, even if we do not use it before defining the type. That's probably correct. * glib/glibmm/containerhandler_helpers.h: When the compiler does not alllow the GObject and GtkObject (dynamic_cast of) specializations here, then put them in glib/glibmm/object.h and gtkmm/gtk/src/object.hg instead.- needed by MipsPro (IRIX) compiler..
Diffstat (limited to 'glib/glibmm/object.h')
-rw-r--r--glib/glibmm/object.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/glib/glibmm/object.h b/glib/glibmm/object.h
index d9bca6e1..ed49e283 100644
--- a/glib/glibmm/object.h
+++ b/glib/glibmm/object.h
@@ -145,6 +145,91 @@ private:
//virtual void set_manage();
};
+
+//For some (proably, more spec-compliant) compilers, these specializations must
+//be next to the objects that they use.
+#ifndef GLIBMM_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION
+#ifndef DOXYGEN_SHOULD_SKIP_THIS /* hide the specializations */
+
+namespace Container_Helpers
+{
+
+/** Partial specialization for pointers to GObject instances.
+ * @ingroup ContHelpers
+ * The C++ type is always a Glib::RefPtr<>.
+ */
+template <class T>
+struct TypeTraits< Glib::RefPtr<T> >
+{
+ typedef Glib::RefPtr<T> CppType;
+ typedef typename T::BaseObjectType * CType;
+ typedef typename T::BaseObjectType * CTypeNonConst;
+
+ static CType to_c_type (const CppType& ptr) { return Glib::unwrap(ptr); }
+ static CType to_c_type (CType ptr) { return ptr; }
+ static CppType to_cpp_type (CType ptr)
+ {
+ //return Glib::wrap(ptr, true);
+
+ //We copy/paste the wrap() implementation here,
+ //because we can not use a specific Glib::wrap(CType) overload here,
+ //because that would be "dependent", and g++ 3.4 does not allow that.
+ //The specific Glib::wrap() overloads don't do anything special anyway.
+ GObject* cobj = (GObject*)const_cast<CTypeNonConst>(ptr);
+ return Glib::RefPtr<T>( dynamic_cast<T*>(Glib::wrap_auto(cobj, true /* take_copy */)) );
+ //We use dynamic_cast<> in case of multiple inheritance.
+ }
+
+ static void release_c_type (CType ptr)
+ {
+ GLIBMM_DEBUG_UNREFERENCE(0, ptr);
+ g_object_unref(ptr);
+ }
+};
+
+//This confuse the SUN Forte compiler, so we ifdef it out:
+#ifdef GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS
+
+/** Partial specialization for pointers to const GObject instances.
+ * @ingroup ContHelpers
+ * The C++ type is always a Glib::RefPtr<>.
+ */
+template <class T>
+struct TypeTraits< Glib::RefPtr<const T> >
+{
+ typedef Glib::RefPtr<const T> CppType;
+ typedef const typename T::BaseObjectType * CType;
+ typedef typename T::BaseObjectType * CTypeNonConst;
+
+ static CType to_c_type (const CppType& ptr) { return Glib::unwrap(ptr); }
+ static CType to_c_type (CType ptr) { return ptr; }
+ static CppType to_cpp_type (CType ptr)
+ {
+ //return Glib::wrap(ptr, true);
+
+ //We copy/paste the wrap() implementation here,
+ //because we can not use a specific Glib::wrap(CType) overload here,
+ //because that would be "dependent", and g++ 3.4 does not allow that.
+ //The specific Glib::wrap() overloads don't do anything special anyway.
+ GObject* cobj = (GObject*)(ptr);
+ return Glib::RefPtr<const T>( dynamic_cast<const T*>(Glib::wrap_auto(cobj, true /* take_copy */)) );
+ //We use dynamic_cast<> in case of multiple inheritance.
+ }
+
+ static void release_c_type (CType ptr)
+ {
+ GLIBMM_DEBUG_UNREFERENCE(0, ptr);
+ g_object_unref(const_cast<CTypeNonConst>(ptr));
+ }
+};
+
+#endif //GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS
+
+} //namespace Container_Helpers
+
+#endif //DOXYGEN_SHOULD_SKIP_THIS
+#endif //GLIBMM_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION
+
} // namespace Glib
#endif /* _GLIBMM_OBJECT_H */