[Python-ogre-commit] SF.net SVN: python-ogre:[686] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
From: <and...@us...> - 2008-08-09 21:51:27
|
Revision: 686 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=686&view=rev Author: andy_miller Date: 2008-08-09 21:51:33 +0000 (Sat, 09 Aug 2008) Log Message: ----------- Small but significant change to expose "overlapping" transformed functions in a more useful way (createive alias now generated) New patch (for Ogre 1.6 SVN) to make renderQueue functions work Modified Paths: -------------- trunk/python-ogre/code_generators/common_utils/__init__.py trunk/python-ogre/code_generators/ogre/generate_code.py trunk/python-ogre/code_generators/ogrenewt/generate_code.py Added Paths: ----------- trunk/python-ogre/patch/ogre_1.6.patch Removed Paths: ------------- trunk/python-ogre/patch/ogre_1.7.patch Modified: trunk/python-ogre/code_generators/common_utils/__init__.py =================================================================== --- trunk/python-ogre/code_generators/common_utils/__init__.py 2008-08-05 07:25:40 UTC (rev 685) +++ trunk/python-ogre/code_generators/common_utils/__init__.py 2008-08-09 21:51:33 UTC (rev 686) @@ -1,4 +1,5 @@ import os, shutil +import sys import shared_ptr ##import hashlib ## makes this 2.5 dependent import md5 @@ -216,6 +217,7 @@ def Auto_Functional_Transformation ( mb, ignore_funs=[], special_vars=[]): toprocess = [] + aliases={} for fun in mb.member_functions(allow_empty=True): toprocess.append( fun ) for fun in mb.free_functions(allow_empty=True): @@ -229,6 +231,7 @@ arg_position = 0 trans=[] desc="" + ctypes_conversion = False for arg in fun.arguments: rawarg = declarations.remove_declarated( declarations.remove_const( @@ -245,6 +248,8 @@ trans.append( ft.modify_type(arg_position,_ReturnUnsignedInt ) ) desc = desc +"Argument: "+arg.name+ "( pos:" + str(arg_position) + " - " +\ arg.type.decl_string + " ) takes a CTypes.addressof(xx). \\n" + ctypes_conversion = True + ctypes_arg = arg.type.decl_string.split()[0] elif declarations.is_reference(arg.type): trans.append( ft.inout(arg_position ) ) desc = desc + "Argument: "+arg.name+ "( pos:" + str(arg_position) + " - " +\ @@ -256,17 +261,35 @@ arg_position += 1 if trans: if fun.documentation: # it's already be tweaked: - print "AUTOFT ERROR: Duplicate Tranforms.", fun + print "AUTOFT ERROR: Duplicate Tranforms.", fun, fun.documentation elif fun.virtuality == "pure virtual": print "AUTOFT WARNING: PURE VIRTUAL function requires tranform.", fun else: - print "AUTOFT OK: Tranformed ", fun - fun.add_transformation ( * trans , **{"alias":fun.name} ) + new_alias = fun.name + if ctypes_conversion: # only manage name changes if ctypes changing + # now lets look for a duplicate function name with the same number arguments + f= [None]*len(fun.arguments) + s = mb.member_functions("::" + fullname, arg_types=f, allow_empty=True) + if len (s) > 1: + # there are duplicate names so need to create something unique + ctypes_arg = ctypes_arg.replace("::", "_") # to clean up function names... + new_alias = fun.name + ctypes_arg[0].upper() + ctypes_arg[1:] + # now for REAL ugly code -- we have faked a new alias and it may not be unique + # so we track previous alias + class name to ensure unique names are generated + keyname = fullname + new_alias # we use the full class + function name + alias as the key + if keyname in aliases: # already exists, need to fake another version.. + new_alias = new_alias + "_" + str( aliases[keyname] ) + aliases[keyname] = aliases[keyname] + 1 + else: + aliases[keyname] = 1 + print "INFO: Adjusting Alias as multiple overlapping functions:", new_alias + + print "AUTOFT OK: Tranformed ", fun, "(",new_alias,")" + fun.add_transformation ( * trans , **{"alias":new_alias} ) fun.documentation = docit ("Auto Modified Arguments:", desc, "...") except: - pass - + print "Unexpected error:", sys.exc_info()[0] def Fix_Void_Ptr_Args ( mb, pointee_types=['unsigned int','int', 'float', 'unsigned char', 'char', 'bool'], ignore_names=[] ): """ we modify functions that take void *'s in their argument list to instead take Modified: trunk/python-ogre/code_generators/ogre/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/ogre/generate_code.py 2008-08-05 07:25:40 UTC (rev 685) +++ trunk/python-ogre/code_generators/ogre/generate_code.py 2008-08-09 21:51:33 UTC (rev 686) @@ -500,10 +500,28 @@ # # # x.documentation = docit ("", "format", "rgba" ) # # # # # # + + + + + # # # ## these need updates to Py++ to handle pointers -# # # # # x = ns.mem_fun('::Ogre::PixelUtil::unpackColour', arg_types=['float *','float *','float *','float *',None,None]) -# # # # # x.add_transformation(ft.output('r'), ft.output('g'), ft.output('b'), ft.output('a') ) -# # # # # x.documentation = docit ("", "Pixelformat, src", "r,g,b,a" ) +# x = ns.mem_fun('::Ogre::PixelUtil::packColour', arg_types=['Ogre::uint8','Ogre::uint8','Ogre::uint8','Ogre::uint8',None,None]) +# x.add_transformation(ft.modify_type(5,_ReturnUnsignedInt ), alias= "packColourUint" ) +# x.documentation = docit ("", "r,g,b,a,Pixelformat, src", "" ) +# +# x = ns.mem_fun('::Ogre::PixelUtil::packColour', arg_types=['float','float','float','float',None,None]) +# x.add_transformation(ft.modify_type(5,_ReturnUnsignedInt ), alias= "packColourFloat" ) +# x.documentation = docit ("", "r,g,b,a,Pixelformat, src", "" ) +# +# x = ns.mem_fun('::Ogre::PixelUtil::unpackColour', arg_types=['float *','float *','float *','float *',None,None]) +# x.add_transformation(ft.output('r'), ft.output('g'), ft.output('b'), ft.output('a'), alias="unpackColourFloat ) +# x.documentation = docit ("", "Pixelformat, src", "r,g,b,a" ) +# +# x = ns.mem_fun('::Ogre::PixelUtil::unpackColour', arg_types=['float *','float *','float *','float *',None,None]) +# x.add_transformation(ft.output('r'), ft.output('g'), ft.output('b'), ft.output('a'), alias="unpackColourFloat ) +# x.documentation = docit ("", "Pixelformat, src", "r,g,b,a" ) + # # # # # # # # x = ns.mem_fun('::Ogre::Frustum::projectSphere') # # # # # x.add_transformation(ft.output('left'), ft.output('top'), ft.output('right'), ft.output('bottom') ) @@ -1038,6 +1056,24 @@ ## need to create a welcome doc string for this... common_utils.add_constants( mb, { '__doc__' : '"Python-Ogre Main Module for OGRE 3D"' } ) + count = 0 + for v in main_ns.variables(): + if not v.ignore: + count +=1 +# v.exclude() + print "\n\nSPECIAL -- variables:", count + count = 0 + for v in main_ns.member_functions(): + if not v.ignore: + count +=1 +# v.exclude() + print "\n\nSPECIAL -- member functions:", count + count=0 + for v in main_ns.classes(): + if not v.ignore: + count +=1 +# v.exclude() + print "\n\nSPECIAL -- Number classes:", count ########################################################################################## # # Creating the code. After this step you should not modify/customize declarations. Modified: trunk/python-ogre/code_generators/ogrenewt/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/ogrenewt/generate_code.py 2008-08-05 07:25:40 UTC (rev 685) +++ trunk/python-ogre/code_generators/ogrenewt/generate_code.py 2008-08-09 21:51:33 UTC (rev 686) @@ -116,8 +116,7 @@ global_ns.namespace( 'Ogre' ).class_('Node').include(already_exposed=True) global_ns.namespace( 'Ogre' ).class_('Serializer').include(already_exposed=True) - - + def set_call_policies_pointee( mb ): # Set the default policy to deal with pointer/reference return types to reference_existing object # as this is the ogrenewt Default. Added: trunk/python-ogre/patch/ogre_1.6.patch =================================================================== --- trunk/python-ogre/patch/ogre_1.6.patch (rev 0) +++ trunk/python-ogre/patch/ogre_1.6.patch 2008-08-09 21:51:33 UTC (rev 686) @@ -0,0 +1,236 @@ +Index: OgreMain/include/OgreMovableObject.h +=================================================================== +--- OgreMain/include/OgreMovableObject.h (revision 7873) ++++ OgreMain/include/OgreMovableObject.h (working copy) +@@ -482,7 +482,7 @@ + included too. + */ + virtual void visitRenderables(Renderable::Visitor* visitor, +- bool debugRenderables = false) = 0; ++ bool debugRenderables = false) { throw std::runtime_error ( std::string ("Virtual function MovableObject::visitRenderables called!") ); } + + /** Sets whether or not the debug display of this object is enabled. + @remarks +Index: OgreMain/include/OgreRenderQueueListener.h +=================================================================== +--- OgreMain/include/OgreRenderQueueListener.h (revision 7873) ++++ OgreMain/include/OgreRenderQueueListener.h (working copy) +@@ -31,7 +31,9 @@ + + #include "OgrePrerequisites.h" + #include "OgreRenderQueue.h" ++#include <stdexcept> + ++ + namespace Ogre { + + /** Abstract interface which classes must implement if they wish to receive +@@ -64,8 +66,8 @@ + rendered. Note that in this case the renderQueueEnded event will not be raised + for this queue group. + */ +- virtual void renderQueueStarted(uint8 queueGroupId, const String& invocation, +- bool& skipThisInvocation) = 0; ++ virtual bool renderQueueStarted(uint8 queueGroupId, const String& invocation, ++ bool skipThisInvocation) { throw std::runtime_error ( std::string ("Virtual function RenderQueueListener::renderQueueStarted called!") ); } + + /** Event raised after a queue group is rendered. + @remarks +@@ -79,8 +81,8 @@ + rendered will be repeated, and the renderQueueStarted and renderQueueEnded + events will also be fired for it again. + */ +- virtual void renderQueueEnded(uint8 queueGroupId, const String& invocation, +- bool& repeatThisInvocation) = 0; ++ virtual bool renderQueueEnded(uint8 queueGroupId, const String& invocation, ++ bool repeatThisInvocation) { throw std::runtime_error ( std::string ("Virtual function RenderQueueListener::renderQueueEnded called!") ); } + }; + + } +Index: OgreMain/include/OgreResourceGroupManager.h +=================================================================== +--- OgreMain/include/OgreResourceGroupManager.h (revision 7873) ++++ OgreMain/include/OgreResourceGroupManager.h (working copy) +@@ -37,6 +37,7 @@ + #include "OgreArchive.h" + #include "OgreIteratorWrappers.h" + #include <ctime> ++#include <stdexcept> + + namespace Ogre { + +@@ -92,7 +93,7 @@ + parsed. Note that in this case the scriptParseEnded event will not be raised + for this script. + */ +- virtual void scriptParseStarted(const String& scriptName, bool& skipThisScript) = 0; ++ virtual bool scriptParseStarted(const String& scriptName, bool skipThisScript) { throw std::runtime_error ( std::string ("Virtual function ResourceGroupListener::scriptParseStarted called!") ); } + + /** This event is fired when the script has been fully parsed. + */ +@@ -350,7 +351,7 @@ + /// Internal event firing method + void fireResourceGroupScriptingStarted(const String& groupName, size_t scriptCount); + /// Internal event firing method +- void fireScriptStarted(const String& scriptName, bool &skipScript); ++ bool fireScriptStarted(const String& scriptName, bool skipScript); + /// Internal event firing method + void fireScriptEnded(const String& scriptName, bool skipped); + /// Internal event firing method +Index: OgreMain/include/OgreDataStream.h +=================================================================== +--- OgreMain/include/OgreDataStream.h (revision 7873) ++++ OgreMain/include/OgreDataStream.h (working copy) +@@ -33,6 +33,7 @@ + #include "OgreString.h" + #include "OgreSharedPtr.h" + #include <istream> ++#include <stdexcept> + + namespace Ogre { + +@@ -79,7 +80,7 @@ + @param count Number of bytes to read + @returns The number of bytes read + */ +- virtual size_t read(void* buf, size_t count) = 0; ++ virtual size_t read(void* buf, size_t count) { throw std::runtime_error ( std::string ("Virtual function DataStream::read called!") ); } + /** Get a single line from the stream. + @remarks + The delimiter character is not included in the data +Index: OgreMain/include/OgreHardwareBuffer.h +=================================================================== +--- OgreMain/include/OgreHardwareBuffer.h (revision 7873) ++++ OgreMain/include/OgreHardwareBuffer.h (working copy) +@@ -31,7 +31,9 @@ + + // Precompiler options + #include "OgrePrerequisites.h" ++#include <stdexcept> + ++ + namespace Ogre { + + /** Abstract class defining common features of hardware buffers. +@@ -244,7 +246,7 @@ + @param pDest The area of memory in which to place the data, must be large enough to + accommodate the data! + */ +- virtual void readData(size_t offset, size_t length, void* pDest) = 0; ++ virtual void readData(size_t offset, size_t length, void* pDest) { throw std::runtime_error ( std::string ("Virtual function HardwareBuffer::readData called!") ); } + /** Writes data to the buffer from an area of system memory; note that you must + ensure that your buffer is big enough. + @param offset The byte offset from the start of the buffer to start writing +@@ -254,7 +256,7 @@ + such that DMA stalls can be avoided; use if you can. + */ + virtual void writeData(size_t offset, size_t length, const void* pSource, +- bool discardWholeBuffer = false) = 0; ++ bool discardWholeBuffer = false) { throw std::runtime_error ( std::string ("Virtual function HardwareBuffer::writeData called!") ); } + + /** Copy data from another buffer into this one. + @remarks +Index: OgreMain/include/OgreCompositorChain.h +=================================================================== +--- OgreMain/include/OgreCompositorChain.h (revision 7873) ++++ OgreMain/include/OgreCompositorChain.h (working copy) +@@ -174,10 +174,10 @@ + public: + /** @copydoc RenderQueueListener::renderQueueStarted + */ +- virtual void renderQueueStarted(uint8 id, const String& invocation, bool& skipThisQueue); ++ virtual bool renderQueueStarted(uint8 id, const String& invocation, bool skipThisQueue); + /** @copydoc RenderQueueListener::renderQueueEnded + */ +- virtual void renderQueueEnded(uint8 id, const String& invocation, bool& repeatThisQueue); ++ virtual bool renderQueueEnded(uint8 id, const String& invocation, bool repeatThisQueue); + + /** Set current operation and target */ + void setOperation(CompositorInstance::TargetOperation *op,SceneManager *sm,RenderSystem *rs); +Index: OgreMain/src/OgreResourceGroupManager.cpp +=================================================================== +--- OgreMain/src/OgreResourceGroupManager.cpp (revision 7873) ++++ OgreMain/src/OgreResourceGroupManager.cpp (working copy) +@@ -929,7 +929,7 @@ + for (FileInfoList::iterator fii = (*flli)->begin(); fii != (*flli)->end(); ++fii) + { + bool skipScript = false; +- fireScriptStarted(fii->filename, skipScript); ++ skipScript = fireScriptStarted(fii->filename, skipScript); + if(skipScript) + { + LogManager::getSingleton().logMessage( +@@ -1218,17 +1218,18 @@ + } + } + //----------------------------------------------------------------------- +- void ResourceGroupManager::fireScriptStarted(const String& scriptName, bool &skipScript) ++ bool ResourceGroupManager::fireScriptStarted(const String& scriptName, bool skipScript) + { + OGRE_LOCK_AUTO_MUTEX + for (ResourceGroupListenerList::iterator l = mResourceGroupListenerList.begin(); + l != mResourceGroupListenerList.end(); ++l) + { + bool temp = false; +- (*l)->scriptParseStarted(scriptName, temp); ++ temp = (*l)->scriptParseStarted(scriptName, temp); + if(temp) + skipScript = true; + } ++ return skipScript; + } + //----------------------------------------------------------------------- + void ResourceGroupManager::fireScriptEnded(const String& scriptName, bool skipped) +Index: OgreMain/src/OgreCompositorChain.cpp +=================================================================== +--- OgreMain/src/OgreCompositorChain.cpp (revision 7873) ++++ OgreMain/src/OgreCompositorChain.cpp (working copy) +@@ -377,8 +377,8 @@ + mViewport = vp; + } + //----------------------------------------------------------------------- +-void CompositorChain::RQListener::renderQueueStarted(uint8 id, +- const String& invocation, bool& skipThisQueue) ++bool CompositorChain::RQListener::renderQueueStarted(uint8 id, ++ const String& invocation, bool skipThisQueue) + { + // Skip when not matching viewport + // shadows update is nested within main viewport update +@@ -392,11 +392,13 @@ + { + skipThisQueue = true; + } ++ return skipThisQueue; + } + //----------------------------------------------------------------------- +-void CompositorChain::RQListener::renderQueueEnded(uint8 id, +- const String& invocation, bool& repeatThisQueue) ++bool CompositorChain::RQListener::renderQueueEnded(uint8 id, ++ const String& invocation, bool repeatThisQueue) + { ++ return repeatThisQueue; + } + //----------------------------------------------------------------------- + void CompositorChain::RQListener::setOperation(CompositorInstance::TargetOperation *op,SceneManager *sm,RenderSystem *rs) +Index: OgreMain/src/OgreSceneManager.cpp +=================================================================== +--- OgreMain/src/OgreSceneManager.cpp (revision 7873) ++++ OgreMain/src/OgreSceneManager.cpp (working copy) +@@ -3651,7 +3651,7 @@ + iend = mRenderQueueListeners.end(); + for (i = mRenderQueueListeners.begin(); i != iend; ++i) + { +- (*i)->renderQueueStarted(id, invocation, skip); ++ skip = (*i)->renderQueueStarted(id, invocation, skip); + } + return skip; + } +@@ -3664,7 +3664,7 @@ + iend = mRenderQueueListeners.end(); + for (i = mRenderQueueListeners.begin(); i != iend; ++i) + { +- (*i)->renderQueueEnded(id, invocation, repeat); ++ repeat = (*i)->renderQueueEnded(id, invocation, repeat); + } + return repeat; + } Deleted: trunk/python-ogre/patch/ogre_1.7.patch =================================================================== --- trunk/python-ogre/patch/ogre_1.7.patch 2008-08-05 07:25:40 UTC (rev 685) +++ trunk/python-ogre/patch/ogre_1.7.patch 2008-08-09 21:51:33 UTC (rev 686) @@ -1,119 +0,0 @@ -Index: ogre/OgreMain/include/OgreDataStream.h -=================================================================== ---- ogre/OgreMain/include/OgreDataStream.h (revision 7701) -+++ ogre/OgreMain/include/OgreDataStream.h (working copy) -@@ -33,6 +33,7 @@ - #include "OgreString.h" - #include "OgreSharedPtr.h" - #include <istream> -+#include <stdexcept> - - namespace Ogre { - -@@ -79,7 +80,7 @@ - @param count Number of bytes to read - @returns The number of bytes read - */ -- virtual size_t read(void* buf, size_t count) = 0; -+ virtual size_t read(void* buf, size_t count) { throw std::runtime_error ( std::string ("Virtual function DataStream::read called!") ); } - /** Get a single line from the stream. - @remarks - The delimiter character is not included in the data -Index: ogre/OgreMain/include/OgreHardwareBuffer.h -=================================================================== ---- ogre/OgreMain/include/OgreHardwareBuffer.h (revision 7701) -+++ ogre/OgreMain/include/OgreHardwareBuffer.h (working copy) -@@ -31,7 +31,9 @@ - - // Precompiler options - #include "OgrePrerequisites.h" -+#include <stdexcept> - -+ - namespace Ogre { - - /** Abstract class defining common features of hardware buffers. -@@ -244,7 +246,7 @@ - @param pDest The area of memory in which to place the data, must be large enough to - accommodate the data! - */ -- virtual void readData(size_t offset, size_t length, void* pDest) = 0; -+ virtual void readData(size_t offset, size_t length, void* pDest) { throw std::runtime_error ( std::string ("Virtual function HardwareBuffer::readData called!") ); } - /** Writes data to the buffer from an area of system memory; note that you must - ensure that your buffer is big enough. - @param offset The byte offset from the start of the buffer to start writing -@@ -254,7 +256,7 @@ - such that DMA stalls can be avoided; use if you can. - */ - virtual void writeData(size_t offset, size_t length, const void* pSource, -- bool discardWholeBuffer = false) = 0; -+ bool discardWholeBuffer = false) { throw std::runtime_error ( std::string ("Virtual function HardwareBuffer::writeData called!") ); } - - /** Copy data from another buffer into this one. - @remarks -Index: ogre/OgreMain/include/OgreMovableObject.h -=================================================================== ---- ogre/OgreMain/include/OgreMovableObject.h (revision 7701) -+++ ogre/OgreMain/include/OgreMovableObject.h (working copy) -@@ -482,7 +482,7 @@ - included too. - */ - virtual void visitRenderables(Renderable::Visitor* visitor, -- bool debugRenderables = false) = 0; -+ bool debugRenderables = false) { throw std::runtime_error ( std::string ("Virtual function MovableObject::visitRenderables called!") ); } - - /** Sets whether or not the debug display of this object is enabled. - @remarks -Index: ogre/OgreMain/include/OgreRenderQueueListener.h -=================================================================== ---- ogre/OgreMain/include/OgreRenderQueueListener.h (revision 7701) -+++ ogre/OgreMain/include/OgreRenderQueueListener.h (working copy) -@@ -31,7 +31,9 @@ - - #include "OgrePrerequisites.h" - #include "OgreRenderQueue.h" -+#include <stdexcept> - -+ - namespace Ogre { - - /** Abstract interface which classes must implement if they wish to receive -@@ -65,7 +67,7 @@ - for this queue group. - */ - virtual void renderQueueStarted(uint8 queueGroupId, const String& invocation, -- bool& skipThisInvocation) = 0; -+ bool& skipThisInvocation) { throw std::runtime_error ( std::string ("Virtual function RenderQueueListener::renderQueueStarted called!") ); } - - /** Event raised after a queue group is rendered. - @remarks -@@ -80,7 +82,7 @@ - events will also be fired for it again. - */ - virtual void renderQueueEnded(uint8 queueGroupId, const String& invocation, -- bool& repeatThisInvocation) = 0; -+ bool& repeatThisInvocation) { throw std::runtime_error ( std::string ("Virtual function RenderQueueListener::renderQueueEnded called!") ); } - }; - - } -Index: ogre/OgreMain/include/OgreResourceGroupManager.h -=================================================================== ---- ogre/OgreMain/include/OgreResourceGroupManager.h (revision 7701) -+++ ogre/OgreMain/include/OgreResourceGroupManager.h (working copy) -@@ -36,6 +36,7 @@ - #include "OgreResource.h" - #include "OgreArchive.h" - #include "OgreIteratorWrappers.h" -+#include <stdexcept> - - namespace Ogre { - -@@ -91,7 +92,7 @@ - parsed. Note that in this case the scriptParseEnded event will not be raised - for this script. - */ -- virtual void scriptParseStarted(const String& scriptName, bool& skipThisScript) = 0; -+ virtual void scriptParseStarted(const String& scriptName, bool& skipThisScript) { throw std::runtime_error ( std::string ("Virtual function ResourceGroupListener::scriptParseStarted called!") ); } - - /** This event is fired when the script has been fully parsed. - */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |