Пример #1
0
    def __init__(self):
        self.__file = os.path.join(random_settings.working_dir,
                                   'random_export.hpp')
        self.__mb = module_builder.module_builder_t(
            [
                parser.create_cached_source_fc(
                    self.__file,
                    os.path.join(random_settings.generated_files_dir,
                                 'random.xml'))
            ],
            gccxml_path=random_settings.gccxml.executable,
            include_paths=[random_settings.boost.include],
            define_symbols=random_settings.defined_symbols,
            undefine_symbols=random_settings.undefined_symbols,
            indexing_suite_version=2)
        self.generators = [
            "ecuyer1988", "hellekalek1995", "kreutzer1986",
            "lagged_fibonacci1279", "lagged_fibonacci19937",
            "lagged_fibonacci2281", "lagged_fibonacci23209",
            "lagged_fibonacci3217", "lagged_fibonacci4423",
            "lagged_fibonacci44497", "lagged_fibonacci607",
            "lagged_fibonacci9689", "minstd_rand", "minstd_rand0", "mt11213b",
            "mt19937", "ranlux3", "ranlux3_01", "ranlux4", "ranlux4_01",
            "ranlux64_3_01", "ranlux64_4_01", "taus88"
        ]

        self.no_min_max = [
            'py_cauchy_distribution', 'py_bernoulli_distribution',
            'py_binomial_distribution', 'py_poisson_distribution',
            'py_normal_distribution', 'py_gamma_distribution',
            'py_triangle_distribution', 'py_uniform_on_sphere',
            'py_exponential_distribution', 'py_geometric_distribution',
            'py_lognormal_distribution'
        ]
Пример #2
0
def create_module():
    parser_config = parser.config_t( )

    fx_xml = os.path.join( settings.xml_files, 'fx.xml' )
    mb = module_builder.module_builder_t( [ parser.create_cached_source_fc( 'fx.h', fx_xml ) ]
                                          , gccxml_path=settings.gccxml_path
                                          , include_paths=[settings.boost_path, settings.tnfox_include_path]
                                          , define_symbols=settings.defined_symbols_gccxml )
    mb.run_query_optimizer()
    print 'filtering declarations'
    filter_decls( mb )
    print 'filtering declarations - done'
    print 'set call policies'
    set_call_policies( mb )
    print 'set call policies - done'
    print 'customize declarations'
    customize_decls( mb )
    print 'customize declarations - done'
    print 'creating module'
    mb.build_code_creator(settings.module_name )
    print 'creating module - done'
    print 'customizing module'
    customize_module( mb )
    print 'customizing module - done'
    return mb
Пример #3
0
def generate_code():

    code_tree = parser.create_cached_source_fc(
        os.path.join(root_dir, "Engine.h"), "BootCache.xml")

    defined_symbols = ['B_NO_INTERLOCKED_INTRINSICS']

    include_dirs = [
        os.path.join(root_dir, "..", "..", "..", "Engine", "Common"),
        os.path.join(root_dir, "..", "..", "..", "Engine", "Graphics"),
        os.path.join(root_dir, "..", "..", "..", "Engine", "FileSystem")
    ]

    mb = module_builder.module_builder_t([code_tree],
                                         gccxml_path=gccxml_bin,
                                         working_directory=root_dir,
                                         include_paths=include_dirs,
                                         define_symbols=defined_symbols,
                                         undefine_symbols=[],
                                         indexing_suite_version=2,
                                         cflags='')

    #ns = mb.global_ns
    #ns.exclude()

    return mb
Пример #4
0
    def __init__(self):
        self.__file = os.path.join(crc_settings.working_dir, "crc_export.hpp")

        self.__mb = module_builder.module_builder_t(
            [parser.create_cached_source_fc(self.__file, os.path.join(crc_settings.generated_files_dir, "crc.xml"))],
            gccxml_path=crc_settings.gccxml.executable,
            include_paths=[crc_settings.boost.include],
            define_symbols=crc_settings.defined_symbols,
            undefine_symbols=crc_settings.undefined_symbols,
            indexing_suite_version=2,
        )
Пример #5
0
    def __init__(self):
        self.__file = os.path.join(crc_settings.working_dir, 'crc_export.hpp')

        self.__mb = module_builder.module_builder_t(
            [
                parser.create_cached_source_fc(
                    self.__file,
                    os.path.join(crc_settings.generated_files_dir, 'crc.xml'))
            ],
            gccxml_path=crc_settings.gccxml.executable,
            include_paths=[crc_settings.boost.include],
            define_symbols=crc_settings.defined_symbols,
            undefine_symbols=crc_settings.undefined_symbols,
            indexing_suite_version=2)
Пример #6
0
 def __init__(self):
     self.__file = os.path.join( random_settings.working_dir, 'random_export.hpp' )
     self.__mb = module_builder.module_builder_t( 
                     [ parser.create_cached_source_fc( 
                         self.__file
                         , os.path.join( random_settings.generated_files_dir, 'random.xml' ) ) ]
                     , gccxml_path=random_settings.gccxml.executable
                     , include_paths=[random_settings.boost.include]
                     , define_symbols=random_settings.defined_symbols
                     , undefine_symbols=random_settings.undefined_symbols
                     , indexing_suite_version=2)
     self.generators = [   "ecuyer1988"
                           , "hellekalek1995"
                           , "kreutzer1986"
                           , "lagged_fibonacci1279"
                           , "lagged_fibonacci19937"
                           , "lagged_fibonacci2281"
                           , "lagged_fibonacci23209"
                           , "lagged_fibonacci3217"
                           , "lagged_fibonacci4423"
                           , "lagged_fibonacci44497"
                           , "lagged_fibonacci607"
                           , "lagged_fibonacci9689"
                           , "minstd_rand"
                           , "minstd_rand0"
                           , "mt11213b"
                           , "mt19937"
                           , "ranlux3"
                           , "ranlux3_01"
                           , "ranlux4"
                           , "ranlux4_01"
                           , "ranlux64_3_01"
                           , "ranlux64_4_01"
                           , "taus88" ]
 
     self.no_min_max = [ 'py_cauchy_distribution'
                         , 'py_bernoulli_distribution'
                         , 'py_binomial_distribution'
                         , 'py_poisson_distribution'
                         , 'py_normal_distribution'
                         , 'py_gamma_distribution'
                         , 'py_triangle_distribution'
                         , 'py_uniform_on_sphere'
                         , 'py_exponential_distribution'
                         , 'py_geometric_distribution'
                         , 'py_lognormal_distribution'
                         ]
Пример #7
0
    def __init__(self):      
        self.__file = os.path.join( rational_settings.working_dir, 'rational_export.hpp' )
        
        self.__mb = module_builder.module_builder_t( 
                        [ parser.create_cached_source_fc( 
                            self.__file
                            , os.path.join( rational_settings.generated_files_dir, 'rational.xml' ) ) ]
                        , gccxml_path=rational_settings.gccxml.executable
                        , include_paths=[rational_settings.boost.include]
                        , define_symbols=rational_settings.defined_symbols
                        , undefine_symbols=rational_settings.undefined_symbols
                        , optimize_queries=False
                        , indexing_suite_version=2 )
        
        for f_decl in self.__mb.free_functions():
            f_decl.alias = f_decl.name
            f_decl.name = f_decl.demangled_name

        self.__mb.run_query_optimizer()
Пример #8
0
    def __init__(self):
        self.__file = os.path.join(rational_settings.working_dir,
                                   'rational_export.hpp')

        self.__mb = module_builder.module_builder_t(
            [
                parser.create_cached_source_fc(
                    self.__file,
                    os.path.join(rational_settings.generated_files_dir,
                                 'rational.xml'))
            ],
            gccxml_path=rational_settings.gccxml.executable,
            include_paths=[rational_settings.boost.include],
            define_symbols=rational_settings.defined_symbols,
            undefine_symbols=rational_settings.undefined_symbols,
            optimize_queries=False,
            indexing_suite_version=2)

        for f_decl in self.__mb.free_functions():
            f_decl.alias = f_decl.name
            f_decl.name = f_decl.demangled_name

        self.__mb.run_query_optimizer()
Пример #9
0
from pygccxml import declarations
from pyplusplus import messages
from pyplusplus import module_builder
from pyplusplus import decl_wrappers

from pyplusplus import function_transformers as ft
from pyplusplus.module_builder import call_policies
from pyplusplus.creators_factory import sort_algorithms

import common_utils.extract_documentation as exdoc
import common_utils.var_checker as varchecker
import common_utils.ogre_properties as ogre_properties


xml_cached_fc = parser.create_cached_source_fc(
                    os.path.join( environment.ogre.root_dir, "python_ogre.h" )
                    , environment.ogre.cache_file )

defined_symbols = [ 'OGRE_NONCLIENT_BUILD' ]
defined_symbols.append( 'OGRE_VERSION_' + environment.ogre.version )  

mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                      , gccxml_path=environment.gccxml_bin
                                      , working_directory=environment.root_dir
                                      , include_paths=environment.ogre.include_dirs
                                      , define_symbols=defined_symbols
                                      , indexing_suite_version=2
                                       )
mb.BOOST_PYTHON_MAX_ARITY = 25
mb.classes().always_expose_using_scope = True
Пример #10
0
def generate_code():

	#
	# Use GCCXML to create the controlling XML file.
	# If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
	# NOTE: If you update the source library code you need to manually delete the cache .XML file
	#
	#parser_conf = parser.project_reader.file_configuration_t( start_with_declarations=environment.namespaces )
	defined_symbols = []  
	undefine_symbols = []

	xml_cached_fc = parser.create_cached_source_fc(
			os.path.join( environment.root_dir, "python_Cream.h" )
			, environment.cache_file
			)
	mb = module_builder.module_builder_t(
			[ xml_cached_fc ]
			, working_directory=environment.root_dir
			, include_paths=environment.include_dirs
			, define_symbols=defined_symbols
			, undefine_symbols=undefine_symbols
			, indexing_suite_version=2
			)

	# Register boost::tuples
	mb.add_registration_code( 'boost::python::register_tuple< boost::tuple<glite::ce::cream_client_api::soap_proxy::JobIdWrapper::RESULT, glite::ce::cream_client_api::soap_proxy::JobIdWrapper, std::string>  >();' );
	mb.add_registration_code( 'boost::python::register_tuple< boost::tuple<glite::ce::cream_client_api::soap_proxy::JobStatusWrapper::RESULT, glite::ce::cream_client_api::soap_proxy::JobStatusWrapper, std::string> >();' );
	mb.add_registration_code( 'boost::python::register_tuple< boost::tuple<glite::ce::cream_client_api::soap_proxy::JobInfoWrapper::RESULT, glite::ce::cream_client_api::soap_proxy::JobInfoWrapper, std::string> >();' );

	# Expose classes
	mb.classes( lambda cls: cls.name in environment.classes ).include()
        # Expose enumerations
	mb.enumerations( lambda cls: cls.name in environment.enumerations ).include()
        # Expose functions
        mb.free_funs( lambda fun: fun.name in environment.functions ).include()

	# Exclude all protected functions
	mb.calldefs( access_type_matcher_t( 'protected' ) ).exclude()

	# Exclude some functions
	# I think it's a quite new function (even not yet documented, so no idea which params are in/out)
	mb.class_( 'CreamProxyFactory' ).mem_fun( 'make_CreamProxy_QueryEvent' ).exclude()

	# Take care of call policies for some functions
	# CreamProxyFactory
	mb.class_( name='CreamProxyFactory' ).member_functions( lambda decl: decl.name.startswith( 'make_CreamProxy' ) ).call_policies = call_policies.return_value_policy( call_policies.manage_new_object )

	# Translate exceptions
	for ex in environment.exception_classes:
		exception = mb.class_( ex )
		exception.translate_exception_to_string( ex, 'exc.what()')

	# Function transformations

	# JobPropertyWrapper has protected operator=
	mb.class_( 'JobPropertyWrapper' ).noncopyable = True

	# Temporarily disable some warnings (messages showed by py++ below)

	# Well, don't you want to see what is going on?
	#	mb.print_declarations()

	#def my_doc_extractor( decl ):
		#	print decl.location.file_name + str( decl.location.line )
		#	return decl.location.file_name + str( decl.location.line )

	# Creating code creator. After this step you should not modify/customize declarations.
	# Additionaly extract Doxygen like documentation
	#mb.build_code_creator( module_name='Cream', doc_extractor=doxygen.doxygen_doc_extractor() )
	mb.build_code_creator( module_name='Cream' )
	#mb.build_code_creator( module_name='Cream', doc_extractor=my_doc_extractor )


	mb.code_creator.add_include( 'pyplusplus_converters/tuples.hpp' )
	mb.code_creator.precompiled_header = 'boost/python.hpp'

	# It is common requirement in software world - each file should have license
	mb.code_creator.license = '// GPLv3 License'

	# I don't want absolute includes within code
	mb.code_creator.user_defined_directories.append( os.path.abspath('.') )


	# Writing code to file.
	mb.write_module( "Cream.cpp" )
Пример #11
0
def generate_code():  
#     messages.disable( 
# #           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
#           messages.W1020
#         , messages.W1021
#         , messages.W1022
#         , messages.W1023
#         , messages.W1024
#         , messages.W1025
#         , messages.W1026
#         , messages.W1027
#         , messages.W1028
#         , messages.W1029
#         , messages.W1030
#         , messages.W1031
#         , messages.W1035
#         , messages.W1040 
#         , messages.W1038 
#         , messages.W1039       
#         , messages.W1041
#         , messages.W1036 # pointer to Python immutable member
#         , messages.W1033 # unnamed variables
#         , messages.W1018 # expose unnamed classes
#         , messages.W1049 # returns reference to local variable
#         , messages.W1014 # unsupported '=' operator
#          )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.navi.root_dir, "python_navi.h" )
                        , environment.navi.cache_file )

    defined_symbols = [ 'OGRE_NONCLIENT_BUILD', 'OGRE_GCC_VISIBILITY', 
                    'NAVI_DYNAMIC_LIB', 
                    '__VECTOR_C','_WIN32']
    
    if environment._USE_THREADS:
        defined_symbols.append('BOOST_HAS_THREADS')
        defined_symbols.append('BOOST_HAS_WINTHREADS')
    defined_symbols.append( 'VERSION_' + environment.navi.version )  
    
    undefined_symbols = []
    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.navi.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.navi.cflags
#                                           , undefine_symbols = undefined_symbols
                                           )
    # NOTE THE CHANGE HERE                                           
    mb.constructors().allow_implicit_conversion = False                                           
    mb.register_module_dependency ( environment.ogre.generated_dir )
 
    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
        
    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    # 
    global_ns = mb.global_ns
    global_ns.exclude()
    main_ns = global_ns.namespace( MAIN_NAMESPACE )
    main_ns.include()
    
    
    common_utils.AutoExclude ( mb, MAIN_NAMESPACE )
    ManualExclude ( mb )
    common_utils.AutoInclude ( mb, MAIN_NAMESPACE )
    ManualInclude ( mb )
    
    # here we fixup functions that expect to modifiy their 'passed' variables and are not autmatically fixed  
    ManualTransformations ( mb )
    
    AutoFixes ( mb, MAIN_NAMESPACE )
    ManualFixes ( mb )
    
    common_utils.Auto_Functional_Transformation ( main_ns, special_vars=['::Ogre::Real &','::Ogre::ushort &','size_t &'] )
    
    
             
    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    Set_Call_Policies ( mb.global_ns )
    
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    NoPropClasses = [""]
    for cls in main_ns.classes():
        if cls.name not in NoPropClasses:
            cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
            
                                          
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.navi )
    
    
    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    extractor = exdoc.doc_extractor("") # I'm excluding the UTFstring docs as lots about nothing 
    mb.build_code_creator (module_name='_navi_' , doc_extractor= extractor )
    
    for inc in environment.navi.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.navi.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.navi.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.navi.version ) )

    mb.split_module(environment.navi.generated_dir, huge_classes,use_files_sum_repository=False)

    ## now we need to ensure a series of headers and additional source files are
    ## copied to the generaated directory..
    additional_files = []
    paths = []

    for p in paths:
        additional_files = os.listdir(p)
        for f in additional_files:
            if f.endswith('cpp') or f.endswith('.h'):
                sourcefile = os.path.join(p, f)
                destfile = os.path.join(environment.navi.generated_dir, f ) 
        
                if not common_utils.samefile( sourcefile ,destfile ):
                    shutil.copy( sourcefile, environment.navi.generated_dir )
                    print "Updated ", f, "as it was missing or out of date"        
Пример #12
0
def generate_code():
#     messages.disable( 
# #           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
#           messages.W1020
#         , messages.W1021
#         , messages.W1022
#         , messages.W1023
#         , messages.W1024
#         , messages.W1025
#         , messages.W1026
#         , messages.W1027
#         , messages.W1028
#         , messages.W1029
#         , messages.W1030
#         , messages.W1031
#         , messages.W1035
# #         , messages.W1040 
# #         , messages.W1038        
#         , messages.W1041
#         , messages.W1036 # pointer to Python immutable member
#         , messages.W1033 # unnamed variables
#         , messages.W1018 # expose unnamed classes
# #         , messages.W1049 # returns reference to local variable
#         , messages.W1014 # unsupported '=' operator
#          )
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.cegui.root_dir, "python_CEGUI.h" )
                        , environment.cegui.cache_file )
                        
    defined_symbols = [ 'OGRE_NONCLIENT_BUILD', 'CEGUI_NONCLIENT_BUILD','OGRE_GCC_VISIBILITY','__PYTHONOGRE_BUILD_CODE',
                        'OGRE_GUIRENDERER_EXPORTS']
    defined_symbols.append( 'VERSION_' + environment.cegui.version.replace ('.','_')   )

    if environment._USE_THREADS:
        defined_symbols.append('BOOST_HAS_THREADS')
        defined_symbols.append('BOOST_HAS_WINTHREADS')

    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.cegui.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.ogre.cflags
                                          )
    # if this module depends on another set it here                                           
    mb.register_module_dependency ( environment.ogre.generated_dir )
                                          
    filter_declarations (mb)
                                          
    ns=mb.global_ns.namespace ('CEGUI')                                      
    print "\n\n"
    c=ns.class_('::CEGUI::Checkbox')
    for f in c.member_functions():
        print "LENGTH ", len( ns.member_functions(f.name ) ), "for ", f.name
        for c in ns.member_functions(f.name ):
           print "==:", c.decl_string
        print f.decl_string  
# #     sys.exit()
    
                                            
   
    change_cls_alias( mb.global_ns.namespace ('CEGUI') )

    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
    
    mb.class_('::CEGUI::EventSet').member_functions('subscribeEvent').exclude()
#     mb.class_('::CEGUI::Scrollbar').member_functions('subscribeEvent').exclude()
    
    configure_exception( mb )

    hand_made_wrappers.apply( mb )

    set_call_policies (mb)
    for cls in mb.global_ns.namespace ('CEGUI').classes():
        cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t()  )
        common_utils.add_LeadingLowerProperties ( cls )
        
    v=mb.global_ns.namespace ('CEGUI') .class_('ScriptModule').variable('d_identifierString')
    print "INCLUDE:", v
    v.include()   
    print "DONE" 
                                      
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.cegui )
    
    #Creating code creator. After this step you should not modify/customize declarations.
    extractor = exdoc.doc_extractor("")
    
    mb.build_code_creator (module_name='_cegui_', doc_extractor= extractor)
    print "VARIABLE exportable:", v.exportable
    
    for incs in environment.cegui.include_dirs:
        mb.code_creator.user_defined_directories.append( incs )
    mb.code_creator.user_defined_directories.append( environment.cegui.generated_dir )
    
#     mb.code_creator.replace_included_headers( customization_data.header_files(environment.cegui.version) )
    ## we need to remove the previous one
    lastc = mb.code_creator.creators[ mb.code_creator.last_include_index() ]
    mb.code_creator.remove_creator( lastc )  
    # and now add our precompiled ones..
    for x in range (len (customization_data.header_files( environment.cegui.version ) ), 0 ,-1 ):
        h = customization_data.header_files( environment.cegui.version )[x-1]        
        mb.code_creator.adopt_creator ( include.include_t ( header= h ), 0)


    huge_classes = map( mb.class_, customization_data.huge_classes(environment.cegui.version) )
    mb.split_module(environment.cegui.generated_dir, huge_classes)
Пример #13
0
def generate_code():  
#     messages.disable( 
# #           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
#           messages.W1020
#         , messages.W1021
#         , messages.W1022
#         , messages.W1023
#         , messages.W1024
#         , messages.W1025
#         , messages.W1026
#         , messages.W1027
#         , messages.W1028
#         , messages.W1029
#         , messages.W1030
#         , messages.W1031
#         , messages.W1035
#         , messages.W1040 
#         , messages.W1038 
#         , messages.W1039       
#         , messages.W1041
#         , messages.W1036 # pointer to Python immutable member
#         , messages.W1033 # unnamed variables
#         , messages.W1018 # expose unnamed classes
#         , messages.W1049 # returns reference to local variable
#         , messages.W1014 # unsupported '=' operator
#          )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.theora.root_dir, "python_theora.h" )
                        , environment.theora.cache_file )

    defined_symbols = [ 'THEORAVIDEO_PLUGIN_EXPORTS','OGRE_NONCLIENT_BUILD', 'OGRE_GCC_VISIBILITY','__PYTHONOGRE_BUILD_CODE']
    if os.name == 'nt':
        defined_symbols.append ( 'WIN32' )
    if environment._USE_THREADS:
        defined_symbols.append('BOOST_HAS_THREADS')
        defined_symbols.append('BOOST_HAS_WINTHREADS')
    defined_symbols.append( 'VERSION_' + environment.theora.version )  
    
    undefined_symbols = []
    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.theora.include_dirs
                                          , define_symbols=defined_symbols
# #                                           , undefine_symbols = undefined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.ogre.cflags
                                           )
    # if this module depends on another set it here                                           
    mb.register_module_dependency ( environment.ogre.generated_dir )

    # NOTE THE CHANGE HERE                                           
    mb.constructors().allow_implicit_conversion = False                                           
    
    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
    
        
    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    # 
    global_ns = mb.global_ns
    global_ns.exclude()
    main_ns = global_ns.namespace( MAIN_NAMESPACE )
    main_ns.exclude()   ## Note we exclude so we don't get the ogre stuff
    
   
    AutoExclude ( mb )
    AutoInclude ( mb )
    ManualInclude ( mb )
    ManualExclude ( mb )
    # here we fixup functions that expect to modifiy their 'passed' variables    
    ManualTransformations ( mb )
    
    AutoFixes ( mb )
    ManualFixes ( mb )
            
    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    Set_Call_Policies ( mb.global_ns.namespace (MAIN_NAMESPACE) )
    c = main_ns.class_('::Ogre::ExternalTextureSource' ).include(already_exposed=True)
        
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    NoPropClasses = [""]
    for cls in main_ns.classes():
        if cls.name not in NoPropClasses:
            cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
            
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.theora )
    
    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    extractor = exdoc.doc_extractor("")  
    mb.build_code_creator (module_name='_theora_' , doc_extractor= extractor )
    
    for inc in environment.theora.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.theora.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.theora.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.theora.version ) )

    mb.split_module(environment.theora.generated_dir, huge_classes,use_files_sum_repository=False)

    ## now we need to ensure a series of headers and additional source files are
    ## copied to the generaated directory..
    additional_files=[
#             os.path.join( environment.shared_ptr_dir, 'py_shared_ptr.h'),
# #             os.path.join( os.path.abspath(os.path.dirname(__file__) ), 'generators.h' ),
# #             os.path.join( os.path.abspath(os.path.dirname(__file__) ), 'custom_rvalue.cpp' ),
#             os.path.join( environment.include_dir, 'tuples.hpp' )
            ]            
    for sourcefile in additional_files:
        p,filename = os.path.split(sourcefile)
        destfile = os.path.join(environment.ogre.generated_dir, filename ) 
    
        if not common_utils.samefile( sourcefile ,destfile ):
            shutil.copy( sourcefile, environment.ogre.generated_dir )
            print "Updated ", filename, "as it was missing or out of date"
Пример #14
0
def generate_code():  
    messages.disable( 
#           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
          messages.W1020
        , messages.W1021
        , messages.W1022
        , messages.W1023
        , messages.W1024
        , messages.W1025
        , messages.W1026
        , messages.W1027
        , messages.W1028
        , messages.W1029
        , messages.W1030
        , messages.W1031
# # #         , messages.W1035
# # #         , messages.W1040 
# # #         , messages.W1038        
# # #         , messages.W1041
# # #         , messages.W1036 # pointer to Python immutable member
# # #         , messages.W1033 # unnamed variables
# # #         , messages.W1018 # expose unnamed classes
# # #         , messages.W1049 # returns reference to local variable
# # #         , messages.W1014 # unsupported '=' operator
         )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
#     print "XXXXXXXXXXXX", environment.ogrevideoffmpeg.root_dir
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.ogrevideoffmpeg.root_dir, "python_ogrevideoffmpeg.h" )
                        , environment.ogrevideoffmpeg.cache_file )


    defined_symbols = environment.defined_symbols

    defined_symbols.append( 'VERSION_' + environment.ogrevideoffmpeg.version )  
    
    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.ogrevideoffmpeg.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.ogrevideoffmpeg.cflags
                                           )
    # NOTE THE CHANGE HERE                                           
    mb.constructors().allow_implicit_conversion = False                                           
    mb.register_module_dependency ( environment.ogre.generated_dir )

    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
    
        
    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    # 
    global_ns = mb.global_ns
    global_ns.exclude()
    global_ns.class_('cVideoPlayer').include()
    
    main_ns = global_ns  # .namespace( MAIN_NAMESPACE )
   
# #     main_ns.include()
    
   
    AutoExclude ( mb )
    ManualExclude ( mb )
    AutoInclude ( mb )
    ManualInclude ( mb )
    # here we fixup functions that expect to modifiy their 'passed' variables    
    ManualTransformations ( mb )
    
    AutoFixes ( mb )
    ManualFixes ( mb )
    
    mb.global_ns.namespace ('Ogre').vars( 'ms_Singleton' ).disable_warnings( messages.W1035 ) #singleton pointers coming up we need to ignore
                
    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    Set_Call_Policies ( mb.global_ns) # .namespace (MAIN_NAMESPACE) )
    Set_Call_Policies ( mb.global_ns.namespace ('Ogre') )  ## need this as we are forcing singleton classes 
    
    
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    NoPropClasses = [""]
    for cls in main_ns.classes():
        if cls.name not in NoPropClasses:
            cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
            
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.ogrevideoffmpeg )

    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    #extractor = exdoc.doc_extractor("::Ogre") # I'm excluding the UTFstring docs as lots about nothing 
    mb.build_code_creator (module_name='_ogrevideoffmpeg_' ) #, doc_extractor= extractor )
    
    for inc in environment.ogrevideoffmpeg.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.ogrevideoffmpeg.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.ogrevideoffmpeg.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.ogrevideoffmpeg.version ) )

    mb.split_module(environment.ogrevideoffmpeg.generated_dir, huge_classes)

    ## now we need to ensure a series of headers and additional source files are
    ## copied to the generated directory..
    additional_files = []
    paths = [environment.Config.PATH_INCLUDE_ogrevideoffmpeg]

    for p in paths:
        additional_files = os.listdir(p)
        for f in additional_files:
            if f.endswith('cpp') or f.endswith('.h'):
                sourcefile = os.path.join(p, f)
                destfile = os.path.join(environment.ogrevideoffmpeg.generated_dir, f ) 
        
                if not common_utils.samefile( sourcefile ,destfile ):
                    shutil.copy( sourcefile, environment.ogrevideoffmpeg.generated_dir )
                    print "Updated ", f, "as it was missing or out of date"
Пример #15
0
def generate(defined_symbols, extraIncludes):
#    messages.disable(
#        messages.W1005 # using a non public variable type for argucments or returns
##           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
#        , messages.W1009 # check this
#        , messages.W1014 # check this
#        , messages.W1020
#        , messages.W1021
#        , messages.W1022
#        , messages.W1023
#        , messages.W1024
#        , messages.W1025
#        , messages.W1026
#        , messages.W1027
#        , messages.W1028
#        , messages.W1029
#        , messages.W1030
#        , messages.W1031
#        , messages.W1036 # check this
#)
    
    print("Install SRC:  ", os.path.abspath(__file__))
    print("Execute from: ", os.getcwd())
    
    sourcedir = os.path.dirname(os.path.abspath(__file__))
    sourceHeader = os.path.abspath(sourcedir + "/" + r"pygimli.h")
    gimliInclude = os.path.dirname(os.path.abspath(sourcedir + "/../src/" + r"gimli.h"))
    settings.includesPaths.append(gimliInclude)
            
    xml_cached_fc = parser.create_cached_source_fc(sourceHeader,
                                                   settings.module_name + '.cache')
    #xml_cached_fc = parser.create_cached_source_fc(os.path.join(r"pygimli.h"), settings.module_name + '.cache')
    

    import platform
    
    defines = ['PYGIMLI_GCCXML', 'HAVE_BOOST_THREAD_HPP']

    if platform.architecture()[0] == '64bit' and platform.architecture()[1] != 'ELF':
    
        if sys.platform == 'darwin':
            pass
        else:
            defines.append('_WIN64')
            print('Marking win64 for gccxml')

    for define in [settings.gimli_defines, defined_symbols]:
        if len(define) > 0:
            defines.append(define)

    try:
        if sys.platform == 'win32':
            #os.name == 'nt' (default on my mingw) results in wrong commandline for gccxml
            os.name = 'mingw'
            gccxmlpath = settings.gccxml_path.replace('\\', '\\\\') + '\\\\gccxml.exe'
        else:
            gccxmlpath = settings.gccxml_path
    except Exception as e:
        print (str(e))
        raise Exception("Problems determine gccxml binary")

    settings.includesPaths.insert(0,os.path.abspath(extraIncludes))

    print("gccxml-binary: ", gccxmlpath)
    print("extra-include: ", os.path.abspath(extraIncludes))
    print("gccxml includes: ", settings.includesPaths)
    print("gccxml defines: ", defines)
    
    mb = module_builder.module_builder_t([xml_cached_fc],
                                         gccxml_path=gccxmlpath,
                                         working_directory=settings.gimli_path,
                                         include_paths=settings.includesPaths,
                                         define_symbols=defines,
                                         indexing_suite_version=2)

    mb.classes().always_expose_using_scope = True
    mb.calldefs().create_with_signature = True

    hand_made_wrappers.apply(mb)

    global_ns = mb.global_ns
    global_ns.exclude()
    main_ns = global_ns.namespace(MAIN_NAMESPACE)
    main_ns.include()

    ### START manual r-value converters
    rvalue_converters = [
                            'register_pysequence_to_StdVectorUL_conversion',
                            'register_pytuple_to_rvector3_conversion',
                            'register_pysequence_to_rvector_conversion',
                            'register_pysequence_to_StdVectorRVector3_conversion'
                        ]

    for converter in rvalue_converters:
        mb.add_declaration_code('void %s();' % converter)
        mb.add_registration_code('%s();' % converter)

    ### END manual r-value converters
        
    custom_rvalue_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'custom_rvalue.cpp')
        
    exclude(main_ns.variables, name = [ 'Triangle6_S1', 'Triangle6_S2', 'Triangle6_S3'
                                        , 'HexahedronFacesID', 'Hexahedron20FacesID'
                                        , 'TetrahedronFacesID'
                                        , 'HexahedronSplit5TetID', 'HexahedronSplit6TetID'
                                        , 'TriPrismFacesID', 'TriPrimSplit3TetID'
                                        , 'NodeCoordinates','EdgeCoordinates' 
                                        , 'TriCoordinates', 'QuadCoordinates' 
                                        , 'TetCoordinates', 'HexCoordinates'
                                        , 'PrismCoordinates', 'PyramidCoordinates', 'PyramidFacesID'
                                        , 'Tet10NodeSplit', 'Tet10NodeSplitZienk'  
                                        , 'Hex20NodeSplit', 'Prism15NodeSplit', 'Pyramid13NodeSplit'
                                        ])

    for f in main_ns.declarations:
        if type(f) == decl_wrappers.calldef_wrapper.free_function_t:
            if (str(f.return_type).find('GIMLI::VectorExpr') != -1):
                f.exclude()

    exclude(main_ns.free_functions,    return_type = [ 'float *', 'float &'
    ,"::GIMLI::__VectorExpr< double, GIMLI::__VectorUnaryExprOp< double, GIMLI::VectorIterator< double >, GIMLI::ABS_ > >"
                                                      ],
                                        name = [ 'strReplaceBlankWithUnderscore'
                                                 , 'toStr', 'toInt', 'toFloat', 'toDouble', 'str'
                                                 , 'getRowSubstrings', 'getNonEmptyRow', 'getSubstrings'
                                                 , 'abs'
                                                 , 'type'
                                                ])

    exclude(main_ns.free_operators,    name = [''],
                                        return_type = ['::std::ostream &', '::std::istream &'])

    exclude(main_ns.classes,           name = [
                                                'ABS_', 'ACOT', 'ATAN', 'COS', 'COT', 'EXP', 'ABS_', 'LOG', 'LOG10', 'SIGN'
                                                ,'SIN', 'SQRT', 'SQR', 'TAN', 'TANH', 'PLUS', 'MINUS', 'MULT', 'DIVID', 'BINASSIGN'
                                                ,'cerrPtr', 'cerrPtrObject', 'coutPtr', 'coutPtrObject', 'deletePtr'
                                                ,'edge_', 'distancePair_'
                                                ,'IPCMessage'
                                                ,'PythonGILSave'
                                                ,'__VectorExpr'
                                                ,'__VectorUnaryExprOp'
                                                ,'__VectorBinaryExprOp'
                                                ,'__VectorValExprOp'
                                                ,'__ValVectorExprOp'
                                                ,'::GIMLI::__VectorValExprOp< double, GIMLI::__VectorIterator< double >, GIMLI::MULT >'
                                                ,'::GIMLI::__VectorBinaryExprOp< double, GIMLI::__VectorIterator< double >, GIMLI::__VectorIterator< double >, GIMLI::MULT>'
                                                ,'::GIMLI::__VectorExpr< double, GIMLI::__VectorBinaryExprOp< double, GIMLI::__VectorIterator< double >, GIMLI::__VectorIterator< double >, GIMLI::MULT > >'
                                                ,'::GIMLI::__VectorExpr< double, GIMLI::__VectorValExprOp< double, GIMLI::__VectorIterator< double >, GIMLI::MULT > >'
                                                ,'::GIMLI::__VectorExpr< double, GIMLI::__VectorUnaryExprOp< double, GIMLI::__VectorIterator< double >, GIMLI::LOG10 > >'
                                                ,'::GIMLI::__VectorExpr< double, GIMLI::__VectorUnaryExprOp< double, GIMLI::__VectorIterator< double >, GIMLI::LOG > >'
                                                ,'::GIMLI::__VectorUnaryExprOp< double, GIMLI::__VectorIterator< double >, GIMLI::LOG10 >'
                                                ,'::GIMLI::__VectorUnaryExprOp< double, GIMLI::__VectorIterator< double >, GIMLI::LOG >'
                                                ,'::GIMLI::__VectorExpr<double, GIMLI::__VectorValExprOp<double, GIMLI::__VectorExpr<double, GIMLI::__ValVectorExprOp<double, GIMLI::__VectorIterator<double >, GIMLI::MULT > >, GIMLI::MULT > >'
    ,'::GIMLI::__VectorValExprOp<double, GIMLI::__VectorExpr<double, GIMLI::__ValVectorExprOp<double, GIMLI::__VectorIterator<double >, GIMLI::MULT > >, GIMLI::MULT >.pypp.hpp',
                                                'GIMLI::Expr<GIMLI::ExprIdentity>'
                                               ])

    exclude(main_ns.member_functions,  name = ['begin', 'end', 'val'],  return_type = [''])

    exclude(main_ns.member_operators,  symbol = [''])

    mb.calldefs(access_type_matcher_t('protected')).exclude()
    mb.calldefs(access_type_matcher_t('private')).exclude()

    #setMemberFunctionCallPolicieByReturn(mb, [ '::GIMLI::Node &'
                                                #, '::GIMLI::Cell &'
                                                #, '::GIMLI::Boundary &'
                                                #, '::GIMLI::Shape &'
                                                #, '::GIMLI::Node *'
                                                #, '::GIMLI::Cell *'
                                                #, '::GIMLI::Boundary *'
                                                #, '::GIMLI::Shape *'
                                        #]
                                        #, call_policies.reference_existing_object)


    setMemberFunctionCallPolicieByReturn(mb, [    '::std::string *', 'float *', 'double *', 'int *', 'long *' 
                                                , 'long long int *', 'unsigned long long int *' 
												, '::GIMLI::Index *']
                                            , call_policies.return_pointee_value)

    #setMemberFunctionCallPolicieByReturn(mb, ['::GIMLI::VectorIterator<double> &']
                                        #, call_policies.copy_const_reference)

    setMemberFunctionCallPolicieByReturn(mb, ['::std::string &'
                                                ,  'double &' ]
                                                , call_policies.return_by_value)

    #setMemberFunctionCallPolicieByReturn(mb, [
                                                #,  'double &' ]
                                                #, call_policies.reference_existing_object)

    #call_policies.return_value_policy(call_policies.reference_existing_object)
    #call_policies.return_value_policy(call_policies.copy_non_const_reference)
    #call_policies.return_value_policy(call_policies.copy_const_reference)


     #addAutoConversions(mb)

   # excludeMemberByReturn(main_ns, ['::DCFEMLib::SparseMatrix<double> &'])
    #main_ns.classes(decl_starts_with(['STLMatrix']), allow_empty=True).exclude()
    #fun = mb.global_ns.member_functions('begin', allow_empty=True)
    #for f in fun:
        #f.exclude()

    #excludeFreeFunctionsByName(main_ns, ['strReplaceBlankWithUnderscore'
                               #'toStr', 'toInt', 'toFloat', 'toDouble',
                               #'getRowSubstrings', 'getNonEmptyRow', 'getSubstrings' ])

    #excludeFreeFunctionsByReturn(main_ns, [ 'float *', 'float &' ])
    #fun = ns.free_operators(return_type=funct, allow_empty=True)


    #excludeMemberOperators(main_ns, ['++', '--', '*'])


    # exclude all that does not match any predefined callpolicie


    excludeRest = True

    if excludeRest:
        mem_funs = mb.calldefs ()

        for mem_fun in mem_funs:
            if mem_fun.call_policies:
                continue
            if not mem_fun.call_policies and \
                (declarations.is_reference(mem_fun.return_type) or declarations.is_pointer (mem_fun.return_type)):
                #print mem_fun
                #mem_fun.exclude()
                mem_fun.call_policies = \
                    call_policies.return_value_policy(call_policies.reference_existing_object)
                #mem_fun.call_policies = \
                #    call_policies.return_value_policy(call_policies.return_pointee_value)
                #mem_fun.call_policies = \
                #    call_policies.return_value_policy(call_policies.return_opaque_pointer)
                #mem_fun.call_policies = \
                 #   call_policies.return_value_policy(call_policies.copy_non_const_reference)


    # Now it is the time to give a name to our module
    from doxygen import doxygen_doc_extractor
    extractor = doxygen_doc_extractor()

    mb.build_code_creator(settings.module_name, doc_extractor=extractor)

    #It is common requirement in software world - each file should have license
    #mb.code_creator.license = '//Boost Software License(http://boost.org/more/license_info.html)'

    #I don't want absolute includes within code
    mb.code_creator.user_defined_directories.append(os.path.abspath('.'))

    #And finally we can write code to the disk
    def ignore(val):
        pass
    mb.split_module('./generated', on_unused_file_found=ignore)
    
    additional_files = [
            os.path.join(os.path.abspath(os.path.dirname(__file__)), 'custom_rvalue.cpp'),
            os.path.join(os.path.abspath(os.path.dirname(__file__)), 'generators.h'),
            os.path.join(os.path.abspath(os.path.dirname(__file__)), 'tuples.hpp') 
            ]
            
    for sourcefile in additional_files:
        p,filename = os.path.split(sourcefile)
        destfile = os.path.join('./generated', filename)

        if not samefile(sourcefile, destfile):
            shutil.copy(sourcefile, './generated')
            print("Updated ", filename, "as it was missing or out of date")
Пример #16
0
def generate_code():  
    messages.disable( 
#           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
          messages.W1020
        , messages.W1021
        , messages.W1022
        , messages.W1023
        , messages.W1024
        , messages.W1025
        , messages.W1026
        , messages.W1027
        , messages.W1028
        , messages.W1029
        , messages.W1030
        , messages.W1031
#         , messages.W1035
#         , messages.W1040 
#         , messages.W1038        
#         , messages.W1041
        , messages.W1036 # pointer to Python immutable member
        , messages.W1033 # unnamed variables
        , messages.W1018 # expose unnamed classes
        , messages.W1049 # returns reference to local variable
        , messages.W1014 # unsupported '=' operator
         )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.bullet.root_dir, "python_bullet.h" )
                        , environment.bullet.cache_file )

    defined_symbols = [ 'BULLET_EXPORTS', '__GCCXML__', '_MSC_VER',
                        '__MINGW32__'   # needed to turn off allocator allignment which boost can't do..
                        
                        ]
    defined_symbols.append( 'VERSION_' + environment.bullet.version )  
    if sys.platform.startswith ( 'linux' ):
        defined_symbols.append('USE_PTHREADS')
    
    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.bullet.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.bullet.cflags
                                           )
                                           
    # if this module depends on another set it here                                           
    ## mb.register_module_dependency ( environment.ogre.generated_dir )
    
    # normally implicit conversions work OK, however they can cause strange things to happen so safer to leave off
    mb.constructors().allow_implicit_conversion = False                                           
    
    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
            
    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    # 
    global_ns = mb.global_ns
    global_ns.exclude()
    
    if MAIN_NAMESPACE == "" :
        main_ns = global_ns
        main_ns.include()
    else:
        main_ns = global_ns.namespace( MAIN_NAMESPACE )
        main_ns.exclude ()
    
    AutoInclude ( mb, MAIN_NAMESPACE ) ## note we use our own version, not common_utils
    common_utils.AutoExclude ( mb, MAIN_NAMESPACE )
    ManualInclude ( mb )
    # here we fixup functions that expect to modifiy their 'passed' variables    
    ManualTransformations ( mb )
    AutoFixes ( mb, MAIN_NAMESPACE )
    
    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    # Do this earlier than normal as I need to override the default in ManualFixes
    common_utils.Set_DefaultCall_Policies ( main_ns )
    
    ManualFixes ( mb )
    ManualExclude ( mb )
    common_utils.Auto_Functional_Transformation ( main_ns ,special_vars=['btScalar *'] )
    
    
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    NoPropClasses = [""]
    for cls in main_ns.classes():
        if cls.name not in NoPropClasses:
            rec = ogre_properties.ogre_property_recognizer_t()
            rec.addSetterType ( 'btScalar' ) # this type is a 'float/double' however we need to tell py++ such so it creates setters
            cls.add_properties( recognizer=rec )
            
    common_utils.Auto_Document( mb, MAIN_NAMESPACE )
            
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.bullet )

    mem_fun = main_ns.member_function('::btVector3::setX')
    ##print "setter:", property_recognizer_i  (mem_fun)
    if len( mem_fun.arguments ) != 1:
        print 'False1'
    if not declarations.is_void( mem_fun.return_type ):
        print 'False2'
    if mem_fun.has_const:
        print 'False3'
    if mem_fun.overloads:
        print 'False4' 
    print "OK"
            
    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
# #     extractor = exdoc.doc_extractor( "Ogre" ) 
# #     mb.build_code_creator (module_name='_ogre_' , doc_extractor= extractor )

    extractor = exdoc.doc_extractor() # I'm excluding the UTFstring docs as lots about nothing 
    mb.build_code_creator (module_name='_bullet_' , doc_extractor= extractor )
    
    for inc in environment.bullet.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.bullet.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.bullet.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.bullet.version ) )

    mb.split_module(environment.bullet.generated_dir, huge_classes, use_files_sum_repository=False)

    ## now we need to ensure a series of headers and additional source files are
    ## copied to the generaated directory..
    additional_files=[
            os.path.join( os.path.abspath(os.path.dirname(__file__) ), 'python_bullet_masterlist.h' )	    
            ]
    if environment.isLinux(): #sBulletDNAlen is defined in the cpp file not the header!! 
       additional_files.append ( os.path.join( environment.Config.PATH_Bullet, 'src', 'LinearMath','btSerializer.cpp' ) )
    for sourcefile in additional_files:
        p,filename = os.path.split(sourcefile)
        destfile = os.path.join(environment.bullet.generated_dir, filename )

        if not common_utils.samefile( sourcefile ,destfile ):
            shutil.copy( sourcefile, environment.bullet.generated_dir )
            print "Updated ", filename, "as it was missing or out of date"
Пример #17
0
def generate_code():
    messages.disable( 
#           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
          messages.W1020
        , messages.W1021
        , messages.W1022
        , messages.W1023
        , messages.W1024
        , messages.W1025
        , messages.W1026
        , messages.W1027
        , messages.W1028
        , messages.W1029
        , messages.W1030
        , messages.W1031
#         , messages.W1035
#         , messages.W1040 
#         , messages.W1038        
#         , messages.W1041
        , messages.W1036 # pointer to Python immutable member
        , messages.W1033 # unnamed variables
        , messages.W1018 # expose unnamed classes
        , messages.W1049 # returns reference to local variable
        , messages.W1014 # unsupported '=' operator
         )
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.ode.root_dir, "python_ode.h" )
                        , environment.ode.cache_file )

    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.ode.include_dirs
                                          , define_symbols=['ode_NONCLIENT_BUILD', 'ODE_LIB']
                                          , indexing_suite_version=2 )

    filter_declarations (mb)
    
    query = lambda decl: isinstance( decl, ( declarations.class_t, declarations.class_declaration_t ) ) \
                         and decl.name.startswith( 'dx' )
    mb.global_ns.decls( query ).opaque = True   
#     mb.global_ns.variable('dSpaceID').opaque=True
                          
#     ## here we adjust for functions that return poiners to ODE "ID's", which are really C structs
#     ## I may have been over agressive in identifing these functions but hopefully not...
#     for func in mb.namespace( 'OgreOde' ).member_functions():  
#         if func.return_type.decl_string.endswith('ID'):
#             print "Setting ", func.name, "to Opaque"
#             func.opaque = True
#             func.call_policies = call_policies.return_value_policy(
#                 call_policies.return_opaque_pointer )
        


    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
    
    Set_Call_Policies (mb)
    AutoArrayArgs( mb )
    ReturnReals( mb )
    hand_made_wrappers.apply( mb )

    ode_ns = mb.global_ns  ## .namespace ('ode')
    common_utils.add_properties( ode_ns.classes() )

    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.ode )
 
    #Creating code creator. After this step you should not modify/customize declarations.
    extractor = exdoc.doc_extractor("")
    mb.build_code_creator (module_name='_ode_' , doc_extractor= extractor)
    
    for inc in environment.ode.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.ode.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files(environment.ode.version) )
    
# #     mb.code_creator.add_include( "__convenience.pypp.hpp" )
# #     mb.code_creator.add_system_header( code_repository.convenience.file_name )

    huge_classes = map( mb.class_, customization_data.huge_classes(environment.ode.version) )

    mb.split_module(environment.ode.generated_dir, huge_classes)

    return_pointee_value_source_path \
        = os.path.join( environment.pyplusplus_install_dir
#                         , 'pyplusplus_dev'
                        , 'pyplusplus'
                        , 'code_repository'
                        , 'return_pointee_value.hpp' )
    if not os.path.exists(return_pointee_value_source_path):
        return_pointee_value_source_path \
            = os.path.join ( os.path.dirname(code_repository.__file__),
                            'return_pointee_value.hpp')
    if not os.path.exists(return_pointee_value_source_path):
        return_pointee_value_source_path \
            = os.path.join ( os.getcwd(),
                            'return_pointee_value.hpp')


    return_pointee_value_target_path \
        = os.path.join( environment.ode.generated_dir, 'return_pointee_value.hpp' )

    if not os.path.exists( return_pointee_value_target_path ):
        shutil.copy( return_pointee_value_source_path, environment.ode.generated_dir )
Пример #18
0
def generate_code():  
    messages.disable( 
#           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
          messages.W1020
        , messages.W1021
        , messages.W1022
        , messages.W1023
        , messages.W1024
        , messages.W1025
        , messages.W1026
        , messages.W1027
        , messages.W1028
        , messages.W1029
        , messages.W1030
        , messages.W1031
# # #         , messages.W1035
# # #         , messages.W1040 
# # #         , messages.W1038        
# # #         , messages.W1041
# # #         , messages.W1036 # pointer to Python immutable member
# # #         , messages.W1033 # unnamed variables
# # #         , messages.W1018 # expose unnamed classes
# # #         , messages.W1049 # returns reference to local variable
# # #         , messages.W1014 # unsupported '=' operator
         )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.noise.root_dir, "python_noise.h" )
                        , environment.noise.cache_file )


    defined_symbols = [ 'OGRE_NONCLIENT_BUILD','__PYTHONOGRE_BUILD_CODE' ]
    if environment._USE_THREADS:
        defined_symbols.append('BOOST_HAS_THREADS')
        defined_symbols.append('BOOST_HAS_WINTHREADS')

    defined_symbols.append( 'VERSION_' + environment.noise.version )  
    
    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.noise.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.noise.cflags
                                           )
    # NOTE THE CHANGE HERE                                           
    mb.constructors().allow_implicit_conversion = False
    
    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True


    global_ns = mb.global_ns
    global_ns.exclude()

    for n in mb.global_ns.namespaces():
        print n._name

    namespaces = ['noise', 'utils', 'model', 'module']
    for n in namespaces:
        global_ns.namespace(n).include()
        common_utils.AutoExclude ( mb, n )

    ## Manual Excludes 
    global_ns.mem_fun('::noise::module::Terrace::GetControlPointArray').exclude()

    ## These generate "<<protected declaration>>\n" and compile fails
    global_ns.mem_fun('::noise::module::Curve::FindInsertionPos').exclude()
    global_ns.mem_fun('::noise::module::Curve::InsertAtPos').exclude()
    global_ns.mem_fun('::noise::module::RidgedMulti::CalcSpectralWeights').exclude()
    global_ns.mem_fun('::noise::module::Terrace::FindInsertionPos').exclude()
    global_ns.mem_fun('::noise::module::Terrace::InsertAtPos').exclude()
    global_ns.mem_fun('::noise::utils::WriterBMP::CalcWidthByteCount').exclude()
    global_ns.mem_fun('::noise::utils::WriterTER::CalcWidthByteCount').exclude()

    for n in namespaces:
        common_utils.AutoInclude ( mb, n)

    ManualInclude ( mb )
    # here we fixup functions that expect to modifiy their 'passed' variables    
    ManualTransformations ( mb )
    
    for n in namespaces:
        AutoFixes ( mb, n )

    ManualFixes ( mb )
    
    ## namespaces 
    namespaces = ['noise', 'model' , 'module', 'utils']

    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    for ns in namespaces:
        common_utils.Set_DefaultCall_Policies (mb.global_ns.namespace(ns))
        common_utils.Auto_Functional_Transformation ( mb.global_ns.namespace(ns) )

    
    
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    ## add properties to the 4 namespaces, in a conservative fashion
    for ns in namespaces:
        for cls in mb.global_ns.namespace(ns).classes():
            cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
                                          
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.noise )

   
    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    extractor = exdoc.doc_extractor() # I'm excluding the UTFstring docs as lots about nothing 
    mb.build_code_creator (module_name='_noise_' , doc_extractor= extractor )
    
    for inc in environment.noise.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.noise.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.noise.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.noise.version ) )

    mb.split_module(environment.noise.generated_dir, huge_classes, use_files_sum_repository=False)

    ## now we need to ensure a series of headers and additional source files are
    ## copied to the generated directory..
    common_utils.copyTree ( sourcePath = environment.Config.PATH_noise, 
                            destPath = environment.noise.generated_dir, 
                            recursive=False )
Пример #19
0
def generate_code():
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.ogrerefapp.root_dir, "python_ogre.h" )
                        , environment.ogrerefapp.cache_file )

    defined_symbols = [ 'OGREREFAPP_NONCLIENT_BUILD', 'OGRE_NONCLIENT_BUILD','__PYTHONOGRE_BUILD_CODE' ]
    defined_symbols.append( 'OGREREFAPP_VERSION_' + environment.ogrerefapp.version )
    if environment._USE_THREADS:
        defined_symbols.append('BOOST_HAS_THREADS')
        defined_symbols.append('BOOST_HAS_WINTHREADS')

    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.ogrerefapp.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2 )

    filter_declarations (mb)

#     common_utils.set_declaration_aliases( mb.global_ns, customization_data.aliases( environment.ogrerefapp.version ) )
    #
    # fix shared Ptr's that are defined as references but NOT const...
    #
    find_nonconst ( mb.namespace( 'OgreRefApp' ) )
  
    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True

    ogrerefapp_ns = mb.namespace( 'OgreRefApp' )
#     common_utils.fix_unnamed_classes( ogre_ns.classes( name='' ), 'OgreRefApp' )

#     common_utils.configure_shared_ptr(mb)
#     configure_exception( mb )
    
    hand_made_wrappers.apply( mb )

    set_call_policies ( mb.global_ns.namespace ('OgreRefApp') )
    
    for cls in ogrerefapp_ns.classes():
        cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
        ## because we want backwards pyogre compatibility lets add leading lowercase properties
        common_utils.add_LeadingLowerProperties ( cls )

    
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.ogrerefapp )

    #Creating code creator. After this step you should not modify/customize declarations.
        
    extractor = exdoc.doc_extractor("")

    mb.build_code_creator (module_name='_ogrerefapp_',doc_extractor= extractor)
    for inc in environment.ogrerefapp.include_dirs :
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.ogrerefapp.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.ogrerefapp.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.ogrerefapp.version ) )

    mb.split_module(environment.ogrerefapp.generated_dir, huge_classes)
Пример #20
0
def generate_code():  
#     messages.disable( 
# # #           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
#           messages.W1020
#         , messages.W1021
#         , messages.W1022
#         , messages.W1023
#         , messages.W1024
#         , messages.W1025
#         , messages.W1026
#         , messages.W1027
#         , messages.W1028
#         , messages.W1029
#         , messages.W1030
#         , messages.W1031
# #         , messages.W1035
# #         , messages.W1040 
# #         , messages.W1038        
#         , messages.W1041
#         , messages.W1036 # pointer to Python immutable member
# #         , messages.W1033 # unnamed variables
# #         , messages.W1018 # expose unnamed classes
#         , messages.W1049 # returns reference to local variable
#         , messages.W1014 # unsupported '=' operator
#          )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.physx.root_dir, "python_physx.h" )
                        , environment.physx.cache_file )

    if os.name == 'nt':
        defined_symbols = ['NXPHYSICS_EXPORTS', 'WIN32', 'PHYSX_EXPORTS'] #'WIN32',
    else:
        defined_symbols = ['LINUX','NX_DISABLE_FLUIDS']
    defined_symbols.append( 'VERSION_' + environment.physx.version )  
    defined_symbols.append ( '__PYTHONOGRE_BUILD_CODE' )
    
    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.physx.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.physx.cflags
                                           )
    # NOTE THE CHANGE HERE                                           
    mb.constructors().allow_implicit_conversion = False                                           
    
    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
    
        
    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    # 
    global_ns = mb.global_ns
    global_ns.exclude()
    AutoInclude ( mb )
    
    common_utils.AutoExclude ( mb, MAIN_NAMESPACE )
    
    ManualExclude ( mb )
    ManualInclude ( mb )
    # here we fixup functions that expect to modifiy their 'passed' variables    
    ManualTransformations ( mb )
    
    AutoFixes ( mb )
    ManualFixes ( mb )
            
    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    common_utils.Set_DefaultCall_Policies ( mb.global_ns )
    ignore=['mallocDEBUG',
                '::NxUserAllocator::mallocDEBUG'
                ,'NxUserAllocator::mallocDEBUG'
                ]
    common_utils.Auto_Functional_Transformation ( mb.global_ns, ignore_funs = ignore ) ## special_vars=['::Ogre::Real &','::Ogre::ushort &','size_t &'] )
    
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    NoPropClasses = [""]
    main_ns = global_ns
    for cls in main_ns.classes():
        if cls.name not in NoPropClasses:
            cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
            
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.physx )

#     for func in mb.global_ns.free_functions ():
#         if not func.ignore:
#             print "Free Func Included", func
#             print func.exportable, func.why_not_exportable()
        
 
    
    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    extractor = exdoc.doc_extractor("") # I'm excluding the UTFstring docs as lots about nothing 
    mb.build_code_creator (module_name='_physx_' , doc_extractor= extractor )
    
    for inc in environment.physx.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.physx.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.physx.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.physx.version ) )

    mb.split_module(environment.physx.generated_dir, huge_classes,use_files_sum_repository=False)

    ## now we need to ensure a series of headers and additional source files are
    ## copied to the generaated directory..

    additional_files=['Stream.h', 'Stream.cpp', 'Joints.h', 'Joints.cpp']
   
    for sourcefile in additional_files:
        sourcefile = os.path.join(environment.Config.PATH_INCLUDE_PhysX_Samples, sourcefile )
        p,filename = os.path.split(sourcefile)
        destfile = os.path.join(environment.physx.generated_dir, filename ) 
    
        if not common_utils.samefile( sourcefile ,destfile ):
            shutil.copy( sourcefile, environment.physx.generated_dir )
            print "Updated ", filename, "as it was missing or out of date"
Пример #21
0
def generate_code():  
    messages.disable( 
#           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
           messages.W1020
         , messages.W1021
         , messages.W1022
         , messages.W1023
         , messages.W1024
         , messages.W1025
         , messages.W1026
         , messages.W1027
         , messages.W1028
         , messages.W1029
         , messages.W1030
         , messages.W1031
         , messages.W1035
         , messages.W1040 
         , messages.W1038        
         , messages.W1041
#         , messages.W1036 # pointer to Python immutable member
#         , messages.W1033 # unnamed variables
#         , messages.W1018 # expose unnamed classes
#         , messages.W1049 # returns reference to local variable
#         , messages.W1014 # unsupported '=' operator
          )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.ogrepcz.root_dir, "python_ogrepcz.h" )
                        , environment.ogrepcz.cache_file )

    defined_symbols = [ 'OGRE_NONCLIENT_BUILD', 'OGRE_GCC_VISIBILITY', 'OGRE_PCZPLUGIN_EXPORTS',
                        '__PYTHONOGRE_BUILD_CODE']
    defined_symbols.append( 'VERSION_' + environment.ogrepcz.version )  
    if environment._USE_THREADS:
        defined_symbols.append('BOOST_HAS_THREADS')
        defined_symbols.append('BOOST_HAS_WINTHREADS')

    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.ogrepcz.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.ogrepcz.cflags
                                           )
                                           
    # if this module depends on another set it here                                           
    mb.register_module_dependency ( environment.ogre.generated_dir )
    
    # normally implicit conversions work OK, however they can cause strange things to happen so safer to leave off
    mb.constructors().allow_implicit_conversion = False                                           
    
    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
            
    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    # 
    global_ns = mb.global_ns
    global_ns.exclude()
    
#     #
#     # I'm assuming that any 'std' classes etc we need will have already been exposed by the Ogre library
#     #
#     std_ns = global_ns.namespace('std')
#     std_ns.include(already_exposed=True) 
    
    # We don't include all of MAIN_NAMESPACE otherwise we get the same full wrapper
    # so instead we include classes with names that start with PCZ
    main_ns = global_ns.namespace( MAIN_NAMESPACE )
# #     main_ns.include( already_exposed = True )  ## force the ogre class to be exposed as well...
    
    for c in main_ns.classes():
        if c.name.startswith ('PCZ') or c.name.startswith ('PCPlane') or  c.name.startswith ('Portal'):
            c.include()
            print "Including ", c, c.already_exposed
            
    for c in ['Portal','PCPlane']:
        main_ns.class_(c).include()
        print "Including ", c            
    
    common_utils.AutoExclude ( mb, MAIN_NAMESPACE )
    ManualInclude ( mb )
    ManualExclude ( mb )
    common_utils.AutoInclude ( mb, MAIN_NAMESPACE )
    # here we fixup functions that expect to modifiy their 'passed' variables    
    ManualTransformations ( mb )
    AutoFixes ( mb, MAIN_NAMESPACE )
    ManualFixes ( mb )
    common_utils.Auto_Functional_Transformation ( main_ns )
    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    common_utils.Set_DefaultCall_Policies ( mb.global_ns.namespace ( MAIN_NAMESPACE ) )
    
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    NoPropClasses = [""]
    for cls in main_ns.classes():
        if cls.name not in NoPropClasses:
            cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
            
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.ogrepcz )

    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    extractor = exdoc.doc_extractor() # I'm excluding the UTFstring docs as lots about nothing 
    mb.build_code_creator (module_name='_ogrepcz_' , doc_extractor= extractor )
    
    for inc in environment.ogrepcz.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.ogrepcz.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.ogrepcz.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.ogrepcz.version ) )

    mb.split_module(environment.ogrepcz.generated_dir, huge_classes, use_files_sum_repository=False)

    ## now we need to ensure a series of headers and additional source files are
    ## copied to the generated directory..
    
#     common_utils.copyTree ( sourcePath = environment.Config.PATH_INCLUDE_ogrepcz, 
#                             destPath = environment.ogrepcz.generated_dir, 
#                             recursive=False )
    if environment.ogre.version.startswith("1.7"):
        ## have a code generation issue that needs resolving...
        filesToFix=['PCZoneFactoryManager.pypp.cpp']
        for filename in filesToFix:
            fname = os.path.join( environment.ogrepcz.generated_dir, filename)
            try:
                f = open(fname, 'r')
                buf = f.read()
                f.close()
                buf = buf.replace ( " MEMCATEGORY_GENERAL", " Ogre::MEMCATEGORY_GENERAL")
                buf = buf.replace ( "<MEMCATEGORY_GENERAL", "<Ogre::MEMCATEGORY_GENERAL")
                f = open ( fname, 'w+')
                f.write ( buf )
                f.close()
                print "UGLY FIX OK:", fname
            except:
                print "ERROR: Unable to fix:", fname        
Пример #22
0
def generate_code():  
    messages.disable( 
# # #           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
          messages.W1020
        , messages.W1021
        , messages.W1022
        , messages.W1023
        , messages.W1024
        , messages.W1025
        , messages.W1026
        , messages.W1027
        , messages.W1028
        , messages.W1029
        , messages.W1030
        , messages.W1031
# #         , messages.W1035
# #         , messages.W1040 
# #         , messages.W1038        
#         , messages.W1041
        , messages.W1036 # pointer to Python immutable member
# #         , messages.W1033 # unnamed variables
# #         , messages.W1018 # expose unnamed classes
        , messages.W1049 # returns reference to local variable
#         , messages.W1014 # unsupported '=' operator
         )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.bullet.root_dir, "python_bullet.h" )
                        , environment.bullet.cache_file )

    defined_symbols =  ['BULLET_EXPORTS'] #
    defined_symbols.append( 'VERSION_' + environment.bullet.version )  
    
    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.bullet.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.bullet.cflags
                                           )
    # NOTE THE CHANGE HERE                                           
    mb.constructors().allow_implicit_conversion = False                                           
    
    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
    
        
    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    # 
    global_ns = mb.global_ns
    global_ns.exclude()
    AutoInclude ( mb )
    
   
    AutoExclude ( mb )
    ManualExclude ( mb )
    ManualInclude ( mb )
    # here we fixup functions that expect to modifiy their 'passed' variables    
    ManualTransformations ( mb )
    
    AutoFixes ( mb )
    ManualFixes ( mb )
            
    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    Set_Call_Policies ( mb.global_ns )
    
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    NoPropClasses = [""]
    main_ns = global_ns
#     for cls in main_ns.classes():
#         if cls.name not in NoPropClasses:
#             cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
            
    common_utils.add_constants( mb, { 'bullet_version' :  '"%s"' % environment.bullet.version.replace("\n", "\\\n") 
                                      , 'python_version' : '"%s"' % sys.version.replace("\n", "\\\n" ) } )
                                      
    ## need to create a welcome doc string for this...                                  
    common_utils.add_constants( mb, { '__doc__' :  '"bullet DESCRIPTION"' } ) 
    
    
    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    extractor = exdoc.doc_extractor("") # I'm excluding the UTFstring docs as lots about nothing 
    mb.build_code_creator (module_name='_bullet_' , doc_extractor= extractor )
    
    for inc in environment.bullet.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.bullet.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.bullet.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.bullet.version ) )

    mb.split_module(environment.bullet.generated_dir, huge_classes, use_files_sum_repository=False)
Пример #23
0
					f.call_policies = call_policies.return_value_policy(call_policies.return_opaque_pointer)
		
####################################################################################################

wrappers_file = os.path.join(settings.root_dir, "wrappers.h")
cache_file = os.path.join(settings.output_directory, "wrappers.xml")

if (len(sys.argv) > 1) and (sys.argv[1] == "enable-cache"):	
	logger.info("Cache enabled")	
else:	
	try:
		os.remove(cache_file)		
	except:
		pass
		
cached_source_fc = parser.create_cached_source_fc(wrappers_file, cache_file)

module_builder = module_builder.module_builder_t(files = [cached_source_fc], 
						    gccxml_path = settings.gccxml_path, 
						    working_directory = settings.working_directory, 
						    include_paths = settings.include_paths, 
						    define_symbols = settings.defined_symbols
						    ,indexing_suite_version = 2
						    )
						    
module_builder.calldefs().create_with_signature = True

namespace_global = module_builder.global_ns
namespace_global.exclude()

namespace_osiris = namespace_global.namespace("osiris");
Пример #24
0
def generate_code():  
    messages.disable( 
# #           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
          messages.W1020
        , messages.W1021
        , messages.W1022
        , messages.W1023
        , messages.W1024
        , messages.W1025
        , messages.W1026
        , messages.W1027
        , messages.W1028
        , messages.W1029
        , messages.W1030
        , messages.W1031
#         , messages.W1035
#         , messages.W1040 
#         , messages.W1038        
        , messages.W1041
        , messages.W1036 # pointer to Python immutable member
#         , messages.W1033 # unnamed variables
#         , messages.W1018 # expose unnamed classes
        , messages.W1049 # returns reference to local variable
        , messages.W1014 # unsupported '=' operator
         )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.opcode.root_dir, "python_opcode.h" )
                        , environment.opcode.cache_file )

    defined_symbols = ['OPCODE_EXPORTS'] #, 'ICE_NO_DLL'] #, 'OPC_USE_CALLBACKS' ]
    defined_symbols.append( 'VERSION_' + environment.opcode.version )  
    
    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.opcode.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.ogre.cflags
                                           )
    # NOTE THE CHANGE HERE                                           
    mb.constructors().allow_implicit_conversion = False                                           
    
    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
    
        
    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    # 
    global_ns = mb.global_ns
    global_ns.exclude()
    for ns in NAMESPACES:
        main_ns = global_ns.namespace( ns )
        main_ns.include()
    
   
    AutoExclude ( mb )
    ManualExclude ( mb )
    AutoInclude ( mb )
    ManualInclude ( mb )
    # here we fixup functions that expect to modifiy their 'passed' variables    
    ManualTransformations ( mb )
    
    AutoFixes ( mb )
    ManualFixes ( mb )
            
    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    for ns in NAMESPACES:
        Set_Call_Policies ( mb.global_ns.namespace (ns) )
    
#IceMaths::Quat IceMaths::Matrix3x3::operator ::IceMaths::Quat() const [casting operator]
    c = mb.global_ns.namespace ( 'IceMaths').class_('Matrix3x3')
    for o in c.operators():
#         print o
#         print dir(o)
#         print o.partial_decl_string
#         print o.name
        if 'Quat' in o.partial_decl_string:
            o.exclude()
            print "Excluded Op", o, "\n", o.partial_decl_string
##  OP float const * IceMaths::Point::operator float const *() const [casting operator]
    c = mb.global_ns.namespace ( 'IceMaths').class_('Point')
    for o in c.operators():
        if 'float const *' in o.partial_decl_string:
            o.exclude()
            print "Excluded Op", o, "\n", o.partial_decl_string
    ##Spere(udword nb_verts, const Point* verts);  Not Implemented
    c = mb.global_ns.namespace ( 'IceMaths').class_('Sphere')
    for o in c.constructors(arg_types=("::udword","::IceMaths::Point const *") ):
        o.exclude()
    c = mb.global_ns.namespace ( 'IceMaths').class_('Matrix4x4')
    for o in c.constructors():
        if len (o.arguments) > 10:
            o.exclude()
    for o in c.member_functions():
        if len (o.arguments) > 10:
            print "Too Many Arguments - excluded:", o, o.partial_decl_string
            o.exclude()
    c = mb.global_ns.namespace ( 'IceMaths').class_('Matrix4x4')
    for o in c.casting_operators():
        rett = o.return_type.decl_string
        if 'Quat' in rett or 'PR' in rett:
            o.exclude()
            print "Excluded Op", o
             
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    NoPropClasses = [""]
    for ns in NAMESPACES:
        main_ns = global_ns.namespace( ns )
        for cls in main_ns.classes():
            if cls.name not in NoPropClasses:
                cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
            
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.opcode )

    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    extractor = exdoc.doc_extractor("") # I'm excluding the UTFstring docs as lots about nothing 
    mb.build_code_creator (module_name='_opcode_' , doc_extractor= extractor )
    
    for inc in environment.opcode.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.opcode.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.opcode.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.opcode.version ) )

    mb.split_module(environment.opcode.generated_dir, huge_classes)

    ## now we need to ensure a series of headers and additional source files are
    ## copied to the generaated directory..
    additional_dirs=[
                    [environment.Config.PATH_OPCODE ,''],
                    [os.path.join(environment.Config.PATH_OPCODE, 'Ice'),'Ice'],
                    [os.path.join(environment.Config.PATH_OPCODE, 'Ice'),''],  ## double copy to make the compile work..
                    ]
    for d,d1 in additional_dirs:
        for f in os.listdir(d):
            if f.endswith('cpp') or f.endswith('.h') or f.endswith('.c'):
                sourcefile = os.path.join(d, f)
                destfile = os.path.join(environment.opcode.generated_dir, d1,  f ) 
                if not os.path.exists ( os.path.join(environment.opcode.generated_dir, d1 ) ):
                    os.mkdir ( os.path.join(environment.opcode.generated_dir, d1 ) )
                if not common_utils.samefile( sourcefile ,destfile ):
                    shutil.copy( sourcefile, environment.opcode.generated_dir )
                    print "Updated ", f, "as it was missing or out of date"
Пример #25
0
def generate_code():  
    messages.disable( 
#           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
          messages.W1020
        , messages.W1021
        , messages.W1022
        , messages.W1023
        , messages.W1024
        , messages.W1025
        , messages.W1026
        , messages.W1027
        , messages.W1028
        , messages.W1029
        , messages.W1030
        , messages.W1031
        , messages.W1035
        , messages.W1040 
        , messages.W1038        
#         , messages.W1041
#         , messages.W1036 # pointer to Python immutable member
#         , messages.W1033 # unnamed variables
#         , messages.W1018 # expose unnamed classes
#         , messages.W1049 # returns reference to local variable
#         , messages.W1014 # unsupported '=' operator
         )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.watermesh.root_dir, "python_watermesh.h" )
                        , environment.watermesh.cache_file )

    defined_symbols = ['OGRE_NONCLIENT_BUILD']
    defined_symbols.append( 'VERSION_' + environment.watermesh.version )  
    
    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.watermesh.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.watermesh.cflags
                                           )
                                           
    # if this module depends on another set it here                                           
    mb.register_module_dependency ( environment.ogre.generated_dir )
    
    # normally implicit conversions work OK, however they can cause strange things to happen so safer to leave off
    mb.constructors().allow_implicit_conversion = False                                           
    
    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
            
    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    # 
    global_ns = mb.global_ns
    global_ns.exclude()
    main_ns = global_ns.namespace( MAIN_NAMESPACE )
    main_ns.exclude()
       
    common_utils.AutoExclude ( mb, MAIN_NAMESPACE )
    ManualExclude ( mb )
    common_utils.AutoInclude ( mb, MAIN_NAMESPACE )
    ManualInclude ( mb )
    # here we fixup functions that expect to modifiy their 'passed' variables    
    ManualTransformations ( mb )
    AutoFixes ( mb, MAIN_NAMESPACE )
    ManualFixes ( mb )
    common_utils.Auto_Functional_Transformation ( main_ns )
    
    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    common_utils.Set_DefaultCall_Policies ( mb.global_ns.namespace ( MAIN_NAMESPACE ) )
    
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    NoPropClasses = [""]
    for cls in main_ns.classes():
        if cls.name not in NoPropClasses:
            cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
            
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.watermesh )

    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    extractor = exdoc.doc_extractor() # I'm excluding the UTFstring docs as lots about nothing 
    mb.build_code_creator (module_name='_watermesh_' , doc_extractor= extractor )
    
    for inc in environment.watermesh.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.watermesh.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.watermesh.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.watermesh.version ) )

    mb.split_module(environment.watermesh.generated_dir, huge_classes, use_files_sum_repository=False)

    ## now we need to ensure a series of headers and additional source files are
    ## copied to the generated directory..
    
    common_utils.copyTree ( sourcePath = environment.Config.PATH_watermesh, 
                            destPath = environment.watermesh.generated_dir, 
                            recursive=False )
Пример #26
0
def generate_code():  
    messages.disable( 
#           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
          messages.W1020
        , messages.W1021
        , messages.W1022
        , messages.W1023
        , messages.W1024
        , messages.W1025
        , messages.W1026
        , messages.W1027
        , messages.W1028
        , messages.W1029
        , messages.W1030
        , messages.W1031
#         , messages.W1035
#         , messages.W1040 
#         , messages.W1038 
#         , messages.W1039       
#         , messages.W1041
        , messages.W1036 # pointer to Python immutable member
        , messages.W1033 # unnamed variables
        , messages.W1018 # expose unnamed classes
        , messages.W1049 # returns reference to local variable
        , messages.W1014 # unsupported '=' operator
         )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.nxogre.root_dir, "python_nxogre.h" )
                        , environment.nxogre.cache_file )
    if os.name == 'nt':
        defined_symbols = [ '__PYTHONOGRE_BUILD_CODE','OGRE_NONCLIENT_BUILD', 'OGRE_GCC_VISIBILITY', 'WIN32', 'GCC_XML','NXOGRE_EXPORTS']
    else:
        defined_symbols = [ '__PYTHONOGRE_BUILD_CODE','LINUX','NX_LINUX', 'NX_DISABLE_FLUIDS', 'OGRE_NONCLIENT_BUILD', 'OGRE_GCC_VISIBILITY', 'GCC_XML']

    if environment._USE_THREADS:
        defined_symbols.append('BOOST_HAS_THREADS')
        defined_symbols.append('BOOST_HAS_WINTHREADS')
    defined_symbols.append( 'VERSION_' + environment.nxogre.version )  
    
    undefined_symbols = []
    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.nxogre.include_dirs
                                          , define_symbols=defined_symbols
# #                                           , undefine_symbols = undefined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.ogre.cflags
                                           )
    # NOTE THE CHANGE HERE                                           
    mb.constructors().allow_implicit_conversion = False                                           
    ## This module depends on Ogre and physx
    mb.register_module_dependency ( environment.ogre.generated_dir )
    mb.register_module_dependency ( environment.physx.generated_dir )

    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
    
        
    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    # 
    global_ns = mb.global_ns
    global_ns.exclude()
    main_ns = global_ns.namespace( MAIN_NAMESPACE )
    main_ns.include()
    
   
    AutoExclude ( mb )
    ManualExclude ( mb )
    AutoInclude ( mb )
    ManualInclude ( mb )
    # here we fixup functions that expect to modifiy their 'passed' variables    
    common_utils.Auto_Functional_Transformation ( main_ns )  #, special_vars=['::Ogre::Real &','::Ogre::ushort &','size_t &'] )
    ManualTransformations ( mb )
    
    AutoFixes ( mb )
    ManualFixes ( mb )
            
    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    Set_Call_Policies ( mb.global_ns.namespace (MAIN_NAMESPACE) )
    
# #     for op in main_ns.operators():
# #         print "op1", op
# # #         if op.allow_implicit_conversion:
# # #             print "Implicit conversion on operator ", op
# #     print dir(op)
# #     for op in main_ns.constructors():
# #         print "con1", op
# #         if op.allow_implicit_conversion:
# #             print "Implicit conversion on constructor ", op
# #     print dir(op)            
# #     for op in main_ns.free_operators():
# #         print "op2", op
# # #         if op.allow_implicit_conversion:
# # #             print "Implicit conversion on free operator ", op
# #     print dir(op)
            
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    NoPropClasses = [""]
    for cls in main_ns.classes():
        if cls.name not in NoPropClasses:
            cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
            
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.nxogre )
    
    
    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    extractor = exdoc.doc_extractor("") # I'm excluding the UTFstring docs as lots about nothing 
    mb.build_code_creator (module_name='_nxogre_' , doc_extractor= extractor )
    
    for inc in environment.nxogre.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.nxogre.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.nxogre.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.nxogre.version ) )

    mb.split_module(environment.nxogre.generated_dir, huge_classes,use_files_sum_repository=False)

    ## now we need to ensure a series of headers and additional source files are
    ## copied to the generaated directory..
    common_utils.copyTree ( sourcePath = environment.Config.PATH_NxOgre, 
                            destPath = environment.nxogre.generated_dir, 
                            recursive=False )
Пример #27
0
def generate_code():  
#     messages.disable( 
# #           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
#           messages.W1020
#         , messages.W1021
#         , messages.W1022
#         , messages.W1023
#         , messages.W1024
#         , messages.W1025
#         , messages.W1026
#         , messages.W1027
#         , messages.W1028
#         , messages.W1029
#         , messages.W1030
#         , messages.W1031
#         , messages.W1035
#         , messages.W1040 
#         , messages.W1038        
#         , messages.W1041
#         , messages.W1036 # pointer to Python immutable member
#         , messages.W1033 # unnamed variables
#         , messages.W1018 # expose unnamed classes
#         , messages.W1049 # returns reference to local variable
#         , messages.W1014 # unsupported '=' operator
#          )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.plsm2.root_dir, "python_plsm2.h" )
                        , environment.plsm2.cache_file )


    defined_symbols = [ '_MSC_VER'
                        ,'_PLSM_OCTREE'
                        ,'OGRE_NONCLIENT_BUILD'
                        , 'OGRE_GCC_VISIBILITY'
                        ,'__PYTHONOGRE_BUILD_CODE' ]
    defined_symbols.append( 'VERSION_' + environment.plsm2.version )

    # threads not tested    
    if environment._USE_THREADS:
        defined_symbols.append('BOOST_HAS_THREADS')
        defined_symbols.append('BOOST_HAS_WINTHREADS')

    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.plsm2.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.plsm2.cflags
                                           )
                                           
    # if this module depends on another set it here                                           
    mb.register_module_dependency ( environment.ogre.generated_dir )
    
    # normally implicit conversions work OK, however they can cause strange things to happen so safer to leave off
    mb.constructors().allow_implicit_conversion = False                                           
    
    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
            
    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    # 
    global_ns = mb.global_ns
    global_ns.exclude()
    
#     #
#     # I'm assuming that any 'std' classes etc we need will have already been exposed by the Ogre library
#     #
    # some of the std classes we need haven't been exposed i.e ColourValue 
    #std_ns = global_ns.namespace('std')
    #std_ns.include(already_exposed=True) 
    
    # We don't include all of MAIN_NAMESPACE otherwise we get the same full wrapper
    # so instead we include classes with names that start with PCZ
    main_ns = global_ns.namespace( MAIN_NAMESPACE )
    main_ns.include( already_exposed = True )  ## force the ogre class to be exposed as well...


            
    # We don't include all of MAIN_NAMESPACE otherwise we get the same full wrapper
    # so instead we include classes as follows:
    includes = [  'PagingLandScape'
                 ,'PagingLandscape'
                 ,'MsgQueType'
                 ,'distanceToBoxSort'
                 ,'FrontToBackNodeSorterOperator'
                 ,'LodTracker'
                 ,'Occlusion'
                 ,'OcclusionBoundingBox'
                 ,'OcclusionElement'
                 ,'OctreeSet'
                 ,'PoolSet'
                 ,'QuerySet'
                 ,'RegisterCameraTraversal'
                 ,'RenderLevel'
                 ,'Traversal'
                 ,'CHCTraversal'
                 ,'SWTraversal'
                 ,'TraversalConst'
                 ,'UnregisterCameraTraversal'
                 ,'ConstTraversalConst'
                 ,'ViewFrustumCullingTraversal'
                 ,'ViewFrustumCullingTraversalDirect'
                 ,'VisibilityData'
                 ,'CDRGNURBSSurface'
                 ,'Point4D'
                 ,'splinePoint'
                   ]
 
 
    # temp hack to overcome problem with gccxml fast delegates taken from plsm samples
    includes.append('CustomPagingLandScapeListener')
    
    for c in main_ns.classes():
        for i in includes:
            if c.name.startswith(i):
                print "Including Class: ", c
                c.include()
    
    # same for member functions            
    includes = ['vectorToBoxDistance']
    for f in main_ns.member_functions():
        for i in includes:
            if f.name.startswith(i):
                print "Including Function: ", f
                f.include()
                
    # same for std namespace            
    #includes = [  'std::list< Ogre::SceneNode* >'
    #             ,'std::vector< Ogre::ColourValue >'
    #             ,'std::vector <Ogre::Real>'       ]

    std_ns = global_ns.namespace('std')
    #for c in std_ns.classes():
    #    print "STDXX ", c.name
    
    
    #for c in std_ns.classes():
    #    for i in includes:
    #        if c.name.startswith(i):
    #            print "Including Std: ", c
    #            c.include()
                
    # problem with colorvalue again                
    #std_ns.class_('vector<Ogre::ColourValue, std::allocator<Ogre::ColourValue> >').exclude()
    #std_ns.class_('list<Ogre::PagingLandScapeData2D*, std::allocator<Ogre::PagingLandScapeData2D*> >').include()
    #std_ns.class_('list<Ogre::PagingLandScapeTile*, std::allocator<Ogre::PagingLandScapeTile*> >').include()
    #std_ns.class_('list<Ogre::PagingLandScapePage*, std::allocator<Ogre::PagingLandScapePage*> >').include()
    #std_ns.class_('list<Ogre::PagingLandScapeOctreeNode*, std::allocator<Ogre::PagingLandScapeOctreeNode*> >').include()

    stdex_ns = mb.global_ns.namespace("stdext")
    for cls in stdex_ns.classes():
        print "STDEXT ", cls.name
    #cc=jj


    # same for enums            
    includes = [  'culling_modes'
                 ,'Intersection'
                 ,'Neighbor'
                 ,'PageQueuingState'
                 ,'PageState' ]
                 
    for c in main_ns.enums():
        for i in includes:
            if c.name.startswith(i):
                print "Including Enum: ", c
                c.include()
                
    # exclude nameless structures
    fixUnionStructs(mb)
    
    common_utils.AutoExclude ( mb, MAIN_NAMESPACE )
    ManualExclude ( mb )
    common_utils.AutoInclude ( mb, MAIN_NAMESPACE )
    ManualInclude ( mb )
    # here we fixup functions that expect to modifiy their 'passed' variables    
    ManualTransformations ( mb )
    AutoFixes ( mb, MAIN_NAMESPACE )
    ManualFixes ( mb )
    common_utils.Auto_Functional_Transformation ( main_ns )
    

    
    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    common_utils.Set_DefaultCall_Policies ( mb.global_ns.namespace ( MAIN_NAMESPACE ) )
    
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    NoPropClasses = [""]
    for cls in main_ns.classes():
        if cls.name not in NoPropClasses:
            cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
            
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.plsm2 )

    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    extractor = exdoc.doc_extractor() # I'm excluding the UTFstring docs as lots about nothing 
    mb.build_code_creator (module_name='_plsm2_' , doc_extractor= extractor )
    
    for inc in environment.plsm2.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.plsm2.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.plsm2.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.plsm2.version ) )

    mb.split_module(environment.plsm2.generated_dir, huge_classes, use_files_sum_repository=False)

    ## now we need to ensure a series of headers and additional source files are
    ## copied to the generated directory..
    
    common_utils.copyTree ( sourcePath = environment.Config.PATH_INCLUDE_plsm2, 
                            destPath = environment.plsm2.generated_dir, 
                            recursive=False )
Пример #28
0
def generate_code():  
    messages.disable( 
#           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
          messages.W1020
        , messages.W1021
        , messages.W1022
        , messages.W1023
        , messages.W1024
        , messages.W1025
        , messages.W1026
        , messages.W1027
        , messages.W1028
        , messages.W1029
        , messages.W1030
        , messages.W1031
        , messages.W1035
        , messages.W1040 
        , messages.W1038        
        , messages.W1041
        , messages.W1036 # pointer to Python immutable member
        , messages.W1033 # unnamed variables
        , messages.W1018 # expose unnamed classes
        , messages.W1049 # returns reference to local variable
        , messages.W1014 # unsupported '=' operator
         )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.ogreode.root_dir, "python_ogreode.h" )
                        , environment.ogreode.cache_file )

    defined_symbols = ['OGRE_NONCLIENT_BUILD', 'ODE_LIB','__PYTHONOGRE_BUILD_CODE' ]
    defined_symbols.append( 'OGREODE_VERSION_' + environment.ogreode.version )
      
    if environment._USE_THREADS:
        defined_symbols.append('BOOST_HAS_THREADS')
        defined_symbols.append('BOOST_HAS_WINTHREADS')
        
    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.ogreode.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.ogreode.cflags
                                           )
                                           
    # if this module depends on another set it here                                           
    mb.register_module_dependency ( environment.ogre.generated_dir )
    mb.register_module_dependency ( environment.ode.generated_dir )

    # normally implicit conversions work OK, however they can cause strange things to happen so safer to leave off
    mb.constructors().allow_implicit_conversion = False                                           
    
    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
            
    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    # 
    global_ns = mb.global_ns
    global_ns.exclude()

    query = lambda decl: isinstance( decl, ( declarations.class_t, declarations.class_declaration_t ) ) \
                         and decl.name.startswith( 'dx' )
    mb.global_ns.decls( query ).opaque = True  
    for ns in MAIN_NAMESPACE:
        main_ns = global_ns.namespace( ns )
        main_ns.include()
           
        common_utils.AutoExclude ( mb, ns )
        common_utils.AutoInclude ( mb, ns )
        ManualInclude ( mb, ns )
        # here we fixup functions that expect to modifiy their 'passed' variables    
        ManualTransformations ( mb, ns )
        AutoFixes ( mb, ns )
        ManualFixes ( mb, ns )
        common_utils.Auto_Functional_Transformation ( main_ns )

        #
        # We need to tell boost how to handle calling (and returning from) certain functions
        #
        common_utils.Set_DefaultCall_Policies ( mb.global_ns.namespace ( ns ) )
    ManualExclude ( mb )
    
    #mb.global_ns.class_('::std::list<Ogre::Plane, Ogre::STLAllocator<Ogre::Plane, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >').include(already_exposed=True)
    try:
        mb.global_ns.class_('::std::list<Ogre::Plane, Ogre::STLAllocator<Ogre::Plane, Ogre::CategorisedAllocPolicy<(Ogre::MemoryCategory)0> > >').exclude()
    except:
        pass
    
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    NoPropClasses = [""]
    for cls in main_ns.classes():
        if cls.name not in NoPropClasses:
            cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
            
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.ogreode )

    
    for cls in global_ns.classes():
        if not cls.ignore:
            print cls, cls.decl_string
    for cls in mb.global_ns.namespace("std").classes():
        if not cls.ignore:
            print cls, cls.decl_string
    
    
    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    extractor = exdoc.doc_extractor() # I'm excluding the UTFstring docs as lots about nothing 
    mb.build_code_creator (module_name='_ogreode_' , doc_extractor= extractor )
    
    for inc in environment.ogreode.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.ogreode.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.ogreode.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.ogreode.version ) )

    mb.split_module(environment.ogreode.generated_dir, huge_classes, use_files_sum_repository=False)

    if False:
        ## UGLY FIX
        ## we have a class that needs to be removed and for some reason py++ isn't doing it :(
        ##
        for f in  ['StdListPlane.pypp.cpp','StdListPlane.pypp.hpp']:
            fname = os.path.join( environment.ogreode.generated_dir, f)
            os.remove ( fname ) #remove the extra files
            
        # now remove the entries for the stdlistplane class     
        fname = os.path.join( environment.ogreode.generated_dir, '_ogreode_.main.cpp')  
        f = open(fname, 'r')
        buf = f.readlines()
        f.close()
        newbuf  =[]
        for line in buf:
            if ('stdlistplane' not in line ) and ('StdListPlane' not in line):
                newbuf.append(line)
        f = open ( fname, 'w+')
        f.writelines ( newbuf )
        f.close()
Пример #29
0
def generate_code():  
#     messages.disable( 
# #           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
#           messages.W1020
#         , messages.W1021
#         , messages.W1022
#         , messages.W1023
#         , messages.W1024
#         , messages.W1025
#         , messages.W1026
#         , messages.W1027
#         , messages.W1028
#         , messages.W1029
#         , messages.W1030
#         , messages.W1031
#         , messages.W1035
#         , messages.W1040 
#         , messages.W1038        
#         , messages.W1041
#         , messages.W1036 # pointer to Python immutable member
#         , messages.W1033 # unnamed variables
#         , messages.W1018 # expose unnamed classes
#         , messages.W1049 # returns reference to local variable
#         , messages.W1014 # unsupported '=' operator
#          )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.particleuniverse.root_dir, "python_particleuniverse.h" )
                        , environment.particleuniverse.cache_file )

    defined_symbols = [ 'OGRE_NONCLIENT_BUILD', 'OGRE_GCC_VISIBILITY' ,'PARTICLE_UNIVERSE_EXPORTS', '__PYTHONOGRE_BUILD_CODE' ]
    defined_symbols.append( 'VERSION_' + environment.particleuniverse.version )      
    if environment._USE_THREADS:
        defined_symbols.append('BOOST_HAS_THREADS')
        defined_symbols.append('BOOST_HAS_WINTHREADS')

    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.particleuniverse.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.particleuniverse.cflags
                                           )
                                           
    
    
    # normally implicit conversions work OK, however they can cause strange things to happen so safer to leave off
    mb.constructors().allow_implicit_conversion = False                                           
    
    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
            
    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    # 
    global_ns = mb.global_ns
    global_ns.exclude()
    
    # if this module depends on another set it here   -- we need to do this after the 'global' excludes as includes pulled from Ogre need to be considered                                        
    mb.register_module_dependency ( environment.ogre.generated_dir )
    print "AFTER LOAD"
    print mb.global_ns.class_("::Ogre::Compiler2Pass").already_exposed
    print mb.global_ns.class_("::Ogre::Compiler2Pass").ignore

    main_ns = global_ns.namespace( MAIN_NAMESPACE )
    main_ns.include()
       
    common_utils.AutoExclude ( mb, MAIN_NAMESPACE )
    ManualExclude ( mb )
    common_utils.AutoInclude ( mb, MAIN_NAMESPACE )
    ManualInclude ( mb )
    # here we fixup functions that expect to modifiy their 'passed' variables    
    ManualTransformations ( mb )
    AutoFixes ( mb, MAIN_NAMESPACE )
    ManualFixes ( mb )
    
    common_utils.Auto_Functional_Transformation ( main_ns, special_vars=['::Ogre::Real &','::Ogre::ushort &','size_t &'] )
    
    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    common_utils.Set_DefaultCall_Policies ( mb.global_ns.namespace ( MAIN_NAMESPACE ) )
    
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    NoPropClasses = [""]
    for cls in main_ns.classes():
        if cls.name not in NoPropClasses:
            cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
            
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.particleuniverse )

    
    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    extractor = exdoc.doc_extractor() # I'm excluding the UTFstring docs as lots about nothing 
    mb.build_code_creator (module_name='_particleuniverse_' , doc_extractor= extractor )
    
    for inc in environment.particleuniverse.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.particleuniverse.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.particleuniverse.version ) )
    print "1111", customization_data.header_files( environment.particleuniverse.version )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.particleuniverse.version ) )

    mb.split_module(environment.particleuniverse.generated_dir, huge_classes, use_files_sum_repository=False)
Пример #30
0
def generate(defined_symbols, extraIncludes):
    messages.disable(
        messages.W1005 # using a non public variable type for arguments or returns
        , messages.W1006 # `Py++` need your
                         # help to expose function that takes > as argument/returns C++ arrays.
                         # Take a look on "Function Transformation" > functionality and define
                         # the transformation.
        , messages.W1007 # more than 10 args -> BOOST_PYTHON_MAX_ARITY is set
        , messages.W1009 # execution error W1009: The function takes as argument (name=pFunIdx, pos=1) >
                         # non-const reference to Python immutable type - function could not be called > from Python
        , messages.W1014 # "operator*" is not supported. See
        , messages.W1016 # `Py++` does not exports non-const casting operators
        # Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
        , messages.W1023 # Py++` will generate class wrapper - there are few functions that should be
                         # redefined in class wrapper
        , messages.W1025 # `Py++` will generate class wrapper - class contains "c_" - T* > member variable
        , messages.W1026 # `Py++` will generate class wrapper - class contains "arr_" - T& > member variable
        , messages.W1027 # `Py++` will generate class wrapper - class contains "mat_" - > array member variable
        , messages.W1035 # error. `Py++` can not expose static pointer member variables.
        , messages.W1036 # error. `Py++` can not expose pointer to Python immutable > member variables. This
                         # could be changed in future.
        , messages.W1040 # error. The declaration is unexposed, but there are other > declarations, which
                         # refer to it. This could cause "no to_python converter > found" run
                         # time error
        # This is serious and lead to RuntimeError: `Py++` is going to write different content to the same file
        , messages.W1047 # There are two or more classes that use same > alias("MatElement"). Duplicated aliases causes
                         # few problems, but the main one > is that some of the classes will not
                         # be exposed to Python.Other classes : >
        , messages.W1049 # This method could not be overriden in Python - method returns >
                         # reference to local variable!
        , messages.W1052 # `Py++` will not expose free operator      
        
    )

    logger.debug("Install SRC:  ", os.path.abspath(__file__))
    logger.debug("Execute from: ", os.getcwd())

    sourcedir = os.path.dirname(os.path.abspath(__file__))
    sourceHeader = os.path.abspath(sourcedir + "/" + r"pygimli.h")
    gimliInclude = os.path.dirname(
                         os.path.abspath(sourcedir + "/../src/" + r"gimli.h"))
    settings.includesPaths.append(gimliInclude)

    xml_cached_fc = parser.create_cached_source_fc(
        sourceHeader, settings.module_name + '.cache')
    #xml_cached_fc = parser.create_cached_source_fc(os.path.join(r"pygimli.h"), settings.module_name + '.cache')

    import platform

    defines = ['PYGIMLI_CAST', 'HAVE_BOOST_THREAD_HPP']
    caster = 'gccxml'

    if platform.architecture()[
            0] == '64bit' and platform.system() == 'Windows':

        if sys.platform == 'darwin':
            pass
        else:
            defines.append('_WIN64')
            logger.info('Marking win64 for gccxml')

    for define in [settings.gimli_defines, defined_symbols]:
        if len(define) > 0:
            defines.append(define)

    try:
        if sys.platform == 'win32':
            # os.name == 'nt' (default on my mingw) results in wrong commandline
            # for gccxml
            os.name = 'mingw'
            casterpath = settings.caster_path.replace('\\', '\\\\')
            casterpath = settings.caster_path.replace('/', '\\')
            
            if not 'gccxml' in casterpath:
                caster = 'castxml'
            
            if not '.exe' in casterpath:
                casterpath += '\\' + caster + '.exe'

        else:
            casterpath = settings.caster_path
            if not 'gccxml' in casterpath:
                caster = 'castxml'
            
    except Exception as e:
        logger.info("caster_path=%s" % casterpath)
        logger.info(str(e))
        raise Exception("Problems determine castxml binary")

    settings.includesPaths.insert(0, os.path.abspath(extraIncludes))

    logger.info("caster_path=%s" % casterpath)
    logger.info("working_directory=%s" % settings.gimli_path)
    logger.info("include_paths=%s" % settings.includesPaths)
    logger.info("define_symbols=%s" % defines)
    logger.info("indexing_suite_version=2")


    mb = module_builder.module_builder_t([xml_cached_fc],
                                         gccxml_path=casterpath,
                                         working_directory=settings.gimli_path,
                                         include_paths=settings.includesPaths,
                                         define_symbols=defines,
                                         indexing_suite_version=2,
                                         caster=caster
                                         )

    logger.info("Reading of c++ sources done.")
        
    mb.classes().always_expose_using_scope = True
    mb.calldefs().create_with_signature = True

    global_ns = mb.global_ns
    global_ns.exclude()
    main_ns = global_ns.namespace(MAIN_NAMESPACE)
    main_ns.include()
    

    #for c in main_ns.free_functions():
        ##print(c)
        #if 'pow' in c.name:
            #print(c)
            #print(c.name)
        ##if c.decl_string.startswith('::GIMLI::pow'):
            ##print(c)
            ##print(c.name)
            
    #sys.exit()
                
    logger.info("Apply handmade wrappers.")
    hand_made_wrappers.apply(mb)

    logger.info("Apply custom rvalues.")
    # START manual r-value converters
    rvalue_converters = [
        'register_pytuple_to_rvector3_conversion',
        'register_pysequence_to_rvector_conversion',
        #'register_pysequence_to_bvector_conversion',
        'register_pysequence_to_indexvector_conversion',
        'register_pysequence_to_r3vector_conversion',
        'register_pysequence_to_StdVectorRVector3_conversion',
        #'register_rvector_to_ndarray_conversion',
    ]
    
    for converter in rvalue_converters:
        mb.add_declaration_code('void %s();' % converter)
        mb.add_registration_code('%s();' % converter)

    # END manual r-value converters

    custom_rvalue_path = os.path.join(
        os.path.abspath(os.path.dirname(__file__)), 'custom_rvalue.cpp')

    logger.info("Starting to exclude stuff that we don't need or that is known to be spurious.")
    
    exclude(main_ns.variables,
            name=[
                'Triangle6_S1',
                'Triangle6_S2',
                'Triangle6_S3',
                'HexahedronFacesID',
                'Hexahedron20FacesID',
                'TetrahedronFacesID',
                'HexahedronSplit5TetID',
                'HexahedronSplit6TetID',
                'TriPrismFacesID',
                'TriPrimSplit3TetID',
                'NodeCoordinates',
                'EdgeCoordinates',
                'TriCoordinates',
                'QuadCoordinates',
                'TetCoordinates',
                'HexCoordinates',
                'PrismCoordinates',
                'PyramidCoordinates',
                'PyramidFacesID',
                'Tet10NodeSplit',
                'Tet10NodeSplitZienk',
                'Hex20NodeSplit',
                'Prism15NodeSplit',
                'Pyramid13NodeSplit'
                ]
            )

    exclude(main_ns.free_functions,
            return_type=[
                'float *',
                'float &',
                "::GIMLI::__VectorExpr< double, GIMLI::__VectorUnaryExprOp< double, GIMLI::VectorIterator< double >, GIMLI::ABS_ > >"],
            name=[
                'strReplaceBlankWithUnderscore',
                'toStr',
                'toInt',
                'toFloat',
                'toDouble',
                'str',
                'getRowSubstrings',
                'getNonEmptyRow',
                'getSubstrings',
                'abs',
                'type']
            )

    exclude(main_ns.free_operators,
            name=[''],
            return_type=['::std::ostream &', '::std::istream &']
        )

    exclude(main_ns.classes,
            name=['ABS_', 'ACOT', 'ATAN', 'COS', 'COT', 'EXP',
                  'ABS_', 'LOG', 'LOG10', 'SIGN', 'SIN', 'SQRT', 'SQR', 'TAN', 'TANH',
                  'PLUS', 'MINUS', 'MULT', 'DIVID', 'BINASSIGN', 'cerrPtr',
                  'cerrPtrObject', 'coutPtr', 'coutPtrObject', 'deletePtr', 'edge_',
                  'distancePair_', 'IPCMessage', 'PythonGILSave',
                  ]
            )

    exclude(main_ns.member_functions,
            name=['begin',
                  'end',
                  'val'],
            return_type=['']
        )

    exclude(main_ns.member_operators, 
            symbol=[''])
    
    
    for f in main_ns.declarations:
        if isinstance(f, decl_wrappers.calldef_wrapper.free_function_t):
            if (str(f.return_type).find('GIMLI::VectorExpr') != -1):
                f.exclude()
    
    ex = ['::GIMLI::MatrixElement',
          '::GIMLI::__VectorUnaryExprOp',
          '::GIMLI::__VectorBinaryExprOp',
          '::GIMLI::__ValVectorExprOp',
          '::GIMLI::__VectorValExprOp',
          '::GIMLI::__VectorExpr',
          '::GIMLI::Expr',
          '::GIMLI::InversionBase',
          'GIMLI::MatrixElement',
          'GIMLI::__VectorUnaryExprOp',
          'GIMLI::__VectorBinaryExprOp',
          'GIMLI::__ValVectorExprOp',
          'GIMLI::__VectorValExprOp',
          'GIMLI::__VectorExpr',
          'GIMLI::Expr',
          'GIMLI::InversionBase',
          'std::vector<unsigned long',
          ]
    
    for c in main_ns.free_functions():
        for e in ex:
            if c.decl_string.find(e) > -1:
                try:
                    c.exclude()
                    logger.debug("Exclude: " + str(c))
                except:
                    logger.debug("Fail to exclude: " + str(c))
                    
    for c in main_ns.classes():
        for e in ex:
            if c.decl_string.startswith(e):
                try:
                    c.exclude()
                    logger.debug("Exclude: " + c.name)
                except:
                    logger.debug("Fail to exclude: " + c.name)
          
        try:
            for mem in c.constructors():
                for e in ex:
                    if mem.decl_string.find(e) > -1:
                        try:
                            mem.exclude()
                            #logger.info("Exclude: " + str(mem))
                        except:
                            logger.debug("Fail to exclude: " + str(mem))
                            
            for mem in c.member_functions():
                for e in ex:
                    if mem.decl_string.find(e) > -1:
                        try:
                            mem.exclude()
                            #logger.info("Exclude: " + str(mem))
                        except:
                            logger.debug("Fail to exclude: " + str(mem))
        except:
            #print(c, "has no member functions")
            pass
        
        #print('#'*100)
        #print(c, c.name)
        if c.name.startswith('Vector<unsigned long>'):
            #print('         ', c.name)
            for mem in c.constructors():
                #print("mem", mem, mem.decl_string)
                if mem.decl_string.find('( ::GIMLI::Index )') > -1:
                    logger.debug("Exclude: " + str(mem))
                    mem.exclude()
                
                #print("mem", mem)
            
    mb.calldefs(access_type_matcher_t('protected')).exclude()
    mb.calldefs(access_type_matcher_t('private')).exclude()

    # setMemberFunctionCallPolicieByReturn(mb, [ '::GIMLI::Node &'
    #, '::GIMLI::Cell &'
    #, '::GIMLI::Boundary &'
    #, '::GIMLI::Shape &'
    #, '::GIMLI::Node *'
    #, '::GIMLI::Cell *'
    #, '::GIMLI::Boundary *'
    #, '::GIMLI::Shape *'
    #]
    #, call_policies.reference_existing_object)

    setMemberFunctionCallPolicieByReturn(
        mb,
        ['::std::string *', 'float *', 'double *',
         'int *',
         'long *',
         'long int *', 
         'long long int *',
         'unsigned int *',
         'long unsigned int *', 
         'unsigned long long int *',
         '::GIMLI::Index *', '::GIMLI::SIndex *', 'bool *'],
        call_policies.return_pointee_value)

    setMemberFunctionCallPolicieByReturn(mb, ['::std::string &',
                                              'float &',
                                              'double &',
                                              'int &',
                                              'long &',
                                              'long int &',
                                              'long long int &',
                                              'unsigned int &',
                                              'long unsigned int &',
                                              'unsigned long long int &',
                                              '::GIMLI::Index &',
                                              '::GIMLI::SIndex &',
                                              'bool &'
                                              ], call_policies.return_by_value)

    # setMemberFunctionCallPolicieByReturn(mb, ['::GIMLI::VectorIterator<double> &']
    #, call_policies.copy_const_reference)
    # setMemberFunctionCallPolicieByReturn(mb, [
    #,  'double &' ]
    #, call_policies.reference_existing_object)

    # call_policies.return_value_policy(call_policies.reference_existing_object)
    # call_policies.return_value_policy(call_policies.copy_non_const_reference)
    # call_policies.return_value_policy(call_policies.copy_const_reference)

    # addAutoConversions(mb)

   # excludeMemberByReturn(main_ns, ['::DCFEMLib::SparseMatrix<double> &'])
    #main_ns.classes(decl_starts_with(['STLMatrix']), allow_empty=True).exclude()
    #fun = mb.global_ns.member_functions('begin', allow_empty=True)
    # for f in fun:
    # f.exclude()

    # excludeFreeFunctionsByName(main_ns, ['strReplaceBlankWithUnderscore'
    #'toStr', 'toInt', 'toFloat', 'toDouble',
    #'getRowSubstrings', 'getNonEmptyRow', 'getSubstrings' ])

    #excludeFreeFunctionsByReturn(main_ns, [ 'float *', 'float &' ])
    #fun = ns.free_operators(return_type=funct, allow_empty=True)

    #excludeMemberOperators(main_ns, ['++', '--', '*'])

    # exclude all that does not match any predefined callpolicie

    excludeRest = True

    if excludeRest:
        mem_funs = mb.calldefs()

        for mem_fun in mem_funs:
            if mem_fun.call_policies:
                continue
            if not mem_fun.call_policies and \
                    (declarations.is_reference(mem_fun.return_type) or declarations.is_pointer(mem_fun.return_type)):
                # print mem_fun
                # mem_fun.exclude()
                mem_fun.call_policies = call_policies.return_value_policy(
                    call_policies.reference_existing_object)
                # mem_fun.call_policies = \
                #    call_policies.return_value_policy(call_policies.return_pointee_value)
                # mem_fun.call_policies = \
                #    call_policies.return_value_policy(call_policies.return_opaque_pointer)
                # mem_fun.call_policies = \
                #   call_policies.return_value_policy(call_policies.copy_non_const_reference)

    logger.info("Create api documentation from Doxgen comments.")
    # Now it is the time to give a name to our module
    from doxygen import doxygen_doc_extractor
    extractor = doxygen_doc_extractor()

    logger.info("Create code creator.")
    mb.build_code_creator(settings.module_name, doc_extractor=extractor)

    # It is common requirement in software world - each file should have license
    #mb.code_creator.license = '//Boost Software License(http://boost.org/more/license_info.html)'

    # I don't want absolute includes within code
    mb.code_creator.user_defined_directories.append(os.path.abspath('.'))

    # And finally we can write code to the disk
    def ignore(val):
        pass
    logger.info("Create bindings code.")
    mb.split_module('./generated', on_unused_file_found=ignore)

    additional_files = [
        os.path.join(
               os.path.abspath(os.path.dirname(__file__)), 'custom_rvalue.cpp'), 
        os.path.join(
                os.path.abspath(os.path.dirname(__file__)), 'generators.h'),
        os.path.join(
                os.path.abspath(os.path.dirname(__file__)), 'tuples.hpp')]

    logger.info("Add additional files.")
    
    for sourcefile in additional_files:
        p, filename = os.path.split(sourcefile)
        destfile = os.path.join('./generated', filename)

        if not samefile(sourcefile, destfile):
            shutil.copy(sourcefile, './generated')
            logger.info("Updated " +  filename + "as it was missing or out of date")
Пример #31
0
def generate_code():  
    messages.disable( 
#           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
          messages.W1020
        , messages.W1021
        , messages.W1022
        , messages.W1023
        , messages.W1024
        , messages.W1025
        , messages.W1026
        , messages.W1027
        , messages.W1028
        , messages.W1029
        , messages.W1030
        , messages.W1031
        , messages.W1035
        , messages.W1040 
        , messages.W1038        
        , messages.W1041
        , messages.W1036 # pointer to Python immutable member
        , messages.W1033 # unnamed variables
        , messages.W1018 # expose unnamed classes
        , messages.W1049 # returns reference to local variable
        , messages.W1014 # unsupported '=' operator
         )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.ogrertshadersystem.root_dir, "python_ogrertshadersystem.h" )
                        , environment.ogrertshadersystem.cache_file )

    defined_symbols = environment.defined_symbols 
    defined_symbols .append('OGRE_RTSHADERSYSTEM_EXPORTS')
    defined_symbols.append( 'VERSION_' + environment.ogrertshadersystem.version )  
    
    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.ogrertshadersystem.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.ogrertshadersystem.cflags
                                           )
                                           
    # if this module depends on another set it here                                           
    mb.register_module_dependency ( environment.ogre.generated_dir )
    
    # normally implicit conversions work OK, however they can cause strange things to happen so safer to leave off
    mb.constructors().allow_implicit_conversion = False                                           
    
    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
            
    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    # 
    global_ns = mb.global_ns
    global_ns.exclude()
    main_ns = global_ns.namespace( MAIN_NAMESPACE )
    main_ns.include()
       
    common_utils.AutoExclude ( mb, MAIN_NAMESPACE )
    common_utils.AutoInclude ( mb, MAIN_NAMESPACE )
    ManualInclude ( mb )
    ManualExclude ( mb )
    # here we fixup functions that expect to modifiy their 'passed' variables    
    ManualTransformations ( mb )
    AutoFixes ( mb, MAIN_NAMESPACE )
    ManualFixes ( mb )
    
    common_utils.Auto_Functional_Transformation ( main_ns ) #, special_vars=[]  )
   
    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    common_utils.Set_DefaultCall_Policies ( mb.global_ns.namespace ( MAIN_NAMESPACE ) )
    
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    NoPropClasses = [""]
    for cls in main_ns.classes():
        if cls.name not in NoPropClasses:
            cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
            
    # THIS MUST BE AFTER Auto_Functional_Transformation
    common_utils.Auto_Document( mb, MAIN_NAMESPACE )
    
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.ogrertshadersystem )

    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    extractor = exdoc.doc_extractor() # I'm excluding the UTFstring docs as lots about nothing 
    mb.build_code_creator (module_name='_ogrertshadersystem_' , doc_extractor= extractor )
    
    for inc in environment.ogrertshadersystem.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.ogrertshadersystem.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.ogrertshadersystem.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.ogrertshadersystem.version ) )

    mb.split_module(environment.ogrertshadersystem.generated_dir, huge_classes, use_files_sum_repository=False)

    ## now we need to ensure a series of headers and additional source files are
    ## copied to the generated directory..
    
#     common_utils.copyTree ( sourcePath = environment.Config.PATH_INCLUDE_ogrertshadersystem, 
#                             destPath = environment.ogrertshadersystem.generated_dir, 
#                             recursive=False )
        
    if environment.ogre.version.startswith("1.7"):
        ## have a code generation issue that needs resolving...
        filesToFix=['CGProgramProcessor.pypp.cpp', 'GLSLProgramProcessor.pypp.cpp','HLSLProgramProcessor.pypp.cpp',
                    'ProgramProcessor.pypp.cpp', 'stdMapRTShaderParameterOperand.pypp.cpp', 
                    'stdMapRTShaderParameterParameter.pypp.cpp',
                    'CGProgramProcessor.pypp.cpp']
        for filename in filesToFix:
            fname = os.path.join( environment.ogrertshadersystem.generated_dir, filename)
            try:
                f = open(fname, 'r')
                buf = f.read()
                f.close()
                print "CHECKING:", fname
                if (" MEMCATEGORY_GENERAL" in buf) or ("<MEMCATEGORY_GENERAL" in buf):
                    buf = buf.replace ( " MEMCATEGORY_GENERAL", " Ogre::MEMCATEGORY_GENERAL")
                    buf = buf.replace ( "<MEMCATEGORY_GENERAL", "<Ogre::MEMCATEGORY_GENERAL")
                    f = open ( fname, 'w+')
                    f.write ( buf )
                    f.close()
                    print "UGLY FIX OK:", fname
            except:
                print "ERROR: Unable to fix:", fname
Пример #32
0
def generate_code():  
# # #     messages.disable( 
# # # #           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
# # #           messages.W1020
# # #         , messages.W1021
# # #         , messages.W1022
# # #         , messages.W1023
# # #         , messages.W1024
# # #         , messages.W1025
# # #         , messages.W1026
# # #         , messages.W1027
# # #         , messages.W1028
# # #         , messages.W1029
# # #         , messages.W1030
# # #         , messages.W1031
# # #         , messages.W1035
# # #         , messages.W1040 
# # #         , messages.W1038        
# # #         , messages.W1041
# # #         , messages.W1036 # pointer to Python immutable member
# # #         , messages.W1033 # unnamed variables
# # #         , messages.W1018 # expose unnamed classes
# # #         , messages.W1049 # returns reference to local variable
# # #         , messages.W1014 # unsupported '=' operator
# # #          )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file   
    #
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.raknet.root_dir, "python_raknet.h" )
                        , environment.raknet.cache_file )

    if os.name == 'nt':
        defined_symbols = [ '_WIN32', '__PYTHONOGRE_BUILD_CODE', '_RELEASE', '_CRT_NONSTDC_NO_DEPRECATE', '_STDINT' ] # '_RAKNET_LIB' ]_RAKNET_DLL
        # added _STDINT to stop overlaps in defines from stdint.h
    else:
        defined_symbols = [ '__PYTHONOGRE_BUILD_CODE', '_RELEASE', '_CRT_NONSTDC_NO_DEPRECATE', '_STDINT' ]        

    defined_symbols.append( 'VERSION_' + environment.raknet.version )  
    
    #
    # build the core Py++ system from the GCCXML created source
    #    
    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.raknet.include_dirs
                                          , define_symbols=defined_symbols
                                          , indexing_suite_version=2
                                          , cflags=environment.raknet.cflags
                                           )
                                           
    # if this module depends on another set it here                                           
#     mb.register_module_dependency ( environment.ogre.generated_dir )
    
    # normally implicit conversions work OK, however they can cause strange things to happen so safer to leave off
    mb.constructors().allow_implicit_conversion = False                                           
    
    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True
            
    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    # 
    global_ns = mb.global_ns
    global_ns.exclude()
    main_ns = global_ns## .namespace( MAIN_NAMESPACE )
#     main_ns.include()
       
    ManualInclude ( mb )
    
    common_utils.AutoExclude ( mb, MAIN_NAMESPACE )
    ManualExclude ( mb )
    common_utils.AutoInclude ( mb, MAIN_NAMESPACE )
    # here we fixup functions that expect to modifiy their 'passed' variables    
    ManualTransformations ( mb )
    AutoFixes ( mb, MAIN_NAMESPACE )
    ManualFixes ( mb )
    
    common_utils.Auto_Functional_Transformation ( main_ns  )
    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    common_utils.Set_DefaultCall_Policies ( main_ns )
    
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )

    NoPropClasses = [""]
    for cls in main_ns.classes():
        if cls.name not in NoPropClasses:
            cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t() )
            
    # THIS MUST BE AFTER Auto_Functional_Transformation
    common_utils.Auto_Document( mb, MAIN_NAMESPACE )
    
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.raknet )

    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    extractor = exdoc.doc_extractor() # I'm excluding the UTFstring docs as lots about nothing 
    mb.build_code_creator (module_name='_raknet_' , doc_extractor= extractor )
    
    for inc in environment.raknet.include_dirs:
        mb.code_creator.user_defined_directories.append(inc )
    mb.code_creator.user_defined_directories.append( environment.raknet.generated_dir )
    mb.code_creator.replace_included_headers( customization_data.header_files( environment.raknet.version ) )

    huge_classes = map( mb.class_, customization_data.huge_classes( environment.raknet.version ) )

    mb.split_module(environment.raknet.generated_dir, huge_classes, use_files_sum_repository=False)

    ## now we need to ensure a series of headers and additional source files are
    ## copied to the generated directory..
    # we could change raknet to be dll exported in raknet source but this would mean patching :(.
    # so instead we simply include the missing class in our own wrapper..
    
    #additional_files=[ 'ReliabilityLayer.cpp','RakMemoryOverride.cpp','DataBlockEncryptor.cpp',
    #                 'SocketLayer.cpp','rijndael.cpp', 'CheckSum.cpp','WSAStartupSingleton.cpp', 'RakPeer.cpp',
    #                 'RakThread.cpp' ]
    
    additional_files=['ReliabilityLayer.cpp','RakMemoryOverride.cpp','CCRakNetUDT.cpp','SuperFastHash.cpp','RakNetTypes.cpp',
                       'CheckSum.cpp','Itoa.cpp','SocketLayer.cpp','WSAStartupSingleton.cpp', 'RakPeer.cpp'] 
                       
    for sourcefile in additional_files:
        sourcefile = os.path.join(environment.Config.PATH_INCLUDE_raknet, sourcefile )
        p,filename = os.path.split(sourcefile)
        destfile = os.path.join(environment.raknet.generated_dir, filename ) 
    
        if not common_utils.samefile( sourcefile ,destfile ):
            shutil.copy( sourcefile, environment.raknet.generated_dir )
            print "Updated ", filename, "as it was missing or out of date"
Пример #33
0
def generate_ogrenewt():
 
    xml_cached_fc = parser.create_cached_source_fc(
                        os.path.join( environment.ogrenewt.root_dir, "python_ogrenewt.h" )
                        , environment.ogrenewt.cache_file )
                        
    defined_symbols = [ 'OGRE_NONCLIENT_BUILD','__PYTHONOGRE_BUILD_CODE',
                        'ogrenewt_NONCLIENT_BUILD','OIS_NONCLIENT_BUILD' ] #, 'OIS_STATIC_BUILD' ]
    defined_symbols.append( 'VERSION_' + environment.ogrenewt.version )
      
    if environment._USE_THREADS:
        defined_symbols.append('BOOST_HAS_THREADS')
        defined_symbols.append('BOOST_HAS_WINTHREADS')
    if environment.isLinux():
        defined_symbols.append('BOOST_IS_ENUM')

    mb = module_builder.module_builder_t( [ xml_cached_fc ]
                                          , gccxml_path=environment.gccxml_bin
                                          , working_directory=environment.root_dir
                                          , include_paths=environment.ogrenewt.include_dirs
                                          , define_symbols=defined_symbols
                                          , cflags=environment.ogrenewt.cflags
                                          , indexing_suite_version=2 )

    ## This module depends on Ogre
    mb.register_module_dependency ( environment.ogre.generated_dir )
    filter_declarations (mb)
    #
    # fix shared Ptr's that are defined as references but NOT const...
    #
    find_nonconst ( mb.namespace( 'Ogre' ) )

    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True

    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply( mb )
    
    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    set_call_policies ( mb.global_ns.namespace ('OgreNewt') )
    
    # here we fixup functions that expect to modifiy their 'passed' variables  
    #  
    add_transformations ( mb )
    
    
    # 
    # now add properties
    #
    for cls in mb.namespace ('OgreNewt').classes():
        cls.add_properties( recognizer=ogre_properties.ogre_property_recognizer_t()  )
        common_utils.add_LeadingLowerProperties ( cls )
    
    ## add additional version information to the module to help identify it correctly 
    common_utils.addDetailVersion ( mb, environment, environment.ogrenewt )

    # create the doc extractor we'll be using
    extractor = exdoc.doc_extractor("")
    #
    #Creating the actual code. After this step you should not modify/customize declarations.
    #
    mb.build_code_creator (module_name='_ogrenewt_', doc_extractor= extractor)
    for incs in environment.ogrenewt.include_dirs:
        mb.code_creator.user_defined_directories.append( incs )
    mb.code_creator.replace_included_headers( customization_data.header_files(environment.ogrenewt.version) )

    huge_classes = map( mb.class_, customization_data.huge_classes(environment.ogrenewt.version) )

    mb.split_module(environment.ogrenewt.generated_dir, huge_classes)

#     return_pointee_value_source_path \
#         = os.path.join( environment.pyplusplus_install_dir
#                         , 'pyplusplus_dev'
#                         , 'pyplusplus'
#                         , 'code_repository' )
#                         ## , 'return_pointee_value.hpp' ) ## Removed AJM 1/1/07

#     return_pointee_value_target_path \
#         = os.path.join( environment.ogrenewt.generated_dir, 'return_pointee_value.hpp' )

#     if not os.path.exists( return_pointee_value_target_path ):
#         shutil.copy( return_pointee_value_source_path, environment.ogrenewt.generated_dir )

    if environment.isMac():
       ## now we need to ensure a series of headers and additional source files are
      ## copied to the generated directory..
      basePath = os.path.join(environment.Config.PATH_OgreAddons,'ogrenewt', 'OgreNewt_Main')
      common_utils.copyTree ( sourcePath = os.path.join(basePath, 'inc'),
                              destPath = environment.ogrenewt.generated_dir, 
                              recursive= False,
                              extensions = ['h'] )
      common_utils.copyTree ( sourcePath = os.path.join(basePath, 'src'),
                              destPath = environment.ogrenewt.generated_dir, 
                              recursive= False,
                              collapse = True, # put all the source in a single directory
                              extensions = ['cpp'] )
