[Python-ogre-commit] SF.net SVN: python-ogre:[826] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
From: <and...@us...> - 2008-12-04 13:12:16
|
Revision: 826 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=826&view=rev Author: andy_miller Date: 2008-12-04 13:12:10 +0000 (Thu, 04 Dec 2008) Log Message: ----------- Added MyGui to the code generators (not finished) Update to ogreode demo Modified Paths: -------------- trunk/python-ogre/PythonOgreConfig_posix.py trunk/python-ogre/demos/OgreNewt/Demo01_TheBasics.py trunk/python-ogre/demos/ogre/Demo_Bezier.py trunk/python-ogre/demos/ogre/tests/Test_OverlayCaption.py trunk/python-ogre/demos/ogreode/Demo_Scenes.py trunk/python-ogre/demos/ogreode/SimpleScenes_BoxStack.py trunk/python-ogre/environment.py Added Paths: ----------- trunk/python-ogre/code_generators/mygui/ trunk/python-ogre/code_generators/mygui/customization_data.py trunk/python-ogre/code_generators/mygui/generate_code.py trunk/python-ogre/code_generators/mygui/hand_made_wrappers.py trunk/python-ogre/code_generators/mygui/python_mygui.h trunk/python-ogre/code_generators/mygui/python_mygui_aliases.h trunk/python-ogre/code_generators/mygui/python_mygui_sizeof.h Modified: trunk/python-ogre/PythonOgreConfig_posix.py =================================================================== --- trunk/python-ogre/PythonOgreConfig_posix.py 2008-11-28 12:39:02 UTC (rev 825) +++ trunk/python-ogre/PythonOgreConfig_posix.py 2008-12-04 13:12:10 UTC (rev 826) @@ -81,6 +81,7 @@ PATH_ogrepcz = os.path.join(PATH_Ogre, 'PlugIns', 'PCZSceneManager' ) PATH_hydrax = os.path.join(PATH_THIRDPARTY, 'Hydrax') PATH_hikari = os.path.join(PATH_THIRDPARTY, 'Hikari' ) # BASE_DIR, 'hikari', 'hikari') +PATH_mygui = os.path.join(BASE_DIR, 'MyGUI_2.2.0_RC1_source' ) ### ### these paths assume you've left all the directory structure as standard @@ -120,6 +121,7 @@ PATH_LIB_particleuniverse = os.path.join(PATH_particleuniverse, 'bin', 'release') PATH_LIB_opensteer = os.path.join(LOCAL_LIB) PATH_LIB_hikari = os.path.join(PATH_hikari ) #, 'lib') +PATH_LIB_mygui = os.path.join(PATH_mygui, 'MyGUIEngine','lib','Release') PATH_INCLUDE_Ogre= os.path.join(LOCAL_INCLUDE,'OGRE') # os.path.join(PATH_Ogre,'OgreMain/include') PATH_INCLUDE_Ogre_Dependencies = PATH_INCLUDE_Ogre # os.path.join( PATH_Ogre, 'Dependencies/include') @@ -191,4 +193,5 @@ PATH_INCLUDE_ogrepcz = os.path.join(PATH_ogrepcz,'include') PATH_INCLUDE_hydrax= PATH_hydrax PATH_INCLUDE_hikari = os.path.join(PATH_hikari ) #, 'include') +PATH_INCLUDE_mygui = os.path.join(PATH_mygui,'MyGUIEngine','include') Added: trunk/python-ogre/code_generators/mygui/customization_data.py =================================================================== --- trunk/python-ogre/code_generators/mygui/customization_data.py (rev 0) +++ trunk/python-ogre/code_generators/mygui/customization_data.py 2008-12-04 13:12:10 UTC (rev 826) @@ -0,0 +1,13 @@ + +def header_files( version ): + return [ 'MyGUI.h' + ,'MYGUI_RenderItem.h' + ,'MYGUI_LayerItemKeeper.h' + ,'MYGUI_LayerKeeper.h' + ,'MYGUI_WidgetSkinInfo.h' + ] + + +def huge_classes( version ): + return [] + \ No newline at end of file Added: trunk/python-ogre/code_generators/mygui/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/mygui/generate_code.py (rev 0) +++ trunk/python-ogre/code_generators/mygui/generate_code.py 2008-12-04 13:12:10 UTC (rev 826) @@ -0,0 +1,325 @@ +#!/usr/bin/env python +# ----------------------------------------------------------------------------- +# This source file is part of Python-Ogre and is covered by the LGPL +# For the latest info, see http://python-ogre.org/ +# +# ----------------------------------------------------------------------------- + +## STARTER TEMPLATE.. +## replace mygui with lowercase project name +## set MAIN_NAMESPACE +## rename and configure .h files + + +import os, sys, time, shutil +try: + import psyco + psyco.full() +except ImportError: + pass +#add environment to the path +sys.path.append( os.path.join( '..', '..' ) ) +#add common utils to the pass +sys.path.append( '..' ) +sys.path.append( '.' ) + +import environment +import common_utils +import customization_data +import hand_made_wrappers + + +from pygccxml import parser +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.module_creator 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 +from common_utils import docit + +MAIN_NAMESPACE = 'MyGUI' + +############################################################ +## +## Here is where we manually exclude stuff +## +############################################################ + +def ManualExclude ( mb ): + global_ns = mb.global_ns + if MAIN_NAMESPACE: + main_ns = global_ns.namespace( MAIN_NAMESPACE ) + else: + main_ns = global_ns + e = ['::MyGUI::delegates::CDelegate3< MyGUI::Widget*, std::string const&, std::string const& >', + '::MyGUI::delegates::CDelegate2< MyGUI::Widget*, unsigned int >', + '::MyGUI::ControllerPosition' + ] + for c in e: + print "Excluding:",c + main_ns.class_(c).exclude() + + for c in main_ns.classes(): + if 'delegates' in c.decl_string: + print "Excuding asssign operator from:", c + c.operators('=').exclude() + c=['::MyGUI::Font', + '::MyGUI::FontManager' + ] + for e in c: + main_ns.class_(e).noncopyable=True + c=['::MyGUI::LogManager::LevelsName' + ] + for e in c: + main_ns.variable(e).exclude() + + c=['::MyGUI::utility::templates::split' + ,'::MyGUI::utility::templates::parseColour' + ,'::MyGUI::templates::get_vector_resource_path' + ,'::MyGUI::templates::get_resource_path' + ] + for e in c: + main_ns.free_functions(e).exclude() + +############################################################ +## +## And there are things that manually need to be INCLUDED +## +############################################################ + +def ManualInclude ( mb ): + global_ns = mb.global_ns + if MAIN_NAMESPACE: + main_ns = global_ns.namespace( MAIN_NAMESPACE ) + else: + main_ns = global_ns + +############################################################ +## +## And things that need manual fixes, but not necessarly hand wrapped +## +############################################################ +def ManualFixes ( mb ): + global_ns = mb.global_ns + if MAIN_NAMESPACE: + main_ns = global_ns.namespace( MAIN_NAMESPACE ) + else: + main_ns = global_ns + +############################################################ +## +## And things that need to have their argument and call values fixed. +## ie functions that pass pointers in the argument list and of course we need +## to read the updated values - so instead we pass them back +## as new values in a tuple (ETC ETC) +## +############################################################ + +def ManualTransformations ( mb ): + global_ns = mb.global_ns + if MAIN_NAMESPACE: + main_ns = global_ns.namespace( MAIN_NAMESPACE ) + else: + main_ns = global_ns + + def create_output( size ): + return [ ft.output( i ) for i in range( size ) ] + + +############################################################################### +## +## Now for the AUTOMATIC stuff that should just work +## +############################################################################### + +def AutoFixes ( mb, MAIN_NAMESPACE ): + """ now we fix a range of things automatically - typically by going through + the entire name space trying to guess stuff and fix it:) + """ + global_ns = mb.global_ns + if MAIN_NAMESPACE: + main_ns = global_ns.namespace( MAIN_NAMESPACE ) + else: + main_ns = global_ns + +# # # Functions that have void pointers in their argument list need to change to unsigned int's +# # pointee_types=[] +# # ignore_names=[] +# # common_utils.Fix_Void_Ptr_Args ( main_ns ) # , pointee_types, ignore_names ) + + # and change functions that return a variety of pointers to instead return unsigned int's + pointee_types=[] + ignore_names=[] # these are function names we know it's cool to exclude + common_utils.Fix_Pointer_Returns ( main_ns ) # , pointee_types, ignore_names ) + + # functions that need to have implicit conversions turned off + ImplicitClasses=[] + common_utils.Fix_Implicit_Conversions ( main_ns, ImplicitClasses ) + + if os.name =='nt': + Fix_NT( mb ) + elif os.name =='posix': + Fix_Posix( mb ) + + common_utils.Auto_Document( mb, MAIN_NAMESPACE ) + + +############################################################################### +## +## here are the helper functions that do much of the work +## +############################################################################### +def Fix_Posix ( mb ): + """ fixup for posix specific stuff -- note only expect to be called on a posix machine + """ + ## we could do more here if need be... + if sys.platform == 'darwin': + pass + elif sys.platform.startswith ('linux'): + pass + + +def Fix_NT ( mb ): + """ fixup for NT systems + """ + + +# +# the 'main'function +# +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.mygui.root_dir, "python_mygui.h" ) + , environment.mygui.cache_file ) + + defined_symbols = ['WIN32','OGRE_NONCLIENT_BUILD', 'OGRE_GCC_VISIBILITY', '__PYTHONOGRE_BUILD_CODE', 'MYGUI_NONCLIENT_BUILD' ] #MYGUI_NO_OIS + + defined_symbols.append( 'VERSION_' + environment.mygui.version ) + + if environment._USE_THREADS: + defined_symbols.append('BOOST_HAS_THREADS') + if environment.isWindows(): + 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.mygui.include_dirs + , define_symbols=defined_symbols + , indexing_suite_version=2 + , cflags=environment.mygui.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 ) + 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.mygui ) + + ########################################################################################## + # + # 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='_mygui_' , doc_extractor= extractor ) + + for inc in environment.mygui.include_dirs: + mb.code_creator.user_defined_directories.append(inc ) + mb.code_creator.user_defined_directories.append( environment.mygui.generated_dir ) + mb.code_creator.replace_included_headers( customization_data.header_files( environment.mygui.version ) ) + + huge_classes = map( mb.class_, customization_data.huge_classes( environment.mygui.version ) ) + + mb.split_module(environment.mygui.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_mygui, +# destPath = environment.mygui.generated_dir, +# recursive=False ) + +if __name__ == '__main__': + start_time = time.clock() + generate_code() + print 'Source code was updated( %f minutes ).' % ( ( time.clock() - start_time )/60 ) Added: trunk/python-ogre/code_generators/mygui/hand_made_wrappers.py =================================================================== --- trunk/python-ogre/code_generators/mygui/hand_made_wrappers.py (rev 0) +++ trunk/python-ogre/code_generators/mygui/hand_made_wrappers.py 2008-12-04 13:12:10 UTC (rev 826) @@ -0,0 +1,15 @@ +import os +import environment + + + +################################################################################################# +################################################################################################# + +def apply_reg ( class_, code ): + for c in code: + class_.add_registration_code ( c ) + +def apply( mb ): + pass + \ No newline at end of file Added: trunk/python-ogre/code_generators/mygui/python_mygui.h =================================================================== --- trunk/python-ogre/code_generators/mygui/python_mygui.h (rev 0) +++ trunk/python-ogre/code_generators/mygui/python_mygui.h 2008-12-04 13:12:10 UTC (rev 826) @@ -0,0 +1,19 @@ + +#include "MyGUI.h" + +// First we create a magic namespace to hold all our aliases +namespace pyplusplus { namespace aliases { + + #include "python_mygui_aliases.h" +} } + +// then we exposed everything needed (and more) to ensure GCCXML makes them visible to Py++ +// +namespace python_mygui{ namespace details{ +inline void instantiate(){ + using namespace MyGUI; + #include "python_mygui_sizeof.h" + +} } } + + Added: trunk/python-ogre/code_generators/mygui/python_mygui_aliases.h =================================================================== --- trunk/python-ogre/code_generators/mygui/python_mygui_aliases.h (rev 0) +++ trunk/python-ogre/code_generators/mygui/python_mygui_aliases.h 2008-12-04 13:12:10 UTC (rev 826) @@ -0,0 +1 @@ +// typedef name nicename; Added: trunk/python-ogre/code_generators/mygui/python_mygui_sizeof.h =================================================================== --- trunk/python-ogre/code_generators/mygui/python_mygui_sizeof.h (rev 0) +++ trunk/python-ogre/code_generators/mygui/python_mygui_sizeof.h 2008-12-04 13:12:10 UTC (rev 826) @@ -0,0 +1 @@ +// sizeof ( variable ); Modified: trunk/python-ogre/demos/OgreNewt/Demo01_TheBasics.py =================================================================== --- trunk/python-ogre/demos/OgreNewt/Demo01_TheBasics.py 2008-11-28 12:39:02 UTC (rev 825) +++ trunk/python-ogre/demos/OgreNewt/Demo01_TheBasics.py 2008-12-04 13:12:10 UTC (rev 826) @@ -81,6 +81,20 @@ light.setType( Ogre.Light.LT_POINT ) light.setPosition( Ogre.Vector3(0.0, 100.0, 100.0) ) + + shapes = OgreNewt.VectorofCollision() + print "shape", shapes + col = OgreNewt.Pyramid(self.World, Ogre.Vector3(5,5,5), Ogre.Quaternion(0, 0, 0), Ogre.Vector3(0,0,-20) ) + print "col", col + shapes.append(col) + print shapes + col2 = OgreNewt.Box(self.World, Ogre.Vector3(5,5,5) ) + print "col2", col2 + shapes.append(col2) + compound = OgreNewt.CompoundCollision(self.World, shapes) + + print "*****", compound + def _createFrameListener(self): ## this is a basic frame listener included with OgreNewt that does nothing but update the Modified: trunk/python-ogre/demos/ogre/Demo_Bezier.py =================================================================== --- trunk/python-ogre/demos/ogre/Demo_Bezier.py 2008-11-28 12:39:02 UTC (rev 825) +++ trunk/python-ogre/demos/ogre/Demo_Bezier.py 2008-12-04 13:12:10 UTC (rev 826) @@ -98,7 +98,7 @@ ## Set ambient light sceneManager.setAmbientLight( (0.2, 0.2, 0.2) ) - print "\n1" + ## Create a point light l = sceneManager.createLight("MainLight") l.setType(ogre.Light.LT_DIRECTIONAL) @@ -232,10 +232,10 @@ patchEntity.setMaterialName("TextMat") patchPass = pMat.getTechnique(0).getPass(0) - print patchPass - print dir(patchPass) - print patchPass.msDirtyHashListMutex - sys.exit() +# print patchPass +# print dir(patchPass) +# print patchPass.msDirtyHashListMutex +# sys.exit() ## Attach the entity to the root of the scene Modified: trunk/python-ogre/demos/ogre/tests/Test_OverlayCaption.py =================================================================== --- trunk/python-ogre/demos/ogre/tests/Test_OverlayCaption.py 2008-11-28 12:39:02 UTC (rev 825) +++ trunk/python-ogre/demos/ogre/tests/Test_OverlayCaption.py 2008-12-04 13:12:10 UTC (rev 826) @@ -1,5 +1,5 @@ # This code is in the Public Domain -import Ogre as ogre +import ogre.renderer.OGRE as ogre import SampleFramework as sf import ctypes, math,sys @@ -10,7 +10,7 @@ overman = ogre.OverlayManager.getSingleton() statspanel = overman.getOverlayElement('Core/StatPanel', False) print statspanel - print dir(statspanel) + statspanel.caption=ogre.UTFString("This does work") statspanel.setCaption(ogre.UTFString("as does this") ) Modified: trunk/python-ogre/demos/ogreode/Demo_Scenes.py =================================================================== --- trunk/python-ogre/demos/ogreode/Demo_Scenes.py 2008-11-28 12:39:02 UTC (rev 825) +++ trunk/python-ogre/demos/ogreode/Demo_Scenes.py 2008-12-04 13:12:10 UTC (rev 826) @@ -112,7 +112,7 @@ sceneManager.setShadowTextureSettings(512, 2) ## Add some default lighting to the scene - sceneManager.setAmbientLight( (.8, .8, .8) ) + sceneManager.setAmbientLight( (.25, .25, .25) ) light = sceneManager.createLight('MainLight') light.setPosition (0, 0, 1) light.CastShadows=True @@ -205,7 +205,7 @@ entity.setUserObject(self._plane) entity.setCastShadows(False) s.addEntity(entity, ogre.Vector3(x,0,z)) - + s.build() ## Load up our UI and display it pOver = ogre.OverlayManager.getSingleton().getByName("OgreOdeDemos/Overlay") pOver.show() Modified: trunk/python-ogre/demos/ogreode/SimpleScenes_BoxStack.py =================================================================== --- trunk/python-ogre/demos/ogreode/SimpleScenes_BoxStack.py 2008-11-28 12:39:02 UTC (rev 825) +++ trunk/python-ogre/demos/ogreode/SimpleScenes_BoxStack.py 2008-12-04 13:12:10 UTC (rev 826) @@ -28,17 +28,13 @@ return "Z - Sphere, X - Box, C - Capsule, G - Ragdoll, T - Trimesh" def frameEnded(self, time, keyinput, mouse): -# print "** Simpel Scenes BoxStack frameEnded" ## Do default processing SimpleScenes.frameEnded(self, time, keyinput, mouse) body = None ## Create random objects, that method will stop them being created too often if (keyinput.isKeyDown(OIS.KC_Z)): - print "Creating a body" body = self.createRandomObject(OgreOde.Geometry.Class_Sphere) - print body - print "OK" elif (keyinput.isKeyDown(OIS.KC_X)): body = self.createRandomObject(OgreOde.Geometry.Class_Box) elif (keyinput.isKeyDown(OIS.KC_C)): @@ -47,6 +43,5 @@ body = self.createRandomObject(OgreOde.Geometry.Class_Convex) #TriangleMesh) elif (keyinput.isKeyDown(OIS.KC_G)): self.createRagDoll() -# print "Returning from frameended" \ No newline at end of file Modified: trunk/python-ogre/environment.py =================================================================== --- trunk/python-ogre/environment.py 2008-11-28 12:39:02 UTC (rev 825) +++ trunk/python-ogre/environment.py 2008-12-04 13:12:10 UTC (rev 826) @@ -1835,28 +1835,33 @@ descText = "Use Flash controls within Ogre" descLink = "http://hikari-library.googlecode.com/" -# class mygui: -# active = False -# pythonModule = True -# version="2.2.0RC1" -# name='mygui' -# parent="ogre/gui" -# cflags = "" -# include_dirs = [ Config.PATH_Boost, -# Config.PATH_INCLUDE_mygui -# , Config.PATH_INCLUDE_Ogre -# ,Config.PATH_INCLUDE_Ogre_Dependencies -# ] -# lib_dirs = [Config.PATH_LIB_Boost -# ,Config.PATH_LIB_Ogre_OgreMain -# ,Config.PATH_LIB_mygui -# -# ] -# CheckIncludes=[] -# libs=[ boost.lib, 'OgreMain', 'MyGUI' ] ##, 'hikari' ] -# ModuleName="mygui" -# descText = "MyGUI Interface System" -# descLink = "http://sourceforge.net/projects/my-gui/" +class mygui: + active = False + pythonModule = True + version="2.2.0RC1" + name='mygui' + parent="ogre/gui" + cflags = "" + source =[ + ["wget", "http://downloads.sourceforge.net/my-gui/MyGUI_2.2.0_RC1_source.zip",downloadPath], + ] + buildCmds = [ + [0, unzip + os.path.join(downloadPath, "MyGUI_2.2.0_RC1_source.zip"), ''] + ] + include_dirs = [ Config.PATH_Boost, + Config.PATH_INCLUDE_mygui + , Config.PATH_INCLUDE_Ogre + ,Config.PATH_INCLUDE_Ogre_Dependencies + ] + lib_dirs = [Config.PATH_LIB_Boost + ,Config.PATH_LIB_Ogre_OgreMain + ,Config.PATH_LIB_mygui + ] + CheckIncludes=[] + libs=[ boost.lib, 'OgreMain', 'MyGUI' ] ##, 'hikari' ] + ModuleName="mygui" + descText = "MyGUI Interface System" + descLink = "http://sourceforge.net/projects/my-gui/" ############################################################################################ @@ -1899,7 +1904,7 @@ , 'ogrepcz' : ogrepcz , 'hydrax' : hydrax , 'hikari' : hikari -# , 'mygui' : mygui + , 'mygui' : mygui } # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |