cppunit-cvs Mailing List for CppUnit - C++ port of JUnit (Page 26)
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-03-04 22:18:03
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3060/include/cpptl Modified Files: functor.h functor.py Log Message: * fixed bad return statement in void Functor. Index: functor.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/functor.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** functor.h 28 Feb 2005 20:33:34 -0000 1.4 --- functor.h 4 Mar 2005 22:17:54 -0000 1.5 *************** *** 1250,1254 **** { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); ! return impl( ); } --- 1250,1254 ---- { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); ! impl( ); } *************** *** 1338,1342 **** { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); ! return impl( a1 ); } --- 1338,1342 ---- { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); ! impl( a1 ); } *************** *** 1430,1434 **** { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); ! return impl( a1, a2 ); } --- 1430,1434 ---- { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); ! impl( a1, a2 ); } *************** *** 1525,1529 **** { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); ! return impl( a1, a2, a3 ); } --- 1525,1529 ---- { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); ! impl( a1, a2, a3 ); } *************** *** 1622,1626 **** { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); ! return impl( a1, a2, a3, a4 ); } --- 1622,1626 ---- { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); ! impl( a1, a2, a3, a4 ); } *************** *** 1721,1725 **** { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); ! return impl( a1, a2, a3, a4, a5 ); } --- 1721,1725 ---- { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); ! impl( a1, a2, a3, a4, a5 ); } Index: functor.py =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/functor.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** functor.py 28 Feb 2005 20:33:47 -0000 1.4 --- functor.py 4 Mar 2005 22:17:54 -0000 1.5 *************** *** 281,285 **** { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); ! return impl( %(fn_call)s ); } --- 281,285 ---- { FunctorImplType &impl = *( static_cast<FunctorImplType *>(impl_) ); ! %(return_keyword)simpl( %(fn_call)s ); } |
From: Baptiste L. <bl...@us...> - 2005-03-04 22:17:07
|
Update of /cvsroot/cppunit/cppunit2/src/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2781/src/cpput Modified Files: properties.cpp Log Message: * added CPPTL_NO_INT64_TO_DOUBLE if compiler does not support conversion from int64 to double (vc6) Index: properties.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpput/properties.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** properties.cpp 27 Feb 2005 10:17:05 -0000 1.7 --- properties.cpp 4 Mar 2005 22:16:59 -0000 1.8 *************** *** 260,267 **** --- 260,270 ---- case vtBoolean: return guts_.boolValue_ ? 1.0 : 0.0; + // @todo implement "hand-made" conversion of int64 to double + #ifndef CPPTL_NO_INT64_TO_DOUBLE case vtSignedInteger: return (long double)(guts_.intValue_); case vtUnsignedInteger: return (long double)(guts_.uintValue_); + #endif case vtReal: return guts_.realValue_; |
From: Baptiste L. <bl...@us...> - 2005-03-04 22:17:07
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2781/include/cpptl Modified Files: config.h Log Message: * added CPPTL_NO_INT64_TO_DOUBLE if compiler does not support conversion from int64 to double (vc6) Index: config.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/config.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** config.h 3 Mar 2005 20:57:13 -0000 1.10 --- config.h 4 Mar 2005 22:16:57 -0000 1.11 *************** *** 19,22 **** --- 19,23 ---- # define CPPTL_NO_TEMPLATE_PARTIAL_SPECIALIZATION # define CPPTL_HAS_INT64 1 + # define CPPTL_NO_INT64_TO_DOUBLE // no conversion from int64 to double # endif |
From: Baptiste L. <bl...@us...> - 2005-03-04 08:24:09
|
Update of /cvsroot/cppunit/cppunit2/src/opentest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20052/src/opentest Modified Files: SConscript Log Message: * added buildLibrary() and buildLibraryUnitTest() exported functions to sconstruct * refactored sconscript to use the exported functions * build productions are now placed in a platform specific subdirectory (bin/mingw/...) Index: SConscript =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/opentest/SConscript,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SConscript 28 Feb 2005 22:11:57 -0000 1.1 --- SConscript 4 Mar 2005 08:23:39 -0000 1.2 *************** *** 1,19 **** ! Import( 'env' ) ! ! env = env.Copy( LIBPATH = '#libs' ) ! opentest_sources=""" texttestdriver.cpp ! """.split() ! ! static_lib = env.StaticLibrary( target='opentest', ! source=opentest_sources ) ! ! ! #shared_lib = env.SharedLibrary( target='cpput', ! # source=cpput_sources ) ! ! libs_dir='#libs' ! bin_dir='#bin' ! ! env.Install( libs_dir, static_lib ) --- 1,6 ---- ! Import( 'env buildLibary' ) ! buildLibary( env, """ texttestdriver.cpp ! """.split(), ! 'opentest' ) |
From: Baptiste L. <bl...@us...> - 2005-03-04 08:24:06
|
Update of /cvsroot/cppunit/cppunit2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20052 Modified Files: sconstruct Log Message: * added buildLibrary() and buildLibraryUnitTest() exported functions to sconstruct * refactored sconscript to use the exported functions * build productions are now placed in a platform specific subdirectory (bin/mingw/...) Index: sconstruct =================================================================== RCS file: /cvsroot/cppunit/cppunit2/sconstruct,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** sconstruct 1 Mar 2005 22:16:30 -0000 1.6 --- sconstruct 4 Mar 2005 08:23:39 -0000 1.7 *************** *** 2,55 **** 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 - 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'] ) env_testing = env.Copy( LIBS = ['cpput','opentest'] ) ! ! def buildCppUnitExample( env, taget_sources, target_name ): exe = env.Program( target=target_name, ! source=taget_sources ) ! bin_dir='#bin' env.Install( bin_dir, exe ) ! Export( 'env env_testing buildCppUnitExample' ) ! SConscript( 'src/cpput/SConscript', build_dir='#buildscons/cpput', duplicate=0 ) ! SConscript( 'src/opentest/SConscript', build_dir='#buildscons/opentest', duplicate=0 ) ! SConscript( 'src/cpputtest/SConscript', build_dir='#buildscons/cpputtest', duplicate=0 ) ! SConscript( 'examples/input_based_test/SConscript', build_dir='#buildscons/examples/input_based_test', duplicate=0 ) ! SConscript( 'examples/parametrized_test/SConscript', build_dir='#buildscons/examples/parametrized_test', duplicate=0 ) ! SConscript( 'examples/checking_assertions/SConscript', build_dir='#buildscons/examples/checking_assertions', duplicate=0 ) ! \ No newline at end of file --- 2,68 ---- import os.path + platform = 'mingw' + + build_dir = os.path.join( '#buildscons', platform ) + bin_dir = os.path.join( '#bin', platform ) + lib_dir = os.path.join( '#libs', platform ) + sconsign_dir_path = Dir(build_dir).abspath + sconsign_path = os.path.join( sconsign_dir_path, '.sconsign.dbm' ) + # Ensure build directory exist (SConsignFile fail otherwise!) ! if not os.path.exists( sconsign_dir_path ): ! os.makedirs( sconsign_dir_path ) # Store all dependencies signature in a database SConsignFile( sconsign_path ) ! if platform == 'suncc': env = Environment( ENV = {'PATH' : os.environ['PATH']}, CPPPATH = '#include', LIBPATH = '#libs', tools=['default','suncc'] ) ! elif platform == 'vacpp': env = Environment( ENV = {'PATH' : os.environ['PATH']}, CCFLAGS = '-qrtti=all', tools=['default','aixcc'], CXX ='xlC_r', LINKFLAGS='-bh:5' ) # -bh:5 remove duplicate symbol warning elif platform == 'msvc': ! env = Environment( CCFLAGS = '-GX -GR -nologo' ) elif platform == 'mingw': ! env = Environment( tools=['default','mingw'] ) + env.Append( CPPPATH = '#include', + LIBPATH = lib_dir ) + env_testing = env.Copy( LIBS = ['cpput','opentest'] ) ! def buildCppUnitExample( env, target_sources, target_name ): exe = env.Program( target=target_name, ! source=target_sources ) ! global bin_dir env.Install( bin_dir, exe ) ! def buildLibary( env, target_sources, target_name ): ! static_lib = env.StaticLibrary( target=target_name, ! source=target_sources ) ! global lib_dir ! env.Install( lib_dir, static_lib ) ! def buildLibraryUnitTest( env, target_sources, target_name ): ! buildCppUnitExample( env, target_sources, target_name ) + Export( 'env env_testing buildCppUnitExample buildLibary buildLibraryUnitTest' ) ! def buildProjectInDirectory( target_directory ): ! global build_dir ! target_build_dir = os.path.join( build_dir, target_directory ) ! target = os.path.join( target_directory, 'SConscript' ) ! SConscript( target, build_dir=target_build_dir, duplicate=0 ) ! ! buildProjectInDirectory( 'src/cpput' ) ! buildProjectInDirectory( 'src/opentest' ) ! buildProjectInDirectory( 'src/cpputtest' ) ! buildProjectInDirectory( 'examples/input_based_test' ) ! buildProjectInDirectory( 'examples/parametrized_test' ) ! buildProjectInDirectory( 'examples/checking_assertions' ) |
From: Baptiste L. <bl...@us...> - 2005-03-04 08:24:06
|
Update of /cvsroot/cppunit/cppunit2/src/cpputtest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20052/src/cpputtest Modified Files: SConscript Log Message: * added buildLibrary() and buildLibraryUnitTest() exported functions to sconstruct * refactored sconscript to use the exported functions * build productions are now placed in a platform specific subdirectory (bin/mingw/...) Index: SConscript =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/SConscript,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SConscript 3 Mar 2005 08:15:54 -0000 1.9 --- SConscript 4 Mar 2005 08:23:39 -0000 1.10 *************** *** 1,7 **** ! # cpputtest build script ! ! Import( 'env_testing' ) ! cpputtest_sources=""" assertenumtest.cpp assertstringtest.cpp --- 1,5 ---- ! Import( 'env_testing buildLibraryUnitTest' ) ! buildLibraryUnitTest( env_testing, """ assertenumtest.cpp assertstringtest.cpp *************** *** 16,32 **** testtestsuite.cpp reflectiontest.cpp ! """.split() ! ! #cpputtest_env = env.Copy(LIBS = ['cpput-vc6-rd']) ! #cpputtest_env.Append( CCFLAGS = ' -DCPPUT_DLL' ) ! ! cpputtest_exe = env_testing.Program( target='cpputtest', ! source=cpputtest_sources ) ! ! #cpputtest_env.Depends( cpputtest_exe, '#libs/cpput-vc6-rd.lib' ) ! ! ! # should not be ! bin_dir='#bin' ! ! env_testing.Install( bin_dir, cpputtest_exe ) --- 14,17 ---- testtestsuite.cpp reflectiontest.cpp ! """.split(), ! 'cpputtest' ) |
From: Baptiste L. <bl...@us...> - 2005-03-04 08:23:53
|
Update of /cvsroot/cppunit/cppunit2/src/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20052/src/cpput Modified Files: SConscript Log Message: * added buildLibrary() and buildLibraryUnitTest() exported functions to sconstruct * refactored sconscript to use the exported functions * build productions are now placed in a platform specific subdirectory (bin/mingw/...) Index: SConscript =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpput/SConscript,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SConscript 23 Feb 2005 23:10:58 -0000 1.3 --- SConscript 4 Mar 2005 08:23:39 -0000 1.4 *************** *** 1,7 **** ! Import( 'env' ) ! ! env = env.Copy( LIBPATH = '#libs' ) ! cpput_sources=""" assert.cpp assertstring.cpp --- 1,5 ---- ! Import( 'env buildLibary' ) ! buildLibary( env, """ assert.cpp assertstring.cpp *************** *** 14,28 **** testsuite.cpp thread.cpp ! """.split() ! ! static_lib = env.StaticLibrary( target='cpput', ! source=cpput_sources ) ! ! ! #shared_lib = env.SharedLibrary( target='cpput', ! # source=cpput_sources ) ! ! libs_dir='#libs' ! bin_dir='#bin' ! ! env.Install( libs_dir, static_lib ) --- 12,15 ---- testsuite.cpp thread.cpp ! """.split(), ! 'cpput' ) |
From: Baptiste L. <bl...@us...> - 2005-03-04 07:31:00
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8198/include/cpptl Modified Files: reflection.h Added Files: reflectionimpl.py reflectionimpl10.h Log Message: * extracted invokable subclass in a specific generated header. --- NEW FILE: reflectionimpl.py --- # script to generate cpptl/reflectionimpl10.h MIN_ARGUMENT_COUNT = 0 MAX_ARGUMENT_COUNT = 10 header =\ """// This script is generated by the python script reflectionimpl.py // Do not edit. #ifndef CPPTL_REFLECTIONIMPL%(MAX_ARGUMENT_COUNT)d_H_INCLUDED # define CPPTL_REFLECTIONIMPL%(MAX_ARGUMENT_COUNT)d_H_INCLUDED namespace CppTL { namespace Impl { %(invokables)s %(invokable_generators)s } // namespace Impl } // namespace CppTL #endif // CPPTL_REFLECTIONIMPL%(MAX_ARGUMENT_COUNT)d_H_INCLUDED """ invokable =\ """ %(invokable_template_decl)s class %(invokable)s : public InvokableBase { public: typedef void (Object::*Member)( %(fn_parameter_types)s ); %(invokable)s( Member member ) : member_( member ) { } void invoke( MethodCall &call ) const { Object &object = *any_cast( call.holder_, Type<Object *>() ); (object.*member_)( %(fn_call)s ); } private: Member member_; }; """ # invokable_template_decl : # template<class Object # ,class Arg1 # ,class Arg2> # invokable : Invokable2 # fn_parameter_types : Arg1, Arg2 # fn_call : # any_cast( call.args_.at(0), Type<Arg1>() ), # any_cast( call.args_.at(1), Type<Arg2>() ) invokable_generator = \ """ %(invokable_template_decl)s Invokable makeInvokable( void (Object::*member)( %(fn_parameter_types)s ) ) { Invokable invokable( InvokableBasePtr( new %(invokable_instantiation)s( member ) ) ); %(push_back_parameter_types)s return invokable; } """ # invokable_instantiation : Invokable2<Object,Arg1,Arg2> # push_back_parameter_types : # invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); # invokable.argTypes_.push_back( typeId( Type<Arg2>() ) ); class GenerationParameters(object): def __init__( self, count ): self.count = count invokable_template_parameters = ['Object'] + [ 'Arg%d' % n for n in xrange(1,count+1) ] self.invokable_template_decl = self.makeTemplateDecl( invokable_template_parameters ) self.invokable = 'Invokable%d' % count self.fn_parameter_types = ', '.join( [ 'Arg%d' % n for n in xrange(1,count+1) ] ) self.fn_call = '\n ,'.join( [ 'any_cast( call.args_.at(%d), Type<Arg%d>() )' % (n,n+1) for n in xrange(0,count) ] ) self.invokable_instantiation = self.invokable + self.makeTemplateInstantiation( invokable_template_parameters ) self.push_back_parameter_types = '\n'.join( [ ' invokable.argTypes_.push_back( typeId( Type<Arg%d>() ) );' % (n+1) for n in xrange(0,count) ] ) 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 ) + ' >' invokables = '' invokable_generators = '' for argument_count in xrange(MIN_ARGUMENT_COUNT,MAX_ARGUMENT_COUNT+1): parameters = GenerationParameters( argument_count ) invokables += invokable % parameters invokable_generators += invokable_generator % parameters final_header = header % locals() out = file( 'reflectionimpl%d.h' % MAX_ARGUMENT_COUNT, 'wt') out.write( final_header ) out.close() --- NEW FILE: reflectionimpl10.h --- // This script is generated by the python script reflectionimpl.py // Do not edit. #ifndef CPPTL_REFLECTIONIMPL10_H_INCLUDED # define CPPTL_REFLECTIONIMPL10_H_INCLUDED namespace CppTL { namespace Impl { template< class Object > class Invokable0 : public InvokableBase { public: typedef void (Object::*Member)( ); Invokable0( Member member ) : member_( member ) { } void invoke( MethodCall &call ) const { Object &object = *any_cast( call.holder_, Type<Object *>() ); (object.*member_)( ); } private: Member member_; }; template< class Object, class Arg1 > class Invokable1 : public InvokableBase { public: typedef void (Object::*Member)( Arg1 ); Invokable1( Member member ) : member_( member ) { } void invoke( MethodCall &call ) const { Object &object = *any_cast( call.holder_, Type<Object *>() ); (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ) ); } private: Member member_; }; template< class Object, class Arg1, class Arg2 > class Invokable2 : public InvokableBase { public: typedef void (Object::*Member)( Arg1, Arg2 ); Invokable2( Member member ) : member_( member ) { } void invoke( MethodCall &call ) const { Object &object = *any_cast( call.holder_, Type<Object *>() ); (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ) ,any_cast( call.args_.at(1), Type<Arg2>() ) ); } private: Member member_; }; template< class Object, class Arg1, class Arg2, class Arg3 > class Invokable3 : public InvokableBase { public: typedef void (Object::*Member)( Arg1, Arg2, Arg3 ); Invokable3( Member member ) : member_( member ) { } void invoke( MethodCall &call ) const { Object &object = *any_cast( call.holder_, Type<Object *>() ); (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ) ,any_cast( call.args_.at(1), Type<Arg2>() ) ,any_cast( call.args_.at(2), Type<Arg3>() ) ); } private: Member member_; }; template< class Object, class Arg1, class Arg2, class Arg3, class Arg4 > class Invokable4 : public InvokableBase { public: typedef void (Object::*Member)( Arg1, Arg2, Arg3, Arg4 ); Invokable4( Member member ) : member_( member ) { } void invoke( MethodCall &call ) const { Object &object = *any_cast( call.holder_, Type<Object *>() ); (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ) ,any_cast( call.args_.at(1), Type<Arg2>() ) ,any_cast( call.args_.at(2), Type<Arg3>() ) ,any_cast( call.args_.at(3), Type<Arg4>() ) ); } private: Member member_; }; template< class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5 > class Invokable5 : public InvokableBase { public: typedef void (Object::*Member)( Arg1, Arg2, Arg3, Arg4, Arg5 ); Invokable5( Member member ) : member_( member ) { } void invoke( MethodCall &call ) const { Object &object = *any_cast( call.holder_, Type<Object *>() ); (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ) ,any_cast( call.args_.at(1), Type<Arg2>() ) ,any_cast( call.args_.at(2), Type<Arg3>() ) ,any_cast( call.args_.at(3), Type<Arg4>() ) ,any_cast( call.args_.at(4), Type<Arg5>() ) ); } private: Member member_; }; template< class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6 > class Invokable6 : public InvokableBase { public: typedef void (Object::*Member)( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6 ); Invokable6( Member member ) : member_( member ) { } void invoke( MethodCall &call ) const { Object &object = *any_cast( call.holder_, Type<Object *>() ); (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ) ,any_cast( call.args_.at(1), Type<Arg2>() ) ,any_cast( call.args_.at(2), Type<Arg3>() ) ,any_cast( call.args_.at(3), Type<Arg4>() ) ,any_cast( call.args_.at(4), Type<Arg5>() ) ,any_cast( call.args_.at(5), Type<Arg6>() ) ); } private: Member member_; }; template< class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7 > class Invokable7 : public InvokableBase { public: typedef void (Object::*Member)( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7 ); Invokable7( Member member ) : member_( member ) { } void invoke( MethodCall &call ) const { Object &object = *any_cast( call.holder_, Type<Object *>() ); (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ) ,any_cast( call.args_.at(1), Type<Arg2>() ) ,any_cast( call.args_.at(2), Type<Arg3>() ) ,any_cast( call.args_.at(3), Type<Arg4>() ) ,any_cast( call.args_.at(4), Type<Arg5>() ) ,any_cast( call.args_.at(5), Type<Arg6>() ) ,any_cast( call.args_.at(6), Type<Arg7>() ) ); } private: Member member_; }; template< class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8 > class Invokable8 : public InvokableBase { public: typedef void (Object::*Member)( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8 ); Invokable8( Member member ) : member_( member ) { } void invoke( MethodCall &call ) const { Object &object = *any_cast( call.holder_, Type<Object *>() ); (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ) ,any_cast( call.args_.at(1), Type<Arg2>() ) ,any_cast( call.args_.at(2), Type<Arg3>() ) ,any_cast( call.args_.at(3), Type<Arg4>() ) ,any_cast( call.args_.at(4), Type<Arg5>() ) ,any_cast( call.args_.at(5), Type<Arg6>() ) ,any_cast( call.args_.at(6), Type<Arg7>() ) ,any_cast( call.args_.at(7), Type<Arg8>() ) ); } private: Member member_; }; template< class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Arg9 > class Invokable9 : public InvokableBase { public: typedef void (Object::*Member)( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9 ); Invokable9( Member member ) : member_( member ) { } void invoke( MethodCall &call ) const { Object &object = *any_cast( call.holder_, Type<Object *>() ); (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ) ,any_cast( call.args_.at(1), Type<Arg2>() ) ,any_cast( call.args_.at(2), Type<Arg3>() ) ,any_cast( call.args_.at(3), Type<Arg4>() ) ,any_cast( call.args_.at(4), Type<Arg5>() ) ,any_cast( call.args_.at(5), Type<Arg6>() ) ,any_cast( call.args_.at(6), Type<Arg7>() ) ,any_cast( call.args_.at(7), Type<Arg8>() ) ,any_cast( call.args_.at(8), Type<Arg9>() ) ); } private: Member member_; }; template< class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Arg9, class Arg10 > class Invokable10 : public InvokableBase { public: typedef void (Object::*Member)( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10 ); Invokable10( Member member ) : member_( member ) { } void invoke( MethodCall &call ) const { Object &object = *any_cast( call.holder_, Type<Object *>() ); (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ) ,any_cast( call.args_.at(1), Type<Arg2>() ) ,any_cast( call.args_.at(2), Type<Arg3>() ) ,any_cast( call.args_.at(3), Type<Arg4>() ) ,any_cast( call.args_.at(4), Type<Arg5>() ) ,any_cast( call.args_.at(5), Type<Arg6>() ) ,any_cast( call.args_.at(6), Type<Arg7>() ) ,any_cast( call.args_.at(7), Type<Arg8>() ) ,any_cast( call.args_.at(8), Type<Arg9>() ) ,any_cast( call.args_.at(9), Type<Arg10>() ) ); } private: Member member_; }; template< class Object > Invokable makeInvokable( void (Object::*member)( ) ) { Invokable invokable( InvokableBasePtr( new Invokable0< Object >( member ) ) ); return invokable; } template< class Object, class Arg1 > Invokable makeInvokable( void (Object::*member)( Arg1 ) ) { Invokable invokable( InvokableBasePtr( new Invokable1< Object, Arg1 >( member ) ) ); invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); return invokable; } template< class Object, class Arg1, class Arg2 > Invokable makeInvokable( void (Object::*member)( Arg1, Arg2 ) ) { Invokable invokable( InvokableBasePtr( new Invokable2< Object, Arg1, Arg2 >( member ) ) ); invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg2>() ) ); return invokable; } template< class Object, class Arg1, class Arg2, class Arg3 > Invokable makeInvokable( void (Object::*member)( Arg1, Arg2, Arg3 ) ) { Invokable invokable( InvokableBasePtr( new Invokable3< Object, Arg1, Arg2, Arg3 >( member ) ) ); invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg2>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg3>() ) ); return invokable; } template< class Object, class Arg1, class Arg2, class Arg3, class Arg4 > Invokable makeInvokable( void (Object::*member)( Arg1, Arg2, Arg3, Arg4 ) ) { Invokable invokable( InvokableBasePtr( new Invokable4< Object, Arg1, Arg2, Arg3, Arg4 >( member ) ) ); invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg2>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg3>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg4>() ) ); return invokable; } template< class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5 > Invokable makeInvokable( void (Object::*member)( Arg1, Arg2, Arg3, Arg4, Arg5 ) ) { Invokable invokable( InvokableBasePtr( new Invokable5< Object, Arg1, Arg2, Arg3, Arg4, Arg5 >( member ) ) ); invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg2>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg3>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg4>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg5>() ) ); return invokable; } template< class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6 > Invokable makeInvokable( void (Object::*member)( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6 ) ) { Invokable invokable( InvokableBasePtr( new Invokable6< Object, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6 >( member ) ) ); invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg2>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg3>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg4>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg5>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg6>() ) ); return invokable; } template< class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7 > Invokable makeInvokable( void (Object::*member)( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7 ) ) { Invokable invokable( InvokableBasePtr( new Invokable7< Object, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7 >( member ) ) ); invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg2>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg3>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg4>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg5>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg6>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg7>() ) ); return invokable; } template< class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8 > Invokable makeInvokable( void (Object::*member)( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8 ) ) { Invokable invokable( InvokableBasePtr( new Invokable8< Object, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8 >( member ) ) ); invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg2>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg3>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg4>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg5>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg6>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg7>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg8>() ) ); return invokable; } template< class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Arg9 > Invokable makeInvokable( void (Object::*member)( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9 ) ) { Invokable invokable( InvokableBasePtr( new Invokable9< Object, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9 >( member ) ) ); invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg2>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg3>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg4>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg5>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg6>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg7>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg8>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg9>() ) ); return invokable; } template< class Object, class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Arg9, class Arg10 > Invokable makeInvokable( void (Object::*member)( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10 ) ) { Invokable invokable( InvokableBasePtr( new Invokable10< Object, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10 >( member ) ) ); invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg2>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg3>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg4>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg5>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg6>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg7>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg8>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg9>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg10>() ) ); return invokable; } } // namespace Impl } // namespace CppTL #endif // CPPTL_REFLECTIONIMPL10_H_INCLUDED Index: reflection.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/reflection.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** reflection.h 3 Mar 2005 20:57:14 -0000 1.3 --- reflection.h 4 Mar 2005 07:30:32 -0000 1.4 *************** *** 42,45 **** --- 42,46 ---- }; + class InvokableBase { *************** *** 53,126 **** - template<class Object> - class Invokable0 : public InvokableBase - { - public: - typedef void (Object::*Member)(); - - Invokable0( Member member ) - : member_( member ) - { - } - - void invoke( MethodCall &call ) const - { - Object &object = *any_cast( call.holder_, Type<Object *>() ); - (object.*member_)(); - } - - private: - Member member_; - }; - - - template<class Object - ,class Arg1> - class Invokable1 : public InvokableBase - { - public: - typedef void (Object::*Member)( Arg1 a1 ); - - Invokable1( Member member ) - : member_( member ) - { - } - - void invoke( MethodCall &call ) const - { - Object &object = *any_cast( call.holder_, Type<Object *>() ); - (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ) ); - } - - private: - Member member_; - }; - - - template<class Object - ,class Arg1 - ,class Arg2> - class Invokable2: public InvokableBase - { - public: - typedef void (Object::*Member)( Arg1 a1, Arg2 a2 ); - - Invokable2( Member member ) - : member_( member ) - { - } - - void invoke( MethodCall &call ) const - { - Object &object = *any_cast( call.holder_, Type<Object *>() ); - (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ), - any_cast( call.args_.at(1), Type<Arg2>() ) ); - } - - private: - Member member_; - }; - - class Invokable { --- 54,57 ---- *************** *** 140,169 **** - template<class Object> - Invokable makeInvokable( void (Object::*member)() ) - { - Invokable invokable( InvokableBasePtr( new Invokable0<Object>( member ) ) ); - return invokable; - } - - - template<class Object, class Arg1> - Invokable makeInvokable( void (Object::*member)( Arg1 a1 ) ) - { - Invokable invokable( InvokableBasePtr( new Invokable1<Object,Arg1>( member ) ) ); - invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); - return invokable; - } - - - template<class Object, class Arg1, class Arg2> - Invokable makeInvokable( void (Object::*member)( Arg1 a1, Arg2 a2 ) ) - { - Invokable invokable( InvokableBasePtr( new Invokable2<Object,Arg1,Arg2>( member ) ) ); - invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); - invokable.argTypes_.push_back( typeId( Type<Arg2>() ) ); - return invokable; - } - class AttributAccessor { --- 71,74 ---- *************** *** 181,184 **** --- 86,90 ---- }; + template<class Object, class AttributType> class AttributAccessorImpl : public AttributAccessor *************** *** 214,217 **** --- 120,124 ---- }; + template<class Object, class TheAttributType> AttributAccessorPtr makeAccessor( TheAttributType Object::*attribut ) *************** *** 324,327 **** --- 231,239 ---- + } // namespace CppTL + + + + # define CPPTL_REFLECT_CLASS_BEGIN( ClassType ) \ typedef ClassType _Reflection_SelfType; \ *************** *** 357,363 **** - } // namespace CppTL - # include <cpptl/reflection.inl> #endif // CPPTL_REFLECTION_H_INCLUDED --- 269,274 ---- # include <cpptl/reflection.inl> + # include <cpptl/reflectionimpl10.h> #endif // CPPTL_REFLECTION_H_INCLUDED |
From: Baptiste L. <bl...@us...> - 2005-03-03 20:57:42
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12359/include/cpput Modified Files: config.h registry.h Log Message: * renamed and moved macro CPPUT_MAKE_UNIQUE_NAME to cpptl library. Index: config.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/config.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** config.h 26 Feb 2005 13:44:38 -0000 1.9 --- config.h 3 Mar 2005 20:57:14 -0000 1.10 *************** *** 106,148 **** - - - // Macro tools... - /////////////////////////////////////////////////////////////////////////// - - - /*! Joins to symbol after expanding them into string. - * - * Use this macro to join two symbols. Example of usage: - * - * \code - * #define MAKE_UNIQUE_NAME(prefix) CPPUT_JOIN( prefix, __LINE__ ) - * \endcode - * - * The macro defined in the example concatenate a given prefix with the line number - * to obtain a 'unique' identifier. - * - * \internal From boost documentation: - * The following piece of macro magic joins the two - * arguments together, even when one of the arguments is - * itself a macro (see 16.3.1 in C++ standard). The key - * is that macro expansion of macro arguments does not - * occur in CPPUT_JOIN2 but does in CPPUT_JOIN. - */ - #define CPPUT_JOIN( symbol1, symbol2 ) _CPPUT_DO_JOIN( symbol1, symbol2 ) - - /// \internal - #define _CPPUT_DO_JOIN( symbol1, symbol2 ) _CPPUT_DO_JOIN2( symbol1, symbol2 ) - - /// \internal - #define _CPPUT_DO_JOIN2( symbol1, symbol2 ) symbol1##symbol2 - - /*! Adds the line number to the specified string to create a unique identifier. - * \param prefix Prefix added to the line number to create a unique identifier. - * \see CPPUT_TEST_SUITE_REGISTRATION for an example of usage. - */ - #define CPPUT_MAKE_UNIQUE_NAME( prefix ) CPPUT_JOIN( prefix, __LINE__ ) - - namespace CppUT { --- 106,109 ---- Index: registry.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/registry.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** registry.h 27 Feb 2005 14:38:26 -0000 1.3 --- registry.h 3 Mar 2005 20:57:14 -0000 1.4 *************** *** 118,132 **** #define CPPUT_REGISTER_NAMED_SUITE_TO_DEFAULT( TestFixtureType, suiteName ) \ static CppUT::SuiteRegisterer< TestFixtureType > \ ! CPPUT_MAKE_UNIQUE_NAME(cpputSuiteRegisterer )(suiteName) #define CPPUT_REGISTER_SUITE_TO_DEFAULT( TestFixtureType ) \ static CppUT::SuiteRegisterer< TestFixtureType > \ ! CPPUT_MAKE_UNIQUE_NAME(cpputSuiteRegisterer )(#TestFixtureType) #define CPPUT_REGISTER_SUITE_IN( TestFixtureType, parentSuiteName ) \ static CppUT::SuiteRegisterer< TestFixtureType > \ ! CPPUT_MAKE_UNIQUE_NAME(cpputSuiteRegisterer )(parentSuiteName,\ Impl::RegisterToNamedSuiteTag() ) --- 118,132 ---- #define CPPUT_REGISTER_NAMED_SUITE_TO_DEFAULT( TestFixtureType, suiteName ) \ static CppUT::SuiteRegisterer< TestFixtureType > \ ! CPPTL_MAKE_UNIQUE_NAME(cpputSuiteRegisterer )(suiteName) #define CPPUT_REGISTER_SUITE_TO_DEFAULT( TestFixtureType ) \ static CppUT::SuiteRegisterer< TestFixtureType > \ ! CPPTL_MAKE_UNIQUE_NAME(cpputSuiteRegisterer )(#TestFixtureType) #define CPPUT_REGISTER_SUITE_IN( TestFixtureType, parentSuiteName ) \ static CppUT::SuiteRegisterer< TestFixtureType > \ ! CPPTL_MAKE_UNIQUE_NAME(cpputSuiteRegisterer )(parentSuiteName,\ Impl::RegisterToNamedSuiteTag() ) *************** *** 136,140 **** suiteName ) \ static CppUT::SuiteRegisterer< TestFixtureType > \ ! CPPUT_MAKE_UNIQUE_NAME(cpputSuiteRegisterer )(parentSuiteName,\ suiteName, \ Impl::RegisterToNamedSuiteTag() ) --- 136,140 ---- suiteName ) \ static CppUT::SuiteRegisterer< TestFixtureType > \ ! CPPTL_MAKE_UNIQUE_NAME(cpputSuiteRegisterer )(parentSuiteName,\ suiteName, \ Impl::RegisterToNamedSuiteTag() ) *************** *** 164,168 **** #define CPPUT_REGISTER_SUITE_RELATIONSHIP( parentSuiteName, childSuiteName ) \ static CppUT::SuiteRelationshipRegisterer \ ! CPPUT_MAKE_UNIQUE_NAME(cpputSuiteRelationShipRegisterer )( \ parentSuiteName, \ childSuiteName ) --- 164,168 ---- #define CPPUT_REGISTER_SUITE_RELATIONSHIP( parentSuiteName, childSuiteName ) \ static CppUT::SuiteRelationshipRegisterer \ ! CPPTL_MAKE_UNIQUE_NAME(cpputSuiteRelationShipRegisterer )( \ parentSuiteName, \ childSuiteName ) |
From: Baptiste L. <bl...@us...> - 2005-03-03 20:57:27
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12359/include/cpptl Modified Files: config.h reflection.h Log Message: * renamed and moved macro CPPUT_MAKE_UNIQUE_NAME to cpptl library. Index: config.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/config.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** config.h 28 Feb 2005 21:36:19 -0000 1.9 --- config.h 3 Mar 2005 20:57:13 -0000 1.10 *************** *** 105,108 **** --- 105,147 ---- # define CPPTL_API + + + + // Macro tools... + /////////////////////////////////////////////////////////////////////////// + + + /*! Joins to symbol after expanding them into string. + * + * Use this macro to join two symbols. Example of usage: + * + * \code + * #define MAKE_UNIQUE_NAME(prefix) CPPTL_JOIN( prefix, __LINE__ ) + * \endcode + * + * The macro defined in the example concatenate a given prefix with the line number + * to obtain a 'unique' identifier. + * + * \internal From boost documentation: + * The following piece of macro magic joins the two + * arguments together, even when one of the arguments is + * itself a macro (see 16.3.1 in C++ standard). The key + * is that macro expansion of macro arguments does not + * occur in CPPUT_JOIN2 but does in CPPTL_JOIN. + */ + #define CPPTL_JOIN( symbol1, symbol2 ) _CPPTL_DO_JOIN( symbol1, symbol2 ) + + /// \internal + #define _CPPTL_DO_JOIN( symbol1, symbol2 ) _CPPTL_DO_JOIN2( symbol1, symbol2 ) + + /// \internal + #define _CPPTL_DO_JOIN2( symbol1, symbol2 ) symbol1##symbol2 + + /*! Adds the line number to the specified string to create a unique identifier. + * \param prefix Prefix added to the line number to create a unique identifier. + * \see CPPUT_TEST_SUITE_REGISTRATION for an example of usage. + */ + #define CPPTL_MAKE_UNIQUE_NAME( prefix ) CPPTL_JOIN( prefix, __LINE__ ) + /////////////////////////////////////////////////////////////////////////// Index: reflection.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/reflection.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** reflection.h 3 Mar 2005 20:48:54 -0000 1.2 --- reflection.h 3 Mar 2005 20:57:14 -0000 1.3 *************** *** 354,358 **** # define CPPTL_REFLECT_REGISTER_CLASS( ClassType ) \ static ::CppTL::AutoRegisterClassReflection<ClassType> \ ! CPPUT_MAKE_UNIQUE_NAME(cpptlReflectRegisterClass); --- 354,358 ---- # define CPPTL_REFLECT_REGISTER_CLASS( ClassType ) \ static ::CppTL::AutoRegisterClassReflection<ClassType> \ ! CPPTL_MAKE_UNIQUE_NAME(cpptlReflectRegisterClass); |
From: Baptiste L. <bl...@us...> - 2005-03-03 20:49:08
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9744/include/cpptl Modified Files: forwards.h reflection.h reflection.inl Log Message: * moved reflection implementation details in Impl namespace * added reflection support for attribut Index: reflection.inl =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/reflection.inl,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** reflection.inl 3 Mar 2005 08:14:23 -0000 1.1 --- reflection.inl 3 Mar 2005 20:48:54 -0000 1.2 *************** *** 2,6 **** # define CPPTL_REFLECTION_INL_INCLUDED ! namespace CppTL { namespace Reflect { // ////////////////////////////////////////////////////////////////// --- 2,6 ---- # define CPPTL_REFLECTION_INL_INCLUDED ! namespace CppTL { // ////////////////////////////////////////////////////////////////// *************** *** 66,70 **** void Class::addMethod( const ConstString &name, ! const Invokable &invokable ) { MethodPtr method( new Method( name, invokable ) ); --- 66,70 ---- void Class::addMethod( const ConstString &name, ! const Impl::Invokable &invokable ) { MethodPtr method( new Method( name, invokable ) ); *************** *** 72,75 **** --- 72,95 ---- } + inline + const Attribut * + Class::findAttribut( const ConstString &name ) const + { + AttributsByName::const_iterator it = attributsByName_.find( name ); + if ( it == attributsByName_.end() ) + return 0; + return it->second.get(); + } + + + inline + void + Class::addAttribut( const ConstString &name, + const Impl::AttributAccessorPtr &accessor ) + { + AttributPtr attribut( new Attribut( name, accessor ) ); + attributsByName_[name] = attribut; + } + // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// *************** *** 80,84 **** inline Method::Method( const ConstString &name, ! const Invokable &invokable ) : name_( name ) , invokable_( invokable ) --- 100,104 ---- inline Method::Method( const ConstString &name, ! const Impl::Invokable &invokable ) : name_( name ) , invokable_( invokable ) *************** *** 88,98 **** inline ! void Method::invoke( const Any &object, ! const ArgValues &args, ! Any &result ) const { ! MethodCall call( *this, object, args, result ); invokable_.invoke( call ); } --- 108,119 ---- inline ! Any Method::invoke( const Any &object, ! const MethodParameters &args ) const { ! Any result; ! Impl::MethodCall call( *this, object, args, result ); invokable_.invoke( call ); + return result; } *************** *** 137,161 **** } // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// ! // Class Invokable // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// inline ! Invokable::Invokable( const InvokableBasePtr &invokable ) ! : invokable_( invokable ) ! , returnType_( typeId( Type<void>() ) ) { } inline void ! Invokable::invoke( MethodCall &call ) const { ! invokable_->invoke( call ); } ! } } // namespace CppTL { namespace Reflect { --- 158,234 ---- } + // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// ! // Class Attribut // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// inline ! Attribut::Attribut( const ConstString &name, ! const Impl::AttributAccessorPtr &accessor ) ! : name_( name ) ! , accessor_( accessor ) { } + + inline + ConstString + Attribut::getName() const + { + return name_; + } + + + inline + TypeId + Attribut::getType() const + { + return accessor_->getType(); + } + + inline void ! Attribut::set( const Any &object, ! const Any &value ) const { ! return accessor_->set( object, value ); } ! ! inline ! Any ! Attribut::get( const Any &object ) const ! { ! return accessor_->get( object ); ! } ! ! ! // ////////////////////////////////////////////////////////////////// ! // ////////////////////////////////////////////////////////////////// ! // Class Invokable ! // ////////////////////////////////////////////////////////////////// ! // ////////////////////////////////////////////////////////////////// ! ! namespace Impl { ! ! inline ! Invokable::Invokable( const InvokableBasePtr &invokable ) ! : invokable_( invokable ) ! , returnType_( typeId( Type<void>() ) ) ! { ! } ! ! inline ! void ! Invokable::invoke( MethodCall &call ) const ! { ! invokable_->invoke( call ); ! } ! ! } // namespace Impl ! } // namespace CppTL Index: reflection.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/reflection.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** reflection.h 3 Mar 2005 08:14:23 -0000 1.1 --- reflection.h 3 Mar 2005 20:48:54 -0000 1.2 *************** *** 11,169 **** ! namespace CppTL { namespace Reflect { ! // Forwards ! class Class; ! class Invokable; ! class InvokableBase; ! class Method; ! struct MethodCall; ! typedef SharedPtr<InvokableBase> InvokableBasePtr; ! typedef std::vector<Any> ArgValues; ! struct MethodCall ! { ! MethodCall( const Method &method, ! const Any &holder, ! const ArgValues &args, ! Any &result ) ! : method_( method ) ! , holder_( holder ) ! , args_( args ) ! , result_( result ) { ! } ! const Method &method_; ! const Any &holder_; ! const ArgValues &args_; ! Any &result_; ! }; ! class Invokable ! { ! public: ! Invokable( const InvokableBasePtr &invokable ); ! virtual ~Invokable() { ! } ! void invoke( MethodCall &call ) const; ! TypeId returnType_; ! std::vector<TypeId> argTypes_; ! InvokableBasePtr invokable_; ! }; ! class InvokableBase ! { ! public: ! virtual ~InvokableBase() { ! } ! virtual void invoke( MethodCall &call ) const = 0; ! }; ! template<class Object> ! class Invokable0 : public InvokableBase ! { ! public: ! typedef void (Object::*Member)(); ! Invokable0( Member member ) ! : member_( member ) { ! } ! void invoke( MethodCall &call ) const { ! Object &object = *any_cast( call.holder_, Type<Object *>() ); ! (object.*member_)(); ! } ! private: ! Member member_; ! }; ! template<class Object ! ,class Arg1> ! class Invokable1 : public InvokableBase ! { ! public: ! typedef void (Object::*Member)( Arg1 a1 ); ! Invokable1( Member member ) ! : member_( member ) { } ! void invoke( MethodCall &call ) const { ! Object &object = *any_cast( call.holder_, Type<Object *>() ); ! (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ) ); } - private: - Member member_; - }; ! template<class Object ! ,class Arg1 ! ,class Arg2> ! class Invokable2: public InvokableBase ! { ! public: ! typedef void (Object::*Member)( Arg1 a1, Arg2 a2 ); ! Invokable2( Member member ) ! : member_( member ) { ! } ! void invoke( MethodCall &call ) const { ! Object &object = *any_cast( call.holder_, Type<Object *>() ); ! (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ), ! any_cast( call.args_.at(1), Type<Arg2>() ) ); } ! private: ! Member member_; ! }; ! template<class Object> ! Invokable makeInvokable( void (Object::*member)() ) { ! Invokable invokable( InvokableBasePtr( new Invokable0<Object>( member ) ) ); ! return invokable; ! } ! template<class Object, class Arg1> ! Invokable makeInvokable( void (Object::*member)( Arg1 a1 ) ) ! { ! Invokable invokable( InvokableBasePtr( new Invokable1<Object,Arg1>( member ) ) ); ! invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); ! return invokable; ! } ! template<class Object, class Arg1, class Arg2> ! Invokable makeInvokable( void (Object::*member)( Arg1 a1, Arg2 a2 ) ) ! { ! Invokable invokable( InvokableBasePtr( new Invokable2<Object,Arg1,Arg2>( member ) ) ); ! invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); ! invokable.argTypes_.push_back( typeId( Type<Arg2>() ) ); ! return invokable; ! } --- 11,248 ---- ! namespace CppTL { ! typedef std::vector<Any> MethodParameters; ! namespace Impl { ! class AttributAccessor; ! class InvokableBase; ! typedef SharedPtr<AttributAccessor> AttributAccessorPtr; ! typedef SharedPtr<InvokableBase> InvokableBasePtr; ! ! class MethodCall { ! public: ! MethodCall( const Method &method, ! const Any &holder, ! const MethodParameters &args, ! Any &result ) ! : method_( method ) ! , holder_( holder ) ! , args_( args ) ! , result_( result ) ! { ! } ! const Method &method_; ! const Any &holder_; ! const MethodParameters &args_; ! Any &result_; ! }; ! class InvokableBase ! { ! public: ! virtual ~InvokableBase() ! { ! } ! virtual void invoke( MethodCall &call ) const = 0; ! }; ! ! ! template<class Object> ! class Invokable0 : public InvokableBase { ! public: ! typedef void (Object::*Member)(); ! Invokable0( Member member ) ! : member_( member ) ! { ! } ! void invoke( MethodCall &call ) const ! { ! Object &object = *any_cast( call.holder_, Type<Object *>() ); ! (object.*member_)(); ! } + private: + Member member_; + }; ! ! template<class Object ! ,class Arg1> ! class Invokable1 : public InvokableBase { ! public: ! typedef void (Object::*Member)( Arg1 a1 ); ! Invokable1( Member member ) ! : member_( member ) ! { ! } + void invoke( MethodCall &call ) const + { + Object &object = *any_cast( call.holder_, Type<Object *>() ); + (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ) ); + } ! private: ! Member member_; ! }; ! ! template<class Object ! ,class Arg1 ! ,class Arg2> ! class Invokable2: public InvokableBase { ! public: ! typedef void (Object::*Member)( Arg1 a1, Arg2 a2 ); ! Invokable2( Member member ) ! : member_( member ) ! { ! } ! ! void invoke( MethodCall &call ) const ! { ! Object &object = *any_cast( call.holder_, Type<Object *>() ); ! (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ), ! any_cast( call.args_.at(1), Type<Arg2>() ) ); ! } ! ! private: ! Member member_; ! }; ! ! ! class Invokable { ! public: ! Invokable( const Impl::InvokableBasePtr &invokable ); ! virtual ~Invokable() ! { ! } + void invoke( Impl::MethodCall &call ) const; ! TypeId returnType_; ! std::vector<TypeId> argTypes_; ! InvokableBasePtr invokable_; ! }; ! ! template<class Object> ! Invokable makeInvokable( void (Object::*member)() ) { + Invokable invokable( InvokableBasePtr( new Invokable0<Object>( member ) ) ); + return invokable; } ! ! template<class Object, class Arg1> ! Invokable makeInvokable( void (Object::*member)( Arg1 a1 ) ) { ! Invokable invokable( InvokableBasePtr( new Invokable1<Object,Arg1>( member ) ) ); ! invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); ! return invokable; } + template<class Object, class Arg1, class Arg2> + Invokable makeInvokable( void (Object::*member)( Arg1 a1, Arg2 a2 ) ) + { + Invokable invokable( InvokableBasePtr( new Invokable2<Object,Arg1,Arg2>( member ) ) ); + invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); + invokable.argTypes_.push_back( typeId( Type<Arg2>() ) ); + return invokable; + } ! class AttributAccessor ! { ! public: ! virtual ~AttributAccessor() ! { ! } ! virtual TypeId getType() const =0; ! ! virtual Any get( const Any &holder) const = 0; ! ! virtual void set( const Any &holder, ! const Any &value ) const = 0; ! }; ! ! template<class Object, class AttributType> ! class AttributAccessorImpl : public AttributAccessor { ! public: ! typedef AttributType Object::*Attribut; ! AttributAccessorImpl( Attribut attribut ) ! : attribut_( attribut ) ! { ! } ! ! TypeId getType() const ! { ! return typeId( Type<AttributType>() ); ! } ! ! Any get( const Any &holder ) const ! { ! Object &object = *any_cast( holder, Type<Object *>() ); ! return makeAny( object.*attribut_ ); ! } ! ! void set( const Any &holder, ! const Any &value ) const ! { ! Object &object = *any_cast( holder, Type<Object *>() ); ! object.*attribut_ = any_cast( value, Type<AttributType>() ); ! } ! ! private: ! Attribut attribut_; ! }; ! ! template<class Object, class TheAttributType> ! AttributAccessorPtr makeAccessor( TheAttributType Object::*attribut ) { ! return AttributAccessorPtr( ! new AttributAccessorImpl<Object ! ,TheAttributType>( attribut ) ); } ! } // namespace Impl ! class Attribut { ! public: ! Attribut( const ConstString &name, ! const Impl::AttributAccessorPtr &accessor ); + ConstString getName() const; ! TypeId getType() const; + void set( const Any &object, + const Any &value ) const; ! Any get( const Any &object ) const; + private: + Class *class_; + ConstString name_; + Impl::AttributAccessorPtr accessor_; + }; *************** *** 172,180 **** public: Method( const ConstString &name, ! const Invokable &invokable ); ! void invoke( const Any &object, ! const ArgValues &args, ! Any &result ) const; ConstString getName() const; --- 251,258 ---- public: Method( const ConstString &name, ! const Impl::Invokable &invokable ); ! Any invoke( const Any &object, ! const MethodParameters &args ) const; ConstString getName() const; *************** *** 191,210 **** Class *class_; ConstString name_; ! Invokable invokable_; }; - template<class Holder> - Any invokeWithArgValues( const Holder &object, - const Method &method, - const ArgValues &args ) - { - Any actualObject = makeAny( &*object ); - Any result; - method.invoke( actualObject, args, result ); - return result; - } - - class Class { --- 269,276 ---- Class *class_; ConstString name_; ! Impl::Invokable invokable_; }; class Class { *************** *** 220,230 **** void addMethod( const ConstString &name, ! const Invokable &invokable ); private: typedef SharedPtr<Class> ClassPtr; typedef SharedPtr<Method> MethodPtr; typedef std::map<ConstString,ClassPtr> ClassesByName; typedef std::map<ConstString,MethodPtr> MethodsByName; static ClassesByName ®istry(); --- 286,303 ---- void addMethod( const ConstString &name, ! const Impl::Invokable &invokable ); ! ! const Attribut *findAttribut( const ConstString &name ) const; ! ! void addAttribut( const ConstString &name, ! const Impl::AttributAccessorPtr &accessor ); private: typedef SharedPtr<Class> ClassPtr; typedef SharedPtr<Method> MethodPtr; + typedef SharedPtr<Attribut> AttributPtr; typedef std::map<ConstString,ClassPtr> ClassesByName; typedef std::map<ConstString,MethodPtr> MethodsByName; + typedef std::map<ConstString,AttributPtr> AttributsByName; static ClassesByName ®istry(); *************** *** 233,236 **** --- 306,310 ---- TypeId type ); + AttributsByName attributsByName_; MethodsByName methodsByName_; ConstString name_; *************** *** 240,247 **** template<class ClassType> ! class AutoRegisterClass { public: ! AutoRegisterClass() { ClassType::registerClassReflection(); --- 314,321 ---- template<class ClassType> ! class AutoRegisterClassReflection { public: ! AutoRegisterClassReflection() { ClassType::registerClassReflection(); *************** *** 250,258 **** ! # define CPPTL_REFLECT_CLASS_BEGIN( ClassType ) \ ! typedef ClassType _Reflection_SelfType; \ ! static void registerClassReflection() \ ! { \ ! ::CppTL::Reflect::Class &class_ = ::CppTL::Reflect::Class::create( #ClassType, \ ::CppTL::typeId( ::CppTL::Type<ClassType>() ) ); --- 324,332 ---- ! # define CPPTL_REFLECT_CLASS_BEGIN( ClassType ) \ ! typedef ClassType _Reflection_SelfType; \ ! static void registerClassReflection() \ ! { \ ! ::CppTL::Class &class_ = ::CppTL::Class::create( #ClassType, \ ::CppTL::typeId( ::CppTL::Type<ClassType>() ) ); *************** *** 260,277 **** # define CPPTL_REFLECT_METHOD( method ) \ { \ ! ::CppTL::Reflect::Invokable invokable = ::CppTL::Reflect::makeInvokable( \ &_Reflection_SelfType::method ); \ class_.addMethod( #method, invokable ); \ } # define CPPTL_REFLECT_CLASS_END() \ } # define CPPTL_REFLECT_REGISTER_CLASS( ClassType ) \ ! static ::CppTL::Reflect::AutoRegisterClass<ClassType> \ CPPUT_MAKE_UNIQUE_NAME(cpptlReflectRegisterClass); ! } } // namespace CppTL { namespace Reflect # include <cpptl/reflection.inl> --- 334,361 ---- # define CPPTL_REFLECT_METHOD( method ) \ { \ ! ::CppTL::Impl::Invokable invokable = ::CppTL::Impl::makeInvokable( \ &_Reflection_SelfType::method ); \ class_.addMethod( #method, invokable ); \ } + # define CPPTL_REFLECT_RENAMED_ATTRIBUT( attribut, name ) \ + { \ + ::CppTL::Impl::AttributAccessorPtr accessor = ::CppTL::Impl::makeAccessor( \ + &_Reflection_SelfType::attribut ); \ + class_.addAttribut( name, accessor ); \ + } + + # define CPPTL_REFLECT_ATTRIBUT( attribut ) \ + CPPTL_REFLECT_RENAMED_ATTRIBUT( attribut, #attribut ) + # define CPPTL_REFLECT_CLASS_END() \ } # define CPPTL_REFLECT_REGISTER_CLASS( ClassType ) \ ! static ::CppTL::AutoRegisterClassReflection<ClassType> \ CPPUT_MAKE_UNIQUE_NAME(cpptlReflectRegisterClass); ! } // namespace CppTL # include <cpptl/reflection.inl> Index: forwards.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/forwards.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** forwards.h 27 Feb 2005 14:38:25 -0000 1.3 --- forwards.h 3 Mar 2005 20:48:54 -0000 1.4 *************** *** 26,29 **** --- 26,35 ---- class Functor0R; + // reflection.h + class Attribut; + class Class; + class Method; + + } // namespace CppTL |
From: Baptiste L. <bl...@us...> - 2005-03-03 20:49:08
|
Update of /cvsroot/cppunit/cppunit2/src/cpputtest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9744/src/cpputtest Modified Files: reflectiontest.cpp Log Message: * moved reflection implementation details in Impl namespace * added reflection support for attribut Index: reflectiontest.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/reflectiontest.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** reflectiontest.cpp 3 Mar 2005 08:15:54 -0000 1.1 --- reflectiontest.cpp 3 Mar 2005 20:48:54 -0000 1.2 *************** *** 13,16 **** --- 13,18 ---- CPPTL_REFLECT_METHOD( multiplyAndAdd ) CPPTL_REFLECT_METHOD( checkTotal ) + CPPTL_REFLECT_ATTRIBUT( initialized_ ) + CPPTL_REFLECT_RENAMED_ATTRIBUT( total_, "total" ) CPPTL_REFLECT_CLASS_END() *************** *** 76,109 **** ReflectionTest::testBasicReflection() { ! Sample1 target; ! const CppTL::Reflect::Class *class_ = CppTL::Reflect::Class::findClass( "Sample1" ); CPPUT_ASSERT( class_ != 0, "Class 'Sample1' not found by reflection." ); ! const CppTL::Reflect::Method *initializeMethod = class_->findMethod( "initialize" ); CPPUT_ASSERT( initializeMethod != 0, "Method 'initialize' not found by reflection." ); ! CppTL::Reflect::ArgValues argsInitialize; ! CppTL::Reflect::invokeWithArgValues( &target, *initializeMethod, argsInitialize ); ! CPPUT_ASSERT_EQUAL( true, target.initialized_, "'initialize' was not called" ); ! const CppTL::Reflect::Method *addMethod = class_->findMethod( "add" ); CPPUT_ASSERT( addMethod != 0, "Method 'add' not found by reflection." ); ! CppTL::Reflect::ArgValues argsAdd; argsAdd.push_back( CppTL::makeAny( 7 ) ); ! CppTL::Reflect::invokeWithArgValues( &target, *addMethod, argsAdd ); ! CPPUT_ASSERT_EQUAL( 7, target.total_ ); ! const CppTL::Reflect::Method *multiplyAndAddMethod = class_->findMethod( "multiplyAndAdd" ); CPPUT_ASSERT( multiplyAndAddMethod != 0, "Method 'multiplyAndAdd' not found by reflection." ); ! CppTL::Reflect::ArgValues argsMultiplyAndAdd; argsMultiplyAndAdd.push_back( CppTL::makeAny( 2 ) ); argsMultiplyAndAdd.push_back( CppTL::makeAny( 6 ) ); ! CppTL::Reflect::invokeWithArgValues( &target, *multiplyAndAddMethod, argsMultiplyAndAdd ); ! CPPUT_ASSERT_EQUAL( 7 + 2*6, target.total_ ); ! const CppTL::Reflect::Method *checkTotalMethod = class_->findMethod( "checkTotal" ); CPPUT_ASSERT( checkTotalMethod != 0, "Method 'checkTotal' not found by reflection." ); ! CppTL::Reflect::ArgValues argsCheckTotal; argsCheckTotal.push_back( CppTL::makeAny( 7 + 2 * 6 ) ); ! CppTL::Reflect::invokeWithArgValues( &target, *checkTotalMethod, argsCheckTotal ); ! CPPUT_ASSERT_EQUAL( 7 + 2*6, target.total_ ); } --- 78,125 ---- ReflectionTest::testBasicReflection() { ! Sample1 sampleTarget; ! CppTL::Any target = CppTL::makeAny( &sampleTarget ); ! ! const CppTL::Class *class_ = CppTL::Class::findClass( "Sample1" ); CPPUT_ASSERT( class_ != 0, "Class 'Sample1' not found by reflection." ); ! const CppTL::Method *initializeMethod = class_->findMethod( "initialize" ); CPPUT_ASSERT( initializeMethod != 0, "Method 'initialize' not found by reflection." ); ! CppTL::MethodParameters argsInitialize; ! initializeMethod->invoke( target, argsInitialize ); ! CPPUT_ASSERT_EQUAL( true, sampleTarget.initialized_, "'initialize' was not called" ); ! const CppTL::Method *addMethod = class_->findMethod( "add" ); CPPUT_ASSERT( addMethod != 0, "Method 'add' not found by reflection." ); ! CppTL::MethodParameters argsAdd; argsAdd.push_back( CppTL::makeAny( 7 ) ); ! addMethod->invoke( target, argsAdd ); ! CPPUT_ASSERT_EQUAL( 7, sampleTarget.total_ ); ! const CppTL::Method *multiplyAndAddMethod = class_->findMethod( "multiplyAndAdd" ); CPPUT_ASSERT( multiplyAndAddMethod != 0, "Method 'multiplyAndAdd' not found by reflection." ); ! CppTL::MethodParameters argsMultiplyAndAdd; argsMultiplyAndAdd.push_back( CppTL::makeAny( 2 ) ); argsMultiplyAndAdd.push_back( CppTL::makeAny( 6 ) ); ! multiplyAndAddMethod->invoke( target, argsMultiplyAndAdd ); ! CPPUT_ASSERT_EQUAL( 7 + 2*6, sampleTarget.total_ ); ! const CppTL::Method *checkTotalMethod = class_->findMethod( "checkTotal" ); CPPUT_ASSERT( checkTotalMethod != 0, "Method 'checkTotal' not found by reflection." ); ! CppTL::MethodParameters argsCheckTotal; argsCheckTotal.push_back( CppTL::makeAny( 7 + 2 * 6 ) ); ! checkTotalMethod->invoke( target, argsCheckTotal ); ! CPPUT_ASSERT_EQUAL( 7 + 2*6, sampleTarget.total_ ); ! ! const CppTL::Attribut *initializedAttribut = class_->findAttribut( "initialized_" ); ! CPPUT_ASSERT( initializedAttribut != 0, "Attribut 'initialized_' not found by reflection." ); ! CPPUT_ASSERT_EQUAL( true, any_cast( initializedAttribut->get( target ), ! CppTL::Type<bool>() ) ); ! ! const CppTL::Attribut *totalAttribut = class_->findAttribut( "total" ); ! CPPUT_ASSERT( totalAttribut != 0, "Attribut 'total' not found by reflection." ); ! CPPUT_ASSERT_EQUAL( 7 + 2*6, any_cast( totalAttribut->get( target ), ! CppTL::Type<int>() ) ); ! totalAttribut->set( target, CppTL::makeAny( 945 ) ); ! CPPUT_ASSERT_EQUAL( 945, sampleTarget.total_ ); } |
From: Baptiste L. <bl...@us...> - 2005-03-03 08:16:05
|
Update of /cvsroot/cppunit/cppunit2/src/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30295/src/cpput Modified Files: cpput.vcproj Log Message: * added unit tests for CppTL::Reflect Index: cpput.vcproj =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpput/cpput.vcproj,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** cpput.vcproj 28 Feb 2005 22:11:55 -0000 1.29 --- cpput.vcproj 3 Mar 2005 08:15:54 -0000 1.30 *************** *** 131,138 **** Filter=""> <File ! RelativePath=".\SConscript"> </File> <File ! RelativePath="..\cpputtest\SConscript"> </File> <File --- 131,138 ---- Filter=""> <File ! RelativePath="..\cpputtest\SConscript"> </File> <File ! RelativePath=".\SConscript"> </File> <File *************** *** 194,197 **** --- 194,200 ---- Filter=""> <File + RelativePath="..\..\include\cpptl\any.h"> + </File> + <File RelativePath="..\..\include\cpptl\atomiccounter.h"> </File> *************** *** 212,215 **** --- 215,224 ---- </File> <File + RelativePath="..\..\include\cpptl\reflection.h"> + </File> + <File + RelativePath="..\..\include\cpptl\reflection.inl"> + </File> + <File RelativePath="..\..\include\cpptl\sharedptr.h"> </File> *************** *** 218,221 **** --- 227,233 ---- </File> <File + RelativePath="..\..\include\cpptl\typeinfo.h"> + </File> + <File RelativePath="..\..\include\cpptl\typename.h"> </File> |
From: Baptiste L. <bl...@us...> - 2005-03-03 08:16:05
|
Update of /cvsroot/cppunit/cppunit2/src/cpputtest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30295/src/cpputtest Modified Files: cpputtest.vcproj main.cpp SConscript Added Files: reflectiontest.cpp reflectiontest.h Log Message: * added unit tests for CppTL::Reflect --- NEW FILE: reflectiontest.cpp --- #include "reflectiontest.h" #include <cpptl/reflection.h> namespace { // anonymous namespace class Sample1 { public: CPPTL_REFLECT_CLASS_BEGIN( Sample1 ) CPPTL_REFLECT_METHOD( initialize ) CPPTL_REFLECT_METHOD( add ) CPPTL_REFLECT_METHOD( multiplyAndAdd ) CPPTL_REFLECT_METHOD( checkTotal ) CPPTL_REFLECT_CLASS_END() Sample1() : initialized_( false ) , total_( 0 ) { } void initialize() { initialized_ = true; } void add( int value ) { total_ += value; } void multiplyAndAdd( int x, int y ) { total_ += x * y; } void checkTotal( int expected ) { CPPUT_ASSERT_EQUAL( expected, total_, "Total did not match expected value" ); } bool initialized_; int total_; }; } // anonymous namespace CPPTL_REFLECT_REGISTER_CLASS( Sample1 ) ReflectionTest::ReflectionTest() { } ReflectionTest::~ReflectionTest() { } void ReflectionTest::setUp() { } void ReflectionTest::tearDown() { } void ReflectionTest::testBasicReflection() { Sample1 target; const CppTL::Reflect::Class *class_ = CppTL::Reflect::Class::findClass( "Sample1" ); CPPUT_ASSERT( class_ != 0, "Class 'Sample1' not found by reflection." ); const CppTL::Reflect::Method *initializeMethod = class_->findMethod( "initialize" ); CPPUT_ASSERT( initializeMethod != 0, "Method 'initialize' not found by reflection." ); CppTL::Reflect::ArgValues argsInitialize; CppTL::Reflect::invokeWithArgValues( &target, *initializeMethod, argsInitialize ); CPPUT_ASSERT_EQUAL( true, target.initialized_, "'initialize' was not called" ); const CppTL::Reflect::Method *addMethod = class_->findMethod( "add" ); CPPUT_ASSERT( addMethod != 0, "Method 'add' not found by reflection." ); CppTL::Reflect::ArgValues argsAdd; argsAdd.push_back( CppTL::makeAny( 7 ) ); CppTL::Reflect::invokeWithArgValues( &target, *addMethod, argsAdd ); CPPUT_ASSERT_EQUAL( 7, target.total_ ); const CppTL::Reflect::Method *multiplyAndAddMethod = class_->findMethod( "multiplyAndAdd" ); CPPUT_ASSERT( multiplyAndAddMethod != 0, "Method 'multiplyAndAdd' not found by reflection." ); CppTL::Reflect::ArgValues argsMultiplyAndAdd; argsMultiplyAndAdd.push_back( CppTL::makeAny( 2 ) ); argsMultiplyAndAdd.push_back( CppTL::makeAny( 6 ) ); CppTL::Reflect::invokeWithArgValues( &target, *multiplyAndAddMethod, argsMultiplyAndAdd ); CPPUT_ASSERT_EQUAL( 7 + 2*6, target.total_ ); const CppTL::Reflect::Method *checkTotalMethod = class_->findMethod( "checkTotal" ); CPPUT_ASSERT( checkTotalMethod != 0, "Method 'checkTotal' not found by reflection." ); CppTL::Reflect::ArgValues argsCheckTotal; argsCheckTotal.push_back( CppTL::makeAny( 7 + 2 * 6 ) ); CppTL::Reflect::invokeWithArgValues( &target, *checkTotalMethod, argsCheckTotal ); CPPUT_ASSERT_EQUAL( 7 + 2*6, target.total_ ); } --- NEW FILE: reflectiontest.h --- #ifndef CPPUT_REFLECTIONTEST_H # define CPPUT_REFLECTIONTEST_H # include <cpput/assert.h> # include <cpput/testfixture.h> class ReflectionTest : public CppUT::TestFixture { CPPUT_TESTSUITE_BEGIN( ReflectionTest ); CPPUT_TEST( testBasicReflection ); CPPUT_TESTSUITE_END(); public: ReflectionTest(); virtual ~ReflectionTest(); void setUp(); void tearDown(); void testBasicReflection(); private: }; #endif // CPPUT_REFLECTIONTEST_H Index: SConscript =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/SConscript,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SConscript 28 Feb 2005 22:11:56 -0000 1.8 --- SConscript 3 Mar 2005 08:15:54 -0000 1.9 *************** *** 15,18 **** --- 15,19 ---- testtestcase.cpp testtestsuite.cpp + reflectiontest.cpp """.split() Index: main.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/main.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** main.cpp 27 Feb 2005 17:42:32 -0000 1.16 --- main.cpp 3 Mar 2005 08:15:54 -0000 1.17 *************** *** 8,11 **** --- 8,12 ---- #include "enumeratortest.h" #include "testfixturetest.h" + #include "reflectiontest.h" #include <cpput/testrunner.h> // cppunit2 testrunner for opentest *************** *** 50,53 **** --- 51,55 ---- allSuite->add( EnumeratorTest::suite() ); allSuite->add( AssertEnumTest::suite() ); + allSuite->add( ReflectionTest::suite() ); // allSuite->add( CommandLineOptionsTest::suite() ); Index: cpputtest.vcproj =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/cpputtest.vcproj,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** cpputtest.vcproj 28 Feb 2005 20:43:02 -0000 1.17 --- cpputtest.vcproj 3 Mar 2005 08:15:54 -0000 1.18 *************** *** 191,205 **** </File> <File RelativePath="registrytest.cpp"> - <FileConfiguration - Name="Release|Win32"> - <Tool - Name="VCCLCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="Debug|Win32"> - <Tool - Name="VCCLCompilerTool"/> - </FileConfiguration> </File> <File --- 191,201 ---- </File> <File + RelativePath=".\reflectiontest.cpp"> + </File> + <File + RelativePath=".\reflectiontest.h"> + </File> + <File RelativePath="registrytest.cpp"> </File> <File *************** *** 220,233 **** <File RelativePath="testfixturetest.cpp"> - <FileConfiguration - Name="Release|Win32"> - <Tool - Name="VCCLCompilerTool"/> - </FileConfiguration> - <FileConfiguration - Name="Debug|Win32"> - <Tool - Name="VCCLCompilerTool"/> - </FileConfiguration> </File> <File --- 216,219 ---- |
From: Baptiste L. <bl...@us...> - 2005-03-03 08:14:32
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29959 Added Files: reflection.h reflection.inl Log Message: * Simple reflection support --- NEW FILE: reflection.inl --- #ifndef CPPTL_REFLECTION_INL_INCLUDED # define CPPTL_REFLECTION_INL_INCLUDED namespace CppTL { namespace Reflect { // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// // Class Class // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// inline Class & Class::create( const ConstString &name, TypeId type ) { ClassPtr class_( new Class( name, type ) ); registry()[ name ] = class_; return *class_; } inline const Class * Class::findClass( const ConstString &name ) { ClassesByName::const_iterator it = registry().find( name ); if ( it == registry().end() ) return 0; return it->second.get(); } inline Class::Class( const ConstString &name, TypeId type ) : name_( name ) , type_( type ) { } inline Class::ClassesByName & Class::registry() { static ClassesByName classes_; return classes_; } inline ConstString Class::getName() const { return name_; } inline const Method * Class::findMethod( const ConstString &name ) const { MethodsByName::const_iterator it = methodsByName_.find( name ); if ( it == methodsByName_.end() ) return 0; return it->second.get(); } inline void Class::addMethod( const ConstString &name, const Invokable &invokable ) { MethodPtr method( new Method( name, invokable ) ); methodsByName_[name] = method; } // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// // Class Method // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// inline Method::Method( const ConstString &name, const Invokable &invokable ) : name_( name ) , invokable_( invokable ) { } inline void Method::invoke( const Any &object, const ArgValues &args, Any &result ) const { MethodCall call( *this, object, args, result ); invokable_.invoke( call ); } inline ConstString Method::getName() const { return name_; } inline size_type Method::getArgCount() const { return invokable_.argTypes_.size(); } inline TypeId Method::getArgType( size_type index ) const { return invokable_.argTypes_.at(index); } inline TypeId Method::getReturnType() const { return typeId( Type<void>() ); } inline AnyEnumerator<TypeId> Method::getArgTypes() const { return Enum::anyContainer( invokable_.argTypes_, Type<TypeId>() ); } // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// // Class Invokable // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// inline Invokable::Invokable( const InvokableBasePtr &invokable ) : invokable_( invokable ) , returnType_( typeId( Type<void>() ) ) { } inline void Invokable::invoke( MethodCall &call ) const { invokable_->invoke( call ); } } } // namespace CppTL { namespace Reflect { #endif // CPPTL_REFLECTION_INL_INCLUDED --- NEW FILE: reflection.h --- #ifndef CPPTL_REFLECTION_H_INCLUDED # define CPPTL_REFLECTION_H_INCLUDED # include <cpptl/conststring.h> # include <cpptl/enumerator.h> # include <cpptl/sharedptr.h> # include <cpptl/any.h> # include <map> # include <vector> namespace CppTL { namespace Reflect { // Forwards class Class; class Invokable; class InvokableBase; class Method; struct MethodCall; typedef SharedPtr<InvokableBase> InvokableBasePtr; typedef std::vector<Any> ArgValues; struct MethodCall { MethodCall( const Method &method, const Any &holder, const ArgValues &args, Any &result ) : method_( method ) , holder_( holder ) , args_( args ) , result_( result ) { } const Method &method_; const Any &holder_; const ArgValues &args_; Any &result_; }; class Invokable { public: Invokable( const InvokableBasePtr &invokable ); virtual ~Invokable() { } void invoke( MethodCall &call ) const; TypeId returnType_; std::vector<TypeId> argTypes_; InvokableBasePtr invokable_; }; class InvokableBase { public: virtual ~InvokableBase() { } virtual void invoke( MethodCall &call ) const = 0; }; template<class Object> class Invokable0 : public InvokableBase { public: typedef void (Object::*Member)(); Invokable0( Member member ) : member_( member ) { } void invoke( MethodCall &call ) const { Object &object = *any_cast( call.holder_, Type<Object *>() ); (object.*member_)(); } private: Member member_; }; template<class Object ,class Arg1> class Invokable1 : public InvokableBase { public: typedef void (Object::*Member)( Arg1 a1 ); Invokable1( Member member ) : member_( member ) { } void invoke( MethodCall &call ) const { Object &object = *any_cast( call.holder_, Type<Object *>() ); (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ) ); } private: Member member_; }; template<class Object ,class Arg1 ,class Arg2> class Invokable2: public InvokableBase { public: typedef void (Object::*Member)( Arg1 a1, Arg2 a2 ); Invokable2( Member member ) : member_( member ) { } void invoke( MethodCall &call ) const { Object &object = *any_cast( call.holder_, Type<Object *>() ); (object.*member_)( any_cast( call.args_.at(0), Type<Arg1>() ), any_cast( call.args_.at(1), Type<Arg2>() ) ); } private: Member member_; }; template<class Object> Invokable makeInvokable( void (Object::*member)() ) { Invokable invokable( InvokableBasePtr( new Invokable0<Object>( member ) ) ); return invokable; } template<class Object, class Arg1> Invokable makeInvokable( void (Object::*member)( Arg1 a1 ) ) { Invokable invokable( InvokableBasePtr( new Invokable1<Object,Arg1>( member ) ) ); invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); return invokable; } template<class Object, class Arg1, class Arg2> Invokable makeInvokable( void (Object::*member)( Arg1 a1, Arg2 a2 ) ) { Invokable invokable( InvokableBasePtr( new Invokable2<Object,Arg1,Arg2>( member ) ) ); invokable.argTypes_.push_back( typeId( Type<Arg1>() ) ); invokable.argTypes_.push_back( typeId( Type<Arg2>() ) ); return invokable; } class Method { public: Method( const ConstString &name, const Invokable &invokable ); void invoke( const Any &object, const ArgValues &args, Any &result ) const; ConstString getName() const; size_type getArgCount() const; TypeId getArgType( size_type index ) const; TypeId getReturnType() const; AnyEnumerator<TypeId> getArgTypes() const; private: Class *class_; ConstString name_; Invokable invokable_; }; template<class Holder> Any invokeWithArgValues( const Holder &object, const Method &method, const ArgValues &args ) { Any actualObject = makeAny( &*object ); Any result; method.invoke( actualObject, args, result ); return result; } class Class { public: static Class &create( const ConstString &name, TypeId type ); static const Class *findClass( const ConstString &name ); ConstString getName() const; const Method *findMethod( const ConstString &name ) const; void addMethod( const ConstString &name, const Invokable &invokable ); private: typedef SharedPtr<Class> ClassPtr; typedef SharedPtr<Method> MethodPtr; typedef std::map<ConstString,ClassPtr> ClassesByName; typedef std::map<ConstString,MethodPtr> MethodsByName; static ClassesByName ®istry(); Class( const ConstString &name, TypeId type ); MethodsByName methodsByName_; ConstString name_; TypeId type_; }; template<class ClassType> class AutoRegisterClass { public: AutoRegisterClass() { ClassType::registerClassReflection(); } }; # define CPPTL_REFLECT_CLASS_BEGIN( ClassType ) \ typedef ClassType _Reflection_SelfType; \ static void registerClassReflection() \ { \ ::CppTL::Reflect::Class &class_ = ::CppTL::Reflect::Class::create( #ClassType, \ ::CppTL::typeId( ::CppTL::Type<ClassType>() ) ); //# define CPPTL_REFLECT_CLASS_EXTEND( ClassType ) # define CPPTL_REFLECT_METHOD( method ) \ { \ ::CppTL::Reflect::Invokable invokable = ::CppTL::Reflect::makeInvokable( \ &_Reflection_SelfType::method ); \ class_.addMethod( #method, invokable ); \ } # define CPPTL_REFLECT_CLASS_END() \ } # define CPPTL_REFLECT_REGISTER_CLASS( ClassType ) \ static ::CppTL::Reflect::AutoRegisterClass<ClassType> \ CPPUT_MAKE_UNIQUE_NAME(cpptlReflectRegisterClass); } } // namespace CppTL { namespace Reflect # include <cpptl/reflection.inl> #endif // CPPTL_REFLECTION_H_INCLUDED |
From: Baptiste L. <bl...@us...> - 2005-03-03 08:13:27
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29667 Added Files: typeinfo.h Log Message: * TypeId is a std::type_info wrapper, and provides a mechanism to support RTTI when the compiler does not provide any support. --- NEW FILE: typeinfo.h --- #ifndef CPPTL_TYPEINFO_H_INCUDED # define CPPTL_TYPEINFO_H_INCUDED # include <string> // ///////////////////////////////////////////////////// // ///////////////////////////////////////////////////// // CTTI using std::type_info & typeid // ///////////////////////////////////////////////////// // ///////////////////////////////////////////////////// # ifndef CPPTL_NO_RTTI # include <typeinfo> namespace CppTL { class TypeId { public: TypeId( const std::type_info &typeId ) : type_( &typeId ) { } bool operator ==( const TypeId &other ) const { return *type_ == *(other.type_); } bool operator !=( const TypeId &other ) const { return !( *this == other ); } bool operator <( const TypeId &other ) const { return type_->before( *(other.type_) ); } private: const std::type_info *type_; }; // Compile Time Type Information functions // ////////////////////////////////////////////////////////////////// template<class AType> TypeId typeId( Type<AType> ) { return typeid( AType ); } } // namespace CppTL // ///////////////////////////////////////////////////// // ///////////////////////////////////////////////////// // CTTI using hande-made mecanism (template overload) // ///////////////////////////////////////////////////// // ///////////////////////////////////////////////////// # else namespace CppTL { class TypeId { public: TypeId( const char *type ) : type_( type ) { } bool operator <( const TypeId &other ) const { return strcmp( type_, other.type_) < 0; } bool operator ==( const TypeId &other ) const { return strcmp( type_, other.type_ ) == 0; } bool operator !=( const TypeId &other ) const { return !( *this == other ); } private: const char *type_; }; inline TypeId typeId( ... ) { return __error__typeId_function_not_overloaded; } #define CPPTL_DECLARE_TYPEINFO( AType ) \ namespace CppTL { \ inline TypeId typeId( Type<AType> ) \ { \ return TypeId( #AType ); \ } \ } CPPUTTOOLS_DECLARE_CTTI( char ); CPPUTTOOLS_DECLARE_CTTI( signed char ); CPPUTTOOLS_DECLARE_CTTI( unsigned char ); CPPUTTOOLS_DECLARE_CTTI( short ); CPPUTTOOLS_DECLARE_CTTI( unsigned short ); CPPUTTOOLS_DECLARE_CTTI( int ); CPPUTTOOLS_DECLARE_CTTI( unsigned int ); CPPUTTOOLS_DECLARE_CTTI( long ); CPPUTTOOLS_DECLARE_CTTI( unsigned long ); CPPUTTOOLS_DECLARE_CTTI( float ); CPPUTTOOLS_DECLARE_CTTI( double ); CPPUTTOOLS_DECLARE_CTTI( long double ); CPPUTTOOLS_DECLARE_CTTI( const char * ); CPPUTTOOLS_DECLARE_CTTI( const wchar_t * ); CPPUTTOOLS_DECLARE_CTTI( std::string ); CPPUTTOOLS_DECLARE_CTTI( std::wstring ); } // namespace CppTL # endif #endif // CPPTL_TYPEINFO_H_INCUDED |
From: Baptiste L. <bl...@us...> - 2005-03-03 08:11:44
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29260 Added Files: any.h Log Message: * Any is a container that can old 'any' value as well as its TypeId. This allows safe casting to the original type. --- NEW FILE: any.h --- #ifndef CPPTL_ANY_H_INCLUDED # define CPPTL_ANY_H_INCLUDED //# include "ctti.h" # include <typeinfo> // std::bad_cast # include <cpptl/typeinfo.h> # include <string> namespace CppTL { class AnyBadCast : public std::bad_cast { public: const char * what() const throw() { return "AnyBadCast: " "Any can not be converted to the specified type."; } }; namespace Impl { class AnyHolder { public: virtual ~AnyHolder() {} virtual TypeId type() const = 0; virtual AnyHolder *clone() const = 0; virtual void *pointer() = 0; }; template<class AnyType> class AnyHolderImpl : public AnyHolder { public: AnyHolderImpl( const AnyType &value ) : value_( value ) { } const AnyType &value() const { return value_; } public: // overridden from AnyHolder TypeId type() const { return typeId( Type<AnyType>() ); } void *pointer() { return &value_; } AnyHolder *clone() const { return new AnyHolderImpl<AnyType>( value_ ); } private: AnyType value_; }; } // namespace Impl class Any { public: Any(); Any( char value ); Any( bool value ); Any( short value ); Any( int value ); Any( long value ); Any( unsigned short value ); Any( unsigned int value ); Any( unsigned long value ); Any( float value ); Any( double value ); Any( long double value ); Any( const std::string &value ); #if !defined(CPPTL_NO_STD_WSTRING) Any( const std::wstring &value ); #endif Any( const Any &other ); Any &operator =( const Any &other ); TypeId type() const; void swap( Any &other ); bool hasSameType( const Any &other ) const; bool isEmpty() const; const void *valuePointer() const; void *valuePointer(); void copyValueTo( void *storage ); //private: // not private for access by get/set/cast function Any( Impl::AnyHolder *holder ); Impl::AnyHolder *holder_; }; template<class ValueType> Any makeAny( const ValueType &newValue ) { return Any( new Impl::AnyHolderImpl<ValueType>( newValue ) ); } // class Any // /////////////////////////////////////////////////////////////// inline Any::Any() : holder_( 0 ) { } inline Any::Any( bool value ) : holder_( new Impl::AnyHolderImpl<bool>( value ) ) { } inline Any::Any( char value ) : holder_( new Impl::AnyHolderImpl<char>( value ) ) { } inline Any::Any( short value ) : holder_( new Impl::AnyHolderImpl<short>( value ) ) { } inline Any::Any( int value ) : holder_( new Impl::AnyHolderImpl<int>( value ) ) { } inline Any::Any( long value ) : holder_( new Impl::AnyHolderImpl<long>( value ) ) { } inline Any::Any( unsigned short value ) : holder_( new Impl::AnyHolderImpl<unsigned short>( value ) ) { } inline Any::Any( unsigned int value ) : holder_( new Impl::AnyHolderImpl<unsigned int>( value ) ) { } inline Any::Any( unsigned long value ) : holder_( new Impl::AnyHolderImpl<unsigned long>( value ) ) { } inline Any::Any( float value ) : holder_( new Impl::AnyHolderImpl<float>( value ) ) { } inline Any::Any( double value ) : holder_( new Impl::AnyHolderImpl<double>( value ) ) { } inline Any::Any( long double value ) : holder_( new Impl::AnyHolderImpl<long double>( value ) ) { } inline Any::Any( const std::string &value ) : holder_( new Impl::AnyHolderImpl<std::string>( value ) ) { } #if !defined(CPPTL_NO_STD_WSTRING) inline Any::Any( const std::wstring &value ) : holder_( new Impl::AnyHolderImpl<std::wstring>( value ) ) { } #endif inline Any::Any( const Any &other ) : holder_( other.holder_ ? other.holder_->clone() : 0 ) { } inline Any & Any::operator =( const Any &other ) { Any tmp( other ); swap( tmp ); return *this; } inline TypeId Any::type() const { return holder_ ? holder_->type() : typeId( Type<void>() ); } inline void Any::swap( Any &other ) { Impl::AnyHolder *tmp = holder_; holder_ = other.holder_; other.holder_ = tmp; } inline bool Any::hasSameType( const Any &other ) const { return type() == other.type(); } inline bool Any::isEmpty() const { return holder_ == 0; } inline Any::Any( Impl::AnyHolder *holder ) : holder_( holder ) { } inline const void * Any::valuePointer() const { // this const cast avoid extra virtual function Impl::AnyHolder *holder = const_cast<Impl::AnyHolder *>( holder_ ); return holder ? holder->pointer() : 0; } inline void * Any::valuePointer() { return holder_ ? holder_->pointer() : 0; } } // namespace CppTL // Those function are imported in the global namespace since all compiler don't have // argument dependent look-up. They all take type 'Any' in parameter which is in a namespace. template<class ValueType> CppTL::Any &set( CppTL::Any &value, const ValueType &newValue ) { value = CppTL::Any( new CppTL::Impl::AnyHolderImpl<ValueType>( newValue ) ); return value; } template<class ValueType> const ValueType &any_cast( const CppTL::Any &value, CppTL::Type<ValueType> ) { if ( value.type() != CppTL::typeId( CppTL::Type<ValueType>() ) ) throw CppTL::AnyBadCast(); return static_cast<CppTL::Impl::AnyHolderImpl<ValueType> *>( value.holder_ )->value(); } template<class ValueType> const ValueType *get( const CppTL::Any *value, CppTL::Type<ValueType> ) { if ( value.type() != CppTL::typeId( CppTL::Type<ValueType>() ) ) return 0; return static_cast<CppTL::Impl::AnyHolderImpl<ValueType> *>( value.holder_ )->value(); } #endif // CPPTL_ANY_H_INCLUDED |
From: Baptiste L. <bl...@us...> - 2005-03-01 22:18:07
|
Update of /cvsroot/cppunit/cppunit2/examples/checking_assertions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15392/examples/checking_assertions Added Files: .cvsignore main.cpp SConscript Log Message: * added example that demonstrate the checking assertions. --- NEW FILE: .cvsignore --- *.plg *.old *.WW *.old --- NEW FILE: SConscript --- Import( 'env_testing buildCppUnitExample' ) buildCppUnitExample( env_testing, """ main.cpp """.split(), 'checking_assertions' ) --- NEW FILE: main.cpp --- #include <cpput/testcase.h> #include <cpput/testsuite.h> #include <cpput/testrunner.h> // cppunit2 testrunner for opentest #include <cpput/assert.h> #include <opentest/texttestdriver.h> #include <opentest/properties.h> // Checking assertion do not abort the test uppon failure: // all the failing assertions below will be reported by the test framework static void testBasicCheckingAssertion() { CPPUT_CHECK( 1 == 2, "1 is not equal to 2..." ); CPPUT_CHECK_EXPR( 1 + 2 == 4 ); CPPUT_CHECK_FALSE( 1 == 1, "1 is equal to 1..." ); CPPUT_CHECK_EXPR_FALSE( 1 + 1 == 2 ); CPPUT_CHECK_EQUAL( 1, 2 ); CPPUT_CHECK_NOT_EQUAL( 34, 34 ); } int main( int argc, const char *argv[] ) { CppUT::TestSuitePtr allSuite = CppUT::makeTestSuite( "All tests" ); allSuite->add( CppUT::makeTestCase( CppTL::cfn0( &testBasicCheckingAssertion ), "testBasicCheckingAssertion" ) ); CppUT::TestRunner runner; CppUT::AbstractTestSuitePtr rootSuite = CppTL::staticPointerCast<CppUT::AbstractTestSuite>( allSuite ); runner.setRootSuite( rootSuite ); OpenTest::TextTestDriver driver( runner ); bool sucessful = driver.run(); return sucessful ? 0 : 1; } |
From: Baptiste L. <bl...@us...> - 2005-03-01 22:17:13
|
Update of /cvsroot/cppunit/cppunit2/examples/parametrized_test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15050/examples/parametrized_test Modified Files: SConscript Log Message: * factorised build sequence for simple examples Index: SConscript =================================================================== RCS file: /cvsroot/cppunit/cppunit2/examples/parametrized_test/SConscript,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SConscript 28 Feb 2005 22:11:54 -0000 1.2 --- SConscript 1 Mar 2005 22:16:46 -0000 1.3 *************** *** 1,13 **** ! # parametrized_test build script ! ! Import( 'env_testing' ) ! parametrized_test_sources=""" main.cpp ! """.split() ! ! parametrized_test_exe = env_testing.Program( target='parametrized_test', ! source=parametrized_test_sources ) ! ! bin_dir='#bin' ! env_testing.Install( bin_dir, parametrized_test_exe ) --- 1,6 ---- ! Import( 'env_testing buildCppUnitExample' ) ! buildCppUnitExample( env_testing, """ main.cpp ! """.split(), ! 'parametrized_test' ) |
From: Baptiste L. <bl...@us...> - 2005-03-01 22:17:12
|
Update of /cvsroot/cppunit/cppunit2/examples/input_based_test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15050/examples/input_based_test Modified Files: SConscript Log Message: * factorised build sequence for simple examples Index: SConscript =================================================================== RCS file: /cvsroot/cppunit/cppunit2/examples/input_based_test/SConscript,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SConscript 28 Feb 2005 22:11:54 -0000 1.2 --- SConscript 1 Mar 2005 22:16:46 -0000 1.3 *************** *** 1,13 **** ! # input_based_test build script ! ! Import( 'env_testing' ) ! input_based_test_sources=""" main.cpp ! """.split() ! ! input_based_test_exe = env_testing.Program( target='input_based_test', ! source=input_based_test_sources ) ! ! bin_dir='#bin' ! env_testing.Install( bin_dir, input_based_test_exe ) --- 1,6 ---- ! Import( 'env_testing buildCppUnitExample' ) ! buildCppUnitExample( env_testing, """ main.cpp ! """.split(), ! 'input_based_test' ) |
From: Baptiste L. <bl...@us...> - 2005-03-01 22:16:55
|
Update of /cvsroot/cppunit/cppunit2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15050 Modified Files: sconstruct Log Message: * factorised build sequence for simple examples Index: sconstruct =================================================================== RCS file: /cvsroot/cppunit/cppunit2/sconstruct,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** sconstruct 28 Feb 2005 22:11:53 -0000 1.5 --- sconstruct 1 Mar 2005 22:16:30 -0000 1.6 *************** *** 36,40 **** env_testing = env.Copy( LIBS = ['cpput','opentest'] ) ! Export( 'env env_testing' ) SConscript( 'src/cpput/SConscript', build_dir='#buildscons/cpput', duplicate=0 ) --- 36,47 ---- env_testing = env.Copy( LIBS = ['cpput','opentest'] ) ! ! def buildCppUnitExample( env, taget_sources, target_name ): ! exe = env.Program( target=target_name, ! source=taget_sources ) ! bin_dir='#bin' ! env.Install( bin_dir, exe ) ! ! Export( 'env env_testing buildCppUnitExample' ) SConscript( 'src/cpput/SConscript', build_dir='#buildscons/cpput', duplicate=0 ) *************** *** 43,45 **** --- 50,55 ---- SConscript( 'examples/input_based_test/SConscript', build_dir='#buildscons/examples/input_based_test', duplicate=0 ) SConscript( 'examples/parametrized_test/SConscript', build_dir='#buildscons/examples/parametrized_test', duplicate=0 ) + SConscript( 'examples/checking_assertions/SConscript', build_dir='#buildscons/examples/checking_assertions', duplicate=0 ) + + \ No newline at end of file |
From: Baptiste L. <bl...@us...> - 2005-03-01 22:14:17
|
Update of /cvsroot/cppunit/cppunit2/examples/checking_assertions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14351/checking_assertions Log Message: Directory /cvsroot/cppunit/cppunit2/examples/checking_assertions added to the repository |
From: Baptiste L. <bl...@us...> - 2005-03-01 19:37:16
|
Update of /cvsroot/cppunit/cppunit2/src/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28913/src/cpput Modified Files: testinfo.cpp Log Message: * newAssertion() now takes the assertion type and location as parameter * added checking assertion macros Index: testinfo.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpput/testinfo.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** testinfo.cpp 27 Feb 2005 10:17:05 -0000 1.8 --- testinfo.cpp 1 Mar 2005 19:36:51 -0000 1.9 *************** *** 155,161 **** } ! void newAssertion() { data().newAssertion(); } --- 155,166 ---- } ! void newAssertion( AssertionType type, ! const char *fileName, ! unsigned int lineNumber, ! const char *functionName ) { data().newAssertion(); + data().assertionType_ = type; + data().assertionLocation_ = CompactLocation( fileName, functionName, lineNumber ); } *************** *** 170,180 **** } - void setAssertionLocation( const char *fileName, - unsigned int lineNumber, - const char *functionName ) - { - data().assertionLocation_ = CompactLocation( fileName, functionName, lineNumber ); - } - OpenTest::Properties ¤tAssertion() { --- 175,178 ---- |
From: Baptiste L. <bl...@us...> - 2005-03-01 19:37:16
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28913/include/cpput Modified Files: assert.h testinfo.h Log Message: * newAssertion() now takes the assertion type and location as parameter * added checking assertion macros Index: testinfo.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/testinfo.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** testinfo.h 27 Feb 2005 10:15:41 -0000 1.8 --- testinfo.h 1 Mar 2005 19:36:51 -0000 1.9 *************** *** 67,71 **** OpenTest::PropertiesAccessor CPPUT_API result(); ! void CPPUT_API newAssertion(); void CPPUT_API setAssertionType( AssertionType type ); --- 67,74 ---- OpenTest::PropertiesAccessor CPPUT_API result(); ! void CPPUT_API newAssertion( AssertionType type, ! const char *fileName, ! unsigned int lineNumber, ! const char *functionName = 0 ); void CPPUT_API setAssertionType( AssertionType type ); *************** *** 73,80 **** AssertionType CPPUT_API assertionType(); - void CPPUT_API setAssertionLocation( const char *fileName, - unsigned int lineNumber, - const char *functionName = 0 ); - OpenTest::Properties &CPPUT_API currentAssertion(); OpenTest::Properties &CPPUT_API currentAssertionActual(); --- 76,79 ---- Index: assert.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/assert.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** assert.h 28 Feb 2005 21:36:19 -0000 1.8 --- assert.h 1 Mar 2005 19:36:51 -0000 1.9 *************** *** 112,121 **** ! # define CPPUT_CHECK_POINT() \ ! ::CppUT::TestInfo::newAssertion(), \ ! ::CppUT::TestInfo::setAssertionLocation( __FILE__, __LINE__ ) # define CPPUT_BEGIN_ASSERTION_MACRO() \ ! CPPUT_CHECK_POINT(), --- 112,123 ---- ! # define CPPUT_CHECK_POINT( assertionType ) \ ! ::CppUT::TestInfo::newAssertion( ::CppUT::assertionType, __FILE__, __LINE__) # define CPPUT_BEGIN_ASSERTION_MACRO() \ ! CPPUT_CHECK_POINT( abortingAssertion ), ! ! # define CPPUT_BEGIN_CHECKING_MACRO() \ ! CPPUT_CHECK_POINT( checkingAssertion ), *************** *** 129,153 **** ::CppUT::checkTrue # define CPPUT_ASSERT_EXPR( expression ) \ CPPUT_ASSERT( (expression), #expression ) # define CPPUT_ASSERT_FALSE \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkFalse # define CPPUT_ASSERT_EXPR_FALSE( expression ) \ CPPUT_ASSERT_FALSE( (expression), #expression ) # define CPPUT_ASSERT_EQUAL \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkEquals # define CPPUT_ASSERT_NOT_EQUAL \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkNotEquals ! # define CPPUT_ASSERT_THROW( expression, ExceptionType ) \ do { \ ! CPPUT_CHECK_POINT(); \ bool cpputExceptionThrown_ = false; \ try { \ --- 131,177 ---- ::CppUT::checkTrue + # define CPPUT_CHECK \ + CPPUT_BEGIN_CHECKING_MACRO() \ + ::CppUT::checkTrue + # define CPPUT_ASSERT_EXPR( expression ) \ CPPUT_ASSERT( (expression), #expression ) + # define CPPUT_CHECK_EXPR( expression ) \ + CPPUT_CHECK( (expression), #expression ) + # define CPPUT_ASSERT_FALSE \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkFalse + # define CPPUT_CHECK_FALSE \ + CPPUT_BEGIN_CHECKING_MACRO() \ + ::CppUT::checkFalse + # define CPPUT_ASSERT_EXPR_FALSE( expression ) \ CPPUT_ASSERT_FALSE( (expression), #expression ) + # define CPPUT_CHECK_EXPR_FALSE( expression ) \ + CPPUT_CHECK_FALSE( (expression), #expression ) + # define CPPUT_ASSERT_EQUAL \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkEquals + # define CPPUT_CHECK_EQUAL \ + CPPUT_BEGIN_CHECKING_MACRO() \ + ::CppUT::checkEquals + # define CPPUT_ASSERT_NOT_EQUAL \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkNotEquals ! # define CPPUT_CHECK_NOT_EQUAL \ ! CPPUT_BEGIN_CHECKING_MACRO() \ ! ::CppUT::checkNotEquals ! ! # define _CPPUT_ASSERT_THROW_IMPL( assertionType, expression, ExceptionType ) \ do { \ ! CPPUT_CHECK_POINT( assertionType ); \ bool cpputExceptionThrown_ = false; \ try { \ *************** *** 164,169 **** } while ( false ) ! # define CPPUT_ASSERT_NO_THROW( expression ) \ try { \ expression; \ } catch ( const std::exception &e ) { \ --- 188,200 ---- } while ( false ) ! # define CPPUT_ASSERT_THROW( expression, ExceptionType ) \ ! _CPPUT_ASSERT_THROW_IMPL( abortingAssertion, expression, ExceptionType ) ! ! # define CPPUT_CHECK_THROW( expression, ExceptionType ) \ ! _CPPUT_CHECK_THROW_IMPL( checkingAssertion, expression, ExceptionType ) ! ! # define _CPPUT_ASSERT_NO_THROW_IMPL( assertionType, expression ) \ try { \ + CPPUT_CHECK_POINT( assertionType ); \ expression; \ } catch ( const std::exception &e ) { \ *************** *** 177,180 **** --- 208,218 ---- } + # define CPPUT_ASSERT_NO_THROW( expression ) \ + _CPPUT_ASSERT_NO_THROW_IMPL( abortingAssertion, expression ) + + # define CPPUT_CHECK_NO_THROW( expression ) \ + _CPPUT_ASSERT_NO_THROW_IMPL( checkingAssertion, expression ) + + // Notes: implementing that assertion checking is a bit tricky since all the state // about the current test/assertions is stored in a "static" and *************** *** 184,191 **** // context for the tested assertion. After the assertion, the // result of the assertion (did it failed), and the test result ! // properties are captured for later introspection. ! # define CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE( assertion, message ) \ { \ ! CPPUT_CHECK_POINT(); \ OpenTest::Properties result; \ bool assertionFailed = false; \ --- 222,229 ---- // context for the tested assertion. After the assertion, the // result of the assertion (did it failed), and the test result ! // properties are captured for later inspection. ! # define _CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE_IMPL( assertionType, assertion, message ) \ { \ ! CPPUT_CHECK_POINT( assertionType ); \ OpenTest::Properties result; \ bool assertionFailed = false; \ *************** *** 203,212 **** } ! # define CPPUT_ASSERT_ASSERTION_FAIL( assertion ) \ CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE( assertion, ::CppUT::Message() ) ! # define CPPUT_ASSERT_ASSERTION_PASS_MESSAGE( assertion, message ) \ { \ ! CPPUT_CHECK_POINT(); \ OpenTest::Properties result; \ bool assertionFailed = false; \ --- 241,259 ---- } ! # define CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE( assertion, message ) \ ! _CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE_IMPL( abortingAssertion, assertion, message ) ! ! # define CPPUT_CHECK_ASSERTION_FAIL_MESSAGE( assertion, message ) \ ! _CPPUT_CHECK_ASSERTION_FAIL_MESSAGE_IMPL( checkingAssertion, assertion, message ) ! ! # define CPPUT_ASSERT_ASSERTION_FAIL( assertion ) \ CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE( assertion, ::CppUT::Message() ) ! # define CPPUT_CHECK_ASSERTION_FAIL( assertion ) \ ! CPPUT_CHECK_ASSERTION_FAIL_MESSAGE( assertion, ::CppUT::Message() ) ! ! # define _CPPUT_ASSERT_ASSERTION_PASS_MESSAGE_IMPL( assertionType, assertion, message ) \ { \ ! CPPUT_CHECK_POINT( assertionType ); \ OpenTest::Properties result; \ bool assertionFailed = false; \ *************** *** 224,230 **** --- 271,286 ---- } + # define CPPUT_ASSERT_ASSERTION_PASS_MESSAGE( assertion, message ) \ + _CPPUT_ASSERT_ASSERTION_PASS_MESSAGE_IMPL( abortingAssertion, assertion, message ) + + # define CPPUT_CHECK_ASSERTION_PASS_MESSAGE( assertion, message ) \ + _CPPUT_CHECK_ASSERTION_PASS_MESSAGE_IMPL( checkingAssertion, assertion, message ) + # define CPPUT_ASSERT_ASSERTION_PASS( assertion ) \ CPPUT_ASSERT_ASSERTION_PASS_MESSAGE( assertion, ::CppUT::Message() ) + # define CPPUT_CHECK_ASSERTION_PASS( assertion ) \ + CPPUT_CHECK_ASSERTION_PASS_MESSAGE( assertion, ::CppUT::Message() ) + #endif // CPPUT_ASSERT_H_INCLUDED |
From: Baptiste L. <bl...@us...> - 2005-02-28 22:31:47
|
Update of /cvsroot/cppunit/cppunit2/src/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6062/src/cpput Modified Files: testrunner.cpp Log Message: * fixed propagation of test input. Index: testrunner.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpput/testrunner.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** testrunner.cpp 21 Nov 2004 22:24:46 -0000 1.8 --- testrunner.cpp 28 Feb 2005 22:31:37 -0000 1.9 *************** *** 139,142 **** --- 139,143 ---- TestInfo::startNewTest(); TestInfo::mergeInResult( configuration ); + TestInfo::mergeInResult( entry.configuration() ); if ( itTest == tests_.end() ) // protocol error => unknown test { |