[pygccxml-commit] SF.net SVN: pygccxml: [935] pyplusplus_dev/unittests
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2007-02-26 21:44:32
|
Revision: 935 http://svn.sourceforge.net/pygccxml/?rev=935&view=rev Author: roman_yakovenko Date: 2007-02-26 13:44:29 -0800 (Mon, 26 Feb 2007) Log Message: ----------- adding initial support for str( self ) ( operator<< ) support Modified Paths: -------------- pyplusplus_dev/unittests/data/operators_to_be_exported.hpp pyplusplus_dev/unittests/operators_tester.py Modified: pyplusplus_dev/unittests/data/operators_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/operators_to_be_exported.hpp 2007-02-26 21:43:00 UTC (rev 934) +++ pyplusplus_dev/unittests/data/operators_to_be_exported.hpp 2007-02-26 21:44:29 UTC (rev 935) @@ -26,6 +26,23 @@ } }; +struct XXX{ + friend std::ostream& operator<<(std::ostream& s, XXX const& x); +}; + +inline std::ostream& operator<<(std::ostream& s, XXX const& x){ + return s << "<XXX instance at " << &x << ">"; +} + +//Boost.Python does not support member operator<< +struct YYY{ + std::ostream& operator<<(std::ostream& s) const{ + return s; + //return s << "<YYY instance at " << reinterpret_cast<unsigned long>( this )<< ">"; + } +}; + + } } Modified: pyplusplus_dev/unittests/operators_tester.py =================================================================== --- pyplusplus_dev/unittests/operators_tester.py 2007-02-26 21:43:00 UTC (rev 934) +++ pyplusplus_dev/unittests/operators_tester.py 2007-02-26 21:44:29 UTC (rev 935) @@ -7,6 +7,7 @@ import sys import unittest import fundamental_tester_base +from pygccxml import declarations from pyplusplus.module_builder import call_policies class tester_t(fundamental_tester_base.fundamental_tester_base_t): @@ -20,6 +21,14 @@ def customize( self, mb ): mb.global_ns.exclude() + + xxx = mb.class_( 'XXX' ) + xxx.include() + xxx_ref = declarations.reference_t( declarations.const_t( declarations.declarated_t( xxx ) ) ) + oper = mb.global_ns.free_operator( '<<', arg_types=[None, xxx_ref] ) + oper.include() + + mb.class_( 'YYY' ).include() rational = mb.class_('rational<long>') rational.include() @@ -78,7 +87,13 @@ r1 = pyrational( 5, 7 ) self.failUnless( r1.assign( 17 ) == pyrational( 17, 1 ) ) + + x = module.XXX() + print str( x ) + y = module.YYY() + print str( y ) + def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |