[pygccxml-commit] SF.net SVN: pygccxml: [41] pyplusplus_dev/examples/pyboost_dev/pyboost
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-05-02 04:55:13
|
Revision: 41 Author: roman_yakovenko Date: 2006-05-01 21:54:58 -0700 (Mon, 01 May 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=41&view=rev Log Message: ----------- adding new unit tests/package from boost - random Added Paths: ----------- pyplusplus_dev/examples/pyboost_dev/pyboost/random/ pyplusplus_dev/examples/pyboost_dev/pyboost/random/generate_code.py pyplusplus_dev/examples/pyboost_dev/pyboost/random/generated/ pyplusplus_dev/examples/pyboost_dev/pyboost/random/sconstruct pyplusplus_dev/examples/pyboost_dev/pyboost/random/settings.py Added: pyplusplus_dev/examples/pyboost_dev/pyboost/random/generate_code.py =================================================================== --- pyplusplus_dev/examples/pyboost_dev/pyboost/random/generate_code.py (rev 0) +++ pyplusplus_dev/examples/pyboost_dev/pyboost/random/generate_code.py 2006-05-02 04:54:58 UTC (rev 41) @@ -0,0 +1,97 @@ +#! /usr/bin/python +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + + +import os +import sys +import time +import shutil +import settings +from pygccxml import parser +from pygccxml import declarations +from pyplusplus import code_creators +from pyplusplus import module_builder + +LICENSE = """// Copyright 2004 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +""" + +class code_generator_t(object): + def __init__(self): + self.__file = os.path.join( settings.boost.include + , 'libs', 'random', 'random_test.cpp' ) + self.__mb = module_builder.module_builder_t( + [ parser.create_cached_source_fc( + self.__file + , os.path.join( settings.generated_files_dir, 'random_test.xml' ) ) ] + , gccxml_path=settings.gccxml.executable + , include_paths=[settings.boost.include] + , undefine_symbols=settings.undefined_symbols) + + def filter_declarations(self ): + self.__mb.global_ns.exclude() + boost_ns = self.__mb.global_ns.namespace( 'boost', recursive=False ) + boost_ns.namespace( 'random' ).include() + boost_ns.namespaces( 'detail' ).exclude() + for cls in boost_ns.namespace( 'random' ).classes(): + if cls.ignore: + continue + else: + aliases = set([ t.name for t in cls.typedefs ]) + for alias in [ 'engine_value_type', 'value_type', 'base_type', 'engine_type' ]: + if alias in aliases: + aliases.remove( alias ) + if len( aliases ) == 1: + cls.alias = list( aliases )[0] + else: + print cls.name + for t in aliases: + print ' ', t + + boost_ns.free_functions( "lessthan_signed_unsigned" ).exclude() + boost_ns.free_functions( "equal_signed_unsigned" ).exclude() + + def beautify_code( self ): + extmodule = self.__mb.code_creator + position = extmodule.last_include_index() + 1 + extmodule.adopt_creator( code_creators.namespace_using_t( 'boost' ) + , position ) + + def customize_extmodule( self ): + global LICENSE + extmodule = self.__mb.code_creator + #beautifying include code generation + extmodule.license = LICENSE + extmodule.user_defined_directories.append( settings.boost.include ) + extmodule.user_defined_directories.append( settings.working_dir ) + extmodule.user_defined_directories.append( settings.generated_files_dir ) + extmodule.precompiled_header = 'boost/python.hpp' + self.beautify_code( ) + + def write_files( self ): + self.__mb.write_module( os.path.join( settings.generated_files_dir, 'random.pypp.cpp' ) ) + + def create(self): + start_time = time.clock() + self.filter_declarations() + + self.__mb.build_code_creator( settings.module_name ) + + self.customize_extmodule() + self.write_files( ) + print 'time taken : ', time.clock() - start_time, ' seconds' + +def export(): + cg = code_generator_t() + cg.create() + +if __name__ == '__main__': + export() + print 'done' + + Added: pyplusplus_dev/examples/pyboost_dev/pyboost/random/sconstruct =================================================================== --- pyplusplus_dev/examples/pyboost_dev/pyboost/random/sconstruct (rev 0) +++ pyplusplus_dev/examples/pyboost_dev/pyboost/random/sconstruct 2006-05-02 04:54:58 UTC (rev 41) @@ -0,0 +1,54 @@ +#! /usr/bin/python +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import os +import sys +from environment import settings + +def get_shlibsuffix(): + if sys.platform == 'win32': + return '.pyd' + else: + return '.so' + +def get_ccflags(): + if sys.platform == 'win32': + return [ '/MD' + , '/EHsc' + , '/GR' + , '/Zc:wchar_t' + , '/Zc:forScope' + , '/GR' ] \ + + map( lambda ds: '/D%s' % ds, settings.defined_symbols ) + else: + return map( lambda ds: '-D' + ds, settings.defined_symbols ) + +def get_py_date_time_files(): + source_files = filter( lambda s: s.endswith( '.cpp' ), os.listdir(settings.generated_files_dir) ) + return map( lambda fname: os.path.join( settings.generated_files_dir, fname ), source_files ) + +def get_libs(): + if sys.platform == 'win32': + return ['boost_python' ] #python24.lib + else: + return ['boost_python', 'libboost_date_time-gcc-1_34'] + +def get_target(): + return os.path.join( settings.unittests_dir + , settings.module_name + get_shlibsuffix() ) + +SharedLibrary( target=get_target() + , source=get_py_date_time_files() + , LIBS=get_libs() + , LIBPATH=[ settings.boost_libs_path, settings.python_libs_path ] + , CPPPATH=[ settings.boost_path + , settings.working_dir + , settings.python_include_path + , settings.generated_files_dir ] + , CCFLAGS=get_ccflags() + , SHLIBPREFIX='' + , SHLIBSUFFIX=get_shlibsuffix() +) Added: pyplusplus_dev/examples/pyboost_dev/pyboost/random/settings.py =================================================================== --- pyplusplus_dev/examples/pyboost_dev/pyboost/random/settings.py (rev 0) +++ pyplusplus_dev/examples/pyboost_dev/pyboost/random/settings.py 2006-05-02 04:54:58 UTC (rev 41) @@ -0,0 +1,25 @@ +#! /usr/bin/python +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import os +import sys + +_script_dir = os.path.split( os.path.abspath( sys.argv[0] ) )[0] +environment_path = os.path.normpath( os.path.join( _script_dir, '..', '..', '..', '..' ) ) + +sys.path.append( environment_path ) + +from environment import boost, scons, gccxml + +module_name = '_random_' +working_dir = _script_dir +generated_files_dir = os.path.join( _script_dir, 'generated' ) +unittests_dir = os.path.join( _script_dir, '..', '..', 'unittests', 'random' ) + +undefined_symbols = [ '__MINGW32__' ] +#defined_symbols = ['BOOST_DATE_TIME_NO_MEMBER_INIT'] +#if sys.platform == 'win32': + #defined_symbols.extend( [ 'BOOST_DATE_TIME_DYN_LINK' ] ) \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |