[complement-svn] SF.net SVN: complement: [1660] trunk/complement/explore
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-08-03 06:31:40
|
Revision: 1660 http://complement.svn.sourceforge.net/complement/?rev=1660&view=rev Author: complement Date: 2007-08-02 23:31:38 -0700 (Thu, 02 Aug 2007) Log Message: ----------- use TR1 type_traits technique; add tricks to compile without STLport Modified Paths: -------------- trunk/complement/explore/include/stem/Event.h trunk/complement/explore/include/stem/EventHandler.h trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/EvManager.cc trunk/complement/explore/lib/stem/EvPack.cc Modified: trunk/complement/explore/include/stem/Event.h =================================================================== --- trunk/complement/explore/include/stem/Event.h 2007-08-03 06:27:59 UTC (rev 1659) +++ trunk/complement/explore/include/stem/Event.h 2007-08-03 06:31:38 UTC (rev 1660) @@ -1,8 +1,8 @@ -// -*- C++ -*- Time-stamp: <07/07/27 09:41:46 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 08:19:34 ptr> /* * - * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 + * Copyright (c) 1995-1999, 2002, 2003, 2005-2007 * Petr Ovtchenkov * * Copyright (c) 1999-2001 @@ -26,53 +26,11 @@ #include <sstream> #include <stdint.h> +#include <misc/type_traits.h> #include <stem/EvPack.h> #include <mt/uid.h> #include <mt/xmt.h> -#ifndef STLPORT -#include <bits/cpp_type_traits.h> - -// libstdc++ v3, timestamp 20050519 (3.4.4) has __type_traits, -// libstdc++ v3, timestamp 20060306 (3.4.6) has __type_traits, -// while libstdc++ v3, 20050921 (4.0.2) not; use boost's staff instead -# if !defined(__GLIBCXX__) || (defined(__GNUC__) && (__GNUC__ > 3)) -#include <boost/type_traits.hpp> - -//bool to type -template <int _Is> -struct __bool2type -{ typedef __true_type _Ret; }; - -template <> -struct __bool2type<1> { typedef __true_type _Ret; }; - -template <> -struct __bool2type<0> { typedef __false_type _Ret; }; - -template <class _Tp> -struct __type_traits { - enum { trivial_constructor = ::boost::has_trivial_constructor<_Tp>::value }; - typedef typename __bool2type<trivial_constructor>::_Ret has_trivial_default_constructor; - - enum { trivial_copy = ::boost::has_trivial_copy<_Tp>::value }; - typedef typename __bool2type<trivial_copy>::_Ret has_trivial_copy_constructor; - - enum { trivial_assign = ::boost::has_trivial_assign<_Tp>::value }; - typedef typename __bool2type<trivial_assign>::_Ret has_trivial_assignment_operator; - - enum { trivial_destructor = ::boost::has_trivial_destructor<_Tp>::value }; - typedef typename __bool2type<trivial_destructor>::_Ret has_trivial_destructor; - - enum { pod = ::boost::is_pod<_Tp>::value }; - typedef typename __bool2type<pod>::_Ret is_POD_type; -}; -# else -# include <bits/type_traits.h> -# endif // __GLIBCXX__ - -#endif - namespace stem { typedef uint32_t addr_type; @@ -84,16 +42,6 @@ extern const addr_type ns_addr; extern const code_type badcode; -#ifdef STLPORT -using std::__true_type; -using std::__false_type; -using std::__type_traits; -#else -using ::__true_type; -using ::__false_type; -using ::__type_traits; -#endif - struct gaddr_type : public __pack_base { @@ -220,8 +168,8 @@ // Forward declarations template <class D, class POD > class __Event_base_aux; -template <class D> class __Event_base_aux<D,__true_type>; -template <class D> class __Event_base_aux<D,__false_type>; +template <class D> class __Event_base_aux<D,std::tr1::true_type>; +template <class D> class __Event_base_aux<D,std::tr1::false_type>; template <class D> class Event_base; @@ -267,7 +215,7 @@ }; template <class D> -class __Event_base_aux<D,__true_type> : +class __Event_base_aux<D,std::tr1::true_type> : public __Event_Base { public: @@ -318,7 +266,7 @@ }; template <class D> -class __Event_base_aux<D,__false_type> : +class __Event_base_aux<D,std::tr1::false_type> : public __Event_Base { public: @@ -369,7 +317,7 @@ }; template <> -class __Event_base_aux<std::string,__false_type> : +class __Event_base_aux<std::string,std::tr1::false_type> : public __Event_Base { public: @@ -420,7 +368,7 @@ }; template <> -class __Event_base_aux<void,__true_type> : +class __Event_base_aux<void,std::tr1::true_type> : public __Event_Base { public: @@ -456,26 +404,26 @@ template <class D> class Event_base : - public __Event_base_aux<D,typename __type_traits<D>::is_POD_type> + public __Event_base_aux<D,typename std::tr1::is_pod<D>::type> { private: - typedef __Event_base_aux<D,typename __type_traits<D>::is_POD_type> _Base; + typedef __Event_base_aux<D,typename std::tr1::is_pod<D>::type> _Base; public: Event_base() : - __Event_base_aux<D,typename __type_traits<D>::is_POD_type>() + __Event_base_aux<D,typename std::tr1::is_pod<D>::type>() { } explicit Event_base( code_type c ) : - __Event_base_aux<D,typename __type_traits<D>::is_POD_type>( c ) + __Event_base_aux<D,typename std::tr1::is_pod<D>::type>( c ) { } Event_base( code_type c, const D& d ) : - __Event_base_aux<D,typename __type_traits<D>::is_POD_type>( c, d ) + __Event_base_aux<D,typename std::tr1::is_pod<D>::type>( c, d ) { } Event_base( const Event_base& e ) : - __Event_base_aux<D,typename __type_traits<D>::is_POD_type>( e, e._data ) + __Event_base_aux<D,typename std::tr1::is_pod<D>::type>( e, e._data ) { } void net_pack( Event& s ) const; @@ -487,26 +435,26 @@ template <> class Event_base<std::string> : - public __Event_base_aux<std::string,__false_type> + public __Event_base_aux<std::string,std::tr1::false_type> { private: - typedef __Event_base_aux<std::string,__false_type> _Base; + typedef __Event_base_aux<std::string,std::tr1::false_type> _Base; public: Event_base() : - __Event_base_aux<std::string,__false_type>() + __Event_base_aux<std::string,std::tr1::false_type>() { } explicit Event_base( code_type c ) : - __Event_base_aux<std::string,__false_type>( c ) + __Event_base_aux<std::string,std::tr1::false_type>( c ) { } Event_base( code_type c, const std::string& d ) : - __Event_base_aux<std::string,__false_type>( c, d ) + __Event_base_aux<std::string,std::tr1::false_type>( c, d ) { } Event_base( const Event_base& e ) : - __Event_base_aux<std::string,__false_type>( e, e._data ) + __Event_base_aux<std::string,std::tr1::false_type>( e, e._data ) { } void net_pack( Event& s ) const @@ -549,7 +497,6 @@ template <class D> void Event_base<D>::net_pack( Event& s ) const { - // std::cerr << "**1\n"; s.code( _Base::_code ); s.dest( _Base::_dst ); s.src( _Base::_src ); @@ -568,7 +515,6 @@ _Base::_flags = s.flags() & ~(__Event_Base::conv | __Event_Base::expand); std::istringstream ss( s.value() ); _Base::net_unpack( ss ); - // std::cerr << "**2 " << std::hex << _Base::flags() << std::dec << std::endl; } template <class D> @@ -582,7 +528,6 @@ std::ostringstream ss; _Base::pack( ss ); s.value() = ss.str(); - // std::cerr << "**3 " << std::hex << s.flags() << std::dec << std::endl; } template <class D> @@ -595,28 +540,27 @@ // _Base::unsetf( __Event_Base::expand ); std::istringstream ss( s.value() ); _Base::unpack( ss ); - // std::cerr << "**4 " << std::hex << _Base::flags() << std::dec << std::endl; } template <> class Event_base<void> : - public __Event_base_aux<void,__true_type> + public __Event_base_aux<void,std::tr1::true_type> { private: - typedef __Event_base_aux<void,__true_type> _Base; + typedef __Event_base_aux<void,std::tr1::true_type> _Base; public: Event_base() : - __Event_base_aux<void,__true_type>() + __Event_base_aux<void,std::tr1::true_type>() { } explicit Event_base( code_type c ) : - __Event_base_aux<void,__true_type>( c ) + __Event_base_aux<void,std::tr1::true_type>( c ) { } __FIT_EXPLICIT Event_base( const Event_base& e ) : - __Event_base_aux<void,__true_type>( e ) + __Event_base_aux<void,std::tr1::true_type>( e ) { } void net_pack( Event& s ) const Modified: trunk/complement/explore/include/stem/EventHandler.h =================================================================== --- trunk/complement/explore/include/stem/EventHandler.h 2007-08-03 06:27:59 UTC (rev 1659) +++ trunk/complement/explore/include/stem/EventHandler.h 2007-08-03 06:31:38 UTC (rev 1660) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/08 17:24:21 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 09:01:32 ptr> /* * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 @@ -509,7 +509,7 @@ typedef HistoryContainer::iterator h_iterator; typedef HistoryContainer::const_iterator const_h_iterator; -_STLP_TEMPLATE_NULL +template <> class __EvHandler<EventHandler,h_iterator > { public: @@ -669,7 +669,7 @@ } } -_STLP_TEMPLATE_NULL +template <> inline void __EvTableLoader<EventHandler>( EventHandler::table_type *, EventHandler * ) { } Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-08-03 06:27:59 UTC (rev 1659) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-08-03 06:31:38 UTC (rev 1660) @@ -1,3 +1,13 @@ +2007-08-03 Petr Ovtchenkov <pt...@is...> + + * Makefile: let's try don't include boost's -I if macro + not defined---mysterious behaviour otherwise happens; + + * Event.h, EvManager.cc, EvPack.cc: use TR1 type_traits technique; + add tricks to compile without STLport; + + * EventHandler.h: remove STLport's macro. + 2007-07-27 Petr Ovtchenkov <pt...@is...> * Event.h, EvManager.cc, EvPack.cc: operator of format output Modified: trunk/complement/explore/lib/stem/EvManager.cc =================================================================== --- trunk/complement/explore/lib/stem/EvManager.cc 2007-08-03 06:27:59 UTC (rev 1659) +++ trunk/complement/explore/lib/stem/EvManager.cc 2007-08-03 06:31:38 UTC (rev 1660) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/03/12 18:53:45 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 09:20:31 ptr> /* * @@ -685,10 +685,10 @@ __FIT_DECLSPEC std::ostream& EvManager::dump( std::ostream& s ) const { - ios_base::fmtflags f = s.flags( 0 ); + ios_base::fmtflags f = s.flags( ios_base::hex | ios_base::showbase ); s << "Local map:\n"; - s << hex << showbase; + // s << hex << showbase; { scoped_lock lk( _lock_heap ); Modified: trunk/complement/explore/lib/stem/EvPack.cc =================================================================== --- trunk/complement/explore/lib/stem/EvPack.cc 2007-08-03 06:27:59 UTC (rev 1659) +++ trunk/complement/explore/lib/stem/EvPack.cc 2007-08-03 06:31:38 UTC (rev 1660) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/24 17:19:05 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 09:22:05 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 @@ -24,9 +24,9 @@ ostream& operator <<( ostream& o, const stem::gaddr_type& g ) { - ios_base::fmtflags f = o.flags( 0 ); + ios_base::fmtflags f = o.flags( ios_base::hex ); - o << hex << setfill( '0' ) + o << setfill( '0' ) << setw(8) << g.hid.u.l[0] << setw(8) << g.hid.u.l[1] << '-' << dec << g.pid << '-' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |