From: <and...@us...> - 2007-12-26 14:48:46
|
Revision: 517 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=517&view=rev Author: andy_miller Date: 2007-12-26 06:48:44 -0800 (Wed, 26 Dec 2007) Log Message: ----------- Update to ogre generation -- creates auto casting functionsto expose base classes Modified Paths: -------------- trunk/python-ogre/code_generators/ogre/customization_data.py trunk/python-ogre/code_generators/ogre/generate_code.py trunk/python-ogre/code_generators/ogre/python_ogre_sizeof.h Modified: trunk/python-ogre/code_generators/ogre/customization_data.py =================================================================== --- trunk/python-ogre/code_generators/ogre/customization_data.py 2007-12-26 14:40:50 UTC (rev 516) +++ trunk/python-ogre/code_generators/ogre/customization_data.py 2007-12-26 14:48:44 UTC (rev 517) @@ -2,7 +2,7 @@ def header_files( version ): if not version.startswith("1.2"): ## 21Nov07; Change to precompiled header support - return [ 'python_ogre_precompiled.h' + return [ 'Python_ogre_precompiled.h' # # ,'boost/python.hpp' # # ,'python_ogre_masterlist.h' # # ,'boost/python/ssize_t.hpp' ## needed for python2.4 as it doesn't define ssize_t Modified: trunk/python-ogre/code_generators/ogre/generate_code.py =================================================================== --- trunk/python-ogre/code_generators/ogre/generate_code.py 2007-12-26 14:40:50 UTC (rev 516) +++ trunk/python-ogre/code_generators/ogre/generate_code.py 2007-12-26 14:48:44 UTC (rev 517) @@ -662,7 +662,6 @@ elif os.name =='posix': Fix_Posix( mb ) - common_utils.Auto_Document( mb, MAIN_NAMESPACE ) ############################################################################### ## @@ -680,10 +679,7 @@ elif sys.platform.startswith ('linux'): pass mb.global_ns.class_('vector<int, std::allocator<int> >').alias='VectorInt' - try: - mb.global_ns.class_('vector<std::pair<unsigned int, unsigned int>, std::allocator<std::pair<unsigned int, unsigned int> > >').alias='VectorUnsignedUnsigned' - except: - pass + mb.global_ns.class_('vector<std::pair<unsigned, unsigned>, std::allocator<std::pair<unsigned, unsigned> > >').alias='VectorUnsignedUnsigned' #as reported by mike with linux:bp::arg("flags")=(std::_Ios_Fmtflags)0 mb.namespace( MAIN_NAMESPACE ).class_('StringConverter').member_functions('toString').exclude() @@ -816,6 +812,48 @@ #~ # # c.exclude() ## exclude the first constructor.. #~ # # break +def autoCasting ( main_ns, ignores = ['ParamCommand','MovableObjectFactory'] ): + """ looks for classes that have parents (bases) and there are overlapping/hidden functions + When we find one insert a asPARENT helper function just in case it might be needed + + Only real world case I know of is casting a Bone to a Node so you can create a new node. + + """ + + CastReg=\ + """ + def( "%(functionName)s", &::%(className)s_%(functionName)s,\ + "Python-Ogre Hand Wrapped to cast to a parent(base) type\\n\ + In this case from a %(className)s to a %(castName)s",\ + bp::return_value_policy< bp::reference_existing_object, bp::default_call_policies >()); + """ + CastDec=\ + """ + %(returnType)s * + %(className)s_%(functionName)s ( %(classDecl)s * me ) { + return ( (%(returnType)s * ) me ); + } + """ + + for c in main_ns.classes(): + if len(c.bases) > 0: + for b in c.bases: + r = b.related_class + if not '<' in r.decl_string : ##and c.name != 'BillboardSet': # don't worry about templates or factories.. + if not r.name in ignores: # there are some bases that we don't care about overlaps on + for f in c.member_functions(allow_empty=True): + if r.member_functions(f.name, allow_empty=True ): + values = { 'returnType':r.decl_string, 'functionName': "as"+r.name, + 'className':c.name, 'classDecl': c.decl_string, + 'castName':r.name } + + regcode = CastReg % values + deccode = CastDec % values + c.add_declaration_code( deccode ) + c.add_registration_code( regcode ) + print "Hand wrapper (as"+r.name+") created to cast from", c.name, "to", r.name ## b.access + break + # # the 'main'function # @@ -878,7 +916,7 @@ mb.classes().always_expose_using_scope = True - + # # We filter (both include and exclude) specific classes and functions that we want to wrap # @@ -887,7 +925,8 @@ main_ns = global_ns.namespace( MAIN_NAMESPACE ) main_ns.include() - + autoCasting ( main_ns ) ## + common_utils.AutoExclude ( mb, MAIN_NAMESPACE ) ManualExclude ( mb ) common_utils.AutoInclude ( mb, MAIN_NAMESPACE ) @@ -899,6 +938,9 @@ ManualAlias ( mb ) AutoFixes ( mb, MAIN_NAMESPACE ) ManualFixes ( mb ) +# # indicated where underlying libraries are protected etc in the doc strings + common_utils.Auto_Document( mb, MAIN_NAMESPACE ) + common_utils.Auto_Functional_Transformation ( main_ns, special_vars=['::Ogre::Real &','::Ogre::ushort &','size_t &'] ) for cls in main_ns.classes(): @@ -928,6 +970,7 @@ # the manual stuff all done here !!! # hand_made_wrappers.apply( mb ) + NoPropClasses = ["UTFString"] for cls in main_ns.classes(): @@ -986,7 +1029,7 @@ ## 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__) ), 'python_ogre_precompiled.h' ), + os.path.join( os.path.abspath(os.path.dirname(__file__) ), 'python_ogre_precompiled.h' ), os.path.join( os.path.abspath(os.path.dirname(__file__) ), 'python_ogre_masterlist.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' ), Modified: trunk/python-ogre/code_generators/ogre/python_ogre_sizeof.h =================================================================== --- trunk/python-ogre/code_generators/ogre/python_ogre_sizeof.h 2007-12-26 14:40:50 UTC (rev 516) +++ trunk/python-ogre/code_generators/ogre/python_ogre_sizeof.h 2007-12-26 14:48:44 UTC (rev 517) @@ -6,15 +6,15 @@ sizeof ( Ogre::MapIterator< std::multimap<Ogre::String, Ogre::String> > ); sizeof ( Ogre::MapIterator< std::map<Ogre::String, std::multimap<Ogre::String, Ogre::String>*> > ); -#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 +#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 sizeof( stdext::_Hash<stdext::_Hmap_traits<std::string, Ogre::Node*, stdext::hash_compare<std::string, std::less<std::string> >, std::allocator<std::pair<std::string const, Ogre::Node*> >, false> > ); //sizeof( stdext::_Hash<stdext::_Hmap_traits<std::string, unsigned short, stdext::hash_compare<std::string, std::less<std::string> >, std::allocator<std::pair<std::string const, unsigned short> >, false> > ); sizeof( stdext::_Hash<stdext::_Hmap_traits<std::string, Ogre::SharedPtr<Ogre::Resource>, stdext::hash_compare<std::string, std::less<std::string> >, std::allocator<std::pair<std::string const, Ogre::SharedPtr<Ogre::Resource> > >, false> > ); sizeof( stdext::_Hash<stdext::_Hmap_traits<std::string, Ogre::MovableObject*, stdext::hash_compare<std::string, std::less<std::string> >, std::allocator<std::pair<std::string const, Ogre::MovableObject*> >, false> > ); -#endif - -sizeof ( std::pair<Ogre::SharedPtr<Ogre::Resource>, bool> ); +#endif +sizeof( std::pair<Ogre::SharedPtr<Ogre::Resource>, bool> ); + std::vector< int > v; std::set< std::string > s; std::multimap< std::string, std::string > ms; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |