diff options
author | Murray Cumming <murrayc@localhost.localdomain> | 2005-01-21 19:26:04 +0000 |
---|---|---|
committer | Murray Cumming <murrayc@src.gnome.org> | 2005-01-21 19:26:04 +0000 |
commit | 17ddd797c53c205fef4b155135caff6899a183f8 (patch) | |
tree | 2fcd531537700efdd8fc0759917ab3b6b0c81fdf /glib/glibmm | |
parent | a8e848b1f08e71f376ddfce775794c7056609f23 (diff) | |
download | glibmm-17ddd797c53c205fef4b155135caff6899a183f8.tar.gz |
Added new compiler tests. 1. To see whether it allows use of non extern C
2005-01-21 Murray Cumming <murrayc@localhost.localdomain>
* configure.in, scripts/cxx.m4, glibmm/glibmmconfig.h.in: Added new
compiler tests.
1. To see whether it allows use of non extern C functions
as extern C callbacks, because the Tru64 compiler does not
allow this, when using strict_ansi. We do not actually use this yet.
2. To see whether it allows us to define a template that uses an
undefined type, even if we do not use it before defining the type.
Tru64 does not allow this. That's probably correct.
* glib/glibmm/container.h: #ifdef out a dynamic_cast that Tru64
does not allow, and which I can not think of a better place to put.
See the comment in the code.
* 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 Tru64 compiler.
* glib/glibmm/value.h, value_custom.[h|cc]: Conditionally moved
the RefPtr Value specialization into object.h, as above.
* glib/src/ optiongroup.ccg, spawn.ccg, thread.ccg: Make C callacks
separate extern C.
* glib/src/optiongroup.ccg: Do not use the StringArrayHandle,
because the Tru64 compiler has problems with it - see comments
in code.
* glib/src/optionentry.hg: Remove the include of value.h, because
it is not used and it causes a Tru64 compile error in
optioncontext.cc because its templates are included before the
types that the template uses.
2005-01-19 Murray Cumming <murrayc@murrayc.com>
* configure.in, scripts/cxx.m4, glibmm/glibmmconfig.h.in: Added a
compiler test, because the IRIX MipsPro compiler does not allow the
inline initialization of ustring::npos.
* glib/glibmm/ustring.[h|cc]: When the compiler does not support the
inline initialization of npos, initialize it in the .cc file.
Declare partial specializations of the SequenceString inner class
inside the class - needed by IRIX MipsPro compiler.
Diffstat (limited to 'glib/glibmm')
-rw-r--r-- | glib/glibmm/containerhandle_shared.h | 6 | ||||
-rw-r--r-- | glib/glibmm/containers.h | 7 | ||||
-rw-r--r-- | glib/glibmm/dispatcher.cc | 12 | ||||
-rw-r--r-- | glib/glibmm/object.h | 131 | ||||
-rw-r--r-- | glib/glibmm/property.h | 3 | ||||
-rw-r--r-- | glib/glibmm/ustring.h | 4 | ||||
-rw-r--r-- | glib/glibmm/value.h | 8 | ||||
-rw-r--r-- | glib/glibmm/value_custom.cc | 1 | ||||
-rw-r--r-- | glib/glibmm/value_custom.h | 5 |
9 files changed, 172 insertions, 5 deletions
diff --git a/glib/glibmm/containerhandle_shared.h b/glib/glibmm/containerhandle_shared.h index 4c8c3a66..ef557b47 100644 --- a/glib/glibmm/containerhandle_shared.h +++ b/glib/glibmm/containerhandle_shared.h @@ -127,6 +127,10 @@ struct TypeTraits #ifndef DOXYGEN_SHOULD_SKIP_THIS /* hide the specializations */ +//For some (proably, more spec-compliant) compilers, these specializations must +//be next to the objects that they use. +#ifdef GLIBMM_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION + /** Partial specialization for pointers to GtkObject instances. * @ingroup ContHelpers */ @@ -260,6 +264,8 @@ struct TypeTraits< Glib::RefPtr<const T> > #endif //GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS +#endif //GLIBMM_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION + /** Specialization for UTF-8 strings. * @ingroup ContHelpers * When converting from C++ to C, Glib::ustring will be accepted as well as diff --git a/glib/glibmm/containers.h b/glib/glibmm/containers.h index 893373d2..c7090681 100644 --- a/glib/glibmm/containers.h +++ b/glib/glibmm/containers.h @@ -228,7 +228,14 @@ public: //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 = static_cast<GObject*>( (*node_).data ); + + #ifdef GLIBMM_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION return *(dynamic_cast<pointer>(Glib::wrap_auto(cobj, false /* take_copy */))); + #else + //We really do need to use dynamic_cast<>, so I expect problems if this code is used. murrayc. + return *(static_cast<pointer>(Glib::wrap_auto(cobj, false /* take_copy */))); + #endif + } return *(pointer)glibmm_null_pointer; diff --git a/glib/glibmm/dispatcher.cc b/glib/glibmm/dispatcher.cc index 7312707d..15c63ae3 100644 --- a/glib/glibmm/dispatcher.cc +++ b/glib/glibmm/dispatcher.cc @@ -30,6 +30,18 @@ #ifndef G_OS_WIN32 #include <unistd.h> + +#if defined(_tru64) //TODO: Use the real define +//EINTR is not defined on Tru64 +//I have tried including these +//#include <sys/types.h> +//#include <sys/statvfs.h> +//#include <signal.h> + #ifndef EINTR + #define EINTR 0 + #endif +#endif + #else #include <windows.h> #include <io.h> diff --git a/glib/glibmm/object.h b/glib/glibmm/object.h index d9bca6e1..3f196f9c 100644 --- a/glib/glibmm/object.h +++ b/glib/glibmm/object.h @@ -25,6 +25,7 @@ #include <glibmm/quark.h> #include <glibmm/refptr.h> #include <glibmm/utility.h> /* Could be private, but that would be tedious. */ +#include <glibmm/containerhandle_shared.h> //Because its specializations may be here. #include <glibmm/value.h> #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -145,6 +146,136 @@ 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 + + +template <class T, class PtrT> inline +PtrT Value_Pointer<T,PtrT>::get_(Glib::Object*) const +{ + return dynamic_cast<T*>(get_object()); +} + + +/** Partial specialization for RefPtr<> to Glib::Object. + * @ingroup glibmmValue + */ +template <class T> +class Value< Glib::RefPtr<T> > : public ValueBase_Object +{ +public: + typedef Glib::RefPtr<T> CppType; + typedef typename T::BaseObjectType* CType; + + static GType value_type() { return T::get_base_type(); } + + void set(const CppType& data) { set_object(data.operator->()); } + CppType get() const { return Glib::RefPtr<T>::cast_dynamic(get_object_copy()); } +}; + +//The SUN Forte Compiler has a problem with this: +#ifdef GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS + +/** Partial specialization for RefPtr<> to const Glib::Object. + * @ingroup glibmmValue + */ +template <class T> +class Value< Glib::RefPtr<const T> > : public ValueBase_Object +{ +public: + typedef Glib::RefPtr<const T> CppType; + typedef typename T::BaseObjectType* CType; + + static GType value_type() { return T::get_base_type(); } + + void set(const CppType& data) { set_object(const_cast<T*>(data.operator->())); } + CppType get() const { return Glib::RefPtr<T>::cast_dynamic(get_object_copy()); } +}; +#endif //GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS + + +#endif //DOXYGEN_SHOULD_SKIP_THIS +#endif //GLIBMM_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION + } // namespace Glib #endif /* _GLIBMM_OBJECT_H */ diff --git a/glib/glibmm/property.h b/glib/glibmm/property.h index 288c17d2..6fd0b941 100644 --- a/glib/glibmm/property.h +++ b/glib/glibmm/property.h @@ -29,11 +29,14 @@ namespace Glib #ifndef DOXYGEN_SHOULD_SKIP_THIS +extern "C" +{ void custom_get_property_callback(GObject* object, unsigned int property_id, GValue* value, GParamSpec* param_spec); void custom_set_property_callback(GObject* object, unsigned int property_id, const GValue* value, GParamSpec* param_spec); +} //extern "C" #endif /* DOXYGEN_SHOULD_SKIP_THIS */ diff --git a/glib/glibmm/ustring.h b/glib/glibmm/ustring.h index 89d7e00a..86578b43 100644 --- a/glib/glibmm/ustring.h +++ b/glib/glibmm/ustring.h @@ -235,7 +235,7 @@ public: #ifdef GLIBMM_HAVE_ALLOWS_STATIC_INLINE_NPOS static const size_type npos = std::string::npos; #else - //The MipsPro compiler (IRIX) says "The indicated constant value is not known", + //The IRIX MipsPro compiler says "The indicated constant value is not known", //so we need to initalize the static member data elsewhere. static const size_type npos; #endif @@ -605,7 +605,7 @@ private: #endif struct SequenceToString; - //The MipsPro (IRIX) compiler needs these partial specializations to be declared here, + //The Tru64 compiler needs these partial specializations to be declared here, //as well as defined later. That's probably correct. murrayc. template <class In> struct SequenceToString<In, char>; diff --git a/glib/glibmm/value.h b/glib/glibmm/value.h index cf8cb524..94203a32 100644 --- a/glib/glibmm/value.h +++ b/glib/glibmm/value.h @@ -83,7 +83,6 @@ protected: GValue gobject_; }; - /** * @ingroup glibmmValue */ @@ -98,7 +97,7 @@ public: protected: void set_boxed(const void* data); - void* get_boxed() const; // doesn't copy + void* get_boxed() const; // doesn't copy }; @@ -206,6 +205,9 @@ public: CppType get() const { return CppType(static_cast<CType>(get_boxed())); } }; +//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 + /** Partial specialization for RefPtr<> to Glib::Object. * @ingroup glibmmValue */ @@ -242,6 +244,8 @@ public: }; #endif //GLIBMM_HAVE_DISAMBIGUOUS_CONST_TEMPLATE_SPECIALIZATIONS +#endif //GLIBMM_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION + } // namespace Glib diff --git a/glib/glibmm/value_custom.cc b/glib/glibmm/value_custom.cc index bb0afcbc..f2774777 100644 --- a/glib/glibmm/value_custom.cc +++ b/glib/glibmm/value_custom.cc @@ -140,5 +140,6 @@ GType custom_pointer_type_register(const char* type_name) return g_type_register_static(G_TYPE_POINTER, full_name.c_str(), &type_info, GTypeFlags(0)); } + } // namespace Glib diff --git a/glib/glibmm/value_custom.h b/glib/glibmm/value_custom.h index 7e972f49..ab4ad7d5 100644 --- a/glib/glibmm/value_custom.h +++ b/glib/glibmm/value_custom.h @@ -88,7 +88,7 @@ private: inline CppType get_(void*) const; }; - + /** Generic value implementation for custom types. * @ingroup glibmmValue * Any type to be used with this template must implement: @@ -164,11 +164,14 @@ void Value_Pointer<T,PtrT>::set_(PtrT data, Glib::Object*) set_object(const_cast<T*>(data)); } +//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 template <class T, class PtrT> inline PtrT Value_Pointer<T,PtrT>::get_(Glib::Object*) const { return dynamic_cast<T*>(get_object()); } +#endif //GLIBMM_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION /** Implementation for custom pointers **/ |