cppunit-cvs Mailing List for CppUnit - C++ port of JUnit (Page 29)
Brought to you by:
blep
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(94) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
|
Feb
(114) |
Mar
(80) |
Apr
|
May
|
Jun
(36) |
Jul
(67) |
Aug
(37) |
Sep
(33) |
Oct
(28) |
Nov
(91) |
Dec
(16) |
2006 |
Jan
(1) |
Feb
(7) |
Mar
(45) |
Apr
|
May
|
Jun
(36) |
Jul
(7) |
Aug
|
Sep
(32) |
Oct
(3) |
Nov
|
Dec
|
2007 |
Jan
(29) |
Feb
(11) |
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(35) |
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
(14) |
Mar
|
Apr
|
May
|
Jun
(5) |
Jul
(13) |
Aug
|
Sep
|
Oct
(3) |
Nov
|
Dec
(15) |
From: Baptiste L. <bl...@us...> - 2005-02-27 10:14:42
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2196/include/cpput Modified Files: forwards.h Log Message: * removed unncessary dependencies Index: forwards.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/forwards.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** forwards.h 26 Feb 2005 11:52:22 -0000 1.13 --- forwards.h 27 Feb 2005 10:14:28 -0000 1.14 *************** *** 2,8 **** # define CPPUT_FORWARDS_H_INCLUDED # include <cpput/config.h> - # include <cpptl/sharedptr.h> - # include <string> namespace CppUT { --- 2,7 ---- # define CPPUT_FORWARDS_H_INCLUDED + # include <cpptl/forwards.h> # include <cpput/config.h> namespace CppUT { *************** *** 30,34 **** ! TestSuitePtr CPPUT_API makeTestSuite( const std::string &name ); --- 29,33 ---- ! TestSuitePtr CPPUT_API makeTestSuite( const CppTL::ConstString &name ); |
From: Baptiste L. <bl...@us...> - 2005-02-27 10:14:12
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2087/include/cpptl Modified Files: forwards.h Log Message: * added ConstString and StringBuffer Index: forwards.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/forwards.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** forwards.h 26 Feb 2005 13:44:14 -0000 1.1 --- forwards.h 27 Feb 2005 10:14:03 -0000 1.2 *************** *** 11,14 **** --- 11,15 ---- // conststring.h class ConstString; + class StringBuffer; // enumerator.h |
From: Baptiste L. <bl...@us...> - 2005-02-27 10:13:51
|
Update of /cvsroot/cppunit/cppunit2/src/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1959/src/cpput Modified Files: assertstring.cpp Log Message: * use ConstString instead of std::string * moved quoteString() from cpput/assertstring to cpptl/stringtools.h. Index: assertstring.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpput/assertstring.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** assertstring.cpp 1 Feb 2004 16:12:56 -0000 1.2 --- assertstring.cpp 27 Feb 2005 10:13:37 -0000 1.3 *************** *** 14,19 **** Message newMessage( message ); newMessage.add( translate( "String does not start with the expected pattern." ) ); ! newMessage.add( translate( "Expected start: " ) + quoteString( pattern ) ); ! newMessage.add( translate( "Actual string: " ) + quoteString( string ) ); fail( newMessage ); } --- 14,19 ---- Message newMessage( message ); newMessage.add( translate( "String does not start with the expected pattern." ) ); ! newMessage.add( translate( "Expected start: " ) + CppTL::quoteString( pattern ) ); ! newMessage.add( translate( "Actual string: " ) + CppTL::quoteString( string ) ); fail( newMessage ); } *************** *** 31,36 **** Message newMessage( message ); newMessage.add( translate( "String does not end with the expected pattern." ) ); ! newMessage.add( translate( "Expected end: " ) + quoteString( pattern ) ); ! newMessage.add( translate( "Actual string: " ) + quoteString( string ) ); fail( newMessage ); } --- 31,36 ---- Message newMessage( message ); newMessage.add( translate( "String does not end with the expected pattern." ) ); ! newMessage.add( translate( "Expected end: " ) + CppTL::quoteString( pattern ) ); ! newMessage.add( translate( "Actual string: " ) + CppTL::quoteString( string ) ); fail( newMessage ); } *************** *** 47,52 **** Message newMessage( message ); newMessage.add( translate( "String does not contain the expected pattern." ) ); ! newMessage.add( translate( "Expected pattern: " ) + quoteString( pattern ) ); ! newMessage.add( translate( "Actual string: " ) + quoteString( string ) ); fail( newMessage ); } --- 47,52 ---- Message newMessage( message ); newMessage.add( translate( "String does not contain the expected pattern." ) ); ! newMessage.add( translate( "Expected pattern: " ) + CppTL::quoteString( pattern ) ); ! newMessage.add( translate( "Actual string: " ) + CppTL::quoteString( string ) ); fail( newMessage ); } *************** *** 76,143 **** newMessage.add( translate( "Strings are not equal." ) ); if ( !common.empty() ) ! newMessage.add( translate( "Common: " ) + quoteString( common ) ); newMessage.add( translate( "Divergence position (0 based): " ) + stringize( differenceIndex ) ); ! newMessage.add( translate( "Expected (at divergence): " ) + quoteString( expectedTail ) ); ! newMessage.add( translate( "Actual (at divergence): " ) + quoteString( actualTail ) ); fail( newMessage ); } - - std::string hex( unsigned int value ) - { - static const char *digit = "0123456789abcdef"; - std::string hexa; - do - { - hexa += digit[ value & 15 ]; - value /= 16; - } - while ( value != 0 ); - - std::reverse( hexa.begin(), hexa.end() ); - return hexa; - } - - - std::string escapeControl( char c ) - { - if ( c == '\n' ) - return "\\n"; - else if ( c == '\t' ) - return "\\t"; - else if ( c == '\r' ) - return "\\r"; - else if ( c == '\v' ) - return "\\v"; - return "\\x" + hex( (unsigned)c ); - } - - - std::string escape( char c ) - { - if ( c >=0 && c < 32 ) - return escapeControl( c ); - else if ( c == '\\' ) - return "\\\\"; - return std::string( 1, c ); - } - - - // need to expose some of those utility functions... - std::string escape( const std::string &text ) - { - std::string escaped; - escaped.reserve( text.length() + 16 ); - std::string::const_iterator it = text.begin(); - while ( it != text.end() ) - escaped += escape( *it++ ); - return escaped; - } - - - std::string quoteString( const std::string &str ) - { - return "\"" + escape(str) + "\""; - } - } // namespace CppUT --- 76,85 ---- newMessage.add( translate( "Strings are not equal." ) ); if ( !common.empty() ) ! newMessage.add( translate( "Common: " ) + CppTL::quoteString( common ) ); newMessage.add( translate( "Divergence position (0 based): " ) + stringize( differenceIndex ) ); ! newMessage.add( translate( "Expected (at divergence): " ) + CppTL::quoteString( expectedTail ) ); ! newMessage.add( translate( "Actual (at divergence): " ) + CppTL::quoteString( actualTail ) ); fail( newMessage ); } } // namespace CppUT |
From: Baptiste L. <bl...@us...> - 2005-02-27 10:13:51
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1959/include/cpput Modified Files: assertstring.h Log Message: * use ConstString instead of std::string * moved quoteString() from cpput/assertstring to cpptl/stringtools.h. Index: assertstring.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/assertstring.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** assertstring.h 1 Feb 2004 16:12:51 -0000 1.2 --- assertstring.h 27 Feb 2005 10:13:36 -0000 1.3 *************** *** 5,20 **** namespace CppUT { - /* - inline std::string CPPUT_API convertToString( const std::string &string ) - { - return string; - } - - inline std::string CPPUT_API convertToString( const char *cstring ) - { - return cstring; - } - */ - std::string CPPUT_API escape( const std::string &text ); void CPPUT_API checkStdStringStartsWith( const std::string &string, --- 5,8 ---- |
From: Baptiste L. <bl...@us...> - 2005-02-27 10:13:27
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1890/include/cpptl Modified Files: stringtools.h Log Message: * use ConstString instead of std::string * moved quoteString() from cpput/assertstring to cpptl/stringtools.h. Index: stringtools.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/stringtools.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** stringtools.h 26 Feb 2005 11:51:10 -0000 1.4 --- stringtools.h 27 Feb 2005 10:13:18 -0000 1.5 *************** *** 2,6 **** # define CPPTL_STRINGTOOLS_H_INCLUDED ! # include <string> # include <float.h> // toString( double ) --- 2,6 ---- # define CPPTL_STRINGTOOLS_H_INCLUDED ! # include <cpptl/conststring.h> # include <float.h> // toString( double ) *************** *** 13,16 **** --- 13,22 ---- } + inline char hexaDigit( unsigned number ) + { + static const char *digit = "0123456789abcdef"; + return digit[number]; + } + template<class IntType> struct SignedPolicy *************** *** 45,49 **** template<class IntType, class SignPolicy> ! std::string integerToString( IntType v, SignPolicy sign ) { char buffer[32]; --- 51,55 ---- template<class IntType, class SignPolicy> ! CppTL::ConstString integerToString( IntType v, SignPolicy sign ) { char buffer[32]; *************** *** 67,74 **** //template<class IntType> ! //std::string integerToString( IntType v ) //{ ! // std::string s; // if ( v == 0 ) // s += '0'; --- 73,100 ---- + template<class UnsignedIntegerType> + CppTL::ConstString + integerToHexaString( UnsignedIntegerType value ) + { + const int bufferLength = sizeof(UnsignedIntegerType) * 2 + 1; + char buffer[ bufferLength ]; + char *current = &buffer[ bufferLength ]; + char *end = current; + *--current = 0; + do + { + *--current += hexaDigit( size_type(value & 15) ); + value /= 16; + } + while ( value != 0 ); + + return CppTL::ConstString( current, end ); + } + + //template<class IntType> ! //CppTL::ConstString integerToString( IntType v ) //{ ! // CppTL::ConstString s; // if ( v == 0 ) // s += '0'; *************** *** 93,127 **** //} ! inline std::string toString( char c ) { ! return std::string( 1, c ); } ! inline std::string toString( int v ) { return integerToString( v, SignedPolicy<int>() ); } ! inline std::string toString( unsigned int v ) { return integerToString( v, UnsignedPolicy<unsigned int>() ); } ! inline std::string toString( long v ) { return integerToString( v, SignedPolicy<long>() ); } ! inline std::string toString( unsigned long v ) { return integerToString( v, UnsignedPolicy<unsigned long>() ); } ! inline std::string toString( short v ) { return integerToString( v, SignedPolicy<short>() ); } ! inline std::string toString( unsigned short v ) { return integerToString( v, UnsignedPolicy<unsigned short>() ); --- 119,153 ---- //} ! inline CppTL::ConstString toString( char c ) { ! return CppTL::ConstString( &c, 1 ); } ! inline CppTL::ConstString toString( int v ) { return integerToString( v, SignedPolicy<int>() ); } ! inline CppTL::ConstString toString( unsigned int v ) { return integerToString( v, UnsignedPolicy<unsigned int>() ); } ! inline CppTL::ConstString toString( long v ) { return integerToString( v, SignedPolicy<long>() ); } ! inline CppTL::ConstString toString( unsigned long v ) { return integerToString( v, UnsignedPolicy<unsigned long>() ); } ! inline CppTL::ConstString toString( short v ) { return integerToString( v, SignedPolicy<short>() ); } ! inline CppTL::ConstString toString( unsigned short v ) { return integerToString( v, UnsignedPolicy<unsigned short>() ); *************** *** 130,139 **** #ifndef CPPTL_NO_INT64 ! inline std::string toString( int64_t v ) { return integerToString( v, SignedPolicy<int64_t>() ); } ! inline std::string toString( uint64_t v ) { return integerToString( v, UnsignedPolicy<uint64_t>() ); --- 156,165 ---- #ifndef CPPTL_NO_INT64 ! inline CppTL::ConstString toString( int64_t v ) { return integerToString( v, SignedPolicy<int64_t>() ); } ! inline CppTL::ConstString toString( uint64_t v ) { return integerToString( v, UnsignedPolicy<uint64_t>() ); *************** *** 141,145 **** #endif ! inline std::string toString( float v ) { #ifdef FLT_DIG --- 167,171 ---- #endif ! inline CppTL::ConstString toString( float v ) { #ifdef FLT_DIG *************** *** 153,157 **** } ! inline std::string toString( double v ) { #ifdef DBL_DIG --- 179,183 ---- } ! inline CppTL::ConstString toString( double v ) { #ifdef DBL_DIG *************** *** 165,169 **** } ! inline std::string toString( long double v ) { #ifdef DBL_DIG --- 191,195 ---- } ! inline CppTL::ConstString toString( long double v ) { #ifdef DBL_DIG *************** *** 177,185 **** } ! inline std::string toString( bool v ) { return v ? "true" : "false"; } } // namespace CppTL --- 203,271 ---- } ! inline CppTL::ConstString toString( bool v ) { return v ? "true" : "false"; } + + inline CppTL::ConstString toHexaString( unsigned int v ) + { + return integerToHexaString( v ); + } + + + #ifndef CPPTL_NO_INT64 + inline CppTL::ConstString toHexaString( uint64_t v ) + { + return integerToHexaString( v ); + } + #endif + + + inline CppTL::ConstString + escapeControl( char c ) + { + if ( c == '\n' ) + return "\\n"; + else if ( c == '\t' ) + return "\\t"; + else if ( c == '\r' ) + return "\\r"; + else if ( c == '\v' ) + return "\\v"; + return "\\x" + toHexaString( unsigned(c) ); + } + + + inline CppTL::ConstString + escape( char c ) + { + if ( c >=0 && c < 32 ) + return escapeControl( c ); + else if ( c == '\\' ) + return "\\\\"; + return CppTL::ConstString( &c, 1 ); + } + + + // need to expose some of those utility functions... + inline CppTL::ConstString + escape( const CppTL::ConstString &text ) + { + CppTL::StringBuffer escaped( size_type(text.length() * 1.2) + 64 ); + CppTL::ConstString::const_iterator it = text.begin(); + while ( it != text.end() ) + escaped += escape( *it++ ); + return escaped; + } + + + inline CppTL::ConstString + quoteString( const CppTL::ConstString &str ) + { + return "\"" + escape(str) + "\""; + } + + } // namespace CppTL |
From: Baptiste L. <bl...@us...> - 2005-02-27 10:11:56
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1509/include/cpptl Modified Files: conststring.h Log Message: * ConstString, a string that can be safely passed between thread * StringBuffer, a mutable string buffer designed for quick buffer expansion Index: conststring.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/conststring.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** conststring.h 26 Feb 2005 13:44:14 -0000 1.1 --- conststring.h 27 Feb 2005 10:11:45 -0000 1.2 *************** *** 2,9 **** # define CPPTL_CONSTSTRING_H_INCLUDED ! # include <cpptl/config.h> # include <string.h> namespace CppTL { class ConstStringIterator --- 2,69 ---- # define CPPTL_CONSTSTRING_H_INCLUDED [...991 lines suppressed...] + return ConstString( buffer_ + index, length ); + } + + + inline void + StringBuffer::prepareBuffer( size_type length ) + { + if ( length <= capacity_ ) + return; + size_type newCapacity = (size_type(capacity_ * 1.43 + 16) & ~15) -1; + if ( length > newCapacity ) + newCapacity = ((length + 16) & ~15) -1; + reserve( newCapacity ); + } + } // namespace CppTL + #endif // CPPTL_CONSTSTRING_H_INCLUDED |
From: Baptiste L. <bl...@us...> - 2005-02-27 09:56:26
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30084/include/cpptl Modified Files: config.h Log Message: * added swap() * added size_type Index: config.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/config.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** config.h 23 Feb 2005 22:45:56 -0000 1.7 --- config.h 27 Feb 2005 09:56:18 -0000 1.8 *************** *** 125,128 **** --- 125,130 ---- # endif + typedef unsigned int size_type; + template<class T> struct Type *************** *** 148,151 **** --- 150,162 ---- }; + template<class T> + inline void + swap( T &left, T &right ) + { + T temp( left ); + left = right; + right = temp; + } + } // namespace CppTL |
From: Baptiste L. <bl...@us...> - 2005-02-27 09:53:28
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29614/include/cpptl Added Files: conststring.py Log Message: * small generator for operator + implementation. --- NEW FILE: conststring.py --- source = """inline CppTL::StringConcatenator operator +( %sleft, %sright ) { return CppTL::StringConcatenator( left, right ); } """ csz = 'const char *' std_string = 'const std::string &' types = [ csz, "const CppTL::ConstString &", "const CppTL::StringConcatenator &", "const CppTL::StringBuffer &" ] for left in xrange(0,len(types)): start = (left == 0) and 1 or 0 for right_type in types[start:]: print source % ( types[left], right_type ) print print '# ifndef CPPTL_CONSTSTRING_NO_STDSTRING' types = types[1:] + [std_string] for left_type in types: for right_type in types: if (left_type != std_string and right_type != std_string) or left_type == right_type: continue print source % ( left_type, right_type ) print '# endif' |
From: Baptiste L. <bl...@us...> - 2005-02-26 13:44:49
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8165/include/cpput Modified Files: config.h Log Message: * removed include of boost/config.hpp Index: config.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/config.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** config.h 15 Nov 2004 08:24:40 -0000 1.8 --- config.h 26 Feb 2005 13:44:38 -0000 1.9 *************** *** 3,7 **** # include <cpptl/config.h> - # include <boost/config.hpp> //# define CPPUT_THREAD_SAFE --- 3,6 ---- |
From: Baptiste L. <bl...@us...> - 2005-02-26 13:44:25
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8088/include/cpptl Added Files: conststring.h forwards.h Log Message: * added simple ConstString implementation --- NEW FILE: conststring.h --- #ifndef CPPTL_CONSTSTRING_H_INCLUDED # define CPPTL_CONSTSTRING_H_INCLUDED # include <cpptl/config.h> # include <string.h> namespace CppTL { class ConstStringIterator { public: typedef char value_type; typedef unsigned int size_type; ConstStringIterator() : current_( 0 ) { } ConstStringIterator( const value_type *current ) : current_( current ) { } char operator *() const { return *current_; } char operator[]( size_type index ) const { return current_[index]; } ConstStringIterator &operator ++() { ++current_; return *this; } ConstStringIterator operator ++(int) { ConstStringIterator it( *this ); ++current_; return it; } ConstStringIterator &operator --() { --current_; return *this; } ConstStringIterator operator --(int) { ConstStringIterator it( *this ); --current_; return it; } bool operator ==( const ConstStringIterator &other ) const { return current_ == other.current_; } bool operator !=( const ConstStringIterator &other ) const { return current_ != other.current_; } bool operator <( const ConstStringIterator &other ) const { return current_ < other.current_; } bool operator <=( const ConstStringIterator &other ) const { return current_ <= other.current_; } bool operator >( const ConstStringIterator &other ) const { return current_ > other.current_; } bool operator >=( const ConstStringIterator &other ) const { return current_ >= other.current_; } private: const value_type *current_; }; class ConstString { public: typedef unsigned int size_type; typedef char value_type; typedef ConstStringIterator const_iterator; ConstString(); ConstString( const value_type *begin, const value_type *end ); ConstString( const value_type *begin, size_type length ); ConstString( const ConstString &other ); ~ConstString(); ConstString &operator =( const ConstString &other ); void swap( ConstString &other ); const value_type *c_str() const; const value_type *end_c_str() const; size_type length() const; bool empty() const; value_type operator[]( size_type index ) const; private: size_type length_; char *buffer_; }; // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// // class ConstString // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// ConstString::ConstString() : length_( 0 ) , buffer_( 0 ) { } ConstString::ConstString( const value_type *begin, const value_type *end ) : length_( end - begin ) , buffer_( new value_type[end-begin+1] ) { memcpy( buffer_, begin, end-begin ); buffer_[ length_ ] = 0; } ConstString::ConstString( const ConstString &other ) : length_( other.length_ ) { buffer_ = new value_type[length_+1]; memcpy( buffer_, other.buffer_, length_+1 ); } ConstString::~ConstString() { delete [] buffer_; } ConstString & ConstString::operator =( const ConstString &other ) { ConstString temp( other ); swap( other ); return *this; } void ConstString::swap( ConstString &other ) { size_type tempLength = length_; value_type *tempBuffer = buffer_; length_ = other.length_; buffer_ = other.buffer_; other.length_ = tempLength; other.buffer_ = tempBuffer; } const ConstString::value_type * ConstString::c_str() const { return buffer_ ? buffer_ : ""; } const ConstString::value_type * ConstString::end_c_str() const { return buffer_ + length_; } ConstString::size_type ConstString::length() const { return length_; } bool ConstString::empty() const { return length_ == 0; } ConstString::value_type ConstString::operator[]( size_type index ) const { return buffer_[index]; } } // namespace CppTL #endif // CPPTL_CONSTSTRING_H_INCLUDED --- NEW FILE: forwards.h --- #ifndef CPPTL_FORWARDS_H_INCLUDED # define CPPTL_FORWARDS_H_INCLUDED # include <cpptl/config.h> namespace CppTL { // atomiccounter.h class AtomicCounter; // conststring.h class ConstString; // enumerator.h template<class ValueType> class AnyEnumerator; // sharedptr.h template<class PointeeType> class SharedPtr; // functor.h class Functor0; } // namespace CppTL #endif // CPPTL_FORWARDS_H_INCLUDED |
From: Baptiste L. <bl...@us...> - 2005-02-26 12:54:49
|
Update of /cvsroot/cppunit/cppunit2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29302 Modified Files: .cvsignore Log Message: * ignore build stuff Index: .cvsignore =================================================================== RCS file: /cvsroot/cppunit/cppunit2/.cvsignore,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** .cvsignore 24 Feb 2005 07:11:09 -0000 1.3 --- .cvsignore 26 Feb 2005 12:54:38 -0000 1.4 *************** *** 1,3 **** scons.py sconsign.py scons-LICENSE scons-README scons-local* build buildscons ! scons-local* \ No newline at end of file --- 1,6 ---- scons.py sconsign.py scons-LICENSE scons-README scons-local* build buildscons ! scons-local* ! bin ! libs ! gcc-options.txt |
From: Baptiste L. <bl...@us...> - 2005-02-26 11:53:17
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14364/include/cpptl Modified Files: atomiccounter.h Log Message: * updated doc Index: atomiccounter.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/atomiccounter.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** atomiccounter.h 15 Nov 2004 08:22:51 -0000 1.1 --- atomiccounter.h 26 Feb 2005 11:53:08 -0000 1.2 *************** *** 22,26 **** long increment(); ! /// Decrements the count and returns the decremented count long decrement(); --- 22,27 ---- long increment(); ! /// Decrements the count ! /// @returns 0 if the count is null, non zero otherwise. long decrement(); |
From: Baptiste L. <bl...@us...> - 2005-02-26 11:52:30
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14191/include/cpput Modified Files: forwards.h Log Message: * updated to reflect the current content. Index: forwards.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/forwards.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** forwards.h 22 Feb 2005 21:14:37 -0000 1.12 --- forwards.h 26 Feb 2005 11:52:22 -0000 1.13 *************** *** 11,31 **** class AbstractTestCase; class AbstractTestSuite; - class AssertException; - class FailureException; - class FaultException; - class Location; class Message; - class ResultException; class StandardTestExceptionGuard; - class SuccessException; class Test; class TestCase; - class TestContext; - class TestResult; - class TestExceptionHandler; class ExceptionGuardElement; class ExceptionGuard; class TestInfoData; - class TestListener; class TestResultUpdater; class TestSuite; --- 11,21 ---- |
From: Baptiste L. <bl...@us...> - 2005-02-26 11:51:34
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13904/include/cpptl Modified Files: stringtools.h Log Message: * rewrote integerToString() so that it no longer use std::string internal (portability issue with suncc). Also avoid warning with gcc about 'always false condition'. Index: stringtools.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/stringtools.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** stringtools.h 23 Feb 2005 21:38:16 -0000 1.3 --- stringtools.h 26 Feb 2005 11:51:10 -0000 1.4 *************** *** 7,37 **** namespace CppTL { ! template<class IntType> ! std::string integerToString( IntType v ) { static const char *digits = "0123456789"; ! std::string s; if ( v == 0 ) ! s += '0'; else { ! bool isSigned = v < 0; ! if ( isSigned ) ! v *= -1; ! while ( v != 0 ) { ! // Thoses cast are necessary to resolve an ambiguity between insert( char *, unsigned, char ) ! // and insert( unsigned, unsigned, char) with Sun CC. ! s.insert( (unsigned int)0, (unsigned int)1, digits[v % 10] ); v /= 10; } ! ! if ( isSigned ) ! s.insert( 0, "-" ); } ! return s; } inline std::string toString( char c ) { --- 7,96 ---- namespace CppTL { ! inline char digit( unsigned number ) { static const char *digits = "0123456789"; ! return digits[number]; ! } ! ! template<class IntType> ! struct SignedPolicy ! { ! void makePositive( IntType &value ) ! { ! isNegative_ = value < 0; ! if ( isNegative_ ) ! value *= -1; ! } ! ! bool needMinusSign() const ! { ! return isNegative_; ! } ! ! bool isNegative_; ! }; ! ! template<class IntType> ! struct UnsignedPolicy ! { ! void makePositive( IntType & ) ! { ! } ! ! bool needMinusSign() const ! { ! return false; ! } ! }; ! ! template<class IntType, class SignPolicy> ! std::string integerToString( IntType v, SignPolicy sign ) ! { ! char buffer[32]; ! char *current = &buffer[32]; ! *--current = 0; if ( v == 0 ) ! *--current = '0'; else { ! sign.makePositive( v ); while ( v != 0 ) { ! *--current = digit( unsigned(v % 10) ); v /= 10; } ! if ( sign.needMinusSign() ) ! *--current = '-'; } ! return current; } + + //template<class IntType> + //std::string integerToString( IntType v ) + //{ + // std::string s; + // if ( v == 0 ) + // s += '0'; + // else + // { + // bool isSigned = v < 0; + // if ( isSigned ) + // v *= -1; + + // while ( v != 0 ) + // { + // // Thoses cast are necessary to resolve an ambiguity between insert( char *, unsigned, char ) + // // and insert( unsigned, unsigned, char) with Sun CC. + // s.insert( (unsigned int)0, (unsigned int)1, digits[v % 10] ); + // v /= 10; + // } + + // if ( isSigned ) + // s.insert( 0, "-" ); + // } + // return s; + //} + inline std::string toString( char c ) { *************** *** 41,70 **** inline std::string toString( int v ) { ! return integerToString( v ); } inline std::string toString( unsigned int v ) { ! return integerToString( v ); } inline std::string toString( long v ) { ! return integerToString( v ); } inline std::string toString( unsigned long v ) { ! return integerToString( v ); } inline std::string toString( short v ) { ! return integerToString( v ); } inline std::string toString( unsigned short v ) { ! return integerToString( v ); } --- 100,129 ---- inline std::string toString( int v ) { ! return integerToString( v, SignedPolicy<int>() ); } inline std::string toString( unsigned int v ) { ! return integerToString( v, UnsignedPolicy<unsigned int>() ); } inline std::string toString( long v ) { ! return integerToString( v, SignedPolicy<long>() ); } inline std::string toString( unsigned long v ) { ! return integerToString( v, UnsignedPolicy<unsigned long>() ); } inline std::string toString( short v ) { ! return integerToString( v, SignedPolicy<short>() ); } inline std::string toString( unsigned short v ) { ! return integerToString( v, UnsignedPolicy<unsigned short>() ); } *************** *** 73,82 **** inline std::string toString( int64_t v ) { ! return integerToString( v ); } inline std::string toString( uint64_t v ) { ! return integerToString( v ); } #endif --- 132,141 ---- inline std::string toString( int64_t v ) { ! return integerToString( v, SignedPolicy<int64_t>() ); } inline std::string toString( uint64_t v ) { ! return integerToString( v, UnsignedPolicy<uint64_t>() ); } #endif *************** *** 84,92 **** inline std::string toString( float v ) { ! #ifdef DBL_DIG const int precision = FLT_DIG; #else const int precision = 6; ! #endif // #ifdef DBL_DIG char buffer[128]; sprintf(buffer, "%.*g", precision, v ); --- 143,151 ---- inline std::string toString( float v ) { ! #ifdef FLT_DIG const int precision = FLT_DIG; #else const int precision = 6; ! #endif // #ifdef FLT_DIG char buffer[128]; sprintf(buffer, "%.*g", precision, v ); |
From: Baptiste L. <bl...@us...> - 2005-02-26 11:46:00
|
Update of /cvsroot/cppunit/cppunit2/src/cpputtest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12919/src/cpputtest Modified Files: testfunctor.cpp Log Message: * added default constructor to work around bogus warning with suncc Index: testfunctor.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/testfunctor.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** testfunctor.cpp 20 Nov 2004 15:07:00 -0000 1.6 --- testfunctor.cpp 26 Feb 2005 11:45:50 -0000 1.7 *************** *** 33,36 **** --- 33,40 ---- struct TestFunctor { + TestFunctor() // avoid bogus suncc warning + { + } + void operator()() const { *************** *** 204,208 **** catch ( CppUT::AbortingAssertionException &e ) { ! std::cout << "testTestContext() failed: " << e.what() << std::endl; return false; } --- 208,212 ---- catch ( CppUT::AbortingAssertionException &e ) { ! std::cout << "testFunctors() failed: " << e.what() << std::endl; return false; } |
From: Baptiste L. <bl...@us...> - 2005-02-26 11:45:17
|
Update of /cvsroot/cppunit/cppunit2/include/opentest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12776/include/opentest Modified Files: texttestdriver.h Log Message: * made ParentSuites public (failed to compile with suncc) Index: texttestdriver.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/opentest/texttestdriver.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** texttestdriver.h 23 Feb 2005 23:04:34 -0000 1.6 --- texttestdriver.h 26 Feb 2005 11:45:06 -0000 1.7 *************** *** 115,121 **** void releaseResources( const ResourceList &resources ) {} ! private: typedef std::deque<TestId> ParentSuites; struct TestInfo { --- 115,123 ---- void releaseResources( const ResourceList &resources ) {} ! public: typedef std::deque<TestId> ParentSuites; + private: + struct TestInfo { |
From: Baptiste L. <bl...@us...> - 2005-02-26 11:44:26
|
Update of /cvsroot/cppunit/cppunit2/include/cpputtools/configuration In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12611/include/cpputtools/configuration Modified Files: validator.h Log Message: * removed extra ';' at global declaration level (fails to compile on sun) Index: validator.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpputtools/configuration/validator.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** validator.h 23 Feb 2005 22:49:39 -0000 1.5 --- validator.h 26 Feb 2005 11:44:16 -0000 1.6 *************** *** 73,88 **** } ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( int, "is not an integer." ); ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( unsigned int, "is not an integer." ); ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( short, "is not an integer." ); ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( unsigned short, "is not an integer." ); ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( long, "is not an integer." ); ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( unsigned long, "is not an integer." ); ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( float, "is not a real number." ); ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( double, "is not a real number." ); ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( long double, "is not a real number." ); ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( char, "is not a character." ); ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( std::string, "is not a string." ); ! //COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( wchar_t, "is not a character." ); --- 73,88 ---- } ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( int, "is not an integer." ) ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( unsigned int, "is not an integer." ) ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( short, "is not an integer." ) ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( unsigned short, "is not an integer." ) ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( long, "is not an integer." ) ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( unsigned long, "is not an integer." ) ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( float, "is not a real number." ) ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( double, "is not a real number." ) ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( long double, "is not a real number." ) ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( char, "is not a character." ) ! COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( std::string, "is not a string." ) ! //COMMANDLINEOPTIONS_VALIDATOR_MESSAGE( wchar_t, "is not a character." ) |
From: Baptiste L. <bl...@us...> - 2005-02-26 11:43:26
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12400/include/cpput Modified Files: assertenum.h Log Message: * added default constructor to work around bogus warning on sun Index: assertenum.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/assertenum.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** assertenum.h 23 Feb 2005 22:08:45 -0000 1.6 --- assertenum.h 26 Feb 2005 11:43:17 -0000 1.7 *************** *** 14,17 **** --- 14,21 ---- struct DefaultComparator { + DefaultComparator() // Declaration needed to avoid bogus suncc warning. + { + } + bool operator()( const AType &a, const BType &b ) const { |
From: Baptiste L. <bl...@us...> - 2005-02-26 11:42:30
|
Update of /cvsroot/cppunit/cppunit2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12196 Modified Files: sconstruct Log Message: * updated environment definition to build correctly on aix and sun. Index: sconstruct =================================================================== RCS file: /cvsroot/cppunit/cppunit2/sconstruct,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sconstruct 24 Feb 2005 07:15:03 -0000 1.3 --- sconstruct 26 Feb 2005 11:42:21 -0000 1.4 *************** *** 7,18 **** # Store all dependencies signature in a database ! SConsignFile( 'buildscons/.sconsign.dbm' ) ! #env = Environment( CCFLAGS = '-GX -GR -nologo', ! env = Environment( CCFLAGS = '', ! CPPPATH = '#include', ! LIBPATH = '#libs', ! tools=['mingw'] ) Export( 'env' ) --- 7,36 ---- # Store all dependencies signature in a database ! sconsign_path = os.path.join( Dir('#buildscons').abspath, '.sconsign.dbm' ) ! SConsignFile( sconsign_path ) + platform = 'mingw' ! if platform == 'sun': ! env = Environment( ENV = {'PATH' : os.environ['PATH']}, ! CPPPATH = '#include', ! LIBPATH = '#libs', ! tools=['default','suncc'] ) ! elif platform == 'aix': ! env = Environment( ENV = {'PATH' : os.environ['PATH']}, ! CCFLAGS = '-qrtti=all', ! CPPPATH = '#include', ! LIBPATH = '#libs', ! tools=['default','aixcc'], ! CXX ='xlC_r', ! LINKFLAGS='-bh:5' ) # -bh:5 remove duplicate symbol warning ! elif platform == 'msvc': ! env = Environment( CCFLAGS = '-GX -GR -nologo', ! CPPPATH = '#include', ! LIBPATH = '#libs' ) ! elif platform == 'mingw': ! env = Environment( CPPPATH = '#include', ! LIBPATH = '#libs', ! tools=['default','mingw'] ) Export( 'env' ) |
From: Baptiste L. <bl...@us...> - 2005-02-26 11:41:07
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11910/include/cpptl Modified Files: functor.h functor.py Log Message: * simpler implementation of functors. * complete rewrote of the generator (much easier to maintain) Index: functor.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/functor.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** functor.h 25 Feb 2005 20:53:56 -0000 1.1 --- functor.h 26 Feb 2005 11:40:58 -0000 1.2 *************** *** 8,11 **** --- 8,46 ---- namespace CppTL { + // Partially borrowed from the standard + // See: + // N1453: http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1453.html + template<class T> + class ReferenceWrapper + { + public: + explicit ReferenceWrapper( T &t ) : t_( &t ) + { + } + + operator T&() const + { + return *t_; + } + + private: + T *t_; + }; + + template<class T> + inline ReferenceWrapper<T> + ref( T &t ) + { + return ReferenceWrapper<T>( t ); + } + + template<class T> + inline ReferenceWrapper<const T> + cref( const T& t ) + { + return ReferenceWrapper<const T>( t ); + } + + namespace Impl { *************** *** 84,87 **** --- 119,146 ---- + template< class Functor, class BindArg > + class Bind0 + { + public: + typedef void result_type; + + + Bind0( Functor functor, BindArg arg ) + : functor_( functor ) + , arg_( arg ) + { + } + + result_type operator()( ) const + { + functor_( arg_ ); + } + private: + Functor functor_; + BindArg arg_; + }; + + + template< class Return > class FunctorBase0R : public FunctorBase *************** *** 148,151 **** --- 207,234 ---- + template< class Functor, class Return, class BindArg > + class Bind0R + { + public: + typedef Return result_type; + + + Bind0R( Functor functor, BindArg arg ) + : functor_( functor ) + , arg_( arg ) + { + } + + result_type operator()( ) const + { + return functor_( arg_ ); + } + private: + Functor functor_; + BindArg arg_; + }; + + + template< class Arg1 > class FunctorBase1 : public FunctorBase *************** *** 212,215 **** --- 295,324 ---- + template< class Functor, class Arg1, class BindArg > + class Bind1 + { + public: + typedef void result_type; + typedef Arg1 arg1_type; + typedef Arg1 first_argument_type; + + + Bind1( Functor functor, BindArg arg ) + : functor_( functor ) + , arg_( arg ) + { + } + + result_type operator()( Arg1 a1 ) const + { + functor_( a1, arg_ ); + } + private: + Functor functor_; + BindArg arg_; + }; + + + template< class Return, class Arg1 > class FunctorBase1R : public FunctorBase *************** *** 276,279 **** --- 385,598 ---- + template< class Functor, class Return, class Arg1, class BindArg > + class Bind1R + { + public: + typedef Return result_type; + typedef Arg1 arg1_type; + typedef Arg1 first_argument_type; + + + Bind1R( Functor functor, BindArg arg ) + : functor_( functor ) + , arg_( arg ) + { + } + + result_type operator()( Arg1 a1 ) const + { + return functor_( a1, arg_ ); + } + private: + Functor functor_; + BindArg arg_; + }; + + + + template< class Arg1, class Arg2 > + class FunctorBase2 : public FunctorBase + { + public: + virtual void operator()( Arg1 a1, Arg2 a2 ) const = 0; + }; + + + template< class Functor, class Arg1, class Arg2 > + class GenericFunctor2 : public FunctorBase2< Arg1, Arg2 > + { + public: + typedef GenericFunctor2< Functor, Arg1, Arg2 > SelfType; + + GenericFunctor2( const Functor &functor ) + : functor_( functor ) + { + } + + void operator()( Arg1 a1, Arg2 a2 ) const + { + functor_( a1, a2 ); + } + + FunctorBase *clone() const + { + return new SelfType( *this ); + } + + private: + Functor functor_; + }; + + + template< class Holder, class Object, class Arg1, class Arg2 > + class MemberFunctor2 : public FunctorBase2< Arg1, Arg2 > + { + public: + typedef MemberFunctor2< Holder, Object, Arg1, Arg2 > SelfType; + typedef void (Object::*MemberFn)( Arg1 a1, Arg2 a2 ); + + MemberFunctor2( const Holder &holder, MemberFn member ) + : holder_( holder ) + , member_( member ) + { + } + + void operator()( Arg1 a1, Arg2 a2 ) const + { + Object &object = *holder_; + (object.*member_)( a1, a2 ); + } + + FunctorBase *clone() const + { + return new SelfType( *this ); + } + + private: + Holder holder_; + MemberFn member_; + }; + + + template< class Functor, class Arg1, class Arg2, class BindArg > + class Bind2 + { + public: + typedef void result_type; + typedef Arg1 arg1_type; + typedef Arg1 first_argument_type; + typedef Arg2 arg2_type; + typedef Arg2 second_argument_type; + + + Bind2( Functor functor, BindArg arg ) + : functor_( functor ) + , arg_( arg ) + { + } + + result_type operator()( Arg1 a1, Arg2 a2 ) const + { + functor_( a1, a2, arg_ ); + } + private: + Functor functor_; + BindArg arg_; + }; + + + + template< class Return, class Arg1, class Arg2 > + class FunctorBase2R : public FunctorBase + { + public: + virtual Return operator()( Arg1 a1, Arg2 a2 ) const = 0; + }; + + + template< class Functor, class Return, class Arg1, class Arg2 > + class GenericFunctor2R : public FunctorBase2R< Return, Arg1, Arg2 > + { + public: + typedef GenericFunctor2R< Functor, Return, Arg1, Arg2 > SelfType; + + GenericFunctor2R( const Functor &functor ) + : functor_( functor ) + { + } + + Return operator()( Arg1 a1, Arg2 a2 ) const + { + return functor_( a1, a2 ); + } + + FunctorBase *clone() const + { + return new SelfType( *this ); + } + + private: + Functor functor_; + }; + + + template< class Holder, class Object, class Return, class Arg1, class Arg2 > + class MemberFunctor2R : public FunctorBase2R< Return, Arg1, Arg2 > + { + public: + typedef MemberFunctor2R< Holder, Object, Return, Arg1, Arg2 > SelfType; + typedef Return (Object::*MemberFn)( Arg1 a1, Arg2 a2 ); + + MemberFunctor2R( const Holder &holder, MemberFn member ) + : holder_( holder ) + , member_( member ) + { + } + + Return operator()( Arg1 a1, Arg2 a2 ) const + { + Object &object = *holder_; + return (object.*member_)( a1, a2 ); + } + + FunctorBase *clone() const + { + return new SelfType( *this ); + } + + private: + Holder holder_; + MemberFn member_; + }; + + + template< class Functor, class Return, class Arg1, class Arg2, class BindArg > + class Bind2R + { + public: + typedef Return result_type; + typedef Arg1 arg1_type; + typedef Arg1 first_argument_type; + typedef Arg2 arg2_type; + typedef Arg2 second_argument_type; + + + Bind2R( Functor functor, BindArg arg ) + : functor_( functor ) + , arg_( arg ) + { + } + + result_type operator()( Arg1 a1, Arg2 a2 ) const + { + return functor_( a1, a2, arg_ ); + } + private: + Functor functor_; + BindArg arg_; + }; + + + *************** *** 510,513 **** --- 829,926 ---- + template< class Arg1, class Arg2 > + class Functor2 : public FunctorCommon + { + public: + typedef Functor2< Arg1, Arg2 > SelfType; + typedef Impl::FunctorBase2< Arg1, Arg2 > FunctorImplType; + typedef void result_type; + typedef Arg1 arg1_type; + typedef Arg1 first_argument_type; + typedef Arg2 arg2_type; + typedef Arg2 second_argument_type; + + + Functor2() + { + } + + explicit Functor2( FunctorImplType *impl ) + : FunctorCommon( impl ) + { + } + + Functor2( const SelfType &other ) + : FunctorCommon( other ) + { + } + + SelfType &operator=( const SelfType &other ) + { + SelfType temp( other ); + swap( temp ); + return *this; + } + + result_type operator()( Arg1 a1, Arg2 a2 ) const + { + FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); + return impl( a1, a2 ); + } + + void swap( SelfType &other ) + { + FunctorCommon::swap( other ); + } + }; + + + template< class Return, class Arg1, class Arg2 > + class Functor2R : public FunctorCommon + { + public: + typedef Functor2R< Return, Arg1, Arg2 > SelfType; + typedef Impl::FunctorBase2R< Return, Arg1, Arg2 > FunctorImplType; + typedef Return result_type; + typedef Arg1 arg1_type; + typedef Arg1 first_argument_type; + typedef Arg2 arg2_type; + typedef Arg2 second_argument_type; + + + Functor2R() + { + } + + explicit Functor2R( FunctorImplType *impl ) + : FunctorCommon( impl ) + { + } + + Functor2R( const SelfType &other ) + : FunctorCommon( other ) + { + } + + SelfType &operator=( const SelfType &other ) + { + SelfType temp( other ); + swap( temp ); + return *this; + } + + result_type operator()( Arg1 a1, Arg2 a2 ) const + { + FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); + return impl( a1, a2 ); + } + + void swap( SelfType &other ) + { + FunctorCommon::swap( other ); + } + }; + + *************** *** 536,540 **** } ! // Functor0R --- 949,960 ---- } ! template<class Functor, class BindArg> ! inline Impl::Bind0<Functor ! ,BindArg > ! bind1( Functor functor, BindArg arg ) ! { ! return Impl::Bind0<Functor ! ,BindArg >( functor, arg ); ! } // Functor0R *************** *** 562,566 **** } ! // Functor1 --- 982,995 ---- } ! template<class Functor, class BindArg> ! inline Impl::Bind0R<Functor ! ,CPPTL_TYPENAME Functor::result_type ! ,BindArg > ! bind1r( Functor functor, BindArg arg ) ! { ! return Impl::Bind0R<Functor ! ,CPPTL_TYPENAME Functor::result_type ! ,BindArg >( functor, arg ); ! } // Functor1 *************** *** 588,592 **** } ! // Functor1R --- 1017,1030 ---- } ! template<class Functor, class BindArg> ! inline Impl::Bind1<Functor ! ,CPPTL_TYPENAME Functor::first_argument_type ! ,BindArg > ! bind2( Functor functor, BindArg arg ) ! { ! return Impl::Bind1<Functor ! ,CPPTL_TYPENAME Functor::first_argument_type ! ,BindArg >( functor, arg ); ! } // Functor1R *************** *** 616,620 **** --- 1054,1151 ---- } + template<class Functor, class BindArg> + inline Impl::Bind1R<Functor + ,CPPTL_TYPENAME Functor::result_type + ,CPPTL_TYPENAME Functor::first_argument_type + ,BindArg > + bind2r( Functor functor, BindArg arg ) + { + return Impl::Bind1R<Functor + ,CPPTL_TYPENAME Functor::result_type + ,CPPTL_TYPENAME Functor::first_argument_type + ,BindArg >( functor, arg ); + } + + // Functor2 + + template< class Arg1, class Arg2 > + inline Functor2< Arg1, Arg2 > cfn2( void (*function)( Arg1 a1, Arg2 a2 ) ) + { + typedef void (*Functor)(Arg1,Arg2); + return Functor2< Arg1, Arg2 >( new Impl::GenericFunctor2< Functor, Arg1, Arg2 >( function ) ); + } + + template< class Holder, class Object, class Arg1, class Arg2 > + inline Functor2< Arg1, Arg2 > + memfn2( const Holder &holder, void (Object::*member)( Arg1 a1, Arg2 a2 ) ) + { + return Functor2< Arg1, Arg2 >( new Impl::MemberFunctor2< Holder, Object, Arg1, Arg2 >( holder, member ) ); + } + + template<class Functor> + inline Functor2< CPPTL_TYPENAME Functor::first_argument_type + ,CPPTL_TYPENAME Functor::second_argument_type > + fn2( Functor functor ) + { + typedef CPPTL_TYPENAME Functor::first_argument_type Arg1; + typedef CPPTL_TYPENAME Functor::second_argument_type Arg2; + return Functor2< Arg1, Arg2 >( new Impl::GenericFunctor2< Functor, Arg1, Arg2 >( functor ) ); + } + + template<class Functor, class BindArg> + inline Impl::Bind2<Functor + ,CPPTL_TYPENAME Functor::first_argument_type + ,CPPTL_TYPENAME Functor::second_argument_type + ,BindArg > + bind3( Functor functor, BindArg arg ) + { + return Impl::Bind2<Functor + ,CPPTL_TYPENAME Functor::first_argument_type + ,CPPTL_TYPENAME Functor::second_argument_type + ,BindArg >( functor, arg ); + } + + // Functor2R + + template< class Return, class Arg1, class Arg2 > + inline Functor2R< Return, Arg1, Arg2 > cfn2r( Return (*function)( Arg1 a1, Arg2 a2 ) ) + { + typedef Return (*Functor)(Arg1,Arg2); + return Functor2R< Return, Arg1, Arg2 >( new Impl::GenericFunctor2R< Functor, Return, Arg1, Arg2 >( function ) ); + } + template< class Holder, class Object, class Return, class Arg1, class Arg2 > + inline Functor2R< Return, Arg1, Arg2 > + memfn2r( const Holder &holder, Return (Object::*member)( Arg1 a1, Arg2 a2 ) ) + { + return Functor2R< Return, Arg1, Arg2 >( new Impl::MemberFunctor2R< Holder, Object, Return, Arg1, Arg2 >( holder, member ) ); + } + + template<class Functor> + inline Functor2R< CPPTL_TYPENAME Functor::result_type + ,CPPTL_TYPENAME Functor::first_argument_type + ,CPPTL_TYPENAME Functor::second_argument_type > + fn2r( Functor functor ) + { + typedef CPPTL_TYPENAME Functor::result_type Return; + typedef CPPTL_TYPENAME Functor::first_argument_type Arg1; + typedef CPPTL_TYPENAME Functor::second_argument_type Arg2; + return Functor2R< Return, Arg1, Arg2 >( new Impl::GenericFunctor2R< Functor, Return, Arg1, Arg2 >( functor ) ); + } + + template<class Functor, class BindArg> + inline Impl::Bind2R<Functor + ,CPPTL_TYPENAME Functor::result_type + ,CPPTL_TYPENAME Functor::first_argument_type + ,CPPTL_TYPENAME Functor::second_argument_type + ,BindArg > + bind3r( Functor functor, BindArg arg ) + { + return Impl::Bind2R<Functor + ,CPPTL_TYPENAME Functor::result_type + ,CPPTL_TYPENAME Functor::first_argument_type + ,CPPTL_TYPENAME Functor::second_argument_type + ,BindArg >( functor, arg ); + } Index: functor.py =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/functor.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** functor.py 25 Feb 2005 20:53:57 -0000 1.1 --- functor.py 26 Feb 2005 11:40:58 -0000 1.2 *************** *** 1,4 **** --- 1,6 ---- # script to generate cpptl/functor.h + MAX_ARGUMENT_COUNT = 2 + header =\ """// This script is generated by the python script functor.py *************** *** 11,14 **** --- 13,51 ---- namespace CppTL { + // Partially borrowed from the standard + // See: + // N1453: http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1453.html + template<class T> + class ReferenceWrapper + { + public: + explicit ReferenceWrapper( T &t ) : t_( &t ) + { + } + + operator T&() const + { + return *t_; + } + + private: + T *t_; + }; + + template<class T> + inline ReferenceWrapper<T> + ref( T &t ) + { + return ReferenceWrapper<T>( t ); + } + + template<class T> + inline ReferenceWrapper<const T> + cref( const T& t ) + { + return ReferenceWrapper<const T>( t ); + } + + namespace Impl { *************** *** 180,183 **** --- 217,249 ---- # member_functor_instantiation : MemberFunctor1R<HolderType,ObjectType,ReturnType,Arg1Type> + bind_functor = \ + """ %(bind_functor_template_decl)s + class %(bind_functor)s + { + public: + typedef %(return_type)s result_type; + %(argument_types_typedef)s + + %(bind_functor)s( Functor functor, BindArg arg ) + : functor_( functor ) + , arg_( arg ) + { + } + + result_type operator()( %(fn_parameters)s ) const + { + %(return_keyword)sfunctor_( %(bind_fn_call)s ); + } + private: + Functor functor_; + BindArg arg_; + }; + + + + """ + # bind_functor : BindR1 + # bind_functor_template_decl : template<class Functor,class ReturnType, class Arg1, class BindArg> + # bind_fn_call: a1, arg_ functor = \ *************** *** 259,263 **** } ! """ --- 325,334 ---- } ! template<class Functor, class BindArg> ! inline Impl::%(bind_functor)s%(bind_functor_deduced_types)s ! %(bind)s( Functor functor, BindArg arg ) ! { ! return Impl::%(bind_functor)s%(bind_functor_deduced_types)s( functor, arg ); ! } """ *************** *** 265,269 **** # fn_types : Arg1 # memfn : memfn1r ! # fn : fnr1 # functor_deduced_types : # CPPTL_TYPENAME Functor::result_type --- 336,340 ---- # fn_types : Arg1 # memfn : memfn1r ! # fn : fn1r # functor_deduced_types : # CPPTL_TYPENAME Functor::result_type *************** *** 272,275 **** --- 343,351 ---- # typedef CPPTL_TYPENAME Functor::result_type Return; # typedef CPPTL_TYPENAME Functor::first_argument_type Arg1; + # bind : bind1r + # bind_functor_deduced_types : + # CPPTL_TYPENAME Functor::result_type + # ,CPPTL_TYPENAME Functor::first_argument_type + # ,BindArg *************** *** 304,307 **** --- 380,387 ---- self.functor_template_decl = self.makeTemplateDecl( base_template_parameters ) self.functor_instantiation = self.functor + self.makeTemplateInstantiation( base_template_parameters ) + self.bind_functor = 'Bind%d%s' % (count,return_suffix) + bind_functor_template_parameters = ['Functor'] + base_template_parameters + ['BindArg'] + self.bind_functor_template_decl = self.makeTemplateDecl( bind_functor_template_parameters ) + self.bind_fn_call = ', '.join( [ 'a%d' % n for n in xrange(1,count+1) ] + ['arg_'] ) self.argument_types_typedef = '' for n in xrange(1,count+1): *************** *** 310,313 **** --- 390,394 ---- self.memfn = 'memfn%d%s' % (count,return_suffix.lower()) self.fn = 'fn%d%s' % (count,return_suffix.lower()) + self.bind = 'bind%d%s' % (count+1,return_suffix.lower()) self.fn_types = ','.join( [ 'Arg%d' % n for n in xrange(1,count+1) ] ) functor_deduced_types = [] *************** *** 327,330 **** --- 408,413 ---- (self.getFunctorArgTypeName(n),n) ) self.functor_deduced_type_alias = '\n'.join( functor_deduced_type_alias ) + bind_functor_deduced_types = ['Functor'] + functor_deduced_types + ['BindArg'] + self.bind_functor_deduced_types = '<' + '\n ,'.join( bind_functor_deduced_types ) + ' >' def __getitem__( self, key ): *************** *** 361,365 **** functor_generators = '' ! for argument_count in xrange(0,2): for is_void in (True,False): parameters = GenerationParameters( argument_count, is_void ) --- 444,448 ---- functor_generators = '' ! for argument_count in xrange(0,MAX_ARGUMENT_COUNT+1): for is_void in (True,False): parameters = GenerationParameters( argument_count, is_void ) *************** *** 367,370 **** --- 450,454 ---- functors_impl += generic_functor % parameters functors_impl += member_functor % parameters + functors_impl += bind_functor % parameters functors += functor % parameters functor_generators += generator % parameters |
From: Baptiste L. <bl...@us...> - 2005-02-26 11:41:07
|
Update of /cvsroot/cppunit/cppunit2/src/cpputtest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11910/src/cpputtest Modified Files: cpputtest.vcproj main.cpp SConscript Added Files: testfunctor3.cpp Log Message: * simpler implementation of functors. * complete rewrote of the generator (much easier to maintain) Index: SConscript =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/SConscript,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SConscript 23 Feb 2005 23:11:23 -0000 1.3 --- SConscript 26 Feb 2005 11:40:58 -0000 1.4 *************** *** 11,14 **** --- 11,15 ---- testbasicassertion.cpp testfunctor.cpp + testfunctor3.cpp testtestcase.cpp testtestsuite.cpp --- NEW FILE: testfunctor3.cpp --- #include <cpput/assert.h> #include <cpptl/functor.h> #include <iostream> namespace { bool callbackCalled; bool badValue; std::string expected; static void callback0() { callbackCalled = true; } static void callback1( bool value ) { callbackCalled = value; } static void callback12( const std::string &str, int x ) { callbackCalled = true; } static void callback1string( const std::string &str ) { callbackCalled = true; badValue = expected == str; } static double returnCallback1( int x ) { return x / 2.0; } struct TestFunctor { TestFunctor() // avoid bogus suncc warning { } void operator()() const { callbackCalled = true; } void operator()( bool value ) const { callbackCalled = value; } }; struct HelperObject { bool flag_; int value_; HelperObject() : flag_( false ) , value_( 0 ) { } HelperObject( const HelperObject &other ) : flag_( other.flag_ ) , value_( other.value_ + 1 ) { } HelperObject &operator =( const HelperObject &other ) { flag_ = other.flag_; value_ = other.value_ + 1; return *this; } void setFlagOn() { flag_ = true; } void setFlag( bool value ) { flag_ = value; } double compute1( int x ) { return (x + value_) / 2.0; } }; } static void testFunctor() { CppTL::Functor0 fn = CppTL::cfn0( &callback0 ); callbackCalled = false; fn(); CPPUT_ASSERT( callbackCalled, "Functor() did not call C function." ); callbackCalled = false; TestFunctor testFunctor; fn = CppTL::fn0( testFunctor ); fn(); CPPUT_ASSERT( callbackCalled, "Functor() did not call functor object." ); CppTL::SharedPtr<HelperObject> helper( new HelperObject() ); helper->flag_ = false; fn = CppTL::memfn0( helper, &HelperObject::setFlagOn ); fn(); CPPUT_ASSERT( helper->flag_, "Functor() did not call object method (shared_ptr)." ); helper->flag_ = false; fn = CppTL::memfn0( helper.get(), &HelperObject::setFlagOn ); fn(); CPPUT_ASSERT( helper->flag_, "Functor() did not call object method (ptr)." ); } static void testFunctor1() { CppTL::Functor1<bool> fn = CppTL::cfn1( &callback1 ); callbackCalled = false; fn( true ); CPPUT_ASSERT( callbackCalled, "Functor1(true) did not call C function." ); fn( false ); CPPUT_ASSERT_FALSE( callbackCalled, "Functor1(false) did not call C function." ); CppTL::SharedPtr<HelperObject> helper( new HelperObject() ); helper->flag_ = false; fn = CppTL::memfn1( helper, &HelperObject::setFlag ); fn( true ); CPPUT_ASSERT( helper->flag_, "Functor1(true) did not call object method." ); fn( false ); CPPUT_ASSERT_FALSE( helper->flag_, "Functor1(false) did not call object method." ); } static void testFunctor1R() { CppTL::Functor1R<double,int> fn = CppTL::cfn1r( &returnCallback1 ); callbackCalled = false; CPPUT_ASSERT_EQUAL( 1.0, fn( 2 ) ); CppTL::SharedPtr<HelperObject> helper( new HelperObject() ); helper->value_ = 0; fn = CppTL::memfn1r( helper, &HelperObject::compute1 ); CPPUT_ASSERT_EQUAL( 1.0, fn( 2 ) ); helper->value_ = 10; CPPUT_ASSERT_EQUAL( 6.0, fn( 2 ) ); } namespace { int extractHelperObjectValue( const HelperObject &object ) { return object.value_; } void doubleHelperObjectValue( HelperObject &object ) { object.value_ *= 2; } } // anonymous namespace static void testConstReferenceParameterSupport() { CppTL::Functor1R<int,const HelperObject &> fncref1( CppTL::cfn1r( &extractHelperObjectValue ) ); HelperObject object; object.value_ = 12345678; CPPUT_ASSERT_EQUAL( 12345678, fncref1( object ) ); } static void testReferenceParameterSupport() { CppTL::Functor1<HelperObject &> fnref1( CppTL::cfn1( &doubleHelperObjectValue ) ); HelperObject object; object.value_ = 1111; fnref1( object ); CPPUT_ASSERT_EQUAL( 1111*2, object.value_ ); } namespace { int multiply( int x, int y ) { return x * y; } } static void testBindValue() { CppTL::Functor2R<int,int,int> fn2 = CppTL::cfn2r( &multiply ); CppTL::Functor1R<int,int> fn1 = CppTL::fn1r( CppTL::bind2r( fn2, 3 ) ); CPPUT_ASSERT_EQUAL( 2*3, fn1(2) ); CPPUT_ASSERT_EQUAL( 5*3, fn1(5) ); } static void testBindConstRef() { CppTL::Functor1R<int,const HelperObject &> fn1( CppTL::cfn1r( &extractHelperObjectValue ) ); HelperObject object; object.value_ = 12345678; CppTL::Functor0R<int> fn0 = CppTL::fn0r( CppTL::bind1r( fn1, CppTL::cref(object) ) ); CPPUT_ASSERT_EQUAL( 12345678, fn0() ); } static void testBindRef() { CppTL::Functor1<HelperObject &> fnref1( CppTL::cfn1( &doubleHelperObjectValue ) ); HelperObject object; object.value_ = 1111; CppTL::Functor0 fn0 = CppTL::fn0( CppTL::bind1( fnref1, CppTL::ref( object ) ) ); fn0(); CPPUT_ASSERT_EQUAL( 1111*2, object.value_ ); } bool testFunctors3() { try { CppUT::TestInfo::startNewTest(); testFunctor(); testFunctor1(); testFunctor1R(); testConstReferenceParameterSupport(); testReferenceParameterSupport(); testBindValue(); testBindConstRef(); testBindRef(); } catch ( CppUT::AbortingAssertionException &e ) { std::cout << "testFunctors3() failed: " << e.what() << std::endl; return false; } return true; } Index: main.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/main.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** main.cpp 17 Nov 2004 21:47:10 -0000 1.10 --- main.cpp 26 Feb 2005 11:40:58 -0000 1.11 *************** *** 19,23 **** bool testTestCase(); bool testFunctors(); ! //bool testFunctors2(); --- 19,23 ---- bool testTestCase(); bool testFunctors(); ! bool testFunctors3(); *************** *** 26,30 **** return testBasicAssertions() && testFunctors() && ! // testFunctors2() && // testTestRunResult() && // testTestContext() && --- 26,30 ---- return testBasicAssertions() && testFunctors() && ! testFunctors3() && // testTestRunResult() && // testTestContext() && Index: cpputtest.vcproj =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/cpputtest.vcproj,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** cpputtest.vcproj 20 Nov 2004 12:17:51 -0000 1.9 --- cpputtest.vcproj 26 Feb 2005 11:40:58 -0000 1.10 *************** *** 238,242 **** </File> <File ! RelativePath=".\testfunctor2.cpp"> </File> <File --- 238,242 ---- </File> <File ! RelativePath=".\testfunctor3.cpp"> </File> <File |
From: Baptiste L. <bl...@us...> - 2005-02-26 11:41:06
|
Update of /cvsroot/cppunit/cppunit2/src/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11910/src/cpput Modified Files: cpput.vcproj Log Message: * simpler implementation of functors. * complete rewrote of the generator (much easier to maintain) Index: cpput.vcproj =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpput/cpput.vcproj,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** cpput.vcproj 23 Feb 2005 23:15:34 -0000 1.25 --- cpput.vcproj 26 Feb 2005 11:40:58 -0000 1.26 *************** *** 204,207 **** --- 204,213 ---- </File> <File + RelativePath="..\..\include\cpptl\functor.h"> + </File> + <File + RelativePath="..\..\include\cpptl\functor3.h"> + </File> + <File RelativePath="..\..\include\cpptl\sharedptr.h"> </File> |
From: Baptiste L. <bl...@us...> - 2005-02-25 20:54:08
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8256 Added Files: functor.h functor.py Log Message: * simpler implementation of functors. * complete rewrote of the generator (much easier to maintain) --- NEW FILE: functor.h --- // This script is generated by the python script functor.py // Do not edit. #ifndef CPPTL_FUNCTOR_H_INCLUDED # define CPPTL_FUNCTOR_H_INCLUDED # include <cpptl/config.h> namespace CppTL { namespace Impl { class FunctorBase { public: virtual ~FunctorBase() { } virtual FunctorBase *clone() const = 0; }; class FunctorBase0 : public FunctorBase { public: virtual void operator()( ) const = 0; }; template< class Functor > class GenericFunctor0 : public FunctorBase0 { public: typedef GenericFunctor0< Functor > SelfType; GenericFunctor0( const Functor &functor ) : functor_( functor ) { } void operator()( ) const { functor_( ); } FunctorBase *clone() const { return new SelfType( *this ); } private: Functor functor_; }; template< class Holder, class Object > class MemberFunctor0 : public FunctorBase0 { public: typedef MemberFunctor0< Holder, Object > SelfType; typedef void (Object::*MemberFn)( ); MemberFunctor0( const Holder &holder, MemberFn member ) : holder_( holder ) , member_( member ) { } void operator()( ) const { Object &object = *holder_; (object.*member_)( ); } FunctorBase *clone() const { return new SelfType( *this ); } private: Holder holder_; MemberFn member_; }; template< class Return > class FunctorBase0R : public FunctorBase { public: virtual Return operator()( ) const = 0; }; template< class Functor, class Return > class GenericFunctor0R : public FunctorBase0R< Return > { public: typedef GenericFunctor0R< Functor, Return > SelfType; GenericFunctor0R( const Functor &functor ) : functor_( functor ) { } Return operator()( ) const { return functor_( ); } FunctorBase *clone() const { return new SelfType( *this ); } private: Functor functor_; }; template< class Holder, class Object, class Return > class MemberFunctor0R : public FunctorBase0R< Return > { public: typedef MemberFunctor0R< Holder, Object, Return > SelfType; typedef Return (Object::*MemberFn)( ); MemberFunctor0R( const Holder &holder, MemberFn member ) : holder_( holder ) , member_( member ) { } Return operator()( ) const { Object &object = *holder_; return (object.*member_)( ); } FunctorBase *clone() const { return new SelfType( *this ); } private: Holder holder_; MemberFn member_; }; template< class Arg1 > class FunctorBase1 : public FunctorBase { public: virtual void operator()( Arg1 a1 ) const = 0; }; template< class Functor, class Arg1 > class GenericFunctor1 : public FunctorBase1< Arg1 > { public: typedef GenericFunctor1< Functor, Arg1 > SelfType; GenericFunctor1( const Functor &functor ) : functor_( functor ) { } void operator()( Arg1 a1 ) const { functor_( a1 ); } FunctorBase *clone() const { return new SelfType( *this ); } private: Functor functor_; }; template< class Holder, class Object, class Arg1 > class MemberFunctor1 : public FunctorBase1< Arg1 > { public: typedef MemberFunctor1< Holder, Object, Arg1 > SelfType; typedef void (Object::*MemberFn)( Arg1 a1 ); MemberFunctor1( const Holder &holder, MemberFn member ) : holder_( holder ) , member_( member ) { } void operator()( Arg1 a1 ) const { Object &object = *holder_; (object.*member_)( a1 ); } FunctorBase *clone() const { return new SelfType( *this ); } private: Holder holder_; MemberFn member_; }; template< class Return, class Arg1 > class FunctorBase1R : public FunctorBase { public: virtual Return operator()( Arg1 a1 ) const = 0; }; template< class Functor, class Return, class Arg1 > class GenericFunctor1R : public FunctorBase1R< Return, Arg1 > { public: typedef GenericFunctor1R< Functor, Return, Arg1 > SelfType; GenericFunctor1R( const Functor &functor ) : functor_( functor ) { } Return operator()( Arg1 a1 ) const { return functor_( a1 ); } FunctorBase *clone() const { return new SelfType( *this ); } private: Functor functor_; }; template< class Holder, class Object, class Return, class Arg1 > class MemberFunctor1R : public FunctorBase1R< Return, Arg1 > { public: typedef MemberFunctor1R< Holder, Object, Return, Arg1 > SelfType; typedef Return (Object::*MemberFn)( Arg1 a1 ); MemberFunctor1R( const Holder &holder, MemberFn member ) : holder_( holder ) , member_( member ) { } Return operator()( Arg1 a1 ) const { Object &object = *holder_; return (object.*member_)( a1 ); } FunctorBase *clone() const { return new SelfType( *this ); } private: Holder holder_; MemberFn member_; }; } // namespace Impl class FunctorCommon { public: ~FunctorCommon() { delete impl_; } bool empty() const { return impl_ == 0; } operator bool() const { return impl_ != 0; } bool operator !() const { return impl_ == 0; } protected: FunctorCommon() : impl_( 0 ) { } FunctorCommon( Impl::FunctorBase *impl ) : impl_( impl ) { } FunctorCommon( const FunctorCommon &other ) : impl_( other.impl_ ? other.impl_->clone() : 0 ) { } void swap( FunctorCommon &other ) { Impl::FunctorBase *temp = impl_; impl_ = other.impl_; other.impl_ = temp; } Impl::FunctorBase *impl_; private: void operator =( const FunctorCommon &other ); }; class Functor0 : public FunctorCommon { public: typedef Functor0 SelfType; typedef Impl::FunctorBase0 FunctorImplType; typedef void result_type; Functor0() { } explicit Functor0( FunctorImplType *impl ) : FunctorCommon( impl ) { } Functor0( const SelfType &other ) : FunctorCommon( other ) { } SelfType &operator=( const SelfType &other ) { SelfType temp( other ); swap( temp ); return *this; } result_type operator()( ) const { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); return impl( ); } void swap( SelfType &other ) { FunctorCommon::swap( other ); } }; template< class Return > class Functor0R : public FunctorCommon { public: typedef Functor0R< Return > SelfType; typedef Impl::FunctorBase0R< Return > FunctorImplType; typedef Return result_type; Functor0R() { } explicit Functor0R( FunctorImplType *impl ) : FunctorCommon( impl ) { } Functor0R( const SelfType &other ) : FunctorCommon( other ) { } SelfType &operator=( const SelfType &other ) { SelfType temp( other ); swap( temp ); return *this; } result_type operator()( ) const { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); return impl( ); } void swap( SelfType &other ) { FunctorCommon::swap( other ); } }; template< class Arg1 > class Functor1 : public FunctorCommon { public: typedef Functor1< Arg1 > SelfType; typedef Impl::FunctorBase1< Arg1 > FunctorImplType; typedef void result_type; typedef Arg1 arg1_type; typedef Arg1 first_argument_type; Functor1() { } explicit Functor1( FunctorImplType *impl ) : FunctorCommon( impl ) { } Functor1( const SelfType &other ) : FunctorCommon( other ) { } SelfType &operator=( const SelfType &other ) { SelfType temp( other ); swap( temp ); return *this; } result_type operator()( Arg1 a1 ) const { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); return impl( a1 ); } void swap( SelfType &other ) { FunctorCommon::swap( other ); } }; template< class Return, class Arg1 > class Functor1R : public FunctorCommon { public: typedef Functor1R< Return, Arg1 > SelfType; typedef Impl::FunctorBase1R< Return, Arg1 > FunctorImplType; typedef Return result_type; typedef Arg1 arg1_type; typedef Arg1 first_argument_type; Functor1R() { } explicit Functor1R( FunctorImplType *impl ) : FunctorCommon( impl ) { } Functor1R( const SelfType &other ) : FunctorCommon( other ) { } SelfType &operator=( const SelfType &other ) { SelfType temp( other ); swap( temp ); return *this; } result_type operator()( Arg1 a1 ) const { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); return impl( a1 ); } void swap( SelfType &other ) { FunctorCommon::swap( other ); } }; // Functor0 inline Functor0 cfn0( void (*function)( ) ) { typedef void (*Functor)(); return Functor0( new Impl::GenericFunctor0< Functor >( function ) ); } template< class Holder, class Object > inline Functor0 memfn0( const Holder &holder, void (Object::*member)( ) ) { return Functor0( new Impl::MemberFunctor0< Holder, Object >( holder, member ) ); } template<class Functor> inline Functor0 fn0( Functor functor ) { return Functor0( new Impl::GenericFunctor0< Functor >( functor ) ); } // Functor0R template< class Return > inline Functor0R< Return > cfn0r( Return (*function)( ) ) { typedef Return (*Functor)(); return Functor0R< Return >( new Impl::GenericFunctor0R< Functor, Return >( function ) ); } template< class Holder, class Object, class Return > inline Functor0R< Return > memfn0r( const Holder &holder, Return (Object::*member)( ) ) { return Functor0R< Return >( new Impl::MemberFunctor0R< Holder, Object, Return >( holder, member ) ); } template<class Functor> inline Functor0R< CPPTL_TYPENAME Functor::result_type > fn0r( Functor functor ) { typedef CPPTL_TYPENAME Functor::result_type Return; return Functor0R< Return >( new Impl::GenericFunctor0R< Functor, Return >( functor ) ); } // Functor1 template< class Arg1 > inline Functor1< Arg1 > cfn1( void (*function)( Arg1 a1 ) ) { typedef void (*Functor)(Arg1); return Functor1< Arg1 >( new Impl::GenericFunctor1< Functor, Arg1 >( function ) ); } template< class Holder, class Object, class Arg1 > inline Functor1< Arg1 > memfn1( const Holder &holder, void (Object::*member)( Arg1 a1 ) ) { return Functor1< Arg1 >( new Impl::MemberFunctor1< Holder, Object, Arg1 >( holder, member ) ); } template<class Functor> inline Functor1< CPPTL_TYPENAME Functor::first_argument_type > fn1( Functor functor ) { typedef CPPTL_TYPENAME Functor::first_argument_type Arg1; return Functor1< Arg1 >( new Impl::GenericFunctor1< Functor, Arg1 >( functor ) ); } // Functor1R template< class Return, class Arg1 > inline Functor1R< Return, Arg1 > cfn1r( Return (*function)( Arg1 a1 ) ) { typedef Return (*Functor)(Arg1); return Functor1R< Return, Arg1 >( new Impl::GenericFunctor1R< Functor, Return, Arg1 >( function ) ); } template< class Holder, class Object, class Return, class Arg1 > inline Functor1R< Return, Arg1 > memfn1r( const Holder &holder, Return (Object::*member)( Arg1 a1 ) ) { return Functor1R< Return, Arg1 >( new Impl::MemberFunctor1R< Holder, Object, Return, Arg1 >( holder, member ) ); } template<class Functor> inline Functor1R< CPPTL_TYPENAME Functor::result_type ,CPPTL_TYPENAME Functor::first_argument_type > fn1r( Functor functor ) { typedef CPPTL_TYPENAME Functor::result_type Return; typedef CPPTL_TYPENAME Functor::first_argument_type Arg1; return Functor1R< Return, Arg1 >( new Impl::GenericFunctor1R< Functor, Return, Arg1 >( functor ) ); } } // namespace CppTL #endif // CPPTL_FUNCTOR_H_INCLUDED --- NEW FILE: functor.py --- # script to generate cpptl/functor.h header =\ """// This script is generated by the python script functor.py // Do not edit. #ifndef CPPTL_FUNCTOR_H_INCLUDED # define CPPTL_FUNCTOR_H_INCLUDED # include <cpptl/config.h> namespace CppTL { namespace Impl { class FunctorBase { public: virtual ~FunctorBase() { } virtual FunctorBase *clone() const = 0; }; %(functors_impl)s } // namespace Impl class FunctorCommon { public: ~FunctorCommon() { delete impl_; } bool empty() const { return impl_ == 0; } operator bool() const { return impl_ != 0; } bool operator !() const { return impl_ == 0; } protected: FunctorCommon() : impl_( 0 ) { } FunctorCommon( Impl::FunctorBase *impl ) : impl_( impl ) { } FunctorCommon( const FunctorCommon &other ) : impl_( other.impl_ ? other.impl_->clone() : 0 ) { } void swap( FunctorCommon &other ) { Impl::FunctorBase *temp = impl_; impl_ = other.impl_; other.impl_ = temp; } Impl::FunctorBase *impl_; private: void operator =( const FunctorCommon &other ); }; %(functors)s %(functor_generators)s } // namespace CppTL #endif // CPPTL_FUNCTOR_H_INCLUDED """ functor_base =\ """ %(base_template_decl)s class %(impl_base)s : public FunctorBase { public: virtual %(return_type)s operator()( %(fn_parameters)s ) const = 0; }; """ # base_template_decl : template<class ReturnType, class Arg1Type> # impl_base : Functor1BaseR # return_type : ReturnType # fn_parameters: Arg1 a1 generic_functor = \ """ %(generic_functor_template_decl)s class %(generic_functor)s : public %(impl_base_instantiation)s { public: typedef %(generic_functor_instantiation)s SelfType; %(generic_functor)s( const Functor &functor ) : functor_( functor ) { } %(return_type)s operator()( %(fn_parameters)s ) const { %(return_keyword)sfunctor_( %(fn_call)s ); } FunctorBase *clone() const { return new SelfType( *this ); } private: Functor functor_; }; """ # generic_functor_template_decl : template<class Functor, class ReturnType, class Arg1Type> # generic_functor : GenericFunctor1R # impl_base_instantiation : Functor1BaseR<ReturnType,Arg1Type> # generic_functor_instantiation : GenericFunctor1R<Functor,ReturnType,Arg1Type> # return_keyword : return # fn_call : a1 member_functor = \ """ %(member_functor_template_decl)s class %(member_functor)s : public %(impl_base_instantiation)s { public: typedef %(member_functor_instantiation)s SelfType; typedef %(return_type)s (Object::*MemberFn)( %(fn_parameters)s ); %(member_functor)s( const Holder &holder, MemberFn member ) : holder_( holder ) , member_( member ) { } %(return_type)s operator()( %(fn_parameters)s ) const { Object &object = *holder_; %(return_keyword)s(object.*member_)( %(fn_call)s ); } FunctorBase *clone() const { return new SelfType( *this ); } private: Holder holder_; MemberFn member_; }; """ # member_functor_template_decl : template<class HolderType, class ObjectType, class ReturnType, class Arg1Type> # member_functor : MemberFunctor1R # member_functor_instantiation : MemberFunctor1R<HolderType,ObjectType,ReturnType,Arg1Type> functor = \ """%(functor_template_decl)s class %(functor)s : public FunctorCommon { public: typedef %(functor_instantiation)s SelfType; typedef Impl::%(impl_base_instantiation)s FunctorImplType; typedef %(return_type)s result_type; %(argument_types_typedef)s %(functor)s() { } explicit %(functor)s( FunctorImplType *impl ) : FunctorCommon( impl ) { } %(functor)s( const SelfType &other ) : FunctorCommon( other ) { } SelfType &operator=( const SelfType &other ) { SelfType temp( other ); swap( temp ); return *this; } result_type operator()( %(fn_parameters)s ) const { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); return impl( %(fn_call)s ); } void swap( SelfType &other ) { FunctorCommon::swap( other ); } }; """ # functor_template_decl : template<class ReturnType, class Arg1Type> # functor : Functor1R # functor_instantiation : Functor1R<ReturnType,Arg1Type> # argument_types_typedef : # typedef Arg1Type first_argument_type; # typedef Arg1Type arg1_type; generator = \ """// %(functor)s %(functor_template_decl)s inline %(functor_instantiation)s %(cfn)s( %(return_type)s (*function)( %(fn_parameters)s ) ) { typedef %(return_type)s (*Functor)(%(fn_types)s); return %(functor_instantiation)s( new Impl::%(generic_functor_instantiation)s( function ) ); } %(member_functor_template_decl)s inline %(functor_instantiation)s %(memfn)s( const Holder &holder, %(return_type)s (Object::*member)( %(fn_parameters)s ) ) { return %(functor_instantiation)s( new Impl::%(member_functor_instantiation)s( holder, member ) ); } template<class Functor> inline %(functor)s%(functor_deduced_types)s %(fn)s( Functor functor ) { %(functor_deduced_type_alias)s return %(functor_instantiation)s( new Impl::%(generic_functor_instantiation)s( functor ) ); } """ # cfn : cfn1r # fn_types : Arg1 # memfn : memfn1r # fn : fnr1 # functor_deduced_types : # CPPTL_TYPENAME Functor::result_type # ,CPPTL_TYPENAME Functor::first_argument_type # functor_deduced_type_alias : # typedef CPPTL_TYPENAME Functor::result_type Return; # typedef CPPTL_TYPENAME Functor::first_argument_type Arg1; class GenerationParameters(object): def __init__( self, count, is_void ): self.count = count self.is_void = is_void self.return_type = (is_void and 'void') or 'Return' self.fn_parameters = ', '.join( [ 'Arg%d a%d' % (n,n) for n in xrange(1,count+1) ] ) self.fn_call = ', '.join( [ 'a%d' % n for n in xrange(1,count+1) ] ) base_template_parameters = [] return_suffix = (not is_void and 'R') or '' self.impl_base = 'FunctorBase%d%s' % (count,return_suffix) self.return_keyword = (not is_void and 'return ') or '' if not is_void: base_template_parameters.append( 'Return' ) base_template_parameters.extend( [ 'Arg%d' % n for n in xrange(1,count+1) ] ) self.base_template_decl = self.makeTemplateDecl( base_template_parameters ) self.impl_base_instantiation = self.impl_base + self.makeTemplateInstantiation( base_template_parameters ) generic_functor_template_parameters = ['Functor'] + base_template_parameters self.generic_functor_template_decl = self.makeTemplateDecl( generic_functor_template_parameters ) self.generic_functor = 'GenericFunctor%d%s' % (count,return_suffix) self.generic_functor_instantiation = self.generic_functor + \ self.makeTemplateInstantiation(generic_functor_template_parameters ) self.member_functor = 'MemberFunctor%d%s' % (count,return_suffix) member_functor_template_parameters = ['Holder','Object'] + base_template_parameters self.member_functor_template_decl = self.makeTemplateDecl( member_functor_template_parameters ) self.member_functor_instantiation = self.member_functor + \ self.makeTemplateInstantiation(member_functor_template_parameters ) self.functor = 'Functor%d%s' % (count,return_suffix) self.functor_template_decl = self.makeTemplateDecl( base_template_parameters ) self.functor_instantiation = self.functor + self.makeTemplateInstantiation( base_template_parameters ) self.argument_types_typedef = '' for n in xrange(1,count+1): self.argument_types_typedef += self.makeArgumentTypedef( n ) self.cfn = 'cfn%d%s' % (count,return_suffix.lower()) self.memfn = 'memfn%d%s' % (count,return_suffix.lower()) self.fn = 'fn%d%s' % (count,return_suffix.lower()) self.fn_types = ','.join( [ 'Arg%d' % n for n in xrange(1,count+1) ] ) functor_deduced_types = [] if not is_void: functor_deduced_types.append( 'CPPTL_TYPENAME Functor::result_type' ) for n in xrange(1,count+1): functor_deduced_types.append( 'CPPTL_TYPENAME Functor::%s' % self.getFunctorArgTypeName(n) ) if len(functor_deduced_types): self.functor_deduced_types = '< ' + '\n ,'.join( functor_deduced_types ) + ' >' else: self.functor_deduced_types = '' functor_deduced_type_alias = [] if not is_void: functor_deduced_type_alias.append(' typedef CPPTL_TYPENAME Functor::result_type Return;') for n in xrange(1,count+1): functor_deduced_type_alias.append( ' typedef CPPTL_TYPENAME Functor::%s Arg%d;' % (self.getFunctorArgTypeName(n),n) ) self.functor_deduced_type_alias = '\n'.join( functor_deduced_type_alias ) def __getitem__( self, key ): return getattr( self, key ) def makeTemplateDecl( self, parameters ): if not parameters: return '' return 'template< class ' + ', class '.join( parameters ) + ' >' def makeTemplateInstantiation( self, parameters ): if not parameters: return '' return '< ' + ', '.join( parameters ) + ' >' def getFunctorArgTypeName( self, n ): names = [ 'arg%d_type' % n ] if n == 1: names.append( 'first_argument_type' ) elif n == 2: names.append( 'second_argument_type' ) return names[-1] def makeArgumentTypedef( self, n ): names = [ 'arg%d_type' % n ] if n == 1: names.append( 'first_argument_type' ) elif n == 2: names.append( 'second_argument_type' ) return '\n'.join( [ ' typedef Arg%d %s;' % (n, name) for name in names ] ) + '\n' functors_impl = '' functors = '' functor_generators = '' for argument_count in xrange(0,2): for is_void in (True,False): parameters = GenerationParameters( argument_count, is_void ) functors_impl += functor_base % parameters functors_impl += generic_functor % parameters functors_impl += member_functor % parameters functors += functor % parameters functor_generators += generator % parameters final_header = header % locals() out = file( 'functor.h', 'wt') out.write( final_header ) out.close() |
From: Baptiste L. <bl...@us...> - 2005-02-24 07:15:13
|
Update of /cvsroot/cppunit/cppunit2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23479 Modified Files: sconstruct Log Message: * use a single sconsign database Index: sconstruct =================================================================== RCS file: /cvsroot/cppunit/cppunit2/sconstruct,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sconstruct 23 Feb 2005 23:13:16 -0000 1.2 --- sconstruct 24 Feb 2005 07:15:03 -0000 1.3 *************** *** 1,3 **** ! import sys #env = Environment( CCFLAGS = '-GX -GR -nologo', --- 1,12 ---- ! import os ! import os.path ! ! # Ensure build directory exist (SConsignFile fail otherwise!) ! if not os.path.exists( Dir('#buildscons').abspath ): ! os.mkdir( Dir('#buildscons').abspath ) ! ! # Store all dependencies signature in a database ! SConsignFile( 'buildscons/.sconsign.dbm' ) ! #env = Environment( CCFLAGS = '-GX -GR -nologo', |
From: Baptiste L. <bl...@us...> - 2005-02-24 07:11:25
|
Update of /cvsroot/cppunit/cppunit2/src/cpputtest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22832/src/cpputtest Modified Files: .cvsignore Log Message: * ignore dummy files Index: .cvsignore =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .cvsignore 27 Jan 2004 23:37:22 -0000 1.1 --- .cvsignore 24 Feb 2005 07:11:11 -0000 1.2 *************** *** 1,2 **** --- 1,5 ---- *.plg *.old + *.WW + *.old + |