Revision: 374
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=374&view=rev
Author: andy_miller
Date: 2007-09-06 03:19:05 -0700 (Thu, 06 Sep 2007)
Log Message:
-----------
Initial 1.1 development.
Added Plib (sound and networking) and Theora (video) modules
Mods to handle Quickgui updates
Code generation handles 'new module' support in Py++ (remove the already registered errors)
Mods for NxOgre SVN 33 support
Modified Paths:
--------------
trunk/python-ogre/PythonOgreConfig_nt.py
trunk/python-ogre/code_generators/betagui/generate_code.py
trunk/python-ogre/code_generators/cleanbuild.bat
trunk/python-ogre/code_generators/nxogre/customization_data.py
trunk/python-ogre/code_generators/nxogre/generate_code.py
trunk/python-ogre/code_generators/nxogre/python_nxogre.h
trunk/python-ogre/code_generators/nxogre/python_nxogre_aliases.h
trunk/python-ogre/code_generators/ogre/generate_code.py
trunk/python-ogre/code_generators/ogre/hand_made_wrappers.py
trunk/python-ogre/code_generators/ogre/python_ogre_aliases.h
trunk/python-ogre/code_generators/ogreal/generate_code.py
trunk/python-ogre/code_generators/ogredshow/generate_code.py
trunk/python-ogre/code_generators/ogrenewt/generate_code.py
trunk/python-ogre/code_generators/ogreode/generate_code.py
trunk/python-ogre/code_generators/ogrevideoffmpeg/generate_code.py
trunk/python-ogre/code_generators/quickgui/generate_code.py
trunk/python-ogre/code_generators/quickgui/python_quickgui_aliases.h
trunk/python-ogre/code_generators/quickgui/python_quickgui_sizeof.h
trunk/python-ogre/code_generators/theora/generate_code.py
trunk/python-ogre/environment.py
trunk/python-ogre/setup.py
Added Paths:
-----------
trunk/python-ogre/code_generators/cleanIncrementalbuild.bat
trunk/python-ogre/code_generators/plib/
trunk/python-ogre/code_generators/plib/customization_data.py
trunk/python-ogre/code_generators/plib/generate_code.py
trunk/python-ogre/code_generators/plib/hand_made_wrappers.py
trunk/python-ogre/code_generators/plib/python_plib.h
trunk/python-ogre/code_generators/plib/python_plib_aliases.h
trunk/python-ogre/code_generators/plib/python_plib_sizeof.h
trunk/python-ogre/code_generators/plib/register_exceptions.py
trunk/python-ogre/demos/theora/
trunk/python-ogre/demos/theora/SampleFramework.py
trunk/python-ogre/demos/theora/demo_video.py
trunk/python-ogre/demos/theora/plugins.cfg
trunk/python-ogre/demos/theora/resources.cfg
Modified: trunk/python-ogre/PythonOgreConfig_nt.py
===================================================================
--- trunk/python-ogre/PythonOgreConfig_nt.py 2007-08-30 11:46:24 UTC (rev 373)
+++ trunk/python-ogre/PythonOgreConfig_nt.py 2007-09-06 10:19:05 UTC (rev 374)
@@ -46,6 +46,8 @@
PATH_ogrevideoffmpeg = os.path.join(root_dir, 'ThirdParty','ffmpeg')
PATH_ffmpeg= os.path.join(BASE_DIR, 'ffmpeg')
PATH_ogredshow = os.path.join(root_dir, 'ThirdParty','dshow')
+PATH_plib = os.path.join(BASE_DIR, 'plib')
+
#
# it's time for the SDK version
if SDK:
@@ -93,6 +95,7 @@
PATH_LIB_ogrevideoffmpeg = PATH_ogrevideoffmpeg
PATH_LIB_ffmpeg= os.path.join(PATH_ffmpeg, 'lib')
PATH_LIB_ogredshow = PATH_ogredshow
+PATH_LIB_plib = PATH_plib
if SDK:
PATH_LIB_Ogre_CEGUIRenderer = os.path.join( PATH_Ogre, 'lib')
@@ -134,6 +137,7 @@
PATH_INCLUDE_ogrevideoffmpeg = PATH_ogrevideoffmpeg
PATH_INCLUDE_ffmpeg = os.path.join (PATH_ffmpeg,'include')
PATH_INCLUDE_ogredshow = PATH_ogredshow
+PATH_INCLUDE_plib = PATH_plib
PATH_INCLUDE_OggVorbisTheora = [ os.path.join(BASE_DIR,'ogg','include')
,os.path.join(BASE_DIR, 'vorbis', 'include')
Modified: trunk/python-ogre/code_generators/betagui/generate_code.py
===================================================================
--- trunk/python-ogre/code_generators/betagui/generate_code.py 2007-08-30 11:46:24 UTC (rev 373)
+++ trunk/python-ogre/code_generators/betagui/generate_code.py 2007-09-06 10:19:05 UTC (rev 374)
@@ -387,7 +387,8 @@
)
# 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
Added: trunk/python-ogre/code_generators/cleanIncrementalbuild.bat
===================================================================
--- trunk/python-ogre/code_generators/cleanIncrementalbuild.bat (rev 0)
+++ trunk/python-ogre/code_generators/cleanIncrementalbuild.bat 2007-09-06 10:19:05 UTC (rev 374)
@@ -0,0 +1,59 @@
+rem del /Q cache\*
+call vcvars32
+rem cd ogre
+rem python generate_code.py >1
+rem cd ..
+cd ogreode
+python generate_code.py >1
+cd ..
+cd ogrenewt
+python generate_code.py >1
+cd ..
+cd ogreal
+python generate_code.py >1
+cd ..
+cd ogrerefapp
+python generate_code.py >1
+cd ..
+cd ode
+python generate_code.py >1
+cd ..
+cd ois
+python generate_code.py >1
+cd ..
+cd cegui
+python generate_code.py >1
+cd ..
+cd quickgui
+python generate_code.py >1
+cd ..
+cd opcode
+python generate_code.py >1
+cd ..
+cd physx
+python generate_code.py >1
+cd ..
+cd nxogre
+python generate_code.py >1
+cd ..
+cd ogredshow
+python generate_code.py >1
+cd ..
+cd ogrevideoffmpeg
+python generate_code.py >1
+cd ..
+cd theora
+python generate_code.py >1
+cd ..
+cd bullet
+python generate_code.py >1
+cd ..
+cd betagui
+python generate_code.py >1
+cd ..
+cd plib
+python generate_code.py >1
+cd ..
+cd ..
+scons -i
+
Modified: trunk/python-ogre/code_generators/cleanbuild.bat
===================================================================
--- trunk/python-ogre/code_generators/cleanbuild.bat 2007-08-30 11:46:24 UTC (rev 373)
+++ trunk/python-ogre/code_generators/cleanbuild.bat 2007-09-06 10:19:05 UTC (rev 374)
@@ -1,5 +1,5 @@
del /Q cache\*
-rmdir /s /q ..\generated
+echo rmdir /s /q ..\generated
cd ogre
python generate_code.py >1
cd ..
@@ -24,4 +24,8 @@
cd cegui
python generate_code.py >1
cd ..
+cd quickgui
+python generate_code.py >1
+cd ..
+
Modified: trunk/python-ogre/code_generators/nxogre/customization_data.py
===================================================================
--- trunk/python-ogre/code_generators/nxogre/customization_data.py 2007-08-30 11:46:24 UTC (rev 373)
+++ trunk/python-ogre/code_generators/nxogre/customization_data.py 2007-09-06 10:19:05 UTC (rev 374)
@@ -1,6 +1,7 @@
def header_files( version ):
return [ 'NxOgre.h'
+ ,'NxOgreSkeleton.h'
, 'Ogre.h'
,'OgrePlugin.h'
,'NxPhysics.h'
Modified: trunk/python-ogre/code_generators/nxogre/generate_code.py
===================================================================
--- trunk/python-ogre/code_generators/nxogre/generate_code.py 2007-08-30 11:46:24 UTC (rev 373)
+++ trunk/python-ogre/code_generators/nxogre/generate_code.py 2007-09-06 10:19:05 UTC (rev 374)
@@ -56,6 +56,17 @@
if c.decl_string.startswith('::NxOgre::Container<') and '*' not in c.decl_string:
print "EXCLUDING: ", c
c.exclude()
+
+ ### Now some of the functions need to be excluded.. This is too much and could be cut back
+ ### ie only some of the containers lists fail at compile time
+ funlist = ['get','has','next','remove']
+ if c.decl_string.startswith('::NxOgre::List<'):
+ for f in funlist:
+ try:
+ c.member_function(f).exclude()
+ print "EXCLUDING: ", c, f
+ except:
+ pass
for v in c.variables(allow_empty=True):
if v.access_type != 'public' :
v.exclude()
@@ -64,9 +75,6 @@
if t.decl_string.startswith('::NxOgre::Container<') and '*' not in t.decl_string:
t.exclude()
print "EXCLUDING: ", t
-# print dir ( main_ns )
-# for t in main_ns.variables():
-# print t
# things not yet implemented in the C source..
excludes=['::NxOgre::Compartment']
@@ -75,26 +83,25 @@
for e in excludes:
if e in m.decl_string:
m.exclude()
-# for c in main_ns.constructors():
-# print c
- # problem with a constructor on Shape
- main_ns.class_('::NxOgre::Shape').constructor(arg_types=['::NxOgre::ShapeParams']).exclude()
- # And coth..
+ # problem with a constructor on Cloth
main_ns.class_('::NxOgre::Cloth').constructor(arg_types=[None,'::NxClothDesc','::NxMeshData',None,None]).exclude()
-
- ### Member Functions
+# # #
+# # # ### Member Functions
excludes=[
'::NxOgre::Container<std::string, NxOgre::FluidDrain*>::begin'
,'::NxOgre::Container<std::string, NxOgre::FluidDrain*>::get'
,'::NxOgre::Container<std::string, NxOgre::FluidDrain*>::getFirst'
,'::NxOgre::Container<std::string, NxOgre::FluidDrain*>::next'
,'::NxOgre::Container<std::string, NxOgre::FluidEmitter*>::getFirst'
+ ,'::NxOgre::List<NxOgre::RemoteDebuggerConnection::Camera>::destroyAndEraseAll'
+ ,'::NxOgre::List<NxOgre::RemoteDebuggerConnection::Camera>::dumpToConsole'
+
,'::NxOgre::UserAllocator::realloc'
- ,'::NxOgre::Serialiser::NXU_notifySaveActor' # takes a * * argument
- # not yet implemented in source
+# # # # not yet implemented in source
,'::NxOgre::WheelSet::attachNewWheel'
,'::NxOgre::WheelSet::createThreeWheelSet'
+ ,'::NxOgre::WheelSet::createSixWheelSet'
,'::NxOgre::Wheel::addEntity'
,'::NxOgre::Cloth::duplicate'
,'::NxOgre::ClothRayCaster::getClosestCloth'
@@ -126,14 +133,9 @@
,'::NxOgre::Scene::createSphericalJoint'
,'::NxOgre::Scene::createPrismaticJoint'
,'::NxOgre::Scene::createFixedJoint'
- ,'::NxOgre::Serialiser::saveScene'
- ,'::NxOgre::Serialiser::restoreScene'
+ ,'::NxOgre::Scene::save'
,'::NxOgre::SoftBody::simulate'
,'::NxOgre::SoftBody::render'
- ,'::NxOgre::WheelSet::createSixWheelSet'
- ,'::NxOgre::Summary::has'
- ,'::NxOgre::ActorBlueprint::setDynamicCollisionModel'
- ,'::NxOgre::ActorBlueprint::setCollisionModel'
,'::NxOgre::PhysXDriver::stop'
,'::NxOgre::PhysXDriver::start'
,'::NxOgre::PhysXDriver::reset'
@@ -144,36 +146,32 @@
main_ns.member_functions(e).exclude()
### Free Functions
- excludes = ['::NxOgre::NxCookTriMeshToDisk'
- ,'::NxOgre::NxCookConvexToDisk'
- ,'::NxOgre::simulateWorldGeometry']
+ excludes = []
for e in excludes:
main_ns.free_functions(e).exclude()
## Classes
excludes = ['::NxOgre::BaseCharacterHitReport'
,'::NxOgre::CharacterHitReport'
+ ,'::NxOgre::Blueprints::ActorBlueprint'
+ ,'::NxOgre::Blueprints::ActorFactory'
+ ,'::NxOgre::Blueprints::WorldBlueprint'
+ ,'::NxOgre::Serialiser::SerialiserBase'
+ ,'::NxOgre::UserAllocator'
+ ,'::NxOgre::State'
+
# not yet implemented in source
]
for e in excludes:
main_ns.class_(e).exclude()
-
-
+# # #
+# # #
## I have a challenge that Py++ doesn't recognise these classes by full name (perhaps because they are structs?)
## so I have to look through and match on a class by class basis
excludeName = ['Container<NxOgre::Scene::Renderables, float>'
,'List<NxOgre::CharacterHitReport*>'
- ,'Container<std::string, NxOgre::RayCastHit>'
,'List<NxOgre::RemoteDebuggerConnection::Camera>'
- ,'List<NxOgre::Wheel*>'
- ,'NxCookTriMeshToDisk'
- ,'NxCookConvexToDisk'
- ,'simulateWorldGeometry'
- ,'UserAllocator'
- ,'ClothVertex'
-# ,'Cloth'
- ##,'PhysXDriver'
- ,'State'
+ ,'List<NxOgre::Blueprints::ActorBlueprint*>'
]
for c in main_ns.classes():
# print c.decl_string
@@ -210,7 +208,7 @@
if 'NxVec3' in a.type.decl_string or 'NxQuat' in a.type.decl_string:
c.exclude()
break
-
+# # #
############################################################
##
@@ -604,7 +602,10 @@
)
# 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
Modified: trunk/python-ogre/code_generators/nxogre/python_nxogre.h
===================================================================
--- trunk/python-ogre/code_generators/nxogre/python_nxogre.h 2007-08-30 11:46:24 UTC (rev 373)
+++ trunk/python-ogre/code_generators/nxogre/python_nxogre.h 2007-09-06 10:19:05 UTC (rev 374)
@@ -1,5 +1,6 @@
#include "NxOgre.h"
+#include "NXOgreSkeleton.h" //missing ??
#include "Ogre.h"
#include "OgrePlugin.h"
#include <NxPhysics.h>
Modified: trunk/python-ogre/code_generators/nxogre/python_nxogre_aliases.h
===================================================================
--- trunk/python-ogre/code_generators/nxogre/python_nxogre_aliases.h 2007-08-30 11:46:24 UTC (rev 373)
+++ trunk/python-ogre/code_generators/nxogre/python_nxogre_aliases.h 2007-09-06 10:19:05 UTC (rev 374)
@@ -7,7 +7,23 @@
typedef std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,std::basic_string<char, std::char_traits<char>, std::allocator<char> > >\
PairString;
-
+typedef NxOgre::List<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > ListString;
+typedef NxOgre::List<NxOgre::Blueprints::ActorBlueprint*> ListBlueprints;
+typedef NxOgre::Container<unsigned, NxOgre::ShapeBlueprint const&> ContainerShapeBlueprint;
+typedef NxOgre::Container<std::string, NxOgre::ActorBlueprint> ContainerActorBlueprint;
+//typedef NxOgre::Container<NxOgre::Scene::Renderables, float> ContainerSceneRencerables;
+typedef std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,float,std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >,std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, float> > >\
+ MapStrings;
+typedef std::map<unsigned, float, std::less<unsigned>, std::allocator<std::pair<unsigned const, float> > >\
+ MapUnsignedFloat;
+typedef std::vector<NxOgre::Scene*, std::allocator<NxOgre::Scene*> > VectorScene;
+typedef std::list<NxOgre::Blueprints::ActorBlueprint*, std::allocator<NxOgre::Blueprints::ActorBlueprint*> > ListBlueprintsActorBlueprint;
+typedef std::list<std::pair<std::string, std::string>, std::allocator<std::pair<std::string, std::string> > >\
+ ListPairString;
+typedef std::map<std::string, NxOgre::Container<std::string, NxOgre::DominanceGroup*>::Containee, std::less<std::string>, std::allocator<std::pair<std::string const, NxOgre::Container<std::string, NxOgre::DominanceGroup*>::Containee> > >\
+ MapContainerDominanceGroup;
+
+
typedef std::map<std::string, NxOgre::Container<std::string, NxOgre::Scene*>::Containee, std::less<std::string> >\
MapContainerScene;
typedef std::list<NxOgre::CharacterHitReport*, std::allocator<NxOgre::CharacterHitReport*> > ListCharacterHitReportPtr;
@@ -41,7 +57,7 @@
MapContainerTrigger;
typedef std::list<NxOgre::RemoteDebuggerConnection::Camera, std::allocator<NxOgre::RemoteDebuggerConnection::Camera> >\
ListRemoteDebuggerConnectionCamera;
-typedef std::vector<NxOgre::Summary::Feature> VectorSummaryFeature;
+// typedef std::vector<NxOgre::Summary::Feature> VectorSummaryFeature;
typedef std::map<unsigned, NxOgre::Container<unsigned, NxOgre::Shape*>::Containee, std::less<unsigned> >\
MapContainerUnsignedShape;
typedef std::map<unsigned, NxOgre::Container<unsigned, NxOgre::ErrorReporter*>::Containee, std::less<unsigned> >\
Modified: trunk/python-ogre/code_generators/ogre/generate_code.py
===================================================================
--- trunk/python-ogre/code_generators/ogre/generate_code.py 2007-08-30 11:46:24 UTC (rev 373)
+++ trunk/python-ogre/code_generators/ogre/generate_code.py 2007-09-06 10:19:05 UTC (rev 374)
@@ -543,7 +543,15 @@
};
}
"""
-
+# c = ns.class_( 'PixelBox' )
+# c.add_declaration_code( pixelBox_size )
+# for f in c.mem_funs( 'getData' ):
+# f.call_policies = call_policies.return_range( f, 'ImageSize' )
+# f.documentation = "Python-Ogre Modified Return Range \\n"
+# if f.has_const:
+# f.alias = 'getReadOnlyData'
+
+
image_size = """
namespace{
struct ImageSize{
@@ -916,10 +924,21 @@
""" we modify functions that take void *'s in their argument list to instead take
unsigned ints, which allows us to use CTypes buffers
"""
+# for fun in mb.class_('PixelUtil').member_functions('unpackColour') :
+# print "Function:", fun
+# for arg in fun.arguments:
+# print arg
+# print arg.type
+# print "Const", declarations.is_const(arg.type)
+# print "pointer", declarations.is_pointer(arg.type)
+# print "Void", declarations.is_void(arg.type)
+# print arg.type.decl_string
+# sys.exit()
+
for fun in mb.member_functions():
arg_position = 0
for arg in fun.arguments:
- if declarations.type_traits.is_void_pointer(arg.type):
+ if arg.type.decl_string == 'void const *' or arg.type.decl_string == 'void *':
fun.add_transformation( ft.modify_type(arg_position,_ReturnUnsignedInt ), alias=fun.name )
fun.documentation = docit ("Modified Input Argument to work with CTypes",
"Argument "+arg.name+ "(pos:" + str(arg_position)\
Modified: trunk/python-ogre/code_generators/ogre/hand_made_wrappers.py
===================================================================
--- trunk/python-ogre/code_generators/ogre/hand_made_wrappers.py 2007-08-30 11:46:24 UTC (rev 373)
+++ trunk/python-ogre/code_generators/ogre/hand_made_wrappers.py 2007-09-06 10:19:05 UTC (rev 374)
@@ -2,7 +2,23 @@
import environment
+WRAPPER_DEFINITION_PixelBox =\
+"""
+// return the data buffer - can't be handled 'normally' by Py++
+void * PixelBox_data ( ::Ogre::PixelBox & me )
+{
+ return me.data;
+}
+"""
+WRAPPER_REGISTRATION_PixelBox = [
+ """def( "getData", &::PixelBox_data,\\
+ "Python-Ogre Helper Function: Returns the data buffer.\\n\\
+ Input: \\n\\
+ Output: A void pointer to the data buffer",\\
+ bp::return_value_policy< bp::return_opaque_pointer >());"""
+ ]
+
WRAPPER_WRAPPER_RenderQueueListener =\
"""
virtual void renderQueueEnded( ::Ogre::uint8 queueGroupId, ::Ogre::String const & invocation, bool & repeatThisInvocation ){
@@ -22,32 +38,6 @@
"""
-# WRAPPER_DEFINITION_ShadowRenderable =\
-# """
-# Ogre::ShadowRenderable * ShadowRenderable_castElement(Ogre::ShadowRenderable * r){
-# if( dynamic_cast< Ogre::Region::RegionShadowRenderable * >( r ) ){
-# return (Ogre::Region::RegionShadowRenderable*) r ;
-# }
-# if( dynamic_cast< Ogre::ManualObject::ManualObjectSectionShadowRenderable * >( r ) ){
-# return (Ogre::ManualObject::ManualObjectSectionShadowRenderable*) r ;
-# }
-# if( dynamic_cast< Ogre::Entity::EntityShadowRenderable * >( r ) ){
-# return (Ogre::Entity::EntityShadowRenderable*) r ;
-# }
-# return ( r );
-# }
-#
-# Ogre::ShadowRenderable* ShadowRenderable_getLightCapRenderable( Ogre::ShadowRenderable & me){
-# return ShadowRenderable_castElement ( me.getLightCapRenderable() );
-# }
-# """
-WRAPPER_REGISTRATION_ShadowRenderable = [
- 'def( "getLightCapRenderable", &::ShadowRenderable_getLightCapRenderable,\
- "Python-Ogre Hand Wrapped\\n",\
- bp::return_value_policy< bp::reference_existing_object, bp::default_call_policies >());',
-
- ]
-
WRAPPER_DEFINITION_OverlayElement = \
"""
@@ -677,6 +667,10 @@
rt.add_declaration_code( WRAPPER_DEFINITION_Node )
apply_reg (rt, WRAPPER_REGISTRATION_Node )
+ rt = mb.class_( 'PixelBox' )
+ rt.add_declaration_code( WRAPPER_DEFINITION_PixelBox )
+ apply_reg (rt, WRAPPER_REGISTRATION_PixelBox )
+
# rt = mb.class_( 'ShadowRenderable' )
# rt.add_declaration_code( WRAPPER_DEFINITION_ShadowRenderable )
# apply_reg (rt, WRAPPER_REGISTRATION_ShadowRenderable )
@@ -712,8 +706,8 @@
for cls in map_iterators:
iter_as_generator_map( cls )
-# rt = mb.class_( 'RenderQueueListener' )
-# rt.add_wrapper_code ( WRAPPER_WRAPPER_RenderQueueListener )
+ rt = mb.class_( 'RenderQueueListener' )
+ rt.add_wrapper_code ( WRAPPER_WRAPPER_RenderQueueListener )
# cls = mb.class_('Animation').class_('NodeTrackIterator')
# iter_as_generator_map( cls )
Modified: trunk/python-ogre/code_generators/ogre/python_ogre_aliases.h
===================================================================
--- trunk/python-ogre/code_generators/ogre/python_ogre_aliases.h 2007-08-30 11:46:24 UTC (rev 373)
+++ trunk/python-ogre/code_generators/ogre/python_ogre_aliases.h 2007-09-06 10:19:05 UTC (rev 374)
@@ -299,7 +299,7 @@
typedef Ogre::Pose::VertexOffsetMap VertexOffsetMap;
typedef Ogre::Pose::VertexOffsetIterator VertexOffsetIterator;
typedef Ogre::Pose::ConstVertexOffsetIterator ConstVertexOffsetIterator;
-typedef Ogre::PlaneBoundedVolume::PlaneList PlaneList;
+typedef Ogre::PlaneBoundedVolume::PlaneList PlaneListBoundedVolume;
typedef Ogre::Pass::PassSet PassSet;
typedef Ogre::Pass::TextureUnitStateIterator TextureUnitStateIterator;
typedef Ogre::Pass::ConstTextureUnitStateIterator ConstTextureUnitStateIterator;
Modified: trunk/python-ogre/code_generators/ogreal/generate_code.py
===================================================================
--- trunk/python-ogre/code_generators/ogreal/generate_code.py 2007-08-30 11:46:24 UTC (rev 373)
+++ trunk/python-ogre/code_generators/ogreal/generate_code.py 2007-09-06 10:19:05 UTC (rev 374)
@@ -174,6 +174,8 @@
, indexing_suite_version=2
)
#
+ mb.register_module_dependency ( environment.ogre.generated_dir )
+
# We filter (both include and exclude) specific classes and functions that we want to wrap
#
filter_declarations (mb)
Modified: trunk/python-ogre/code_generators/ogredshow/generate_code.py
===================================================================
--- trunk/python-ogre/code_generators/ogredshow/generate_code.py 2007-08-30 11:46:24 UTC (rev 373)
+++ trunk/python-ogre/code_generators/ogredshow/generate_code.py 2007-09-06 10:19:05 UTC (rev 374)
@@ -462,7 +462,8 @@
)
# 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
Modified: trunk/python-ogre/code_generators/ogrenewt/generate_code.py
===================================================================
--- trunk/python-ogre/code_generators/ogrenewt/generate_code.py 2007-08-30 11:46:24 UTC (rev 373)
+++ trunk/python-ogre/code_generators/ogrenewt/generate_code.py 2007-09-06 10:19:05 UTC (rev 374)
@@ -212,6 +212,8 @@
'OIS_NONCLIENT_BUILD', 'OIS_STATIC_BUILD']
, 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...
Modified: trunk/python-ogre/code_generators/ogreode/generate_code.py
===================================================================
--- trunk/python-ogre/code_generators/ogreode/generate_code.py 2007-08-30 11:46:24 UTC (rev 373)
+++ trunk/python-ogre/code_generators/ogreode/generate_code.py 2007-09-06 10:19:05 UTC (rev 374)
@@ -37,7 +37,8 @@
def filter_declarations( mb ):
global_ns = mb.global_ns
global_ns.exclude()
-
+
+ global_ns.namespace("std").class_('list<Ogre::Plane, std::allocator<Ogre::Plane> >').exclude()
if not environment.ogre.version.startswith("1.2") and os.name =='nt':
mb.global_ns.class_( 'vector<Ogre::Vector4, std::allocator<Ogre::Vector4> >' ).exclude( )
@@ -112,9 +113,11 @@
global_ns.namespace( 'Ogre' ).class_('SceneManager').include(already_exposed=True)
global_ns.namespace( 'Ogre' ).class_('Matrix4').include(already_exposed=True)
global_ns.namespace( 'Ogre' ).class_('Plugin').include(already_exposed=True)
-# print "\nCLASSES::: Std"
-# for c in global_ns.namespace('std').classes():
-# print c.name, c
+ print "\nCLASSES::: Std"
+ for c in global_ns.namespace('std').classes():
+ print c.name, c
+ global_ns.namespace("std").class_('list<Ogre::Plane, std::allocator<Ogre::Plane> >').exclude()
+
# print "\nCLASSES::: Ode"
# for c in global_ns.namespace('OgreOde').classes():
# print c.name, c
@@ -180,7 +183,9 @@
, include_paths=environment.ogreode.include_dirs
, define_symbols= defined_symbols
, indexing_suite_version=2 )
-
+
+ ## This module depends on Ogre
+ mb.register_module_dependency ( environment.ogre.generated_dir )
filter_declarations (mb)
## we need to handle "ode" return values etc
@@ -255,7 +260,7 @@
huge_classes = map( mb.class_, customization_data.huge_classes(environment.ogreode.version) )
print "ABOUT TO SPLIT"
- mb.split_module(environment.ogreode.generated_dir, huge_classes)
+ mb.split_module(environment.ogreode.generated_dir, huge_classes, use_files_sum_repository=False )
if __name__ == '__main__':
start_time = time.clock()
Modified: trunk/python-ogre/code_generators/ogrevideoffmpeg/generate_code.py
===================================================================
--- trunk/python-ogre/code_generators/ogrevideoffmpeg/generate_code.py 2007-08-30 11:46:24 UTC (rev 373)
+++ trunk/python-ogre/code_generators/ogrevideoffmpeg/generate_code.py 2007-09-06 10:19:05 UTC (rev 374)
@@ -361,7 +361,8 @@
)
# 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
Added: trunk/python-ogre/code_generators/plib/customization_data.py
===================================================================
--- trunk/python-ogre/code_generators/plib/customization_data.py (rev 0)
+++ trunk/python-ogre/code_generators/plib/customization_data.py 2007-09-06 10:19:05 UTC (rev 374)
@@ -0,0 +1,11 @@
+
+def header_files( version ):
+ return [ 'ul.h'
+ ,'sl.h'
+ , 'sm.h'
+ , 'net.h'
+ ]
+
+def huge_classes( version ):
+ return []
+
\ No newline at end of file
Added: trunk/python-ogre/code_generators/plib/generate_code.py
===================================================================
--- trunk/python-ogre/code_generators/plib/generate_code.py (rev 0)
+++ trunk/python-ogre/code_generators/plib/generate_code.py 2007-09-06 10:19:05 UTC (rev 374)
@@ -0,0 +1,563 @@
+#!/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/
+#
+# -----------------------------------------------------------------------------
+
+
+import os, sys, time, shutil
+
+#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
+import register_exceptions
+
+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
+
+MAIN_NAMESPACE = ''
+
+## small helper function
+def docit ( general, i, o ):
+ docs = "Python-Ogre Modified Function Call\\n" + general +"\\n"
+ docs = docs + "Input: " + i + "\\n"
+ docs = docs + "Output: " + o + "\\n\\\n"
+ return docs
+
+############################################################
+##
+## Here is where we manually exclude stuff
+##
+############################################################
+
+def ManualExclude ( mb ):
+ global_ns = mb.global_ns
+ main_ns = global_ns
+
+ # things not yet implemented in the C source..
+ excludes=[]
+ for c in main_ns.classes():
+ for m in c.member_functions(allow_empty=True):
+ for e in excludes:
+ if e in m.decl_string:
+ m.exclude()
+
+ ### Member Functions
+ excludes=[ #'::slScheduler::waveOutClose'
+# ,'::slScheduler::waveOutWrite'
+# ,'::slScheduler::waveOutReset'
+# ,'::slScheduler::waveOutGetPosition'
+# ,'::slScheduler::waveOutPrepareHeader'
+ '::netMessage::print' # strange / ugly defination
+ ,'::slSample::getBuffer' # returns char pointer -- needs wrapping
+ ,'::slSample::getComment' # same..
+ # have callbacks and need to be hand wrapped
+ ,'::slScheduler::loopSample'
+ ,'::slScheduler::loopMusic'
+ ,'::slScheduler::playSample'
+ ,'::slScheduler::playMusic'
+ # handwrapped to handle python lists instead of c buffers
+ ,'::netSocket::send'
+ ,'::netSocket::sendto'
+ ,'::netSocket::recv'
+ ,'::netSocket::recvfrom'
+ ,'::netBuffer::getData' ## returns a char pointer to the data which needs wrapping
+ ,'::netChannel::send'
+ ,'::netChannel::recv'
+ ,'::netMonitorServer::setCommandFunc' ## needs to handle callbacks
+
+ ]
+ for e in excludes:
+ print "excluding ", e
+ main_ns.member_functions(e).exclude()
+
+ ### Free Functions
+ excludes = []
+ for e in excludes:
+ main_ns.free_functions(e).exclude()
+
+ ## Classes
+ excludes = []
+ for e in excludes:
+ main_ns.class_(e).exclude()
+
+
+ ## I have a challenge that Py++ doesn't recognise these classes by full name (perhaps because they are structs?)
+ ## so I have to look through and match on a class by class basis
+ excludeName = []
+ for c in main_ns.classes():
+ if c.name in excludeName:
+ c.exclude()
+
+ ### Variables
+ excludes = []
+ for e in excludes:
+ main_ns.variable(e).exclude()
+
+ ### Typedefs
+ excludes = []
+ for e in excludes:
+ main_ns.typedefs(e).exclude()
+
+ ### Operators
+ excludes=[]
+ for e in excludes:
+ main_ns.operators(e).exclude()
+
+# ### Constructors
+# for c in main_ns.class_('::plib::Pose').constructors(): ## these hide the working constructors
+# for a in c.arguments:
+# if 'NxVec3' in a.type.decl_string or 'NxQuat' in a.type.decl_string:
+# c.exclude()
+# break
+
+
+############################################################
+##
+## And there are things that manually need to be INCLUDED
+##
+############################################################
+
+def ManualInclude ( mb ):
+ global_ns = mb.global_ns
+ main_ns = global_ns
+
+ includes=['netInit']
+ ### Free Functions
+ for e in includes:
+ main_ns.free_functions(e).include()
+
+############################################################
+##
+## And things that need manual fixes, but not necessarly hand wrapped
+##
+############################################################
+def ManualFixes ( mb ):
+
+ global_ns = mb.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 ):
+ def _ReturnUnsignedInt( type_ ):
+ """helper to return an UnsignedInt call for tranformation functions
+ """
+ return declarations.cpptypes.unsigned_int_t()
+
+ global_ns = mb.global_ns
+ main_ns = global_ns
+
+ def create_output( size ):
+ return [ ft.output( i ) for i in range( size ) ]
+
+ ## hack to get things working -- needs to be wrapped to handle a python call back
+ change = ['loopSample', 'loopMusic','playSample','playMusic']
+ for fun in change:
+ f = global_ns.class_('::slScheduler').mem_fun(fun)
+ f.add_transformation( ft.modify_type('cb',_ReturnUnsignedInt ), alias=fun )
+ print "Changed ", f
+
+###############################################################################
+##
+## Now for the AUTOMATIC stuff that should just work
+##
+###############################################################################
+
+
+def AutoExclude( mb ):
+ """ Automaticaly exclude a range of things that don't convert well from C++ to Python
+ """
+ global_ns = mb.global_ns
+ main_ns = global_ns
+
+ # vars that are static consts but have their values set in the header file are bad
+ Remove_Static_Consts ( main_ns )
+
+ ## Exclude protected and private that are not pure virtual
+ query = ~declarations.access_type_matcher_t( 'public' ) \
+ & ~declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL )
+ non_public_non_pure_virtual = main_ns.calldefs( query )
+ non_public_non_pure_virtual.exclude()
+
+ #Virtual functions that return reference could not be overriden from Python
+ query = declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.VIRTUAL ) \
+ & declarations.custom_matcher_t( lambda decl: declarations.is_reference( decl.return_type ) )
+ try:
+ main_ns.calldefs( query ).virtuality = declarations.VIRTUALITY_TYPES.NOT_VIRTUAL
+ except:
+ pass
+
+def AutoInclude( mb ):
+ main_ns = mb.global_ns ## doesn't have it's own namespace..
+ validPrefix= ['sl','sm','net','ul']
+
+ for cls in main_ns.classes():
+ for p in validPrefix:
+ if cls.name.startswith ( p ) and cls.name[len(p)].isupper():
+ print "Including class: ", cls.name
+ cls.include()
+
+ for cls in main_ns.enums():
+ for p in validPrefix:
+ if cls.name.startswith ( p ) and cls.name[len(p)].isupper():
+ print "Including enum: ", cls.name
+ cls.include()
+
+ for cls in main_ns.free_functions():
+ print "Free Function:", cls
+ for p in validPrefix:
+ if cls.name.startswith ( p ) and cls.name[len(p)].isupper():
+ print "Including free function: ", cls.name
+ cls.include()
+
+
+def AutoFixes ( mb ):
+ """ 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
+ main_ns = global_ns
+
+ # arguments passed as refs but not const are not liked by boost
+ #Fix_Ref_Not_Const ( main_ns )
+
+ # Functions that have void pointers in their argument list need to change to unsigned int's
+ Fix_Void_Ptr_Args ( main_ns )
+
+ # and change functions that return a variety of pointers to instead return unsigned int's
+ Fix_Pointer_Returns ( main_ns )
+
+ # functions that need to have implicit conversions turned off
+ Fix_Implicit_Conversions ( main_ns)
+
+ if os.name =='nt':
+ Fix_NT( mb )
+ elif os.name =='posix':
+ Fix_Posix( mb )
+
+
+###############################################################################
+##
+## 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
+ """
+
+
+def Fix_Implicit_Conversions ( mb ):
+ """By default we disable explicit conversion, however sometimes it makes sense
+ """
+ pass
+
+def Add_Auto_Conversions( mb ):
+ pass
+
+
+def Set_Call_Policies( mb ):
+ """ set the return call policies on classes that this hasn't already been done for.
+ Set the default policy to deal with pointer/reference return types to reference_existing object
+ """
+ mem_funs = mb.calldefs ()
+ mem_funs.create_with_signature = True #Generated code will not compile on
+ #MSVC 7.1 if function has throw modifier.
+ 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) ):
+ mem_fun.call_policies = call_policies.return_value_policy(
+ call_policies.reference_existing_object )
+
+
+def Set_Exception(mb):
+ pass
+ #~ """We don't exclude Exception, because it contains functionality, that could
+ #~ be useful to user. But, we will provide automatic exception translator
+ #~ """
+ #~ Exception = mb.namespace( 'Ogre' ).class_( 'Exception' )
+ #~ Exception.include()
+ #~ Exception.mem_fun('what').exclude() # declared with empty throw
+ #~ Exception.mem_fun('getNumber').exclude() # declared with empty throw
+ #~ Exception.translate_exception_to_string( 'PyExc_RuntimeError', 'exc.getFullDescription().c_str()' )
+
+
+def _ReturnUnsignedInt( type_ ):
+ """helper to return an UnsignedInt call for tranformation functions
+ """
+ return declarations.cpptypes.unsigned_int_t()
+
+def Fix_Void_Ptr_Args ( mb ):
+ """ we modify functions that take void *'s in their argument list to instead take
+ unsigned ints, which allows us to use CTypes buffers
+ """
+ for fun in mb.member_functions():
+ arg_position = 0
+ for arg in fun.arguments:
+ if declarations.type_traits.is_void_pointer(arg.type) or arg.type.decl_string == "void const *":
+ fun.add_transformation( ft.modify_type(arg_position,_ReturnUnsignedInt ), alias=fun.name )
+ fun.documentation = docit ("Modified Input Argument to work with CTypes",
+ "Argument "+arg.name+ "(pos:" + str(arg_position)\
+ +") takes a CTypes.adddressof(xx)", "...")
+ print "Fixed Void Ptr", fun, arg_position
+ break
+ arg_position +=1
+
+ ## lets go and look for stuff that might be a problem
+ pointee_types=['unsigned int',' int ', ' float ', ' Real ', 'uchar', 'uint8',
+ 'unsigned char']
+
+ function_names=[]
+ for fun in mb.member_functions():
+ if fun.documentation or fun.ignore: continue ## means it's been tweaked somewhere else
+ for n in function_names:
+ if n in fun.name:
+ print "CHECK :", fun
+ break
+ arg_position = 0
+ for arg in fun.arguments:
+ if declarations.is_pointer(arg.type): ## and "const" not in arg.type.decl_string:
+ for i in pointee_types:
+ if i in arg.type.decl_string:
+ print '"',arg.type.decl_string, '"'
+ print "CHECK ", fun, str(arg_position)
+ fun.documentation=docit("SUSPECT - MAYBE BROKEN", "....", "...")
+ break
+ arg_position +=1
+
+## NEED To do the same for constructors
+ for fun in mb.constructors():
+ arg_position = 0
+ for arg in fun.arguments:
+ if declarations.is_pointer(arg.type): ## and "const" not in arg.type.decl_string:
+ for i in pointee_types:
+ if i in arg.type.decl_string:
+ print '"',arg.type.decl_string, '"'
+ print "Excluding: ", fun
+ fun.exclude()
+ break
+ arg_position +=1
+
+def Fix_Pointer_Returns ( mb ):
+ """ Change out functions that return a variety of pointer to base types and instead
+ have them return the address the pointer is pointing to (the pointer value)
+ This allow us to use CTypes to handle in memory buffers from Python
+
+ Also - if documentation has been set then ignore the class/function as it means it's been tweaked else where
+ """
+ pointee_types=['unsigned int','int', 'float', 'unsigned char']
+ known_names=[] # these are function names we know it's cool to exclude
+ for fun in mb.member_functions():
+ if declarations.is_pointer (fun.return_type) and not fun.documentation:
+ for i in pointee_types:
+ if fun.return_type.decl_string.startswith ( i ) and not fun.documentation:
+ if not fun.name in known_names:
+ print "Excluding (function):", fun, "as it returns (pointer)", i
+ fun.exclude()
+ for fun in mb.member_operators(allow_empty=True):
+ if declarations.is_pointer (fun.return_type) and not fun.documentation:
+ for i in pointee_types:
+ if fun.return_type.decl_string.startswith ( i ) and not fun.documentation:
+ print "Excluding (operator):", fun
+ fun.exclude()
+
+
+
+def query_containers_with_ptrs(decl):
+ if not isinstance( decl, declarations.class_types ):
+ return False
+ if not decl.indexing_suite:
+ return False
+ return declarations.is_pointer( decl.indexing_suite.element_type )
+
+
+def Remove_Static_Consts ( mb ):
+ """ linux users have compile problems with vars that are static consts AND have values set in the .h files
+ we can simply leave these out """
+ checker = varchecker.var_checker()
+ for var in mb.vars():
+ if type(var.type) == declarations.cpptypes.const_t:
+ if checker( var ):
+ print "Excluding static const ", var
+ var.exclude()
+
+#
+# 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.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.plib.root_dir, "python_plib.h" )
+ , environment.plib.cache_file )
+
+ defined_symbols = [ ]
+ if environment._USE_THREADS:
+ defined_symbols.append('BOOST_HAS_THREADS')
+ defined_symbols.append('BOOST_HAS_WINTHREADS')
+ defined_symbols.append( 'VERSION_' + environment.plib.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.plib.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()
+ main_ns = global_ns
+# # main_ns.include()
+
+
+ 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 = [""]
+ 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, { 'PROJECT_version' : '"%s"' % environment.plib.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__' : '"plib PROJECT 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='_plib_' , doc_extractor= extractor )
+
+ for inc in environment.plib.include_dirs:
+ mb.code_creator.user_defined_directories.append(inc )
+ mb.code_creator.user_defined_directories.append( environment.plib.generated_dir )
+ mb.code_creator.replace_included_headers( customization_data.header_files( environment.plib.version ) )
+
+ huge_classes = map( mb.class_, customization_data.huge_classes( environment.plib.version ) )
+
+ mb.split_module(environment.plib.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 = [os.path.join(environment.Config.PATH_plib,'src','sl'),
+ os.path.join(environment.Config.PATH_plib,'src','util'),
+ os.path.join(environment.Config.PATH_plib,'src','net')
+ ]
+
+ for p in paths:
+ additional_files = os.listdir(p)
+ for f in additional_files:
+ if f.endswith('cxx') or f.endswith('.h'):
+ sourcefile = os.path.join(p, f)
+ destfile = os.path.join(environment.plib.generated_dir, f )
+
+ if not common_utils.samefile( sourcefile ,destfile ):
+ shutil.copy( sourcefile, environment.plib.generated_dir )
+ print "Updated ", f, "as it was missing or out of date"
+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/plib/hand_made_wrappers.py
===================================================================
--- trunk/python-ogre/code_generators/plib/hand_made_wrappers.py (rev 0)
+++ trunk/python-ogre/code_generators/plib/hand_made_wrappers.py 2007-09-06 10:19:05 UTC (rev 374)
@@ -0,0 +1,304 @@
+import os
+import environment
+
+WRAPPER_DEFINITION_netSocket =\
+"""
+int netSocket_send ( netSocket & me, boost::python::list listin, int flags = 0 )
+{
+ int index, result;
+ int size = len(listin);
+ byte * buffer = new byte [size];
+ for (index=0;index<size;index++ ) {
+ buffer[index] = (byte) boost::python::extract<int> (listin[index]);
+ }
+ result = me.send((const void *) buffer, size, flags );
+ delete buffer;
+ return result;
+}
+
+int netSocket_send_str ( netSocket & me, boost::python::str listin, int flags = 0 )
+{
+ int index, result;
+ int size = len(listin);
+ byte * buffer = new byte[size];
+ for (index=0;index<size;index++ ) {
+ buffer[index] = (byte) boost::python::extract<char> (listin[index]);
+ }
+ result = me.send((const void *) buffer, size, flags );
+ delete buffer;
+ return result;
+}
+int netSocket_sendto ( netSocket & me, boost::python::list listin, int flags, const netAddress* to )
+{
+ int index, result;
+ int size = len(listin);
+ byte * buffer = new byte[size];
+ for (index=0;index<size;index++ ) {
+ buffer[index] = boost::python::extract<int> (listin[index]);
+ }
+ result= me.sendto((const void *) buffer, size, flags, to );
+ delete buffer;
+ return result;
+}
+int netSocket_sendto_str ( netSocket & me, boost::python::str listin, int flags, const netAddress* to )
+{
+ int index, result;
+ int size = len(listin);
+ byte * buffer = new byte[size];
+ for (index=0;index<size;index++ ) {
+ buffer[index] = boost::python::extract<char> (listin[index]);
+ }
+ result= me.sendto((const void *) buffer, size, flags, to );
+ delete buffer;
+ return result;
+}
+
+
+boost::python::list netSocket_recv ( netSocket & me, int MaxSize=20486, int flags = 0 )
+{
+ byte * buffer = new byte [MaxSize];
+ int length,x;
+ boost::python::list listout;
+ length = me.recv ( (void *) buffer, MaxSize, flags);
+ for (x=0;x<length;x++) {
+ listout.append ( buffer[x] );
+ }
+ delete buffer;
+ return listout;
+}
+boost::python::str netSocket_recv_str ( netSocket & me, int MaxSize=2048, int flags = 0 )
+{
+ char * buffer = new char [MaxSize];
+ int length;
+ boost::python::str str_out;
+ length = me.recv ( (void *) buffer, MaxSize, flags);
+ if (length > 0 )
+ str_out = boost::python::str (buffer, length);
+ else
+ str_out = boost::python::str();
+ delete buffer;
+ return str_out;
+}
+
+boost::python::list netSocket_recvfrom ( netSocket & me, int MaxSize, int flags, netAddress* from )
+{
+ byte * buffer = new byte [MaxSize];
+ int length,x;
+ boost::python::list listout;
+ length = me.recvfrom ( (void *) buffer, MaxSize, flags, from);
+ for (x=0;x<length;x++) {
+ listout.append ( buffer[x] );
+ }
+ delete buffer;
+ return listout;
+}
+boost::python::str netSocket_recvfrom_str ( netSocket & me, int MaxSize, int flags, netAddress* from )
+{
+ char * buffer = new char [MaxSize];
+ int length;
+ boost::python::str str_out;
+ length = me.recvfrom ( (void *) buffer, MaxSize, flags, from);
+ if (length > 0 )
+ str_out = boost::python::str (buffer, length);
+ else
+ str_out = boost::python::str();
+ delete buffer;
+ return str_out;
+}
+"""
+WRAPPER_REGISTRATION_netSocket = [
+ """def( "send", &::netSocket_send,
+ ( bp::arg("listin"), bp::arg("flags")=(0) ),
+ "Python-Ogre Hand Wrapped\\n" );""",
+ """def( "send", &::netSocket_send_str,
+ ( bp::arg("listin"), bp::arg("flags")=(0) ),
+ "Python-Ogre Hand Wrapped\\n" );""",
+ """def( "sendto", &::netSocket_sendto,
+ "Python-Ogre Hand Wrapped\\n" );""",
+ """def( "sendto", &::netSocket_sendto_str,
+ "Python-Ogre Hand Wrapped\\n" );""",
+
+ """def( "recv", &::netSocket_recv,
+ ( bp::arg("MaxSize")=(2048), bp::arg("flags")=(0) ),
+ "Python-Ogre Hand Wrapped\\n" );""",
+ """def( "recv_str", &::netSocket_recv_str,
+ ( bp::arg("MaxSize")=(2048), bp::arg("flags")=(0) ),
+ "Python-Ogre Hand Wrapped\\n" );""",
+ """def( "recvfrom", &::netSocket_recvfrom,
+ "Python-Ogre Hand Wrapped\\n" );""",
+ """def( "recvfrom_str", &::netSocket_recvfrom_str,
+ "Python-Ogre Hand Wrapped - receives a string\\n" );""",
+]
+
+
+WRAPPER_DEFINITION_netBuffer =\
+"""
+char * netBuffer_getData(netBuffer & me) {
+ return me.getData() ;
+ }
+
+boost::python::str netBuffer_getData_str(netBuffer & me) {
+ boost::python::str str_out;
+ int length = me.getLength();
+ if (length > 0)
+ str_out = boost::python::str( me.getData(), length );
+ else
+ str_out = boost::python::str();
+ return str_out;
+ }
+"""
+WRAPPER_REGISTRATION_netBuffer = [
+ """def( "getData", &::netBuffer_getData,
+ bp::return_value_policy< bp::return_opaque_pointer >(),
+ "Python-Ogre Hand Wrapped - returns pointer to data buffer suitable to use with ctypes\\n" );""",
+ """def( "getData_str", &::netBuffer_getData_str,
+ "Python-Ogre Hand Wrapped - returns a string containing the buffer data\\n" );"""
+ ]
+
+
+WRAPPER_DEFINITION_netChannel =\
+"""
+int netChannel_send ( netChannel & me, boost::python::list listin, int flags = 0 )
+{
+ int index, result;
+ int size = len(listin);
+ byte * buffer = new byte [size];
+ for (index=0;index<size;index++ ) {
+ buffer[index] = (byte) boost::python::extract<int> (listin[index]);
+ }
+ result = me.send((const void *) buffer, size, flags );
+ delete buffer;
+ return result;
+}
+
+int netChannel_send_str ( netChannel & me, boost::python::str listin, int flags = 0 )
+{
+ int index, result;
+ int size = len(listin);
+ byte * buffer = new byte[size];
+ for (index=0;index<size;index++ ) {
+ buffer[index] = (byte) boost::python::extract<char> (listin[index]);
+ }
+ result = me.send((const void *) buffer, size, flags );
+ delete buffer;
+ return result;
+}
+boost::python::list netChannel_recv ( netChannel & me, int MaxSize=2048, int flags = 0 )
+{
+ byte * buffer = new byte [MaxSize];
+ int length,x;
+ boost::python::list listout;
+ length = me.recv ( (void *) buffer, MaxSize, flags);
+ for (x=0;x<length;x++) {
+ listout.append ( buffer[x] );
+ }
+ delete buffer;
+ return listout;
+}
+boost::python::str netChannel_recv_str ( netChannel & me, int MaxSize=2048, int flags = 0 )
+{
+ char * buffer = new char [MaxSize];
+ int length;
+ boost::python::str str_out;
+ length = me.recv ( (void *) buffer, MaxSize, flags);
+ if (length > 0 )
+ str_out = boost::python::str (buffer, length);
+ else
+ str_out = boost::python::str();
+ delete buffer;
+ return str_out;
+}
+
+"""
+WRAPPER_REGISTRATION_netChannel = [
+ """def( "send", &::netChannel_send,
+ ( bp::arg("listin"), bp::arg("flags")=(0) ),
+ "Python-Ogre Hand Wrapped\\n" );""",
+ """def( "send", &::netChannel_send_str,
+ ( bp::arg("listin"), bp::arg("flags")=(0) ),
+ "Python-Ogre Hand Wrapped\\n" );""",
+ """def( "recv", &::netChannel_recv,
+ ( bp::arg("MaxSize")=(2048), bp::arg("flags")=(0) ),
+ "Python-Ogre Hand Wrapped\\n" );""",
+ """def( "recv_str", &::netChannel_recv_str,
+ ( bp::arg("MaxSize")=(2048), bp::arg("flags")=(0) ),
+ "Python-Ogre Hand Wrapped\\n" );""",
+]
+
+WRAPPER_DEFINITION_netMonitorServer =\
+"""
+ void setCommandFunc ( void (*func)(const char*) )
+"""
+
+
+WRAPPER_DEFINITION_slScheduler =\
+"""
+int slScheduler_loopSample(slScheduler &me, slSample * s, int pri=0,
+ slPreemptMode mode=::SL_SAMPLE_MUTE, int magic=0,
+ PyObject* subscriber=0, std::string const & method="")
+{
+ return me.loopSample ( s, pri, mode, magic ); // note calling with a null callback
+}
+int slScheduler_playSample(slScheduler &me, slSample * s, int pri=1,
+ slPreemptMode mode=::SL_SAMPLE_ABORT, int magic=0,
+ PyObject* subscriber=0, std::string const & method="")
+{
+ return me.playSample ( s, pri, mode, magic ); // note calling with a null callback
+}
+int slScheduler_loopMusic(slScheduler &me, const char *fname, int pri=0,
+ slPreemptMode mode=::SL_SAMPLE_MUTE, int magic=0,
+ PyObject* subscriber=0, std::string const & method="")
+{
+ return me.loopMusic ( fname, pri, mode, magic ); // note calling with a null callback
+}
+int slScheduler_playMusic(slScheduler &me, const char *fname, int pri=1,
+ slPreemptMode mode=::SL_SAMPLE_ABORT, int magic=0,
+ PyObject* subscriber=0, std::string const & method="")
+{
+ return me.playMusic ( fname, pri, mode, magic ); // note calling with a null callback
+}
+""" ...
[truncated message content] |