Пример #34
0
def generate(defined_symbols, extraIncludes):
    messages.disable(
        messages.W1005  # using a non public variable type for arguments or returns
        , messages.W1006  # `Py++` need your
                          # help to expose function that takes > as argument/returns C++ arrays.
                          # Take a look on "Function Transformation" > functionality and define
                          # the transformation.
        , messages.W1007  # more than 10 args -> BOOST_PYTHON_MAX_ARITY is set
        , messages.W1009  # execution error W1009: The function takes as argument (name=pFunIdx, pos=1) >
                          # non-const reference to Python immutable type - function could not be called > from Python
        , messages.W1014  # "operator*" is not supported. See
        , messages.W1016  # `Py++` does not exports non-const casting operators
        # Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
        , messages.W1023  # Py++` will generate class wrapper - there are few functions that should be
                          # redefined in class wrapper
        , messages.W1025  # `Py++` will generate class wrapper - class contains "c_" - T* > member variable
        , messages.W1026  # `Py++` will generate class wrapper - class contains "arr_" - T& > member variable
        , messages.W1027  # `Py++` will generate class wrapper - class contains "mat_" - > array member variable
        , messages.W1035  # error. `Py++` can not expose static pointer member variables.
        , messages.W1036  # error. `Py++` can not expose pointer to Python immutable > member variables. This
                          # could be changed in future.
        , messages.W1040  # error. The declaration is unexposed, but there are other > declarations, which
                          # refer to it. This could cause "no to_python converter > found" run
                          # time error
        # This is serious and lead to RuntimeError: `Py++` is going to write different content to the same file
        , messages.W1047 # There are two or more classes that use same > alias("MatElement"). Duplicated aliases causes
                         # few problems, but the main one > is that some of the classes will not
                         # be exposed to Python.Other classes : >
        , messages.W1049  # This method could not be overriden in Python - method returns >
                          # reference to local variable!
        , messages.W1052  # `Py++` will not expose free operator
    )

    logger.debug("Install SRC:  ", os.path.abspath(__file__))
    logger.debug("Execute from: ", os.getcwd())

    sourcedir = os.path.dirname(os.path.abspath(__file__))
    sourceHeader = os.path.abspath(sourcedir + "/" + r"pygimli.h")
    gimliInclude = os.path.dirname(
                         os.path.abspath(sourcedir + "/../src/" + r"gimli.h"))
    settings.includesPaths.append(gimliInclude)

    xml_cached_fc = parser.create_cached_source_fc(
        sourceHeader, settings.module_name + '.cache')

    import platform

    defines = ['PYGIMLI_CAST', 'HAVE_BOOST_THREAD_HPP']
    caster = 'gccxml'
    compiler_path = options.clang

    if platform.system() == 'Windows':
        if platform.architecture()[0] == '64bit':
            #compiler_path = 'C:/msys64/mingw64/bin/clang++'
            if sys.platform == 'darwin':
                pass
            else:
                defines.append('_WIN64')
                defines.append('MS_WIN64')

                logger.info('Marking win64 for gccxml')
        else:
            pass
            #compiler_path = 'C:/msys32/mingw32/bin/clang++'

    if len(compiler_path) == 0:
        compiler_path = None

    for define in [settings.gimli_defines, defined_symbols]:
        if len(define) > 0:
            defines.append(define)

    try:
        if sys.platform == 'win32':
            # os.name == 'nt' (default on my mingw)results in wrong commandline
            # for gccxml
            os.name = 'mingw'
            casterpath = settings.caster_path.replace('\\', '\\\\')
            casterpath = settings.caster_path.replace('/', '\\')

            if 'gccxml' not in casterpath:
                caster = 'castxml'

            if '.exe' not in casterpath:
                casterpath += '\\' + caster + '.exe'

        else:
            casterpath = settings.caster_path
            if 'gccxml' not in casterpath:
                caster = 'castxml'

    except Exception as e:
        logger.info("caster_path=%s" % casterpath)
        logger.info(str(e))
        raise Exception("Problems determine castxml binary")

    settings.includesPaths.insert(0, os.path.abspath(extraIncludes))

    logger.info("caster_path=%s" % casterpath)
    logger.info("working_directory=%s" % settings.gimli_path)
    logger.info("include_paths=%s" % settings.includesPaths)
    logger.info("define_symbols=%s" % defines)
    logger.info("compiler_path=%s" % compiler_path)
    logger.info("indexing_suite_version=2")

    xml_generator_config = parser.xml_generator_configuration_t(
                                        xml_generator=caster,
                                        xml_generator_path=casterpath,
                                        working_directory=settings.gimli_path,
                                        include_paths=settings.includesPaths,
                                        define_symbols=defines,
                                        ignore_gccxml_output=False,
                                        cflags="",
                                        compiler_path=compiler_path)

    mb = module_builder.module_builder_t(
                                [xml_cached_fc],
                                indexing_suite_version=2,
                                xml_generator_config=xml_generator_config
                                )

    logger.info("Reading of c++ sources done.")

    mb.classes().always_expose_using_scope = True
    mb.calldefs().create_with_signature = True

    global_ns = mb.global_ns
    global_ns.exclude()
    main_ns = global_ns.namespace(MAIN_NAMESPACE)
    main_ns.include()

    # for c in main_ns.free_functions():
    #   print(c)
    #   if 'pow' in c.name:
    #       print(c)
    #       print(c.name)
    #   if c.decl_string.startswith('::GIMLI::pow'):
    #       print(c)
    #       print(c.name)
    # sys.exit()

    logger.info("Apply handmade wrappers.")
    try:
        hand_made_wrappers.apply(mb)
    except BaseException as e:
        print(e)

    logger.info("Apply custom rvalues.")
    # START manual r-value converters
    rvalue_converters = [
        'register_pytuple_to_rvector3_conversion',
        'register_pysequence_to_rvector_conversion',
        # 'register_pysequence_to_bvector_conversion',
        'register_pysequence_to_indexvector_conversion',
        'register_pysequence_to_r3vector_conversion',
        'register_pysequence_to_StdVectorRVector3_conversion',
        # 'register_rvector_to_ndarray_conversion',
    ]

    for converter in rvalue_converters:
        mb.add_declaration_code('void %s();' % converter)
        mb.add_registration_code('%s();' % converter)

    # END manual r-value converters

    custom_rvalue_path = os.path.join(
        os.path.abspath(os.path.dirname(__file__)), 'custom_rvalue.cpp')

    logger.info("Starting to exclude stuff that we don't need "
                "or that is known to be spurious.")

    exclude(main_ns.variables,
            name=[
                'Triangle6_S1',
                'Triangle6_S2',
                'Triangle6_S3',
                'HexahedronFacesID',
                'Hexahedron20FacesID',
                'TetrahedronFacesID',
                'HexahedronSplit5TetID',
                'HexahedronSplit6TetID',
                'TriPrismFacesID',
                'TriPrimSplit3TetID',
                'NodeCoordinates',
                'EdgeCoordinates',
                'TriCoordinates',
                'QuadCoordinates',
                'TetCoordinates',
                'HexCoordinates',
                'PrismCoordinates',
                'PyramidCoordinates',
                'PyramidFacesID',
                'Tet10NodeSplit',
                'Tet10NodeSplitZienk',
                'Hex20NodeSplit',
                'Prism15NodeSplit',
                'Pyramid13NodeSplit'
                ]
            )

    exclude(main_ns.free_functions,
            return_type=[
                'float *',
                'float &',
                "::GIMLI::__VectorExpr< double, " +
                "GIMLI::__VectorUnaryExprOp< double, " +
                "GIMLI::VectorIterator< double >, GIMLI::ABS_ > >"],
            name=[
                'strReplaceBlankWithUnderscore',
                'toStr',
                'toInt',
                'toFloat',
                'toDouble',
                'str',
                'getRowSubstrings',
                'getNonEmptyRow',
                'getSubstrings',
                'abs',
                'type']
            )

    exclude(main_ns.free_operators,
            name=[''],
            return_type=['::std::ostream &', '::std::istream &']
            )

    exclude(main_ns.classes,
            name=['ABS_', 'ACOT', 'ATAN', 'COS', 'COT', 'EXP',
                  'ABS_', 'LOG', 'LOG10', 'SIGN', 'SIN', 'SQRT', 'SQR',
                  'TAN', 'TANH',
                  'PLUS', 'MINUS', 'MULT', 'DIVID', 'BINASSIGN', 'cerrPtr',
                  'cerrPtrObject', 'coutPtr', 'coutPtrObject', 'deletePtr',
                  'edge_',
                  'distancePair_', 'IPCMessage', 'PythonGILSave',
                  ]
            )

    exclude(main_ns.member_functions,
            name=['begin',
                  'end',
                  'val'],
            return_type=['']
            )

    exclude(main_ns.member_operators,
            symbol=[''])

    for f in main_ns.declarations:
        if isinstance(f, decl_wrappers.calldef_wrapper.free_function_t):
            if (str(f.return_type).find('GIMLI::VectorExpr') != -1):
                f.exclude()

    ex = ['::GIMLI::MatrixElement',
          '::GIMLI::__VectorUnaryExprOp',
          '::GIMLI::__VectorBinaryExprOp',
          '::GIMLI::__ValVectorExprOp',
          '::GIMLI::__VectorValExprOp',
          '::GIMLI::__VectorExpr',
          '::GIMLI::Expr',
          '::GIMLI::InversionBase',
          'GIMLI::MatrixElement',
          'GIMLI::__VectorUnaryExprOp',
          'GIMLI::__VectorBinaryExprOp',
          'GIMLI::__ValVectorExprOp',
          'GIMLI::__VectorValExprOp',
          'GIMLI::__VectorExpr',
          'GIMLI::Expr',
          'GIMLI::InversionBase',
          'std::vector<unsigned long',
          'std::vector<bool',
          'std::vector<double',
          ]

    for c in main_ns.free_functions():
        for e in ex:
            if c.decl_string.find(e) > -1:
                try:
                    c.exclude()
                    logger.debug("Exclude: " + str(c))
                except BaseException as _:
                    logger.debug("Fail to exclude: " + str(c))

    for c in main_ns.classes():
        for e in ex:
            if c.decl_string.startswith(e):
                try:
                    c.exclude()
                    logger.debug("Exclude: " + c.name)
                except BaseException as _:
                    logger.debug("Fail to exclude: " + c.name)

        try:
            for mem in c.variables():
                try:
                    mem.exclude()
                    # logger.info("Exclude: " + str(mem))
                except BaseException as _:
                    logger.debug("Fail to exclude: " + str(mem))
        except BaseException as _:
            # print(c, "has no member functions")
            pass

        try:
            for mem in c.constructors():
                for e in ex:
                    if mem.decl_string.find(e) > -1:
                        try:
                            mem.exclude()
                            # logger.info("Exclude: " + str(mem))
                        except BaseException as _:
                            logger.debug("Fail to exclude: " + str(mem))

            for mem in c.member_functions():
                for e in ex:
                    if mem.decl_string.find(e) > -1:
                        try:
                            mem.exclude()
                            # logger.info("Exclude: " + str(mem))
                        except BaseException as _:
                            logger.debug("Fail to exclude: " + str(mem))



        except BaseException as _:
            # print(c, "has no member functions")
            pass

        # print('#'*100)
        # print(c, c.name)
        if c.name.startswith('Vector<unsigned long>'):
            # print('         ', c.name)
            for mem in c.constructors():
                # print("mem", mem, mem.decl_string)
                if mem.decl_string.find('( ::GIMLI::Index )') > -1:
                    logger.debug("Exclude: " + str(mem))
                    mem.exclude()

                # print("mem", mem)

    try:
        mb.calldefs(access_type_matcher_t('protected')).exclude()
        mb.calldefs(access_type_matcher_t('private')).exclude()
    except BaseException as _:
        pass

    # setMemberFunctionCallPolicieByReturn(mb, [ '::GIMLI::Node &'
    # , '::GIMLI::Cell &'
    # , '::GIMLI::Boundary &'
    # , '::GIMLI::Shape &'
    # , '::GIMLI::Node *'
    # , '::GIMLI::Cell *'
    # , '::GIMLI::Boundary *'
    # , '::GIMLI::Shape *'
    # ]
    # , call_policies.reference_existing_object)

    setMemberFunctionCallPolicieByReturn(
        mb,
        ['::std::string *', 'float *', 'double *',
         'int *',
         'long *',
         'long int *',
         'long long int *',
         'unsigned int *',
         'long unsigned int *',
         'unsigned long long int *',
         'long long unsigned int *',
         '::GIMLI::Index *', '::GIMLI::SIndex *', 'bool *'],
        call_policies.return_pointee_value)

    setMemberFunctionCallPolicieByReturn(mb, ['::std::string &',
                                              'float &',
                                              'double &',
                                              'int &',
                                              'long &',
                                              'long int &',
                                              'long long int &',
                                              'unsigned int &',
                                              'long unsigned int &',
                                              'long long unsigned int &',
                                              'unsigned long long int &',
                                              '::GIMLI::Index &',
                                              '::GIMLI::SIndex &',
                                              'bool &'
                                              ], call_policies.return_by_value)

    # setMemberFunctionCallPolicieByReturn(mb,
    #                                   ['::GIMLI::VectorIterator<double> &']
    # , call_policies.copy_const_reference)
    # setMemberFunctionCallPolicieByReturn(mb, [
    # ,  'double &' ]
    # , call_policies.reference_existing_object)

    # call_policies.return_value_policy(call_policies.reference_existing_object)
    # call_policies.return_value_policy(call_policies.copy_non_const_reference)
    # call_policies.return_value_policy(call_policies.copy_const_reference)

    # addAutoConversions(mb)

    # excludeMemberByReturn(main_ns, ['::DCFEMLib::SparseMatrix<double> &'])
    # fun = mb.global_ns.member_functions('begin', allow_empty=True)
    # for f in fun:
    # f.exclude()

    # excludeFreeFunctionsByName(main_ns, ['strReplaceBlankWithUnderscore'
    # 'toStr', 'toInt', 'toFloat', 'toDouble',
    # 'getRowSubstrings', 'getNonEmptyRow', 'getSubstrings' ])

    # excludeFreeFunctionsByReturn(main_ns, [ 'float *', 'float &' ])
    # fun = ns.free_operators(return_type=funct, allow_empty=True)

    # excludeMemberOperators(main_ns, ['++', '--', '*'])

    # exclude all that does not match any predefined callpolicie

    excludeRest = True

    if excludeRest:
        mem_funs = mb.calldefs()

        for mem_fun in mem_funs:
            if mem_fun.call_policies:
                continue
            if not mem_fun.call_policies and \
                    (declarations.is_reference(mem_fun.return_type) or
                        declarations.is_pointer(mem_fun.return_type)):
                # print mem_fun
                # mem_fun.exclude()
                mem_fun.call_policies = call_policies.return_value_policy(
                    call_policies.reference_existing_object)
                # mem_fun.call_policies = \
                #    call_policies.return_value_policy(call_policies.return_pointee_value)
                # mem_fun.call_policies = \
                #    call_policies.return_value_policy(call_policies.return_opaque_pointer)
                # mem_fun.call_policies = \
                #   call_policies.return_value_policy(call_policies.copy_non_const_reference)

    logger.info("Create api documentation from Doxgen comments.")
    # Now it is the time to give a name to our module
    from doxygen import doxygen_doc_extractor
    extractor = doxygen_doc_extractor()

    logger.info("Create code creator.")
    mb.build_code_creator(settings.module_name, doc_extractor=extractor)

    # It is common requirement in software world-each file should have license
    # mb.code_creator.license = '//Boost Software
    # License(http://boost.org/more/license_info.html)'

    # I don't want absolute includes within code
    mb.code_creator.user_defined_directories.append(os.path.abspath('.'))

    # And finally we can write code to the disk
    def ignore(val):
        pass
    logger.info("Create bindings code.")
    mb.split_module('./generated', on_unused_file_found=ignore)

    additional_files = [
        os.path.join(
            os.path.abspath(os.path.dirname(__file__)), 'custom_rvalue.cpp'),
        os.path.join(
            os.path.abspath(os.path.dirname(__file__)), 'generators.h'),
        os.path.join(
            os.path.abspath(os.path.dirname(__file__)), 'tuples.hpp')]

    logger.info("Add additional files.")

    for sourcefile in additional_files:
        p, filename = os.path.split(sourcefile)
        destfile = os.path.join('./generated', filename)

        if not samefile(sourcefile, destfile):
            shutil.copy(sourcefile, './generated')
            logger.info("Updated " + filename +
                        "as it was missing or out of date")
Пример #35
0
def generate_code():
    messages.disable(
        #           Warnings 1020 - 1031 are all about why Py++ generates wrapper for class X
        messages.W1020,
        messages.W1021,
        messages.W1022,
        messages.W1023,
        messages.W1024,
        messages.W1025,
        messages.W1026,
        messages.W1027,
        messages.W1028,
        messages.W1029,
        messages.W1030,
        messages.W1031
        #         , messages.W1035
        #         , messages.W1040
        #         , messages.W1038
        #         , messages.W1041
        ,
        messages.W1036,  # pointer to Python immutable member
        messages.W1033,  # unnamed variables
        messages.W1018,  # expose unnamed classes
        messages.W1049,  # returns reference to local variable
        messages.W1014,  # unsupported '=' operator
    )
    #
    # Use GCCXML to create the controlling XML file.
    # If the cache file (../cache/*.xml) doesn't exist it gets created, otherwise it just gets loaded
    # NOTE: If you update the source library code you need to manually delete the cache .XML file
    #
    xml_cached_fc = parser.create_cached_source_fc(
        os.path.join(environment.ogreforests.root_dir, "python_forests.h"), environment.ogreforests.cache_file
    )

    defined_symbols = ["OGRE_NONCLIENT_BUILD", "WIN32", "GCCXML_BUG", "__PYTHONOGRE_BUILD_CODE"]
    undefine_symbols = []
    if environment._USE_THREADS:
        defined_symbols.append("BOOST_HAS_THREADS")
        defined_symbols.append("BOOST_HAS_WINTHREADS")

    defined_symbols.append("VERSION_" + environment.ogreforests.version)

    #
    # build the core Py++ system from the GCCXML created source
    #
    mb = module_builder.module_builder_t(
        [xml_cached_fc],
        gccxml_path=environment.gccxml_bin,
        working_directory=environment.root_dir,
        include_paths=environment.ogreforests.include_dirs,
        define_symbols=defined_symbols,
        indexing_suite_version=2,
        cflags=environment.ogreforests.cflags,
    )

    # if this module depends on another set it here
    ## mb.register_module_dependency ( environment.ogre.generated_dir )

    # normally implicit conversions work OK, however they can cause strange things to happen so safer to leave off
    mb.constructors().allow_implicit_conversion = False
    mb.register_module_dependency(environment.ogre.generated_dir)

    mb.BOOST_PYTHON_MAX_ARITY = 25
    mb.classes().always_expose_using_scope = True

    #
    # We filter (both include and exclude) specific classes and functions that we want to wrap
    #
    global_ns = mb.global_ns
    global_ns.exclude()
    main_ns = global_ns.namespace(MAIN_NAMESPACE)
    main_ns.include()

    common_utils.AutoExclude(mb, MAIN_NAMESPACE)
    ManualExclude(mb)
    common_utils.AutoInclude(mb, MAIN_NAMESPACE)
    ManualInclude(mb)

    # here we fixup functions that expect to modifiy their 'passed' variables and are not autmatically fixed
    ManualTransformations(mb)

    AutoFixes(mb, MAIN_NAMESPACE)
    ManualFixes(mb)
    common_utils.Auto_Functional_Transformation(main_ns)

    common_utils.Auto_Document(mb, MAIN_NAMESPACE)

    ## note change to clear prefix_output as this will force all transforms to be inout (and not 'output') to ensure the arguments are matched
    ## problem with overload virtual fuctions from parent class such as getMetrics in RenderWindow and RenderTarget
    common_utils.Auto_Functional_Transformation(
        main_ns
    )  ##, special_vars=['::Ogre::Real &','::Ogre::ushort &','size_t &']  )

    #
    # We need to tell boost how to handle calling (and returning from) certain functions
    #
    common_utils.Set_DefaultCall_Policies(main_ns)
    for c in main_ns.classes():
        print "CLass", c
    #
    # the manual stuff all done here !!!
    #
    hand_made_wrappers.apply(mb)

    NoPropClasses = [""]
    for cls in main_ns.classes():
        if cls.name not in NoPropClasses:
            cls.add_properties(recognizer=ogre_properties.ogre_property_recognizer_t())

    ## add additional version information to the module to help identify it correctly
    common_utils.addDetailVersion(mb, environment, environment.ogreforests)

    ##########################################################################################
    #
    # Creating the code. After this step you should not modify/customize declarations.
    #
    ##########################################################################################
    extractor = exdoc.doc_extractor()  # I'm excluding the UTFstring docs as lots about nothing
    mb.build_code_creator(module_name="_ogreforests_", doc_extractor=extractor)

    for inc in environment.ogreforests.include_dirs:
        mb.code_creator.user_defined_directories.append(inc)
    mb.code_creator.user_defined_directories.append(environment.ogreforests.generated_dir)
    mb.code_creator.replace_included_headers(customization_data.header_files(environment.ogreforests.version))

    huge_classes = map(mb.class_, customization_data.huge_classes(environment.ogreforests.version))

    mb.split_module(environment.ogreforests.generated_dir, huge_classes, use_files_sum_repository=False)

    ## now we need to ensure a series of headers and additional source files are
    ## copied to the generated directory..
    common_utils.copyTree(
        sourcePath=environment.Config.PATH_INCLUDE_ogreforests,
        destPath=environment.ogreforests.generated_dir,
        recursive=False,
    )