From 5f2c0a6e043fdfc76dce555160e59ac4ac6fe294 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 20 Feb 2014 13:33:26 +0000 Subject: [PATCH] Big commit aiding in separation of Python bindings: * Most extension functions have been moved to C++. * In makepanda, Python bindings are compiled into panda3d/.pyd. --- direct/src/directnotify/DirectNotify.py | 2 +- direct/src/directnotify/Notifier.py | 4 +- .../src/extensions/EggGroupNode-extensions.py | 11 - .../src/extensions/EggPrimitive-extensions.py | 8 - .../NodePathCollection-extensions.py | 34 -- direct/src/extensions/OdeBody-extensions.py | 6 - direct/src/extensions/OdeGeom-extensions.py | 44 -- direct/src/extensions/OdeJoint-extensions.py | 39 -- direct/src/extensions/OdeSpace-extensions.py | 32 -- direct/src/extensions/Ramfile-extensions.py | 15 - .../src/extensions/StreamReader-extensions.py | 15 - .../EggGroupNode_extensions.py | 16 - .../EggPrimitive_extensions.py | 13 - .../NodePathCollection_extensions.py | 31 -- .../extensions_native/NodePath_extensions.py | 9 - .../extensions_native/OdeBody_extensions.py | 18 - .../extensions_native/OdeGeom_extensions.py | 60 --- .../extensions_native/OdeJoint_extensions.py | 54 -- .../extensions_native/OdeSpace_extensions.py | 50 -- .../extensions_native/Ramfile_extensions.py | 16 - .../StreamReader_extensions.py | 16 - direct/src/showbase/Messenger.py | 2 +- direct/src/showbase/PythonUtil.py | 5 +- dtool/src/interrogate/functionRemap.cxx | 46 +- dtool/src/interrogate/functionRemap.h | 3 +- .../interfaceMakerPythonNative.cxx | 332 ++++++------ dtool/src/interrogatedb/extension.h | 12 +- dtool/src/interrogatedb/py_panda.cxx | 6 +- dtool/src/prc/streamReader.h | 1 + makepanda/makepanda.py | 486 ++++++++++-------- makepanda/makepandacore.py | 40 +- panda/src/display/Sources.pp | 4 +- panda/src/display/graphicsStateGuardian.cxx | 69 +-- panda/src/display/graphicsStateGuardian.h | 8 +- panda/src/egg/Sources.pp | 7 +- panda/src/egg/eggGroupNode.h | 2 + panda/src/event/pythonTask.cxx | 2 +- panda/src/express/Sources.pp | 12 +- panda/src/express/memoryUsagePointers.cxx | 73 --- panda/src/express/memoryUsagePointers.h | 4 +- panda/src/express/memoryUsagePointers_ext.cxx | 72 +++ panda/src/express/memoryUsagePointers_ext.h | 40 ++ panda/src/express/p3express_ext_composite.cxx | 4 + panda/src/express/ramfile.h | 1 + panda/src/express/ramfile_ext.cxx | 48 ++ panda/src/express/ramfile_ext.h | 40 ++ panda/src/express/streamReader_ext.cxx | 48 ++ panda/src/express/streamReader_ext.h | 40 ++ panda/src/express/virtualFileSystem_ext.cxx | 2 +- panda/src/linmath/lpoint2_ext_src.I | 2 +- panda/src/linmath/lpoint3_ext_src.I | 2 +- panda/src/linmath/lpoint4_ext_src.I | 2 +- panda/src/linmath/lvector2_ext_src.I | 2 +- panda/src/linmath/lvector3_ext_src.I | 2 +- panda/src/linmath/lvector4_ext_src.I | 2 +- panda/src/ode/Sources.pp | 24 +- panda/src/ode/odeAMotorJoint.h | 2 +- panda/src/ode/odeBallJoint.h | 2 +- panda/src/ode/odeBody.h | 4 +- panda/src/ode/odeBoxGeom.h | 2 +- panda/src/ode/odeCappedCylinderGeom.h | 2 +- panda/src/ode/odeContactJoint.h | 2 +- panda/src/ode/odeConvexGeom.h | 2 +- panda/src/ode/odeCylinderGeom.h | 2 +- panda/src/ode/odeFixedJoint.h | 2 +- panda/src/ode/odeGeom.h | 12 +- panda/src/ode/odeHashSpace.h | 2 +- panda/src/ode/odeHeightFieldGeom.h | 2 +- panda/src/ode/odeHinge2Joint.h | 2 +- panda/src/ode/odeHingeJoint.h | 2 +- panda/src/ode/odeJoint.cxx | 2 +- panda/src/ode/odeJoint.h | 12 +- panda/src/ode/odeLMotorJoint.h | 2 +- panda/src/ode/odeNullJoint.h | 2 +- panda/src/ode/odePlane2dJoint.h | 2 +- panda/src/ode/odePlaneGeom.h | 2 +- panda/src/ode/odeQuadTreeSpace.h | 2 +- panda/src/ode/odeRayGeom.h | 2 +- panda/src/ode/odeSimpleSpace.h | 2 +- panda/src/ode/odeSliderJoint.h | 2 +- panda/src/ode/odeSpace.cxx | 74 +-- panda/src/ode/odeSpace.h | 33 +- panda/src/ode/odeSphereGeom.h | 2 +- panda/src/ode/odeTriMeshGeom.h | 5 +- panda/src/ode/odeUniversalJoint.h | 2 +- panda/src/ode/odeUtil.cxx | 57 +- panda/src/ode/odeUtil.h | 18 +- panda/src/ode/p3ode_ext_composite.cxx | 4 + panda/src/pgraph/Sources.pp | 3 + panda/src/pgraph/nodePath.I | 159 ------ panda/src/pgraph/nodePath.cxx | 220 -------- panda/src/pgraph/nodePath.h | 41 +- panda/src/pgraph/nodePathCollection.cxx | 76 +-- panda/src/pgraph/nodePathCollection.h | 6 +- panda/src/putil/Sources.pp | 5 +- panda/src/putil/typedWritable.cxx | 271 +--------- panda/src/putil/typedWritable.h | 29 +- 97 files changed, 1047 insertions(+), 1966 deletions(-) delete mode 100644 direct/src/extensions/EggGroupNode-extensions.py delete mode 100644 direct/src/extensions/EggPrimitive-extensions.py delete mode 100644 direct/src/extensions/NodePathCollection-extensions.py delete mode 100755 direct/src/extensions/OdeBody-extensions.py delete mode 100755 direct/src/extensions/OdeGeom-extensions.py delete mode 100755 direct/src/extensions/OdeJoint-extensions.py delete mode 100755 direct/src/extensions/OdeSpace-extensions.py delete mode 100644 direct/src/extensions/Ramfile-extensions.py delete mode 100644 direct/src/extensions/StreamReader-extensions.py delete mode 100644 direct/src/extensions_native/EggGroupNode_extensions.py delete mode 100644 direct/src/extensions_native/EggPrimitive_extensions.py delete mode 100644 direct/src/extensions_native/NodePathCollection_extensions.py delete mode 100755 direct/src/extensions_native/OdeBody_extensions.py delete mode 100755 direct/src/extensions_native/OdeGeom_extensions.py delete mode 100755 direct/src/extensions_native/OdeJoint_extensions.py delete mode 100755 direct/src/extensions_native/OdeSpace_extensions.py delete mode 100644 direct/src/extensions_native/Ramfile_extensions.py delete mode 100755 direct/src/extensions_native/StreamReader_extensions.py create mode 100644 panda/src/express/memoryUsagePointers_ext.cxx create mode 100644 panda/src/express/memoryUsagePointers_ext.h create mode 100644 panda/src/express/p3express_ext_composite.cxx create mode 100644 panda/src/express/ramfile_ext.cxx create mode 100644 panda/src/express/ramfile_ext.h create mode 100644 panda/src/express/streamReader_ext.cxx create mode 100644 panda/src/express/streamReader_ext.h create mode 100644 panda/src/ode/p3ode_ext_composite.cxx diff --git a/direct/src/directnotify/DirectNotify.py b/direct/src/directnotify/DirectNotify.py index f2b8e351d1..923de31a44 100644 --- a/direct/src/directnotify/DirectNotify.py +++ b/direct/src/directnotify/DirectNotify.py @@ -64,7 +64,7 @@ class DirectNotify: # we're running before ShowBase has finished initializing; and # we import it directly from libpandaexpress, in case we're # running before libpanda.dll is available. - from libpandaexpress import ConfigVariableString + from panda3d.core import ConfigVariableString dconfigParam = ("notify-level-" + categoryName) cvar = ConfigVariableString(dconfigParam, "") diff --git a/direct/src/directnotify/Notifier.py b/direct/src/directnotify/Notifier.py index 5b1508fa99..eb91d5244e 100644 --- a/direct/src/directnotify/Notifier.py +++ b/direct/src/directnotify/Notifier.py @@ -4,7 +4,7 @@ for the programmer/user """ from LoggerGlobal import defaultLogger from direct.showbase import PythonUtil -from libpandaexpress import ConfigVariableBool +from panda3d.core import ConfigVariableBool import time import types import sys @@ -18,7 +18,7 @@ class Notifier: # with the C++ notify system. streamWriter = None if ConfigVariableBool('notify-integrate', True): - from libpandaexpress import StreamWriter, Notify + from panda3d.core import StreamWriter, Notify streamWriter = StreamWriter(Notify.out(), False) showTime = ConfigVariableBool('notify-timestamp', False) diff --git a/direct/src/extensions/EggGroupNode-extensions.py b/direct/src/extensions/EggGroupNode-extensions.py deleted file mode 100644 index 660e556a8f..0000000000 --- a/direct/src/extensions/EggGroupNode-extensions.py +++ /dev/null @@ -1,11 +0,0 @@ - - # For iterating over children - def getChildren(self): - """Returns a Python list of the egg node's children.""" - result = [] - child = self.getFirstChild() - while (child != None): - result.append(child) - child = self.getNextChild() - return result - diff --git a/direct/src/extensions/EggPrimitive-extensions.py b/direct/src/extensions/EggPrimitive-extensions.py deleted file mode 100644 index 60c5bf7392..0000000000 --- a/direct/src/extensions/EggPrimitive-extensions.py +++ /dev/null @@ -1,8 +0,0 @@ - - # For iterating over vertices - def getVertices(self): - """Returns a Python list of the egg primitive's vertices.""" - result = [] - for i in range(self.getNumVertices()): - result.append(self.getVertex(i)) - return result diff --git a/direct/src/extensions/NodePathCollection-extensions.py b/direct/src/extensions/NodePathCollection-extensions.py deleted file mode 100644 index 99a1c7fca6..0000000000 --- a/direct/src/extensions/NodePathCollection-extensions.py +++ /dev/null @@ -1,34 +0,0 @@ - - """ - NodePathCollection-extensions module: contains methods to extend - functionality of the NodePathCollection class - """ - - # For iterating over children - def asList(self): - """Converts a NodePathCollection into a list""" - if self.isEmpty(): - return [] - else: - npList = [] - for nodePathIndex in range(self.getNumPaths()): - npList.append(self.getPath(nodePathIndex)) - return npList - - def getTightBounds(self): - from pandac import Point3 - - if self.getNumPaths() == 0: - return (Point3.Point3(0), Point3.Point3(0)) - - v1, v2 = self.getPath(0).getTightBounds() - for i in range(1, self.getNumPaths()): - v1x, v2x = self.getPath(i).getTightBounds() - v1 = Point3.Point3(min(v1[0], v1x[0]), - min(v1[1], v1x[1]), - min(v1[2], v1x[2])) - v2 = Point3.Point3(max(v2[0], v2x[0]), - max(v2[1], v2x[1]), - max(v2[2], v2x[2])) - - return v1, v2 diff --git a/direct/src/extensions/OdeBody-extensions.py b/direct/src/extensions/OdeBody-extensions.py deleted file mode 100755 index 6b0f60a633..0000000000 --- a/direct/src/extensions/OdeBody-extensions.py +++ /dev/null @@ -1,6 +0,0 @@ - -def getConvertedJoint(self, index): - """ - Return a downcast joint on this body. - """ - return self.getJoint(index).convert() diff --git a/direct/src/extensions/OdeGeom-extensions.py b/direct/src/extensions/OdeGeom-extensions.py deleted file mode 100755 index 0796dc5cf7..0000000000 --- a/direct/src/extensions/OdeGeom-extensions.py +++ /dev/null @@ -1,44 +0,0 @@ - -def convert(self): - """ - Do a sort of pseudo-downcast on this geom in - order to expose its specialized functions. - """ - if self.getGeomClass() == OdeGeom.GCSphere: - return self.convertToSphere() - elif self.getGeomClass() == OdeGeom.GCBox: - return self.convertToBox() - elif self.getGeomClass() == OdeGeom.GCCappedCylinder: - return self.convertToCappedCylinder() - elif self.getGeomClass() == OdeGeom.GCPlane: - return self.convertToPlane() - elif self.getGeomClass() == OdeGeom.GCRay: - return self.convertToRay() - # elif self.getGeomClass() == OdeGeom.GCConvex: - # return self.convertToConvex() - # elif self.getGeomClass() == OdeGeom.GCGeomTransform: - # return self.convertToGeomTransform() - elif self.getGeomClass() == OdeGeom.GCTriMesh: - return self.convertToTriMesh() - # elif self.getGeomClass() == OdeGeom.GCHeightfield: - # return self.convertToHeightfield() - elif self.getGeomClass() == OdeGeom.GCSimpleSpace: - return self.convertToSimpleSpace() - elif self.getGeomClass() == OdeGeom.GCHashSpace: - return self.convertToHashSpace() - elif self.getGeomClass() == OdeGeom.GCQuadTreeSpace: - return self.convertToQuadTreeSpace() - -def getConvertedSpace(self): - """ - """ - return self.getSpace().convert() - -def getAABounds(self): - """ - A more Pythonic way of calling getAABB(). - """ - min = Point3() - max = Point3() - self.getAABB(min,max) - return min,max \ No newline at end of file diff --git a/direct/src/extensions/OdeJoint-extensions.py b/direct/src/extensions/OdeJoint-extensions.py deleted file mode 100755 index 3e3eeccfc8..0000000000 --- a/direct/src/extensions/OdeJoint-extensions.py +++ /dev/null @@ -1,39 +0,0 @@ -def attach(self, body1, body2): - """ - Attach two bodies together. - If either body is None, the other will be attached to the environment. - """ - if body1 and body2: - self.attachBodies(body1, body2) - elif body1 and not body2: - self.attachBody(body1, 0) - elif not body1 and body2: - self.attachBody(body2, 1) - -def convert(self): - """ - Do a sort of pseudo-downcast on this joint in - order to expose its specialized functions. - """ - if self.getJointType() == OdeJoint.JTBall: - return self.convertToBall() - elif self.getJointType() == OdeJoint.JTHinge: - return self.convertToHinge() - elif self.getJointType() == OdeJoint.JTSlider: - return self.convertToSlider() - elif self.getJointType() == OdeJoint.JTContact: - return self.convertToContact() - elif self.getJointType() == OdeJoint.JTUniversal: - return self.convertToUniversal() - elif self.getJointType() == OdeJoint.JTHinge2: - return self.convertToHinge2() - elif self.getJointType() == OdeJoint.JTFixed: - return self.convertToFixed() - elif self.getJointType() == OdeJoint.JTNull: - return self.convertToNull() - elif self.getJointType() == OdeJoint.JTAMotor: - return self.convertToAMotor() - elif self.getJointType() == OdeJoint.JTLMotor: - return self.convertToLMotor() - elif self.getJointType() == OdeJoint.JTPlane2d: - return self.convertToPlane2d() diff --git a/direct/src/extensions/OdeSpace-extensions.py b/direct/src/extensions/OdeSpace-extensions.py deleted file mode 100755 index f110615831..0000000000 --- a/direct/src/extensions/OdeSpace-extensions.py +++ /dev/null @@ -1,32 +0,0 @@ - -def convert(self): - """ - Do a sort of pseudo-downcast on this space in - order to expose its specialized functions. - """ - if self.getClass() == OdeGeom.GCSimpleSpace: - return self.convertToSimpleSpace() - elif self.getClass() == OdeGeom.GCHashSpace: - return self.convertToHashSpace() - elif self.getClass() == OdeGeom.GCQuadTreeSpace: - return self.convertToQuadTreeSpace() - -def getConvertedGeom(self, index): - """ - Return a downcast geom on this body. - """ - return self.getGeom(index).convert() - -def getConvertedSpace(self): - """ - """ - return self.getSpace().convert() - -def getAABounds(self): - """ - A more Pythonic way of calling getAABB() - """ - min = Point3() - max = Point3() - self.getAABB(min,max) - return min,max \ No newline at end of file diff --git a/direct/src/extensions/Ramfile-extensions.py b/direct/src/extensions/Ramfile-extensions.py deleted file mode 100644 index a05a666a24..0000000000 --- a/direct/src/extensions/Ramfile-extensions.py +++ /dev/null @@ -1,15 +0,0 @@ - - """ - Ramfile-extensions module: contains methods to extend functionality - of the Ramfile class - """ - - def readlines(self): - """Reads all the lines at once and returns a list.""" - lines = [] - line = self.readline() - while line: - lines.append(line) - line = self.readline() - return lines - diff --git a/direct/src/extensions/StreamReader-extensions.py b/direct/src/extensions/StreamReader-extensions.py deleted file mode 100644 index 792abde3a6..0000000000 --- a/direct/src/extensions/StreamReader-extensions.py +++ /dev/null @@ -1,15 +0,0 @@ - - """ - StreamReader-extensions module: contains methods to extend functionality - of the StreamReader class - """ - - def readlines(self): - """Reads all the lines at once and returns a list.""" - lines = [] - line = self.readline() - while line: - lines.append(line) - line = self.readline() - return lines - diff --git a/direct/src/extensions_native/EggGroupNode_extensions.py b/direct/src/extensions_native/EggGroupNode_extensions.py deleted file mode 100644 index 6c6173e66f..0000000000 --- a/direct/src/extensions_native/EggGroupNode_extensions.py +++ /dev/null @@ -1,16 +0,0 @@ -#################################################################### -#Dtool_funcToMethod(func, class) -#del func -##################################################################### - # For iterating over children -def getChildren(self): - """Returns a Python list of the egg node's children.""" - result = [] - child = self.getFirstChild() - while (child != None): - result.append(child) - child = self.getNextChild() - return result - -Dtool_funcToMethod(getChildren, EggGroupNode) -del getChildren diff --git a/direct/src/extensions_native/EggPrimitive_extensions.py b/direct/src/extensions_native/EggPrimitive_extensions.py deleted file mode 100644 index 657f99a132..0000000000 --- a/direct/src/extensions_native/EggPrimitive_extensions.py +++ /dev/null @@ -1,13 +0,0 @@ -#################################################################### -#Dtool_funcToMethod(func, class) -#del func -##################################################################### - # For iterating over vertices -def getVertices(self): - """Returns a Python list of the egg primitive's vertices.""" - result = [] - for i in range(self.getNumVertices()): - result.append(self.getVertex(i)) - return result -Dtool_funcToMethod(getVertices, EggPrimitive) -del getVertices diff --git a/direct/src/extensions_native/NodePathCollection_extensions.py b/direct/src/extensions_native/NodePathCollection_extensions.py deleted file mode 100644 index f7f379ab32..0000000000 --- a/direct/src/extensions_native/NodePathCollection_extensions.py +++ /dev/null @@ -1,31 +0,0 @@ -##################################################################### - -# For iterating over children -def asList(self): - """Converts a NodePathCollection into a list""" - print "Warning: NodePathCollection.asList() is no longer needed and deprecated. Iterate on the collection directly instead." - return list(self) - -Dtool_funcToMethod(asList, NodePathCollection) -del asList -#####################################################################3333 - -def getTightBounds(self): - from pandac.PandaModules import Point3 - - if self.getNumPaths() == 0: - return (Point3(0), Point3(0)) - v1, v2 = self.getPath(0).getTightBounds() - for i in range(1, self.getNumPaths()): - v1x, v2x = self.getPath(i).getTightBounds() - v1 = Point3(min(v1[0], v1x[0]), - min(v1[1], v1x[1]), - min(v1[2], v1x[2])) - v2 = Point3(max(v2[0], v2x[0]), - max(v2[1], v2x[1]), - max(v2[2], v2x[2])) - return v1, v2 - -Dtool_funcToMethod(getTightBounds, NodePathCollection) -del getTightBounds -#####################################################################3333 diff --git a/direct/src/extensions_native/NodePath_extensions.py b/direct/src/extensions_native/NodePath_extensions.py index c1a19f3784..7b17dc34f6 100644 --- a/direct/src/extensions_native/NodePath_extensions.py +++ b/direct/src/extensions_native/NodePath_extensions.py @@ -154,15 +154,6 @@ def getAncestry(self): Dtool_funcToMethod(getAncestry, NodePath) del getAncestry ##################################################################### -def getTightBounds(self): - from pandac.PandaModules import Point3 - v1 = Point3(0) - v2 = Point3(0) - self.calcTightBounds(v1, v2) - return v1, v2 -Dtool_funcToMethod(getTightBounds, NodePath) -del getTightBounds -##################################################################### def pPrintString(self, other = None): """ diff --git a/direct/src/extensions_native/OdeBody_extensions.py b/direct/src/extensions_native/OdeBody_extensions.py deleted file mode 100755 index 78b71cb638..0000000000 --- a/direct/src/extensions_native/OdeBody_extensions.py +++ /dev/null @@ -1,18 +0,0 @@ -#################################################################### -#Dtool_funcToMethod(func, class) -#del func -##################################################################### - -""" -OdeBody-extensions module: contains methods to extend functionality -of the OdeBody classe -""" - -def getConvertedJoint(self, index): - """ - Return a downcast joint on this body. - """ - return self.getJoint(index).convert() -Dtool_funcToMethod(getConvertedJoint, OdeBody) -del getConvertedJoint - diff --git a/direct/src/extensions_native/OdeGeom_extensions.py b/direct/src/extensions_native/OdeGeom_extensions.py deleted file mode 100755 index e154e05e55..0000000000 --- a/direct/src/extensions_native/OdeGeom_extensions.py +++ /dev/null @@ -1,60 +0,0 @@ -#################################################################### -#Dtool_funcToMethod(func, class) -#del func -##################################################################### - -""" -OdeGeom-extensions module: contains methods to extend functionality -of the OdeGeom class -""" - -def convert(self): - """ - Do a sort of pseudo-downcast on this geom in - order to expose its specialized functions. - """ - if self.getClass() == OdeGeom.GCSphere: - return self.convertToSphere() - elif self.getClass() == OdeGeom.GCBox: - return self.convertToBox() - elif self.getClass() == OdeGeom.GCCappedCylinder: - return self.convertToCappedCylinder() - elif self.getClass() == OdeGeom.GCPlane: - return self.convertToPlane() - elif self.getClass() == OdeGeom.GCRay: - return self.convertToRay() - # elif self.getClass() == OdeGeom.GCConvex: - # return self.convertToConvex() - # elif self.getClass() == OdeGeom.GCGeomTransform: - # return self.convertToGeomTransform() - elif self.getClass() == OdeGeom.GCTriMesh: - return self.convertToTriMesh() - # elif self.getClass() == OdeGeom.GCHeightfield: - # return self.convertToHeightfield() - elif self.getClass() == OdeGeom.GCSimpleSpace: - return self.convertToSimpleSpace() - elif self.getClass() == OdeGeom.GCHashSpace: - return self.convertToHashSpace() - elif self.getClass() == OdeGeom.GCQuadTreeSpace: - return self.convertToQuadTreeSpace() -Dtool_funcToMethod(convert, OdeGeom) -del convert - -def getConvertedSpace(self): - """ - """ - return self.getSpace().convert() -Dtool_funcToMethod(getConvertedSpace, OdeGeom) -del getConvertedSpace - -def getAABounds(self): - """ - A more Pythonic way of calling getAABB() - """ - min = Point3() - max = Point3() - self.getAABB(min,max) - return min,max -Dtool_funcToMethod(getAABounds, OdeGeom) -del getAABounds - diff --git a/direct/src/extensions_native/OdeJoint_extensions.py b/direct/src/extensions_native/OdeJoint_extensions.py deleted file mode 100755 index e113e6fdfa..0000000000 --- a/direct/src/extensions_native/OdeJoint_extensions.py +++ /dev/null @@ -1,54 +0,0 @@ -#################################################################### -#Dtool_funcToMethod(func, class) -#del func -##################################################################### - -""" -OdeJoint-extensions module: contains methods to extend functionality -of the OdeJoint class -""" - -def attach(self, body1, body2): - """ - Attach two bodies together. - If either body is None, the other will be attached to the environment. - """ - if body1 and body2: - self.attachBodies(body1, body2) - elif body1 and not body2: - self.attachBody(body1, 0) - elif not body1 and body2: - self.attachBody(body2, 1) -Dtool_funcToMethod(attach, OdeJoint) -del attach - -def convert(self): - """ - Do a sort of pseudo-downcast on this joint in - order to expose its specialized functions. - """ - if self.getJointType() == OdeJoint.JTBall: - return self.convertToBall() - elif self.getJointType() == OdeJoint.JTHinge: - return self.convertToHinge() - elif self.getJointType() == OdeJoint.JTSlider: - return self.convertToSlider() - elif self.getJointType() == OdeJoint.JTContact: - return self.convertToContact() - elif self.getJointType() == OdeJoint.JTUniversal: - return self.convertToUniversal() - elif self.getJointType() == OdeJoint.JTHinge2: - return self.convertToHinge2() - elif self.getJointType() == OdeJoint.JTFixed: - return self.convertToFixed() - elif self.getJointType() == OdeJoint.JTNull: - return self.convertToNull() - elif self.getJointType() == OdeJoint.JTAMotor: - return self.convertToAMotor() - elif self.getJointType() == OdeJoint.JTLMotor: - return self.convertToLMotor() - elif self.getJointType() == OdeJoint.JTPlane2d: - return self.convertToPlane2d() -Dtool_funcToMethod(convert, OdeJoint) -del convert - diff --git a/direct/src/extensions_native/OdeSpace_extensions.py b/direct/src/extensions_native/OdeSpace_extensions.py deleted file mode 100755 index 14b3c1e618..0000000000 --- a/direct/src/extensions_native/OdeSpace_extensions.py +++ /dev/null @@ -1,50 +0,0 @@ -#################################################################### -#Dtool_funcToMethod(func, class) -#del func -##################################################################### - -""" -OdeSpace-extensions module: contains methods to extend functionality -of the OdeSpace classe -""" - -def convert(self): - """ - Do a sort of pseudo-downcast on this space in - order to expose its specialized functions. - """ - if self.getClass() == OdeGeom.GCSimpleSpace: - return self.convertToSimpleSpace() - elif self.getClass() == OdeGeom.GCHashSpace: - return self.convertToHashSpace() - elif self.getClass() == OdeGeom.GCQuadTreeSpace: - return self.convertToQuadTreeSpace() -Dtool_funcToMethod(convert, OdeSpace) -del convert - -def getConvertedGeom(self, index): - """ - Return a downcast geom on this space. - """ - return self.getGeom(index).convert() -Dtool_funcToMethod(getConvertedGeom, OdeSpace) -del getConvertedGeom - -def getConvertedSpace(self): - """ - """ - return self.getSpace().convert() -Dtool_funcToMethod(getConvertedSpace, OdeSpace) -del getConvertedSpace - -def getAABounds(self): - """ - A more Pythonic way of calling getAABB() - """ - min = Point3() - max = Point3() - self.getAABB(min,max) - return min,max -Dtool_funcToMethod(getAABounds, OdeSpace) -del getAABounds - diff --git a/direct/src/extensions_native/Ramfile_extensions.py b/direct/src/extensions_native/Ramfile_extensions.py deleted file mode 100644 index c05040c73e..0000000000 --- a/direct/src/extensions_native/Ramfile_extensions.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -Ramfile_extensions module: contains methods to extend functionality -of the Ramfile class -""" - -def readlines(self): - """Reads all the lines at once and returns a list.""" - lines = [] - line = self.readline() - while line: - lines.append(line) - line = self.readline() - return lines - -Dtool_funcToMethod(readlines, Ramfile) -del readlines diff --git a/direct/src/extensions_native/StreamReader_extensions.py b/direct/src/extensions_native/StreamReader_extensions.py deleted file mode 100755 index b4111cc965..0000000000 --- a/direct/src/extensions_native/StreamReader_extensions.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -StreamReader_extensions module: contains methods to extend functionality -of the StreamReader class -""" - -def readlines(self): - """Reads all the lines at once and returns a list.""" - lines = [] - line = self.readline() - while line: - lines.append(line) - line = self.readline() - return lines - -Dtool_funcToMethod(readlines, StreamReader) -del readlines diff --git a/direct/src/showbase/Messenger.py b/direct/src/showbase/Messenger.py index 56ec2958de..44248e6a4e 100644 --- a/direct/src/showbase/Messenger.py +++ b/direct/src/showbase/Messenger.py @@ -7,7 +7,7 @@ from PythonUtil import * from direct.directnotify import DirectNotifyGlobal import types -from libpandaexpress import ConfigVariableBool +from panda3d.core import ConfigVariableBool # If using the Toontown ActiveX launcher, this must be set true. # Also, Panda must be compiled with SIMPLE_THREADS or no HAVE_THREADS diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index 418bb86f6b..38d4df8663 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -60,10 +60,7 @@ import bisect __report_indent = 3 from direct.directutil import Verify -# Don't import libpandaexpressModules, which doesn't get built until -# genPyCode. -import direct.extensions_native.extension_native_helpers -from libpandaexpress import ConfigVariableBool +from panda3d.core import ConfigVariableBool ScalarTypes = (types.FloatType, types.IntType, types.LongType) diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index b6bae90ab7..ec583b082d 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -14,7 +14,7 @@ #include "functionRemap.h" #include "typeManager.h" -#include "interrogate.h" +#include "interrogate.h" #include "parameterRemap.h" #include "parameterRemapThis.h" #include "interfaceMaker.h" @@ -324,7 +324,6 @@ make_wrapper_entry(FunctionIndex function_index) { _flags |= F_explicit_self; } } - if (!_void_return) { iwrapper._flags |= InterrogateFunctionWrapper::F_has_return; @@ -340,15 +339,15 @@ make_wrapper_entry(FunctionIndex function_index) { if (_return_value_needs_management) { iwrapper._flags |= InterrogateFunctionWrapper::F_caller_manages; FunctionIndex destructor = _return_value_destructor; - + if (destructor != 0) { iwrapper._return_value_destructor = destructor; - + } else { // We don't need to report this warning, since the FFI code // understands that if the destructor function is zero, it // should use the regular class destructor. - + // nout << "Warning! Destructor for " // << *_return_type->get_orig_type() // << " is unavailable.\n" @@ -397,8 +396,12 @@ get_call_str(const string &container, const vector_string &pexprs) const { // If this function is marked as having an extension function, // call that instead. - if (_extension && !container.empty()) { - call << "invoke_extension(" << container << ")."; + if (_extension) { + if (!container.empty()) { + call << "invoke_extension(" << container << ")."; + } else { + call << "Extension<" << _cpptype->get_local_name(&parser) << ">::"; + } call << _cppfunc->get_local_name(); call << "("; @@ -413,7 +416,7 @@ get_call_str(const string &container, const vector_string &pexprs) const { // If we have a "this" parameter, the calling convention is also // a bit different. call << "(" << container << ")->" << _cppfunc->get_local_name(); - + } else { call << _cppfunc->get_local_name(&parser); } @@ -465,7 +468,7 @@ get_parameter_expr(int n, const vector_string &pexprs) const { //////////////////////////////////////////////////////////////////// bool FunctionRemap:: setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_maker) { - _function_signature = + _function_signature = TypeManager::get_function_signature(_cppfunc, _num_default_parameters); _expression = ifunc._expression; @@ -519,7 +522,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak _parameters.push_back(param); _first_true_parameter = 1; } - + // Also check the name of the function. If it's one of the // assignment-style operators, flag it as such. if (fname == "operator =" || @@ -611,7 +614,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } } - if (_return_type == (ParameterRemap *)NULL || + if (_return_type == (ParameterRemap *)NULL || !_return_type->is_valid()) { // If our return type isn't something we can deal with, treat the // function as if it returns NULL. @@ -621,25 +624,25 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak _return_type = interface_maker->remap_parameter(_cpptype, void_type); assert(_return_type != (ParameterRemap *)NULL); } - + // Do we need to manage the return value? - _return_value_needs_management = + _return_value_needs_management = _return_type->return_value_needs_management(); - _return_value_destructor = + _return_value_destructor = _return_type->get_return_value_destructor(); - + // Should we manage a reference count? CPPType *return_type = _return_type->get_new_type(); return_type = TypeManager::resolve_type(return_type, _cppscope); CPPType *return_meat_type = TypeManager::unwrap_pointer(return_type); - + if (manage_reference_counts && TypeManager::is_reference_count_pointer(return_type) && !TypeManager::has_protected_destructor(return_meat_type)) { // Yes! _manage_reference_count = true; _return_value_needs_management = true; - + // This is problematic, because we might not have the class in // question fully defined here, particularly if the class is // defined in some other library. @@ -709,11 +712,18 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak _flags |= F_releasebuffer; } + + } else if (fname == "compare_to" ) { + if (_has_this && _parameters.size() == 2 && + TypeManager::is_integer(_return_type->get_new_type())) { + // It receives one parameter, and returns an integer. + _flags |= F_compare_to; + } } } else if (_type == T_constructor) { if (!_has_this && _parameters.size() == 1) { - if (TypeManager::unwrap(_parameters[0]._remap->get_orig_type()) == + if (TypeManager::unwrap(_parameters[0]._remap->get_orig_type()) == TypeManager::unwrap(_return_type->get_orig_type())) { // If this is the only parameter, and it's the same as the // "this" type, this is a copy constructor. diff --git a/dtool/src/interrogate/functionRemap.h b/dtool/src/interrogate/functionRemap.h index 7ab8224ad1..db23ba0139 100644 --- a/dtool/src/interrogate/functionRemap.h +++ b/dtool/src/interrogate/functionRemap.h @@ -90,6 +90,7 @@ public: F_iter = 0x0100, F_getbuffer = 0x0200, F_releasebuffer = 0x0400, + F_compare_to = 0x0800, }; typedef vector Parameters; @@ -113,7 +114,7 @@ public: string _reported_name; string _wrapper_name; FunctionWrapperIndex _wrapper_index; - + bool _return_value_needs_management; FunctionIndex _return_value_destructor; bool _manage_reference_count; diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 01ec64a781..564fb41420 100755 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -196,8 +196,8 @@ classNameFromCppName(const std::string &cppName, bool mangle) { bool nextCap = false; bool firstChar = true && mangle; - for (std::string::const_iterator chr = cppName.begin(); - chr != cppName.end(); + for (std::string::const_iterator chr = cppName.begin(); + chr != cppName.end(); chr++) { if ((*chr == '_' || *chr == ' ') && mangle) { nextCap = true; @@ -222,10 +222,10 @@ classNameFromCppName(const std::string &cppName, bool mangle) { className = classRenameDictionary[x]._to; } } - + if (className.empty()) { std::string text = "** ERROR ** Renaming class: " + cppName + " to empty string"; - printf("%s",text.c_str()); + printf("%s", text.c_str()); } className = checkKeyword(className); @@ -248,8 +248,8 @@ methodNameFromCppName(const std::string &cppName, const std::string &className, std::string methodName; const std::string badChars("!@#$%^&*()<>,.-=+~{}? "); bool nextCap = false; - for (std::string::const_iterator chr = origName.begin(); - chr != origName.end(); + for (std::string::const_iterator chr = origName.begin(); + chr != origName.end(); chr++) { if ((*chr == '_' || *chr == ' ') && mangle) { nextCap = true; @@ -282,7 +282,7 @@ methodNameFromCppName(const std::string &cppName, const std::string &className, } } } - + // # Mangle names that happen to be python keywords so they are not anymore methodName = checkKeyword(methodName); return methodName; @@ -301,13 +301,13 @@ std::string methodNameFromCppName(InterfaceMaker::Function *func, const std::str bool isInplaceFunction(InterfaceMaker::Function *func) { std::string wname = methodNameFromCppName(func, "", false); - + for (int x = 0; InPlaceSet[x] != NULL; x++) { if (InPlaceSet[x] == wname) { return true; } } - + return false; } @@ -343,13 +343,13 @@ get_slotted_function_def(Object *obj, Function *func, SlottedFunctionDef &def) { if (method_name == "operator -" && is_unary_op) { def._answer_location = "tp_as_number->nb_negative"; def._wrapper_type = WT_no_params; - return true; + return true; } if (method_name == "operator -") { def._answer_location = "tp_as_number->nb_subtract"; def._wrapper_type = WT_numeric_operator; - return true; + return true; } if (method_name == "operator *") { @@ -486,7 +486,7 @@ get_slotted_function_def(Object *obj, Function *func, SlottedFunctionDef &def) { return true; } } - + if (obj->_protocol_types & Object::PT_mapping) { if (func->_flags & FunctionRemap::F_getitem) { def._answer_location = "tp_as_mapping->mp_subscript"; @@ -602,7 +602,7 @@ get_valid_child_classes(std::map &answer, CPPStructTyp ++bi) { const CPPStructType::Base &base = (*bi); -// if (base._vis <= V_public) +// if (base._vis <= V_public) // can_downcast = false; CPPStructType *base_type = TypeManager::resolve_type(base._base)->as_struct_type(); if (base_type != NULL) { @@ -855,13 +855,13 @@ write_class_details(ostream &out, Object *obj) { out << "//********************************************************************\n"; out << "//*** Functions for .. " << cClassName << "\n" ; out << "//********************************************************************\n"; - + for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) { Function *func = (*fi); if (func) { SlottedFunctionDef def; get_slotted_function_def(obj, func, def); - + ostringstream GetThis; GetThis << " " << cClassName << " *local_this = NULL;\n"; GetThis << " DTOOL_Call_ExtractThisPointerForType(self, &Dtool_" << ClassName << ", (void **)&local_this);\n"; @@ -902,7 +902,7 @@ write_class_details(ostream &out, Object *obj) { for (fi = obj->_constructors.begin(); fi != obj->_constructors.end(); ++fi) { Function *func = (*fi); std::string fname = "int Dtool_Init_" + ClassName + "(PyObject *self, PyObject *args, PyObject *kwds)"; - + write_function_for_name(out, obj, func, fname, "", ClassName, true, coercion_attempted); } if (coercion_attempted) { @@ -912,7 +912,7 @@ write_class_details(ostream &out, Object *obj) { for (fi = obj->_constructors.begin(); fi != obj->_constructors.end(); ++fi) { Function *func = (*fi); std::string fname = "int Dtool_InitNoCoerce_" + ClassName + "(PyObject *self, PyObject *args, PyObject *kwds)"; - + write_function_for_name(out, obj, func, fname, "", ClassName, false, coercion_attempted); } } else { @@ -930,7 +930,7 @@ write_class_details(ostream &out, Object *obj) { for (msi = obj->_make_seqs.begin(); msi != obj->_make_seqs.end(); ++msi) { write_make_seq(out, obj, ClassName, *msi); } - + CPPType *cpptype = TypeManager::resolve_type(obj->_itype._cpptype); std::map details; std::map::iterator di; @@ -944,7 +944,7 @@ write_class_details(ostream &out, Object *obj) { } { // the Cast Converter - + out << "inline void *Dtool_UpcastInterface_" << ClassName << "(PyObject *self, Dtool_PyTypedObject *requested_type) {\n"; out << " Dtool_PyTypedObject *SelfType = ((Dtool_PyInstDef *)self)->_My_Type;\n"; out << " if (SelfType != &Dtool_" << ClassName << ") {\n"; @@ -959,7 +959,7 @@ write_class_details(ostream &out, Object *obj) { for (di = details.begin(); di != details.end(); di++) { if (di->second._is_legal_py_class) { - out << " if (requested_type == &Dtool_" <second._to_class_name) << ") {\n"; + out << " if (requested_type == &Dtool_" << make_safe_name(di->second._to_class_name) << ") {\n"; out << " return " << di->second._up_cast_string << " local_this;\n"; out << " }\n"; } @@ -1099,7 +1099,7 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { out << " PyModule_AddStringConstant(module, \"" << name2 << "\", \"" << value << "\");\n"; } } - } + } for (oi = _objects.begin(); oi != _objects.end(); ++oi) { Object *object = (*oi).second; @@ -1131,10 +1131,10 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { if (!func->_itype.is_global() && is_function_legal(func)) { string name1 = methodNameFromCppName(func, "", false); string name2 = methodNameFromCppName(func, "", true); - out << " { \"" << name1 << "\", (PyCFunction) &" + out << " { \"" << name1 << "\", (PyCFunction) &" << func->_name << ", METH_VARARGS | METH_KEYWORDS, (char *)" << func->_name << "_comment},\n"; if (name1 != name2) { - out << " { \"" << name2 << "\", (PyCFunction) &" + out << " { \"" << name2 << "\", (PyCFunction) &" << func->_name << ", METH_VARARGS | METH_KEYWORDS, (char *)" << func->_name << "_comment},\n"; } } @@ -1261,11 +1261,11 @@ write_module_class(ostream &out, Object *obj) { string name1 = methodNameFromCppName(func, export_class_name, false); string name2 = methodNameFromCppName(func, export_class_name, true); - out << " { \"" << name1 << "\", (PyCFunction) &" + out << " { \"" << name1 << "\", (PyCFunction) &" << func->_name << ", METH_VARARGS | METH_KEYWORDS, (char *) " << func->_name << "_comment},\n"; ++x; if (name1 != name2) { - out << " { \"" << name2 << "\", (PyCFunction) &" + out << " { \"" << name2 << "\", (PyCFunction) &" << func->_name << ", METH_VARARGS | METH_KEYWORDS, (char *) " << func->_name << "_comment},\n"; ++x; } @@ -1291,7 +1291,7 @@ write_module_class(ostream &out, Object *obj) { if (got_copy && !got_deepcopy) { out << " { \"__deepcopy__\", (PyCFunction) &map_deepcopy_to_copy, METH_VARARGS, NULL},\n"; } - + MakeSeqs::iterator msi; for (msi = obj->_make_seqs.begin(); msi != obj->_make_seqs.end(); ++msi) { string flags = "METH_NOARGS"; @@ -1316,7 +1316,7 @@ write_module_class(ostream &out, Object *obj) { for (di = 0; di < num_derivations; di++) { TypeIndex d_type_Index = obj->_itype.get_derivation(di); if (!interrogate_type_is_unpublished(d_type_Index)) { - const InterrogateType &d_itype = idb->get_type(d_type_Index); + const InterrogateType &d_itype = idb->get_type(d_type_Index); if (is_cpp_type_legal(d_itype._cpptype)) { if (!isExportThisRun(d_itype._cpptype)) { _external_imports.insert(make_safe_name(d_itype.get_scoped_name().c_str())); @@ -1331,7 +1331,7 @@ write_module_class(ostream &out, Object *obj) { for (di = 0; di < num_derivations; di++) { TypeIndex d_type_Index = obj->_itype.get_derivation(di); if (!interrogate_type_is_unpublished(d_type_Index)) { - const InterrogateType &d_itype = idb->get_type(d_type_Index); + const InterrogateType &d_itype = idb->get_type(d_type_Index); if (is_cpp_type_legal(d_itype._cpptype)) { bases.push_back(make_safe_name(d_itype.get_scoped_name().c_str())); } @@ -1362,7 +1362,7 @@ write_module_class(ostream &out, Object *obj) { out << "}\n\n"; } break; - + case WT_one_param: case WT_numeric_operator: // PyObject *func(PyObject *self, PyObject *one) @@ -1518,7 +1518,7 @@ write_module_class(ostream &out, Object *obj) { out << "}\n\n"; } break; - + case WT_inquiry: // int func(PyObject *self) { @@ -1739,7 +1739,7 @@ write_module_class(ostream &out, Object *obj) { has_local_hash = true; } } - + int need_repr = NeedsAReprFunction(obj->_itype); if (need_repr > 0) { out << "//////////////////\n"; @@ -1824,6 +1824,7 @@ write_module_class(ostream &out, Object *obj) { out << "\n"; out << " switch (op) {\n"; + Function *compare_to_func = NULL; for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) { std::set remaps; Function *func = (*fi); @@ -1851,13 +1852,18 @@ write_module_class(ostream &out, Object *obj) { out << " case Py_GT:\n"; } else if (fname == "operator >=") { out << " case Py_GE:\n"; + } else if (fname == "compare_to") { + compare_to_func = func; + continue; } else { continue; } + ostringstream forward_decl; string expected_params; bool coercion_attempted = false; write_function_forset(out, obj, func, remaps, expected_params, 2, forward_decl, false, true, coercion_attempted, args_cleanup); + out << " if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_TypeError)) {\n"; out << " PyErr_Clear();\n"; out << " }\n"; @@ -1865,12 +1871,48 @@ write_module_class(ostream &out, Object *obj) { has_local_richcompare = true; } - out << " }\n"; + out << " }\n\n"; + out << " " << args_cleanup << "\n"; out << " if (PyErr_Occurred()) {\n"; out << " return (PyObject *)NULL;\n"; out << " }\n\n"; + if (compare_to_func != NULL) { + out << "#if PY_MAJOR_VERSION >= 3\n"; + out << " // All is not lost; we still have the compare_to function to fall back onto.\n"; + out << " PyObject *result = " << compare_to_func->_name << "(self, args, kwds);\n"; + out << " if (result != NULL) {\n"; + out << " if (PyLong_Check(result)) {;\n"; + out << " long cmpval = PyLong_AsLong(result);\n"; + out << " switch (op) {\n"; + out << " case Py_LT:\n"; + out << " return PyBool_FromLong(cmpval < 0);\n"; + out << " case Py_LE:\n"; + out << " return PyBool_FromLong(cmpval <= 0);\n"; + out << " case Py_EQ:\n"; + out << " return PyBool_FromLong(cmpval == 0);\n"; + out << " case Py_NE:\n"; + out << " return PyBool_FromLong(cmpval != 0);\n"; + out << " case Py_GT:\n"; + out << " return PyBool_FromLong(cmpval > 0);\n"; + out << " case Py_GE:\n"; + out << " return PyBool_FromLong(cmpval >= 0);\n"; + out << " }\n"; + out << " }\n"; + out << " Py_DECREF(result);\n"; + out << " }\n\n"; + + out << " if (PyErr_Occurred()) {\n"; + out << " if (PyErr_ExceptionMatches(PyExc_TypeError)) {\n"; + out << " PyErr_Clear();\n"; + out << " } else {\n"; + out << " return (PyObject *)NULL;\n"; + out << " }\n"; + out << " }\n"; + out << "#endif\n\n"; + } + out << " Py_INCREF(Py_NotImplemented);\n"; out << " return Py_NotImplemented;\n"; out << "}\n\n"; @@ -1884,11 +1926,11 @@ write_module_class(ostream &out, Object *obj) { // out << " memset(Dtool_" << ClassName << ".As_PyTypeObject().tp_as_mapping,0,sizeof(PyMappingMethods));\n"; // out << " static Dtool_PyTypedObject *InheritsFrom[] = {"; - // add doc string + // add doc string if (obj->_itype.has_comment()) { out << "#ifndef NDEBUG\n"; out << " // Class documentation string\n"; - out << " Dtool_" << ClassName + out << " Dtool_" << ClassName << ".As_PyTypeObject().tp_doc =\n"; output_quoted(out, 6, obj->_itype.get_comment()); out << ";\n" @@ -2242,7 +2284,7 @@ write_function_for_name(ostream &out1, InterfaceMaker::Object *obj, InterfaceMak if (MapSets.size() > 1) { string expected_params; - + indent(out, 2) << "int parameter_count = 1;\n"; indent(out, 2) << "if (PyTuple_Check(args)) {\n"; indent(out, 2) << " parameter_count = PyTuple_Size(args);\n"; @@ -2250,7 +2292,7 @@ write_function_for_name(ostream &out1, InterfaceMaker::Object *obj, InterfaceMak indent(out, 2) << " parameter_count += PyDict_Size(kwds);\n"; indent(out, 2) << " }\n"; indent(out, 2) << "}\n"; - + indent(out, 2) << "switch (parameter_count) {\n"; for (mii = MapSets.begin(); mii != MapSets.end(); mii ++) { indent(out, 2) << "case " << mii->first << ": {\n"; @@ -2263,7 +2305,7 @@ write_function_for_name(ostream &out1, InterfaceMaker::Object *obj, InterfaceMak indent(out, 4) << "}\n"; indent(out, 4) << "break;\n"; } - + indent(out, 2) << "default:\n"; indent(out, 4) << "{\n"; indent(out, 6) @@ -2275,8 +2317,8 @@ write_function_for_name(ostream &out1, InterfaceMaker::Object *obj, InterfaceMak // Python convention. int add_self = func->_has_this ? 1 : 0; size_t mic; - for (mic = 0, mii = MapSets.begin(); - mii != MapSets.end(); + for (mic = 0, mii = MapSets.begin(); + mii != MapSets.end(); ++mii, ++mic) { if (mic == MapSets.size() - 1) { if (mic == 1) { @@ -2292,16 +2334,16 @@ write_function_for_name(ostream &out1, InterfaceMaker::Object *obj, InterfaceMak } out << " arguments (%d given)\", parameter_count + " << add_self << ");\n"; - + if (constructor) indent(out, 6) << "return -1;\n"; else indent(out, 6) << "return (PyObject *) NULL;\n"; - + indent(out, 4) << "}\n"; indent(out, 4) << "break;\n"; indent(out, 2) << "}\n"; - + out << " if (!PyErr_Occurred()) { // Let error pass on\n"; out << " PyErr_SetString(PyExc_TypeError,\n"; out << " \"Arguments must match one of:\\n\"\n"; @@ -2318,7 +2360,7 @@ write_function_for_name(ostream &out1, InterfaceMaker::Object *obj, InterfaceMak if (!expected_params.empty() && FunctionComment1.empty()) { FunctionComment1 += "C++ Interface:\n"; } - + FunctionComment1 += expected_params; } else { @@ -2345,7 +2387,7 @@ write_function_for_name(ostream &out1, InterfaceMaker::Object *obj, InterfaceMak if (!expected_params.empty() && FunctionComment1.empty()) { FunctionComment1 += "C++ Interface:\n"; } - + FunctionComment1 += expected_params; } @@ -2400,13 +2442,13 @@ int GetParnetDepth(CPPType *type) { int deepest = 0; TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(type)), false); InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); - const InterrogateType &itype = idb->get_type(type_index); + const InterrogateType &itype = idb->get_type(type_index); if (itype.is_class() || itype.is_struct()) { int num_derivations = itype.number_of_derivations(); for (int di = 0; di < num_derivations; di++) { TypeIndex d_type_Index = itype.get_derivation(di); - const InterrogateType &d_itype = idb->get_type(d_type_Index); + const InterrogateType &d_itype = idb->get_type(d_type_Index); int this_one = GetParnetDepth(d_itype._cpptype); if (this_one > deepest) { deepest = this_one; @@ -2466,10 +2508,10 @@ SortFunctionSet(std::set &remaps) { // A set is defined as all remaps that have the same number of paramaters.. /////////////////////////////////////////////////////////// void InterfaceMakerPythonNative:: -write_function_forset(ostream &out, InterfaceMaker::Object *obj, - InterfaceMaker::Function *func, - std::set &remapsin, - string &expected_params, int indent_level, +write_function_forset(ostream &out, InterfaceMaker::Object *obj, + InterfaceMaker::Function *func, + std::set &remapsin, + string &expected_params, int indent_level, ostream &forward_decl, bool is_inplace, bool coercion_allowed, bool &coercion_attempted, @@ -2489,7 +2531,7 @@ write_function_forset(ostream &out, InterfaceMaker::Object *obj, } while (pn < (int)remap->_parameters.size()) { CPPType *type = remap->_parameters[pn]._remap->get_new_type(); - + if (TypeManager::is_char_pointer(type)) { } else if (TypeManager::is_wchar_pointer(type)) { } else if (TypeManager::is_pointer_to_PyObject(type)) { @@ -2512,17 +2554,17 @@ write_function_forset(ostream &out, InterfaceMaker::Object *obj, indent(out, indent_level) << "{\n"; indent_level += 2; - indent(out, indent_level) + indent(out, indent_level) << "PyObject *coerced = NULL;\n"; - indent(out, indent_level) + indent(out, indent_level) << "PyObject **coerced_ptr = NULL;\n"; - indent(out, indent_level) + indent(out, indent_level) << "bool report_errors = false;\n"; - indent(out, indent_level) + indent(out, indent_level) << "while (true) {\n"; indent_level += 2; } - + if (remapsin.size() > 1) { // There are multiple different overloads for this number of // parameters. Sort them all into order from most-specific to @@ -2536,7 +2578,7 @@ write_function_forset(ostream &out, InterfaceMaker::Object *obj, if (remap->_has_this && !remap->_const_method) { // If it's a non-const method, we only allow a // non-const this. - indent(out, indent_level) + indent(out, indent_level) << "if (!((Dtool_PyInstDef *)self)->_is_const) {\n"; } else { indent(out, indent_level) @@ -2549,7 +2591,7 @@ write_function_forset(ostream &out, InterfaceMaker::Object *obj, write_function_instance(out, obj, func, remap, expected_params, indent_level + 2, false, forward_decl, func->_name, is_inplace, coercion_possible, coercion_attempted, args_cleanup); indent(out, indent_level + 2) << "PyErr_Clear();\n"; - indent(out, indent_level) << "}\n\n"; + indent(out, indent_level) << "}\n\n"; } } } else { @@ -2562,16 +2604,16 @@ write_function_forset(ostream &out, InterfaceMaker::Object *obj, if (remap->_has_this && !remap->_const_method) { // If it's a non-const method, we only allow a // non-const this. - indent(out, indent_level) + indent(out, indent_level) << "if (!((Dtool_PyInstDef *)self)->_is_const) {\n"; } else { indent(out, indent_level) << "{\n"; } - indent(out, indent_level + 2) + indent(out, indent_level + 2) << "// 1-" ; - remap->write_orig_prototype(out, 0); + remap->write_orig_prototype(out, 0); out << "\n" ; write_function_instance(out, obj, func, remap, expected_params, indent_level + 2, true, forward_decl, func->_name, is_inplace, coercion_possible, coercion_attempted, args_cleanup); @@ -2596,7 +2638,7 @@ write_function_forset(ostream &out, InterfaceMaker::Object *obj, << "}\n\n"; } else { indent(out, indent_level) - << "}\n\n"; + << "}\n\n"; } } } @@ -2606,38 +2648,38 @@ write_function_forset(ostream &out, InterfaceMaker::Object *obj, if (coercion_possible) { // Try again, this time with coercion enabled. - indent(out, indent_level) + indent(out, indent_level) << "if (coerced_ptr == NULL && !report_errors) {\n"; - indent(out, indent_level + 2) + indent(out, indent_level + 2) << "coerced_ptr = &coerced;\n"; - indent(out, indent_level + 2) + indent(out, indent_level + 2) << "continue;\n"; - indent(out, indent_level) + indent(out, indent_level) << "}\n"; // No dice. Go back one more time, and this time get the error // message. - indent(out, indent_level) + indent(out, indent_level) << "if (!report_errors) {\n"; - indent(out, indent_level + 2) + indent(out, indent_level + 2) << "report_errors = true;\n"; - indent(out, indent_level + 2) + indent(out, indent_level + 2) << "continue;\n"; - indent(out, indent_level) + indent(out, indent_level) << "}\n"; // We've been through three times. We're done. - indent(out, indent_level) + indent(out, indent_level) << "break;\n"; - + indent_level -= 2; - indent(out, indent_level) + indent(out, indent_level) << "}\n"; - - indent(out, indent_level) + + indent(out, indent_level) << "Py_XDECREF(coerced);\n"; indent_level -= 2; - indent(out, indent_level) + indent(out, indent_level) << "}\n"; } } @@ -2649,11 +2691,11 @@ write_function_forset(ostream &out, InterfaceMaker::Object *obj, // single instance of an overloaded function. //////////////////////////////////////////////////////////////////// void InterfaceMakerPythonNative:: -write_function_instance(ostream &out, InterfaceMaker::Object *obj, +write_function_instance(ostream &out, InterfaceMaker::Object *obj, InterfaceMaker::Function *func1, - FunctionRemap *remap, string &expected_params, - int indent_level, bool errors_fatal, - ostream &ForwardDeclrs, + FunctionRemap *remap, string &expected_params, + int indent_level, bool errors_fatal, + ostream &ForwardDeclrs, const std::string &functionnamestr, bool is_inplace, bool coercion_possible, bool &coercion_attempted, const string &args_cleanup) { @@ -2672,21 +2714,21 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj, if (remap->_type == FunctionRemap::T_constructor) { is_constructor = true; } - + if (is_constructor && (remap->_flags & FunctionRemap::F_explicit_self) != 0) { // If we'll be passing "self" to the constructor, we need to // pre-initialize it here. Unfortunately, we can't pre-load the // "this" pointer, but the constructor itself can do this. - + indent(out, indent_level) << "// Pre-initialize self for the constructor\n"; CPPType *orig_type = remap->_return_type->get_orig_type(); TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(orig_type)), false); InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); - const InterrogateType &itype = idb->get_type(type_index); + const InterrogateType &itype = idb->get_type(type_index); indent(out, indent_level) - << "DTool_PyInit_Finalize(self, NULL, &" + << "DTool_PyInit_Finalize(self, NULL, &" << CLASS_PREFIX << make_safe_name(itype.get_scoped_name()) << ", false, false);\n"; } @@ -2723,7 +2765,7 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj, indent(out, indent_level) << "char *" << param_name << ";\n"; format_specifiers += "s"; parameter_list += ", &" + param_name; - + } else if (TypeManager::is_wchar_pointer(orig_type)) { out << "#if PY_MAJOR_VERSION >= 3\n"; indent(out, indent_level) << "PyObject *" << param_name << ";\n"; @@ -2741,7 +2783,7 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj, pexpr_string = param_name + "_str"; extra_cleanup += " delete[] " + param_name + "_str;"; - + } else if (TypeManager::is_wstring(orig_type)) { out << "#if PY_MAJOR_VERSION >= 3\n"; indent(out, indent_level) << "PyObject *" << param_name << ";\n"; @@ -2892,7 +2934,7 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj, expected_params += classNameFromCppName(obj_type->get_simple_name(), false); if (!remap->_has_this || pn != 0) { - indent(out, indent_level) + indent(out, indent_level) << "PyObject *" << param_name << ";\n"; format_specifiers += "O"; parameter_list += ", &" + param_name; @@ -2900,7 +2942,7 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj, TypeIndex p_type_index = builder.get_type(obj_type, false); InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); - const InterrogateType &p_itype = idb->get_type(p_type_index); + const InterrogateType &p_itype = idb->get_type(p_type_index); bool is_copy_constructor = false; if (is_constructor && remap->_parameters.size() == 1 && pn == 0) { @@ -2927,9 +2969,9 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj, } ostringstream str; - str << "DTOOL_Call_GetPointerThisClass(" << param_name - << ", &Dtool_" << make_safe_name(p_itype.get_scoped_name()) - << ", " << pn << ", \"" + str << "DTOOL_Call_GetPointerThisClass(" << param_name + << ", &Dtool_" << make_safe_name(p_itype.get_scoped_name()) + << ", " << pn << ", \"" << method_prefix << methodNameFromCppName(func1, class_name, false) << "\", " << const_ok; if (coercion_possible && !is_copy_constructor) { @@ -2971,29 +3013,29 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj, pexprs.push_back(pexpr_string); } expected_params += ")\n"; - + // If we got what claimed to be a unary operator, don't check for // parameters, since we won't be getting any anyway. if (!func1->_ifunc.is_unary_op()) { - std::string format_specifiers1 = format_specifiers + ":" + + std::string format_specifiers1 = format_specifiers + ":" + methodNameFromCppName(func1, "", false); indent(out, indent_level) << "static char *keyword_list[] = {" << keyword_list << "NULL};\n"; - if (remap->_parameters.size() == 1 || + if (remap->_parameters.size() == 1 || (remap->_has_this && remap->_parameters.size() == 2)) { indent(out, indent_level) << "// Special case to make operators work\n"; indent(out, indent_level) << "if (PyTuple_Check(args) || (kwds != NULL && PyDict_Check(kwds))) {\n"; indent(out, indent_level) - << " PyArg_ParseTupleAndKeywords(args, kwds, \"" + << " PyArg_ParseTupleAndKeywords(args, kwds, \"" << format_specifiers1 << "\", keyword_list" << parameter_list << ");\n"; indent(out, indent_level) << "} else {\n"; indent(out, indent_level) - << " PyArg_Parse(args, \"" << format_specifiers1 << "\"" + << " PyArg_Parse(args, \"" << format_specifiers1 << "\"" << parameter_list << ");\n"; indent(out, indent_level) << "}\n"; @@ -3002,7 +3044,7 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj, } else { indent(out, indent_level) - << "if (PyArg_ParseTupleAndKeywords(args, kwds, \"" + << "if (PyArg_ParseTupleAndKeywords(args, kwds, \"" << format_specifiers1 << "\", keyword_list" << parameter_list << ")) {\n"; } @@ -3048,11 +3090,11 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj, indent(out, extra_indent_level) << "}\n"; } - - if (!remap->_void_return && + + if (!remap->_void_return && remap->_return_type->new_type_is_atomic_string()) { // Treat strings as a special case. We don't want to format the - // return expression. + // return expression. if (remap->_blocking) { // With SIMPLE_THREADS, it's important that we never release the // interpreter lock. @@ -3166,7 +3208,7 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj, extra_indent_level -= 2; indent(out, extra_indent_level) << "}\n"; } - + indent(out, indent_level) << "}\n"; } @@ -3187,7 +3229,7 @@ pack_return_value(ostream &out, int indent_level, FunctionRemap *remap, TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(orig_type)), false); InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); - const InterrogateType &itype = idb->get_type(type_index); + const InterrogateType &itype = idb->get_type(type_index); indent(out, indent_level) << "return DTool_PyInit_Finalize(self, " << return_expr << ", &" << CLASS_PREFIX << make_safe_name(itype.get_scoped_name()) << ", true, false);\n"; @@ -3240,7 +3282,7 @@ pack_python_value(ostream &out, int indent_level, FunctionRemap *remap, indent(out, indent_level+2) << assign_stmt << "Py_None;\n"; indent(out, indent_level) << "} else {\n"; indent(out, indent_level+2) - << assign_stmt << "PyUnicode_FromWideChar(" + << assign_stmt << "PyUnicode_FromWideChar(" << return_expr << ", wcslen(" << return_expr << "));\n"; indent(out, indent_level) << "}\n"; @@ -3320,11 +3362,11 @@ pack_python_value(ostream &out, int indent_level, FunctionRemap *remap, indent(out, indent_level) << assign_stmt << "PyInt_FromLong(" << return_expr << ");\n"; out << "#endif\n"; - + } else if (TypeManager::is_float(type)) { indent(out, indent_level) << assign_stmt << "PyFloat_FromDouble(" << return_expr << ");\n"; - + } else if (TypeManager::is_char_pointer(type)) { indent(out, indent_level) << "if (" << return_expr << " == NULL) {\n"; indent(out, indent_level) << " Py_INCREF(Py_None);\n"; @@ -3340,14 +3382,14 @@ pack_python_value(ostream &out, int indent_level, FunctionRemap *remap, out << "#endif\n"; indent(out, indent_level) << "}\n"; - + } else if (TypeManager::is_wchar_pointer(type)) { indent(out, indent_level) << "if (" << return_expr << " == NULL) {\n"; indent(out, indent_level) << " Py_INCREF(Py_None);\n"; indent(out, indent_level+2) << assign_stmt << "Py_None;\n"; indent(out, indent_level) << "} else {\n"; indent(out, indent_level+2) << assign_stmt - << "PyUnicode_FromWideChar(" + << "PyUnicode_FromWideChar(" << return_expr << ", wcslen(" << return_expr << "));\n"; indent(out, indent_level) << "}\n"; @@ -3372,12 +3414,12 @@ pack_python_value(ostream &out, int indent_level, FunctionRemap *remap, } else { const_flag = "false"; } - + if (TypeManager::is_struct(orig_type) || TypeManager::is_ref_to_anything(orig_type)) { if (TypeManager::is_ref_to_anything(orig_type)) { TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(type)),false); InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); - const InterrogateType &itype = idb->get_type(type_index); + const InterrogateType &itype = idb->get_type(type_index); std::string owns_memory_flag("true"); if (remap->_return_value_needs_management) { @@ -3404,7 +3446,7 @@ pack_python_value(ostream &out, int indent_level, FunctionRemap *remap, if (remap->_manage_reference_count) { TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(type)),false); InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); - const InterrogateType &itype = idb->get_type(type_index); + const InterrogateType &itype = idb->get_type(type_index); if (!isExportThisRun(itype._cpptype)) { _external_imports.insert(make_safe_name(itype.get_scoped_name())); @@ -3416,7 +3458,7 @@ pack_python_value(ostream &out, int indent_level, FunctionRemap *remap, } else { TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(orig_type)),false); InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); - const InterrogateType &itype = idb->get_type(type_index); + const InterrogateType &itype = idb->get_type(type_index); if (!isExportThisRun(itype._cpptype)) { _external_imports.insert(make_safe_name(itype.get_scoped_name())); @@ -3430,7 +3472,7 @@ pack_python_value(ostream &out, int indent_level, FunctionRemap *remap, } else if (TypeManager::is_struct(orig_type->as_pointer_type()->_pointing_at)) { TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(orig_type)),false); InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); - const InterrogateType &itype = idb->get_type(type_index); + const InterrogateType &itype = idb->get_type(type_index); std::string owns_memory_flag("true"); if (remap->_return_value_needs_management) { @@ -3474,7 +3516,7 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, string num_name = methodNameFromCppName(make_seq->_num_name, ClassName, false); string element_name = methodNameFromCppName(make_seq->_element_name, ClassName, false); - out << " return make_list_for_item(self, \"" << num_name + out << " return make_list_for_item(self, \"" << num_name << "\", \"" << element_name << "\");\n"; out << "}\n"; } @@ -3498,7 +3540,7 @@ record_object(TypeIndex type_index) { } InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); - const InterrogateType &itype = idb->get_type(type_index); + const InterrogateType &itype = idb->get_type(type_index); if (!is_cpp_type_legal(itype._cpptype)) { return (Object *)NULL; @@ -3517,7 +3559,7 @@ record_object(TypeIndex type_index) { object->_constructors.push_back(function); } } - + int num_methods = itype.number_of_methods(); int mi; for (mi = 0; mi < num_methods; mi++) { @@ -3526,7 +3568,7 @@ record_object(TypeIndex type_index) { object->_methods.push_back(function); } } - + int num_casts = itype.number_of_casts(); for (mi = 0; mi < num_casts; mi++) { function = record_function(itype, itype.get_cast(mi)); @@ -3534,11 +3576,11 @@ record_object(TypeIndex type_index) { object->_methods.push_back(function); } } - + int num_derivations = itype.number_of_derivations(); for (int di = 0; di < num_derivations; di++) { TypeIndex d_type_Index = itype.get_derivation(di); - idb->get_type(d_type_Index); + idb->get_type(d_type_Index); if (!interrogate_type_is_unpublished(d_type_Index)) { if (itype.derivation_has_upcast(di)) { @@ -3576,7 +3618,7 @@ record_object(TypeIndex type_index) { FunctionIndex func_index = ielement.get_setter(); record_function(itype, func_index); } - } + } object->check_protocols(); @@ -3622,9 +3664,7 @@ generate_wrappers() { for (int fi = 0; fi < num_functions; fi++) { FunctionIndex func_index = idb->get_global_function(fi); record_function(dummy_type, func_index); - } - - + } int num_manifests = idb->get_num_global_manifests(); for (int mi = 0; mi < num_manifests; mi++) { @@ -3634,7 +3674,7 @@ generate_wrappers() { FunctionIndex func_index = iman.get_getter(); record_function(dummy_type, func_index); } - } + } int num_elements = idb->get_num_global_elements(); for (int ei = 0; ei < num_elements; ei++) { @@ -3648,10 +3688,11 @@ generate_wrappers() { FunctionIndex func_index = ielement.get_setter(); record_function(dummy_type, func_index); } - } + } inside_python_native = false; -} -////////////////////////////////////////////// +} + +////////////////////////////////////////////// // Function :is_cpp_type_legal // // is the cpp object supported by by the dtool_py interface.. @@ -3769,7 +3810,7 @@ is_function_legal(Function *func) { return true; } - } + } // printf(" Function Is Marked Illegal %s\n",func->_name.c_str()); return false; @@ -3788,7 +3829,7 @@ isFunctionWithThis(Function *func) { if (remap->_has_this) { return true; } - } + } return false; } @@ -3900,7 +3941,7 @@ DoesInheritFromIsClass(const CPPStructType *inclass, const std::string &name) { return true; } } - } + } return false; } @@ -3928,22 +3969,22 @@ HasAGetKeyFunction(const InterrogateType &itype_class) { ++ii) { CPPInstance *cppinst = (*ii).second; CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); - + if (cppfunc != NULL) { if (cppfunc->_parameters != NULL && - cppfunc->_return_type != NULL && + cppfunc->_return_type != NULL && TypeManager::is_integer(cppfunc->_return_type)) { if (cppfunc->_parameters->_parameters.size() == 0) { return ifunc.get_name(); } } } - } + } } } } return string(); -}; +} //////////////////////////////////////////////////////////////////////////////////////////// // Function : HasAGetClassTypeFunction @@ -3953,7 +3994,7 @@ HasAGetKeyFunction(const InterrogateType &itype_class) { bool InterfaceMakerPythonNative:: HasAGetClassTypeFunction(const InterrogateType &itype_class) { InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); - + int num_methods = itype_class.number_of_methods(); int mi; for (mi = 0; mi < num_methods; mi++) { @@ -3965,7 +4006,7 @@ HasAGetClassTypeFunction(const InterrogateType &itype_class) { for (ii = ifunc._instances->begin();ii != ifunc._instances->end();++ii) { CPPInstance *cppinst = (*ii).second; CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); - + if (cppfunc != NULL && cppfunc->_return_type != NULL && cppfunc->_parameters != NULL) { CPPType *ret_type = TypeManager::unwrap(cppfunc->_return_type); @@ -3976,8 +4017,7 @@ HasAGetClassTypeFunction(const InterrogateType &itype_class) { } } } - - } + } } } } @@ -4013,8 +4053,8 @@ NeedsAStrFunction(const InterrogateType &itype_class) { CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); if (cppfunc != NULL) { - if (cppfunc->_parameters != NULL && - cppfunc->_return_type != NULL && + if (cppfunc->_parameters != NULL && + cppfunc->_return_type != NULL && TypeManager::is_void(cppfunc->_return_type)) { if (cppfunc->_parameters->_parameters.size() == 1) { CPPInstance *inst1 = cppfunc->_parameters->_parameters[0]; @@ -4041,7 +4081,7 @@ NeedsAStrFunction(const InterrogateType &itype_class) { } } } - } + } } } } @@ -4082,8 +4122,8 @@ NeedsAReprFunction(const InterrogateType &itype_class) { CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); if (cppfunc != NULL) { - if (cppfunc->_parameters != NULL && - cppfunc->_return_type != NULL && + if (cppfunc->_parameters != NULL && + cppfunc->_return_type != NULL && TypeManager::is_void(cppfunc->_return_type)) { if (cppfunc->_parameters->_parameters.size() == 2) { CPPInstance *inst1 = cppfunc->_parameters->_parameters[0]; @@ -4102,7 +4142,7 @@ NeedsAReprFunction(const InterrogateType &itype_class) { } } } - } + } } } } @@ -4120,8 +4160,8 @@ NeedsAReprFunction(const InterrogateType &itype_class) { CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); if (cppfunc != NULL) { - if (cppfunc->_parameters != NULL && - cppfunc->_return_type != NULL && + if (cppfunc->_parameters != NULL && + cppfunc->_return_type != NULL && TypeManager::is_void(cppfunc->_return_type)) { if (cppfunc->_parameters->_parameters.size() == 1) { CPPInstance *inst1 = cppfunc->_parameters->_parameters[0]; @@ -4143,7 +4183,7 @@ NeedsAReprFunction(const InterrogateType &itype_class) { } } } - } + } } } } diff --git a/dtool/src/interrogatedb/extension.h b/dtool/src/interrogatedb/extension.h index 53f2e6241d..0d41ef2c60 100644 --- a/dtool/src/interrogatedb/extension.h +++ b/dtool/src/interrogatedb/extension.h @@ -17,10 +17,7 @@ #include "dtoolbase.h" -struct _object; -typedef struct _object PyObject; - -//////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////// // Class : ExtensionBase // Description : This is where all extensions should derive from. // It defines the _self and _this members that can @@ -30,7 +27,6 @@ template class EXPCL_DTOOLCONFIG ExtensionBase { public: T * _this; - PyObject * _self; }; //////////////////////////////////////////////////////////////////// @@ -52,10 +48,9 @@ class EXPCL_DTOOLCONFIG Extension : public ExtensionBase { //////////////////////////////////////////////////////////////////// template inline Extension -invoke_extension(T *ptr, PyObject *self = NULL) { +invoke_extension(T *ptr) { Extension ext; ext._this = ptr; - ext._self = self; return ext; } @@ -65,10 +60,9 @@ invoke_extension(T *ptr, PyObject *self = NULL) { //////////////////////////////////////////////////////////////////// template inline const Extension -invoke_extension(const T *ptr, PyObject *self = NULL) { +invoke_extension(const T *ptr) { Extension ext; ext._this = (T *) ptr; - ext._self = self; return ext; } diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index 786b45d15e..f0123e459e 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -49,7 +49,7 @@ bool DtoolCanThisBeAPandaInstance(PyObject *self) { //////////////////////////////////////////////////////////////////////// void DTOOL_Call_ExtractThisPointerForType(PyObject *self, Dtool_PyTypedObject *classdef, void **answer) { if (DtoolCanThisBeAPandaInstance(self)) { - *answer = ((Dtool_PyInstDef *)self)->_My_Type->_Dtool_UpcastInterface(self,classdef); + *answer = ((Dtool_PyInstDef *)self)->_My_Type->_Dtool_UpcastInterface(self, classdef); } else { *answer = NULL; } @@ -298,7 +298,7 @@ void *DTOOL_Call_GetPointerThis(PyObject *self) { // this function relies on the behavior of typed objects in the panda system. // //////////////////////////////////////////////////////////////////////// -PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject & known_class_type, bool memory_rules, bool is_const, int RunTimeType) { +PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject & known_class_type, bool memory_rules, bool is_const, int RunTimeType) { if (local_this_in == NULL) { // Let's not be stupid.. PyErr_SetString(PyExc_TypeError, "C Function Return Null 'this'"); @@ -339,7 +339,7 @@ PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject & // if we get this far .. just wrap the thing in the known type ?? // better than aborting...I guess.... ///////////////////////////////////////////////////// - Dtool_PyInstDef * self = (Dtool_PyInstDef *) known_class_type.As_PyTypeObject().tp_new(&known_class_type.As_PyTypeObject(), NULL, NULL); + Dtool_PyInstDef *self = (Dtool_PyInstDef *) known_class_type.As_PyTypeObject().tp_new(&known_class_type.As_PyTypeObject(), NULL, NULL); if (self != NULL) { self->_ptr_to_object = local_this_in; self->_memory_rules = memory_rules; diff --git a/dtool/src/prc/streamReader.h b/dtool/src/prc/streamReader.h index e8900704cd..8d71cf6b9b 100644 --- a/dtool/src/prc/streamReader.h +++ b/dtool/src/prc/streamReader.h @@ -70,6 +70,7 @@ PUBLISHED: BLOCKING size_t extract_bytes(unsigned char *into, size_t size); BLOCKING string readline(); + EXTENSION(BLOCKING PyObject *readlines()); private: istream *_in; diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 9fbe316221..2b7564b94f 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2376,17 +2376,24 @@ CreatePandaVersionFiles() ########################################################################################## # -# Copy the "direct" tree and panda3d.py +# Copy the "direct" tree # ########################################################################################## if (PkgSkip("DIRECT")==0): CopyPythonTree(GetOutputDir() + '/direct', 'direct/src', lib2to3_fixers=['all']) ConditionalWriteFile(GetOutputDir() + '/direct/__init__.py', "") - if (GetTarget() == 'windows'): - CopyFile(GetOutputDir()+'/bin/panda3d.py', 'direct/src/ffi/panda3d.py') - else: - CopyFile(GetOutputDir()+'/lib/panda3d.py', 'direct/src/ffi/panda3d.py') + + # This file used to be copied, but would nowadays cause conflicts. + # Let's get it out of the way in case someone hasn't cleaned their build since. + if os.path.isfile(GetOutputDir() + '/bin/panda3d.py'): + os.remove(GetOutputDir() + '/bin/panda3d.py') + if os.path.isfile(GetOutputDir() + '/lib/panda3d.py'): + os.remove(GetOutputDir() + '/lib/panda3d.py') + + # Don't copy this file, which would cause conflict with our 'panda3d' module. + if os.path.isfile(GetOutputDir() + '/direct/ffi/panda3d.py'): + os.remove(GetOutputDir() + '/direct/ffi/panda3d.py') ########################################################################################## # @@ -2919,11 +2926,11 @@ TargetAdd('p3pandabase_pandabase.obj', opts=OPTS, input='pandabase.cxx') OPTS=['DIR:panda/src/express', 'BUILDING:PANDAEXPRESS', 'OPENSSL', 'ZLIB'] TargetAdd('p3express_composite1.obj', opts=OPTS, input='p3express_composite1.cxx') TargetAdd('p3express_composite2.obj', opts=OPTS, input='p3express_composite2.cxx') +TargetAdd('p3express_ext_composite.obj', opts=OPTS, input='p3express_ext_composite.cxx') IGATEFILES=GetDirectoryContents('panda/src/express', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3express.in', opts=OPTS, input=IGATEFILES) -TargetAdd('libp3express.in', opts=['IMOD:pandaexpress', 'ILIB:libp3express', 'SRCDIR:panda/src/express']) +TargetAdd('libp3express.in', opts=['IMOD:core', 'ILIB:libp3express', 'SRCDIR:panda/src/express']) TargetAdd('libp3express_igate.obj', input='libp3express.in', opts=["DEPENDENCYONLY"]) -TargetAdd('p3express_virtualFileSystem_ext.obj', opts=OPTS, input='virtualFileSystem_ext.cxx') # # DIRECTORY: panda/src/downloader/ @@ -2934,7 +2941,7 @@ TargetAdd('p3downloader_composite1.obj', opts=OPTS, input='p3downloader_composit TargetAdd('p3downloader_composite2.obj', opts=OPTS, input='p3downloader_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/downloader', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3downloader.in', opts=OPTS, input=IGATEFILES) -TargetAdd('libp3downloader.in', opts=['IMOD:pandaexpress', 'ILIB:libp3downloader', 'SRCDIR:panda/src/downloader']) +TargetAdd('libp3downloader.in', opts=['IMOD:core', 'ILIB:libp3downloader', 'SRCDIR:panda/src/downloader']) TargetAdd('libp3downloader_igate.obj', input='libp3downloader.in', opts=["DEPENDENCYONLY"]) # @@ -2943,20 +2950,14 @@ TargetAdd('libp3downloader_igate.obj', input='libp3downloader.in', opts=["DEPEND OPTS=['DIR:panda/metalibs/pandaexpress', 'BUILDING:PANDAEXPRESS', 'ZLIB'] TargetAdd('pandaexpress_pandaexpress.obj', opts=OPTS, input='pandaexpress.cxx') -TargetAdd('libpandaexpress_module.obj', input='libp3downloader.in') -TargetAdd('libpandaexpress_module.obj', input='libp3express.in') -TargetAdd('libpandaexpress_module.obj', opts=['ADVAPI', 'OPENSSL']) -TargetAdd('libpandaexpress_module.obj', opts=['IMOD:pandaexpress', 'ILIB:libpandaexpress']) - TargetAdd('libpandaexpress.dll', input='pandaexpress_pandaexpress.obj') -TargetAdd('libpandaexpress.dll', input='libpandaexpress_module.obj') TargetAdd('libpandaexpress.dll', input='p3downloader_composite1.obj') TargetAdd('libpandaexpress.dll', input='p3downloader_composite2.obj') TargetAdd('libpandaexpress.dll', input='libp3downloader_igate.obj') TargetAdd('libpandaexpress.dll', input='p3express_composite1.obj') TargetAdd('libpandaexpress.dll', input='p3express_composite2.obj') +TargetAdd('libpandaexpress.dll', input='p3express_ext_composite.obj') TargetAdd('libpandaexpress.dll', input='libp3express_igate.obj') -TargetAdd('libpandaexpress.dll', input='p3express_virtualFileSystem_ext.obj') TargetAdd('libpandaexpress.dll', input='p3pandabase_pandabase.obj') TargetAdd('libpandaexpress.dll', input=COMMON_DTOOL_LIBS) TargetAdd('libpandaexpress.dll', opts=['ADVAPI', 'WINSOCK2', 'OPENSSL', 'ZLIB', 'WINGDI', 'WINUSER']) @@ -2972,7 +2973,7 @@ if (not RUNTIME): TargetAdd('p3pipeline_contextSwitch.obj', opts=OPTS, input='contextSwitch.c') IGATEFILES=GetDirectoryContents('panda/src/pipeline', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3pipeline.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3pipeline.in', opts=['IMOD:panda', 'ILIB:libp3pipeline', 'SRCDIR:panda/src/pipeline']) + TargetAdd('libp3pipeline.in', opts=['IMOD:core', 'ILIB:libp3pipeline', 'SRCDIR:panda/src/pipeline']) TargetAdd('libp3pipeline_igate.obj', input='libp3pipeline.in', opts=["DEPENDENCYONLY"]) # @@ -2986,8 +2987,9 @@ if (not RUNTIME): IGATEFILES=GetDirectoryContents('panda/src/putil', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove("test_bam.h") TargetAdd('libp3putil.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3putil.in', opts=['IMOD:panda', 'ILIB:libp3putil', 'SRCDIR:panda/src/putil']) + TargetAdd('libp3putil.in', opts=['IMOD:core', 'ILIB:libp3putil', 'SRCDIR:panda/src/putil']) TargetAdd('libp3putil_igate.obj', input='libp3putil.in', opts=["DEPENDENCYONLY"]) + TargetAdd('p3putil_typedWritable_ext.obj', opts=OPTS, input='typedWritable_ext.cxx') # # DIRECTORY: panda/src/audio/ @@ -2998,7 +3000,7 @@ if (not RUNTIME): TargetAdd('p3audio_composite1.obj', opts=OPTS, input='p3audio_composite1.cxx') IGATEFILES=["audio.h"] TargetAdd('libp3audio.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3audio.in', opts=['IMOD:panda', 'ILIB:libp3audio', 'SRCDIR:panda/src/audio']) + TargetAdd('libp3audio.in', opts=['IMOD:core', 'ILIB:libp3audio', 'SRCDIR:panda/src/audio']) TargetAdd('libp3audio_igate.obj', input='libp3audio.in', opts=["DEPENDENCYONLY"]) # @@ -3011,7 +3013,7 @@ if (not RUNTIME): TargetAdd('p3event_composite2.obj', opts=OPTS, input='p3event_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/event', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3event.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3event.in', opts=['IMOD:panda', 'ILIB:libp3event', 'SRCDIR:panda/src/event']) + TargetAdd('libp3event.in', opts=['IMOD:core', 'ILIB:libp3event', 'SRCDIR:panda/src/event']) TargetAdd('libp3event_igate.obj', input='libp3event.in', opts=["DEPENDENCYONLY"]) # @@ -3030,7 +3032,7 @@ if (not RUNTIME): IGATEFILES.remove('lmat_ops.h') IGATEFILES.remove('cast_to_float.h') TargetAdd('libp3linmath.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3linmath.in', opts=['IMOD:panda', 'ILIB:libp3linmath', 'SRCDIR:panda/src/linmath']) + TargetAdd('libp3linmath.in', opts=['IMOD:core', 'ILIB:libp3linmath', 'SRCDIR:panda/src/linmath']) TargetAdd('libp3linmath_igate.obj', input='libp3linmath.in', opts=["DEPENDENCYONLY"]) # @@ -3043,7 +3045,7 @@ if (not RUNTIME): TargetAdd('p3mathutil_composite2.obj', opts=OPTS, input='p3mathutil_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/mathutil', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3mathutil.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3mathutil.in', opts=['IMOD:panda', 'ILIB:libp3mathutil', 'SRCDIR:panda/src/mathutil']) + TargetAdd('libp3mathutil.in', opts=['IMOD:core', 'ILIB:libp3mathutil', 'SRCDIR:panda/src/mathutil']) TargetAdd('libp3mathutil_igate.obj', input='libp3mathutil.in', opts=["DEPENDENCYONLY"]) # @@ -3055,7 +3057,7 @@ if (not RUNTIME): TargetAdd('p3gsgbase_composite1.obj', opts=OPTS, input='p3gsgbase_composite1.cxx') IGATEFILES=GetDirectoryContents('panda/src/gsgbase', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3gsgbase.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3gsgbase.in', opts=['IMOD:panda', 'ILIB:libp3gsgbase', 'SRCDIR:panda/src/gsgbase']) + TargetAdd('libp3gsgbase.in', opts=['IMOD:core', 'ILIB:libp3gsgbase', 'SRCDIR:panda/src/gsgbase']) TargetAdd('libp3gsgbase_igate.obj', input='libp3gsgbase.in', opts=["DEPENDENCYONLY"]) # @@ -3068,7 +3070,7 @@ if (not RUNTIME): TargetAdd('p3pnmimage_composite2.obj', opts=OPTS, input='p3pnmimage_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/pnmimage', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3pnmimage.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3pnmimage.in', opts=['IMOD:panda', 'ILIB:libp3pnmimage', 'SRCDIR:panda/src/pnmimage']) + TargetAdd('libp3pnmimage.in', opts=['IMOD:core', 'ILIB:libp3pnmimage', 'SRCDIR:panda/src/pnmimage']) TargetAdd('libp3pnmimage_igate.obj', input='libp3pnmimage.in', opts=["DEPENDENCYONLY"]) # @@ -3080,7 +3082,7 @@ if (not RUNTIME): TargetAdd('p3nativenet_composite1.obj', opts=OPTS, input='p3nativenet_composite1.cxx') IGATEFILES=GetDirectoryContents('panda/src/nativenet', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3nativenet.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3nativenet.in', opts=['IMOD:panda', 'ILIB:libp3nativenet', 'SRCDIR:panda/src/nativenet']) + TargetAdd('libp3nativenet.in', opts=['IMOD:core', 'ILIB:libp3nativenet', 'SRCDIR:panda/src/nativenet']) TargetAdd('libp3nativenet_igate.obj', input='libp3nativenet.in', opts=["DEPENDENCYONLY"]) # @@ -3094,7 +3096,7 @@ if (not RUNTIME): IGATEFILES=GetDirectoryContents('panda/src/net', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove("datagram_ui.h") TargetAdd('libp3net.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3net.in', opts=['IMOD:panda', 'ILIB:libp3net', 'SRCDIR:panda/src/net']) + TargetAdd('libp3net.in', opts=['IMOD:core', 'ILIB:libp3net', 'SRCDIR:panda/src/net']) TargetAdd('libp3net_igate.obj', input='libp3net.in', opts=["DEPENDENCYONLY"]) # @@ -3107,7 +3109,7 @@ if (not RUNTIME): TargetAdd('p3pstatclient_composite2.obj', opts=OPTS, input='p3pstatclient_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/pstatclient', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3pstatclient.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3pstatclient.in', opts=['IMOD:panda', 'ILIB:libp3pstatclient', 'SRCDIR:panda/src/pstatclient']) + TargetAdd('libp3pstatclient.in', opts=['IMOD:core', 'ILIB:libp3pstatclient', 'SRCDIR:panda/src/pstatclient']) TargetAdd('libp3pstatclient_igate.obj', input='libp3pstatclient.in', opts=["DEPENDENCYONLY"]) # @@ -3121,7 +3123,7 @@ if (not RUNTIME): IGATEFILES=GetDirectoryContents('panda/src/gobj', ["*.h", "*_composite*.cxx"]) if ("cgfx_states.h" in IGATEFILES): IGATEFILES.remove("cgfx_states.h") TargetAdd('libp3gobj.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3gobj.in', opts=['IMOD:panda', 'ILIB:libp3gobj', 'SRCDIR:panda/src/gobj']) + TargetAdd('libp3gobj.in', opts=['IMOD:core', 'ILIB:libp3gobj', 'SRCDIR:panda/src/gobj']) TargetAdd('libp3gobj_igate.obj', input='libp3gobj.in', opts=["DEPENDENCYONLY"]) TargetAdd('p3gobj_geomVertexArrayData_ext.obj', opts=OPTS, input='geomVertexArrayData_ext.cxx') @@ -3135,7 +3137,7 @@ if (not RUNTIME): TargetAdd('p3pgraphnodes_composite2.obj', opts=OPTS, input='p3pgraphnodes_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/pgraphnodes', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3pgraphnodes.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3pgraphnodes.in', opts=['IMOD:panda', 'ILIB:libp3pgraphnodes', 'SRCDIR:panda/src/pgraphnodes']) + TargetAdd('libp3pgraphnodes.in', opts=['IMOD:core', 'ILIB:libp3pgraphnodes', 'SRCDIR:panda/src/pgraphnodes']) TargetAdd('libp3pgraphnodes_igate.obj', input='libp3pgraphnodes.in', opts=["DEPENDENCYONLY"]) # @@ -3151,8 +3153,10 @@ if (not RUNTIME): TargetAdd('p3pgraph_composite4.obj', opts=OPTS, input='p3pgraph_composite4.cxx') IGATEFILES=GetDirectoryContents('panda/src/pgraph', ["*.h", "nodePath.cxx", "*_composite*.cxx"]) TargetAdd('libp3pgraph.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3pgraph.in', opts=['IMOD:panda', 'ILIB:libp3pgraph', 'SRCDIR:panda/src/pgraph']) + TargetAdd('libp3pgraph.in', opts=['IMOD:core', 'ILIB:libp3pgraph', 'SRCDIR:panda/src/pgraph']) TargetAdd('libp3pgraph_igate.obj', input='libp3pgraph.in', opts=["DEPENDENCYONLY","BIGOBJ"]) + TargetAdd('p3pgraph_nodePath_ext.obj', opts=OPTS, input='nodePath_ext.cxx') + TargetAdd('p3pgraph_nodePathCollection_ext.obj', opts=OPTS, input='nodePathCollection_ext.cxx') # # DIRECTORY: panda/src/cull/ @@ -3164,7 +3168,7 @@ if (not RUNTIME): TargetAdd('p3cull_composite2.obj', opts=OPTS, input='p3cull_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/cull', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3cull.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3cull.in', opts=['IMOD:panda', 'ILIB:libp3cull', 'SRCDIR:panda/src/cull']) + TargetAdd('libp3cull.in', opts=['IMOD:core', 'ILIB:libp3cull', 'SRCDIR:panda/src/cull']) TargetAdd('libp3cull_igate.obj', input='libp3cull.in', opts=["DEPENDENCYONLY"]) # @@ -3179,7 +3183,7 @@ if (not RUNTIME): IGATEFILES.remove('movingPart.h') IGATEFILES.remove('animChannelFixed.h') TargetAdd('libp3chan.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3chan.in', opts=['IMOD:panda', 'ILIB:libp3chan', 'SRCDIR:panda/src/chan']) + TargetAdd('libp3chan.in', opts=['IMOD:core', 'ILIB:libp3chan', 'SRCDIR:panda/src/chan']) TargetAdd('libp3chan_igate.obj', input='libp3chan.in', opts=["DEPENDENCYONLY"]) @@ -3192,7 +3196,7 @@ if (not RUNTIME): TargetAdd('p3char_composite2.obj', opts=OPTS, input='p3char_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/char', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3char.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3char.in', opts=['IMOD:panda', 'ILIB:libp3char', 'SRCDIR:panda/src/char']) + TargetAdd('libp3char.in', opts=['IMOD:core', 'ILIB:libp3char', 'SRCDIR:panda/src/char']) TargetAdd('libp3char_igate.obj', input='libp3char.in', opts=["DEPENDENCYONLY"]) # @@ -3205,7 +3209,7 @@ if (not RUNTIME): TargetAdd('p3dgraph_composite2.obj', opts=OPTS, input='p3dgraph_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/dgraph', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3dgraph.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3dgraph.in', opts=['IMOD:panda', 'ILIB:libp3dgraph', 'SRCDIR:panda/src/dgraph']) + TargetAdd('libp3dgraph.in', opts=['IMOD:core', 'ILIB:libp3dgraph', 'SRCDIR:panda/src/dgraph']) TargetAdd('libp3dgraph_igate.obj', input='libp3dgraph.in', opts=["DEPENDENCYONLY"]) # @@ -3219,8 +3223,9 @@ if (not RUNTIME): IGATEFILES=GetDirectoryContents('panda/src/display', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove("renderBuffer.h") TargetAdd('libp3display.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3display.in', opts=['IMOD:panda', 'ILIB:libp3display', 'SRCDIR:panda/src/display']) + TargetAdd('libp3display.in', opts=['IMOD:core', 'ILIB:libp3display', 'SRCDIR:panda/src/display']) TargetAdd('libp3display_igate.obj', input='libp3display.in', opts=["DEPENDENCYONLY"]) + TargetAdd('p3display_graphicsStateGuardian_ext.obj', opts=OPTS, input='graphicsStateGuardian_ext.cxx') if RTDIST and GetTarget() == 'darwin': OPTS=['DIR:panda/src/display'] @@ -3237,7 +3242,7 @@ if (not RUNTIME): TargetAdd('p3device_composite2.obj', opts=OPTS, input='p3device_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/device', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3device.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3device.in', opts=['IMOD:panda', 'ILIB:libp3device', 'SRCDIR:panda/src/device']) + TargetAdd('libp3device.in', opts=['IMOD:core', 'ILIB:libp3device', 'SRCDIR:panda/src/device']) TargetAdd('libp3device_igate.obj', input='libp3device.in', opts=["DEPENDENCYONLY"]) # @@ -3249,7 +3254,7 @@ if (PkgSkip("FREETYPE")==0 and not RUNTIME): TargetAdd('p3pnmtext_composite1.obj', opts=OPTS, input='p3pnmtext_composite1.cxx') IGATEFILES=GetDirectoryContents('panda/src/pnmtext', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3pnmtext.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3pnmtext.in', opts=['IMOD:panda', 'ILIB:libp3pnmtext', 'SRCDIR:panda/src/pnmtext']) + TargetAdd('libp3pnmtext.in', opts=['IMOD:core', 'ILIB:libp3pnmtext', 'SRCDIR:panda/src/pnmtext']) TargetAdd('libp3pnmtext_igate.obj', input='libp3pnmtext.in', opts=["DEPENDENCYONLY"]) # @@ -3262,7 +3267,7 @@ if (not RUNTIME): TargetAdd('p3text_composite2.obj', opts=OPTS, input='p3text_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/text', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3text.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3text.in', opts=['IMOD:panda', 'ILIB:libp3text', 'SRCDIR:panda/src/text']) + TargetAdd('libp3text.in', opts=['IMOD:core', 'ILIB:libp3text', 'SRCDIR:panda/src/text']) TargetAdd('libp3text_igate.obj', input='libp3text.in', opts=["DEPENDENCYONLY"]) # @@ -3274,7 +3279,7 @@ if (not RUNTIME): TargetAdd('p3movies_composite1.obj', opts=OPTS, input='p3movies_composite1.cxx') IGATEFILES=GetDirectoryContents('panda/src/movies', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3movies.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3movies.in', opts=['IMOD:panda', 'ILIB:libp3movies', 'SRCDIR:panda/src/movies']) + TargetAdd('libp3movies.in', opts=['IMOD:core', 'ILIB:libp3movies', 'SRCDIR:panda/src/movies']) TargetAdd('libp3movies_igate.obj', input='libp3movies.in', opts=["DEPENDENCYONLY"]) # @@ -3288,7 +3293,7 @@ if (not RUNTIME): TargetAdd('p3grutil_composite2.obj', opts=OPTS, input='p3grutil_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/grutil', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3grutil.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3grutil.in', opts=['IMOD:panda', 'ILIB:libp3grutil', 'SRCDIR:panda/src/grutil']) + TargetAdd('libp3grutil.in', opts=['IMOD:core', 'ILIB:libp3grutil', 'SRCDIR:panda/src/grutil']) TargetAdd('libp3grutil_igate.obj', input='libp3grutil.in', opts=["DEPENDENCYONLY"]) # @@ -3301,7 +3306,7 @@ if (not RUNTIME): TargetAdd('p3tform_composite2.obj', opts=OPTS, input='p3tform_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/tform', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3tform.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3tform.in', opts=['IMOD:panda', 'ILIB:libp3tform', 'SRCDIR:panda/src/tform']) + TargetAdd('libp3tform.in', opts=['IMOD:core', 'ILIB:libp3tform', 'SRCDIR:panda/src/tform']) TargetAdd('libp3tform_igate.obj', input='libp3tform.in', opts=["DEPENDENCYONLY"]) # @@ -3314,7 +3319,7 @@ if (not RUNTIME): TargetAdd('p3collide_composite2.obj', opts=OPTS, input='p3collide_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/collide', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3collide.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3collide.in', opts=['IMOD:panda', 'ILIB:libp3collide', 'SRCDIR:panda/src/collide']) + TargetAdd('libp3collide.in', opts=['IMOD:core', 'ILIB:libp3collide', 'SRCDIR:panda/src/collide']) TargetAdd('libp3collide_igate.obj', input='libp3collide.in', opts=["DEPENDENCYONLY"]) # @@ -3327,7 +3332,7 @@ if (not RUNTIME): TargetAdd('p3parametrics_composite2.obj', opts=OPTS, input='p3parametrics_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/parametrics', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3parametrics.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3parametrics.in', opts=['IMOD:panda', 'ILIB:libp3parametrics', 'SRCDIR:panda/src/parametrics']) + TargetAdd('libp3parametrics.in', opts=['IMOD:core', 'ILIB:libp3parametrics', 'SRCDIR:panda/src/parametrics']) TargetAdd('libp3parametrics_igate.obj', input='libp3parametrics.in', opts=["DEPENDENCYONLY"]) # @@ -3340,7 +3345,7 @@ if (not RUNTIME): TargetAdd('p3pgui_composite2.obj', opts=OPTS, input='p3pgui_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/pgui', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3pgui.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3pgui.in', opts=['IMOD:panda', 'ILIB:libp3pgui', 'SRCDIR:panda/src/pgui']) + TargetAdd('libp3pgui.in', opts=['IMOD:core', 'ILIB:libp3pgui', 'SRCDIR:panda/src/pgui']) TargetAdd('libp3pgui_igate.obj', input='libp3pgui.in', opts=["DEPENDENCYONLY"]) # @@ -3362,7 +3367,7 @@ if (not RUNTIME): TargetAdd('p3recorder_composite2.obj', opts=OPTS, input='p3recorder_composite2.cxx') IGATEFILES=GetDirectoryContents('panda/src/recorder', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3recorder.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3recorder.in', opts=['IMOD:panda', 'ILIB:libp3recorder', 'SRCDIR:panda/src/recorder']) + TargetAdd('libp3recorder.in', opts=['IMOD:core', 'ILIB:libp3recorder', 'SRCDIR:panda/src/recorder']) TargetAdd('libp3recorder_igate.obj', input='libp3recorder.in', opts=["DEPENDENCYONLY"]) # @@ -3381,7 +3386,7 @@ if (not RUNTIME): TargetAdd('p3dxml_composite1.obj', opts=OPTS, input='p3dxml_composite1.cxx') IGATEFILES=GetDirectoryContents('panda/src/dxml', ["*.h", "p3dxml_composite1.cxx"]) TargetAdd('libp3dxml.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3dxml.in', opts=['IMOD:panda', 'ILIB:libp3dxml', 'SRCDIR:panda/src/dxml']) + TargetAdd('libp3dxml.in', opts=['IMOD:core', 'ILIB:libp3dxml', 'SRCDIR:panda/src/dxml']) TargetAdd('libp3dxml_igate.obj', input='libp3dxml.in', opts=["DEPENDENCYONLY"]) # @@ -3395,38 +3400,7 @@ if (not RUNTIME): TargetAdd('panda_panda.obj', opts=OPTS, input='panda.cxx') - TargetAdd('libpanda_module.obj', input='libp3recorder.in') - TargetAdd('libpanda_module.obj', input='libp3pgraphnodes.in') - TargetAdd('libpanda_module.obj', input='libp3pgraph.in') - TargetAdd('libpanda_module.obj', input='libp3cull.in') - TargetAdd('libpanda_module.obj', input='libp3grutil.in') - TargetAdd('libpanda_module.obj', input='libp3chan.in') - TargetAdd('libpanda_module.obj', input='libp3pstatclient.in') - TargetAdd('libpanda_module.obj', input='libp3char.in') - TargetAdd('libpanda_module.obj', input='libp3collide.in') - TargetAdd('libpanda_module.obj', input='libp3device.in') - TargetAdd('libpanda_module.obj', input='libp3dgraph.in') - TargetAdd('libpanda_module.obj', input='libp3display.in') - TargetAdd('libpanda_module.obj', input='libp3pipeline.in') - TargetAdd('libpanda_module.obj', input='libp3event.in') - TargetAdd('libpanda_module.obj', input='libp3gobj.in') - TargetAdd('libpanda_module.obj', input='libp3gsgbase.in') - TargetAdd('libpanda_module.obj', input='libp3linmath.in') - TargetAdd('libpanda_module.obj', input='libp3mathutil.in') - TargetAdd('libpanda_module.obj', input='libp3parametrics.in') - TargetAdd('libpanda_module.obj', input='libp3pnmimage.in') - TargetAdd('libpanda_module.obj', input='libp3text.in') - TargetAdd('libpanda_module.obj', input='libp3tform.in') - TargetAdd('libpanda_module.obj', input='libp3putil.in') - TargetAdd('libpanda_module.obj', input='libp3audio.in') - TargetAdd('libpanda_module.obj', input='libp3nativenet.in') - TargetAdd('libpanda_module.obj', input='libp3net.in') - TargetAdd('libpanda_module.obj', input='libp3pgui.in') - TargetAdd('libpanda_module.obj', input='libp3movies.in') - TargetAdd('libpanda_module.obj', input='libp3dxml.in') - TargetAdd('libpanda.dll', input='panda_panda.obj') - TargetAdd('libpanda.dll', input='libpanda_module.obj') TargetAdd('libpanda.dll', input='p3recorder_composite1.obj') TargetAdd('libpanda.dll', input='p3recorder_composite2.obj') TargetAdd('libpanda.dll', input='libp3recorder_igate.obj') @@ -3478,7 +3452,6 @@ if (not RUNTIME): TargetAdd('libpanda.dll', input='p3gobj_composite1.obj') TargetAdd('libpanda.dll', input='p3gobj_composite2.obj') TargetAdd('libpanda.dll', input='libp3gobj_igate.obj') - TargetAdd('libpanda.dll', input='p3gobj_geomVertexArrayData_ext.obj') TargetAdd('libpanda.dll', input='p3gsgbase_composite1.obj') TargetAdd('libpanda.dll', input='libp3gsgbase_igate.obj') TargetAdd('libpanda.dll', input='p3linmath_composite1.obj') @@ -3521,17 +3494,62 @@ if (not RUNTIME): TargetAdd('libpanda.dll', input='libp3dtoolconfig.dll') TargetAdd('libpanda.dll', input='libp3dtool.dll') + TargetAdd('libpanda.dll', input='p3putil_typedWritable_ext.obj') + TargetAdd('libpanda.dll', input='p3gobj_geomVertexArrayData_ext.obj') + TargetAdd('libpanda.dll', input='p3pgraph_nodePath_ext.obj') + TargetAdd('libpanda.dll', input='p3pgraph_nodePathCollection_ext.obj') + TargetAdd('libpanda.dll', input='p3display_graphicsStateGuardian_ext.obj') + if PkgSkip("FREETYPE")==0: TargetAdd('libpanda.dll', input="p3pnmtext_composite1.obj") TargetAdd('libpanda.dll', input="libp3pnmtext_igate.obj") - TargetAdd('libpanda_module.obj', input='libp3pnmtext.in') - - TargetAdd('libpanda_module.obj', opts=OPTS) - TargetAdd('libpanda_module.obj', opts=['IMOD:panda', 'ILIB:libpanda']) TargetAdd('libpanda.dll', dep='dtool_have_freetype.dat') TargetAdd('libpanda.dll', opts=OPTS) + TargetAdd('core_module.obj', input='libp3downloader.in') + TargetAdd('core_module.obj', input='libp3express.in') + + TargetAdd('core_module.obj', input='libp3recorder.in') + TargetAdd('core_module.obj', input='libp3pgraphnodes.in') + TargetAdd('core_module.obj', input='libp3pgraph.in') + TargetAdd('core_module.obj', input='libp3cull.in') + TargetAdd('core_module.obj', input='libp3grutil.in') + TargetAdd('core_module.obj', input='libp3chan.in') + TargetAdd('core_module.obj', input='libp3pstatclient.in') + TargetAdd('core_module.obj', input='libp3char.in') + TargetAdd('core_module.obj', input='libp3collide.in') + TargetAdd('core_module.obj', input='libp3device.in') + TargetAdd('core_module.obj', input='libp3dgraph.in') + TargetAdd('core_module.obj', input='libp3display.in') + TargetAdd('core_module.obj', input='libp3pipeline.in') + TargetAdd('core_module.obj', input='libp3event.in') + TargetAdd('core_module.obj', input='libp3gobj.in') + TargetAdd('core_module.obj', input='libp3gsgbase.in') + TargetAdd('core_module.obj', input='libp3linmath.in') + TargetAdd('core_module.obj', input='libp3mathutil.in') + TargetAdd('core_module.obj', input='libp3parametrics.in') + TargetAdd('core_module.obj', input='libp3pnmimage.in') + TargetAdd('core_module.obj', input='libp3text.in') + TargetAdd('core_module.obj', input='libp3tform.in') + TargetAdd('core_module.obj', input='libp3putil.in') + TargetAdd('core_module.obj', input='libp3audio.in') + TargetAdd('core_module.obj', input='libp3nativenet.in') + TargetAdd('core_module.obj', input='libp3net.in') + TargetAdd('core_module.obj', input='libp3pgui.in') + TargetAdd('core_module.obj', input='libp3movies.in') + TargetAdd('core_module.obj', input='libp3dxml.in') + + if PkgSkip("FREETYPE")==0: + TargetAdd('core_module.obj', input='libp3pnmtext.in') + + TargetAdd('core_module.obj', opts=['IMOD:core', 'ILIB:core']) + + TargetAdd('core.pyd', input='core_module.obj') + TargetAdd('core.pyd', input='libpandaexpress.dll') + TargetAdd('core.pyd', input='libpanda.dll') + TargetAdd('core.pyd', opts=['PYTHON']) + # # DIRECTORY: panda/src/vision/ # @@ -3539,21 +3557,25 @@ if (not RUNTIME): if (PkgSkip("VISION") ==0) and (not RUNTIME): OPTS=['DIR:panda/src/vision', 'BUILDING:VISION', 'ARTOOLKIT', 'OPENCV', 'DX9', 'DIRECTCAM', 'JPEG'] TargetAdd('p3vision_composite1.obj', opts=OPTS, input='p3vision_composite1.cxx') - IGATEFILES=GetDirectoryContents('panda/src/vision', ["*.h", "*_composite*.cxx"]) - TargetAdd('libp3vision.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3vision.in', opts=['IMOD:p3vision', 'ILIB:libp3vision', 'SRCDIR:panda/src/vision']) - TargetAdd('libp3vision_igate.obj', input='libp3vision.in', opts=["DEPENDENCYONLY"]) - - TargetAdd('libp3vision_module.obj', input='libp3vision.in') - TargetAdd('libp3vision_module.obj', opts=OPTS) - TargetAdd('libp3vision_module.obj', opts=['IMOD:p3vision', 'ILIB:libp3vision']) TargetAdd('libp3vision.dll', input='p3vision_composite1.obj') - TargetAdd('libp3vision.dll', input='libp3vision_igate.obj') - TargetAdd('libp3vision.dll', input='libp3vision_module.obj') TargetAdd('libp3vision.dll', input=COMMON_PANDA_LIBS) TargetAdd('libp3vision.dll', opts=OPTS) + IGATEFILES=GetDirectoryContents('panda/src/vision', ["*.h", "*_composite*.cxx"]) + TargetAdd('libp3vision.in', opts=OPTS, input=IGATEFILES) + TargetAdd('libp3vision.in', opts=['IMOD:vision', 'ILIB:libp3vision', 'SRCDIR:panda/src/vision']) + TargetAdd('libp3vision_igate.obj', input='libp3vision.in', opts=["DEPENDENCYONLY"]) + + TargetAdd('vision_module.obj', input='libp3vision.in') + TargetAdd('vision_module.obj', opts=OPTS) + TargetAdd('vision_module.obj', opts=['IMOD:vision', 'ILIB:vision']) + + TargetAdd('vision.pyd', input='vision_module.obj') + TargetAdd('vision.pyd', input='libp3vision_igate.obj') + TargetAdd('vision.pyd', input='libp3vision.dll') + TargetAdd('vision.pyd', opts=['PYTHON']) + # # DIRECTORY: panda/src/rocket/ # @@ -3561,24 +3583,27 @@ if (PkgSkip("VISION") ==0) and (not RUNTIME): if (PkgSkip("ROCKET") ==0) and (not RUNTIME): OPTS=['DIR:panda/src/rocket', 'BUILDING:ROCKET', 'ROCKET'] TargetAdd('p3rocket_composite1.obj', opts=OPTS, input='p3rocket_composite1.cxx') + + TargetAdd('libp3rocket.dll', input='p3rocket_composite1.obj') + TargetAdd('libp3rocket.dll', input=COMMON_PANDA_LIBS) + TargetAdd('libp3rocket.dll', opts=OPTS) + IGATEFILES=GetDirectoryContents('panda/src/rocket', ["rocketInputHandler.h", "rocketInputHandler.cxx", "rocketRegion.h", "rocketRegion.cxx", "rocketRegion_ext.h"]) TargetAdd('libp3rocket.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3rocket.in', opts=['IMOD:p3rocket', 'ILIB:libp3rocket', 'SRCDIR:panda/src/rocket']) + TargetAdd('libp3rocket.in', opts=['IMOD:rocket', 'ILIB:libp3rocket', 'SRCDIR:panda/src/rocket']) TargetAdd('libp3rocket_igate.obj', input='libp3rocket.in', opts=["DEPENDENCYONLY"]) - - TargetAdd('libp3rocket_module.obj', input='libp3rocket.in') - TargetAdd('libp3rocket_module.obj', opts=OPTS) - TargetAdd('libp3rocket_module.obj', opts=['IMOD:p3rocket', 'ILIB:libp3rocket']) - TargetAdd('p3rocket_rocketRegion_ext.obj', opts=OPTS, input='rocketRegion_ext.cxx') - TargetAdd('libp3rocket.dll', input='p3rocket_composite1.obj') - TargetAdd('libp3rocket.dll', input='libp3rocket_igate.obj') - TargetAdd('libp3rocket.dll', input='libp3rocket_module.obj') - TargetAdd('libp3rocket.dll', input='p3rocket_rocketRegion_ext.obj') - TargetAdd('libp3rocket.dll', input=COMMON_PANDA_LIBS) - TargetAdd('libp3rocket.dll', opts=OPTS) + TargetAdd('rocket_module.obj', input='libp3rocket.in') + TargetAdd('rocket_module.obj', opts=OPTS) + TargetAdd('rocket_module.obj', opts=['IMOD:rocket', 'ILIB:rocket']) + + TargetAdd('rocket.pyd', input='rocket_module.obj') + TargetAdd('rocket.pyd', input='libp3rocket_igate.obj') + TargetAdd('rocket.pyd', input='p3rocket_rocketRegion_ext.obj') + TargetAdd('rocket.pyd', input='libp3rocket.dll') + TargetAdd('rocket.pyd', opts=['PYTHON']) # # DIRECTORY: panda/src/p3awesomium @@ -3588,19 +3613,22 @@ if PkgSkip("AWESOMIUM") == 0 and not RUNTIME: TargetAdd('pandaawesomium_composite1.obj', opts=OPTS, input='pandaawesomium_composite1.cxx') IGATEFILES=GetDirectoryContents('panda/src/awesomium', ["*.h", "*_composite1.cxx"]) TargetAdd('libp3awesomium.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3awesomium.in', opts=['IMOD:p3awesomium', 'ILIB:libp3awesomium', 'SRCDIR:panda/src/awesomium']) + TargetAdd('libp3awesomium.in', opts=['IMOD:awesomium', 'ILIB:libp3awesomium', 'SRCDIR:panda/src/awesomium']) TargetAdd('libp3awesomium_igate.obj', input='libp3awesomium.in', opts=["DEPENDENCYONLY"]) - TargetAdd('libp3awesomium_module.obj', input='libp3awesomium.in') - TargetAdd('libp3awesomium_module.obj', opts=OPTS) - TargetAdd('libp3awesomium_module.obj', opts=['IMOD:p3awesomium', 'ILIB:libp3awesomium']) - TargetAdd('libp3awesomium.dll', input='pandaawesomium_composite1.obj') - TargetAdd('libp3awesomium.dll', input='libp3awesomium_igate.obj') - TargetAdd('libp3awesomium.dll', input='libp3awesomium_module.obj') TargetAdd('libp3awesomium.dll', input=COMMON_PANDA_LIBS) TargetAdd('libp3awesomium.dll', opts=OPTS) + TargetAdd('awesomium_module.obj', input='libp3awesomium.in') + TargetAdd('awesomium_module.obj', opts=OPTS) + TargetAdd('awesomium_module.obj', opts=['IMOD:awesomium', 'ILIB:awesomium']) + + TargetAdd('awesomium.pyd', input='awesomium_module.obj') + TargetAdd('awesomium.pyd', input='libp3awesomium_igate.obj') + TargetAdd('awesomium.pyd', input='libp3awesomium.dll') + TargetAdd('awesomium.pyd', opts=['PYTHON']) + # # DIRECTORY: panda/src/p3skel # @@ -3610,7 +3638,7 @@ if (PkgSkip('SKEL')==0) and (not RUNTIME): TargetAdd('p3skel_composite1.obj', opts=OPTS, input='p3skel_composite1.cxx') IGATEFILES=GetDirectoryContents("panda/src/skel", ["*.h", "*_composite*.cxx"]) TargetAdd('libp3skel.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3skel.in', opts=['IMOD:pandaskel', 'ILIB:libp3skel', 'SRCDIR:panda/src/skel']) + TargetAdd('libp3skel.in', opts=['IMOD:skel', 'ILIB:libp3skel', 'SRCDIR:panda/src/skel']) TargetAdd('libp3skel_igate.obj', input='libp3skel.in', opts=["DEPENDENCYONLY"]) # @@ -3620,16 +3648,19 @@ if (PkgSkip('SKEL')==0) and (not RUNTIME): if (PkgSkip('SKEL')==0) and (not RUNTIME): OPTS=['BUILDING:PANDASKEL', 'ADVAPI'] - TargetAdd('libpandaskel_module.obj', input='libp3skel.in') - TargetAdd('libpandaskel_module.obj', opts=OPTS) - TargetAdd('libpandaskel_module.obj', opts=['IMOD:pandaskel', 'ILIB:libpandaskel']) - TargetAdd('libpandaskel.dll', input='p3skel_composite1.obj') - TargetAdd('libpandaskel.dll', input='libp3skel_igate.obj') - TargetAdd('libpandaskel.dll', input='libpandaskel_module.obj') TargetAdd('libpandaskel.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpandaskel.dll', opts=OPTS) + TargetAdd('skel_module.obj', input='libp3skel.in') + TargetAdd('skel_module.obj', opts=OPTS) + TargetAdd('skel_module.obj', opts=['IMOD:skel', 'ILIB:skel']) + + TargetAdd('skel.pyd', input='skel_module.obj') + TargetAdd('skel.pyd', input='libp3skel_igate.obj') + TargetAdd('skel.pyd', input='libpandaskel.dll') + TargetAdd('skel.pyd', opts=['PYTHON']) + # # DIRECTORY: panda/src/distort/ # @@ -3639,7 +3670,7 @@ if (PkgSkip('PANDAFX')==0) and (not RUNTIME): TargetAdd('p3distort_composite1.obj', opts=OPTS, input='p3distort_composite1.cxx') IGATEFILES=GetDirectoryContents('panda/src/distort', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3distort.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3distort.in', opts=['IMOD:pandafx', 'ILIB:libp3distort', 'SRCDIR:panda/src/distort']) + TargetAdd('libp3distort.in', opts=['IMOD:fx', 'ILIB:libp3distort', 'SRCDIR:panda/src/distort']) TargetAdd('libp3distort_igate.obj', input='libp3distort.in', opts=["DEPENDENCYONLY"]) # @@ -3650,38 +3681,44 @@ if (PkgSkip('PANDAFX')==0) and (not RUNTIME): OPTS=['DIR:panda/metalibs/pandafx', 'DIR:panda/src/distort', 'BUILDING:PANDAFX', 'NVIDIACG'] TargetAdd('pandafx_pandafx.obj', opts=OPTS, input='pandafx.cxx') - TargetAdd('libpandafx_module.obj', input='libp3distort.in') - TargetAdd('libpandafx_module.obj', opts=OPTS) - TargetAdd('libpandafx_module.obj', opts=['IMOD:pandafx', 'ILIB:libpandafx']) - TargetAdd('libpandafx.dll', input='pandafx_pandafx.obj') - TargetAdd('libpandafx.dll', input='libpandafx_module.obj') TargetAdd('libpandafx.dll', input='p3distort_composite1.obj') - TargetAdd('libpandafx.dll', input='libp3distort_igate.obj') TargetAdd('libpandafx.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpandafx.dll', opts=['ADVAPI', 'NVIDIACG']) + TargetAdd('fx_module.obj', input='libp3distort.in') + TargetAdd('fx_module.obj', opts=OPTS) + TargetAdd('fx_module.obj', opts=['IMOD:fx', 'ILIB:fx']) + + TargetAdd('fx.pyd', input='fx_module.obj') + TargetAdd('fx.pyd', input='libp3distort_igate.obj') + TargetAdd('fx.pyd', input='libpandafx.dll') + TargetAdd('fx.pyd', opts=['PYTHON']) + # # DIRECTORY: panda/src/vrpn/ # if (PkgSkip("VRPN")==0 and not RUNTIME): + TargetAdd('libp3vrpn.dll', input='p3vrpn_composite1.obj') + TargetAdd('libp3vrpn.dll', input=COMMON_PANDA_LIBS) + TargetAdd('libp3vrpn.dll', opts=['VRPN']) + OPTS=['DIR:panda/src/vrpn', 'BUILDING:VRPN', 'VRPN'] TargetAdd('p3vrpn_composite1.obj', opts=OPTS, input='p3vrpn_composite1.cxx') IGATEFILES=GetDirectoryContents('panda/src/vrpn', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3vrpn.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3vrpn.in', opts=['IMOD:p3vrpn', 'ILIB:libp3vrpn', 'SRCDIR:panda/src/vrpn']) + TargetAdd('libp3vrpn.in', opts=['IMOD:vrpn', 'ILIB:libp3vrpn', 'SRCDIR:panda/src/vrpn']) TargetAdd('libp3vrpn_igate.obj', input='libp3vrpn.in', opts=["DEPENDENCYONLY"]) - TargetAdd('libp3vrpn_module.obj', input='libp3vrpn.in') - TargetAdd('libp3vrpn_module.obj', opts=OPTS) - TargetAdd('libp3vrpn_module.obj', opts=['IMOD:p3vrpn', 'ILIB:libp3vrpn']) + TargetAdd('vrpn_module.obj', input='libp3vrpn.in') + TargetAdd('vrpn_module.obj', opts=OPTS) + TargetAdd('vrpn_module.obj', opts=['IMOD:vrpn', 'ILIB:vrpn']) - TargetAdd('libp3vrpn.dll', input='libp3vrpn_module.obj') - TargetAdd('libp3vrpn.dll', input='p3vrpn_composite1.obj') - TargetAdd('libp3vrpn.dll', input='libp3vrpn_igate.obj') - TargetAdd('libp3vrpn.dll', input=COMMON_PANDA_LIBS) - TargetAdd('libp3vrpn.dll', opts=['VRPN']) + TargetAdd('vrpn.pyd', input='vrpn_module.obj') + TargetAdd('vrpn.pyd', input='libp3vrpn_igate.obj') + TargetAdd('vrpn.pyd', input='libp3vrpn.dll') + TargetAdd('vrpn.pyd', opts=['PYTHON']) # # DIRECTORY: panda/src/ffmpeg @@ -3843,8 +3880,9 @@ if (not RUNTIME): IGATEFILES=GetDirectoryContents('panda/src/egg', ["*.h", "*_composite*.cxx"]) if "parser.h" in IGATEFILES: IGATEFILES.remove("parser.h") TargetAdd('libp3egg.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3egg.in', opts=['IMOD:pandaegg', 'ILIB:libp3egg', 'SRCDIR:panda/src/egg']) + TargetAdd('libp3egg.in', opts=['IMOD:egg', 'ILIB:libp3egg', 'SRCDIR:panda/src/egg']) TargetAdd('libp3egg_igate.obj', input='libp3egg.in', opts=["DEPENDENCYONLY"]) + TargetAdd('p3egg_eggGroupNode_ext.obj', opts=OPTS, input='eggGroupNode_ext.cxx') # # DIRECTORY: panda/src/egg2pg/ @@ -3856,7 +3894,7 @@ if (not RUNTIME): TargetAdd('p3egg2pg_composite2.obj', opts=OPTS, input='p3egg2pg_composite2.cxx') IGATEFILES=['load_egg_file.h'] TargetAdd('libp3egg2pg.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3egg2pg.in', opts=['IMOD:pandaegg', 'ILIB:libp3egg2pg', 'SRCDIR:panda/src/egg2pg']) + TargetAdd('libp3egg2pg.in', opts=['IMOD:egg', 'ILIB:libp3egg2pg', 'SRCDIR:panda/src/egg2pg']) TargetAdd('libp3egg2pg_igate.obj', input='libp3egg2pg.in', opts=["DEPENDENCYONLY"]) # @@ -3905,24 +3943,28 @@ if (not RUNTIME): OPTS=['DIR:panda/metalibs/pandaegg', 'DIR:panda/src/egg', 'BUILDING:PANDAEGG'] TargetAdd('pandaegg_pandaegg.obj', opts=OPTS, input='pandaegg.cxx') - TargetAdd('libpandaegg_module.obj', input='libp3egg2pg.in') - TargetAdd('libpandaegg_module.obj', input='libp3egg.in') - TargetAdd('libpandaegg_module.obj', opts=OPTS) - TargetAdd('libpandaegg_module.obj', opts=['IMOD:pandaegg', 'ILIB:libpandaegg']) - TargetAdd('libpandaegg.dll', input='pandaegg_pandaegg.obj') - TargetAdd('libpandaegg.dll', input='libpandaegg_module.obj') TargetAdd('libpandaegg.dll', input='p3egg2pg_composite1.obj') TargetAdd('libpandaegg.dll', input='p3egg2pg_composite2.obj') - TargetAdd('libpandaegg.dll', input='libp3egg2pg_igate.obj') TargetAdd('libpandaegg.dll', input='p3egg_composite1.obj') TargetAdd('libpandaegg.dll', input='p3egg_composite2.obj') TargetAdd('libpandaegg.dll', input='p3egg_parser.obj') TargetAdd('libpandaegg.dll', input='p3egg_lexer.obj') - TargetAdd('libpandaegg.dll', input='libp3egg_igate.obj') TargetAdd('libpandaegg.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpandaegg.dll', opts=['ADVAPI']) + TargetAdd('egg_module.obj', input='libp3egg2pg.in') + TargetAdd('egg_module.obj', input='libp3egg.in') + TargetAdd('egg_module.obj', opts=OPTS) + TargetAdd('egg_module.obj', opts=['IMOD:egg', 'ILIB:egg']) + + TargetAdd('egg.pyd', input='egg_module.obj') + TargetAdd('egg.pyd', input='p3egg_eggGroupNode_ext.obj') + TargetAdd('egg.pyd', input='libp3egg_igate.obj') + TargetAdd('egg.pyd', input='libp3egg2pg_igate.obj') + TargetAdd('egg.pyd', input='libpandaegg.dll') + TargetAdd('egg.pyd', opts=['PYTHON']) + # # DIRECTORY: panda/src/mesadisplay/ # @@ -4065,12 +4107,15 @@ if (PkgSkip("ODE")==0 and not RUNTIME): TargetAdd('p3ode_composite1.obj', opts=OPTS, input='p3ode_composite1.cxx') TargetAdd('p3ode_composite2.obj', opts=OPTS, input='p3ode_composite2.cxx') TargetAdd('p3ode_composite3.obj', opts=OPTS, input='p3ode_composite3.cxx') + TargetAdd('p3ode_ext_composite.obj', opts=OPTS, input='p3ode_ext_composite.cxx') + + OPTS=['DIR:panda/src/ode', 'ODE'] IGATEFILES=GetDirectoryContents('panda/src/ode', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove("odeConvexGeom.h") IGATEFILES.remove("odeHeightFieldGeom.h") IGATEFILES.remove("odeHelperStructs.h") TargetAdd('libpandaode.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libpandaode.in', opts=['IMOD:pandaode', 'ILIB:libpandaode', 'SRCDIR:panda/src/ode']) + TargetAdd('libpandaode.in', opts=['IMOD:ode', 'ILIB:libpandaode', 'SRCDIR:panda/src/ode']) TargetAdd('libpandaode_igate.obj', input='libpandaode.in', opts=["DEPENDENCYONLY"]) # @@ -4080,19 +4125,24 @@ if (PkgSkip("ODE")==0 and not RUNTIME): OPTS=['DIR:panda/metalibs/pandaode', 'BUILDING:PANDAODE', 'ODE'] TargetAdd('pandaode_pandaode.obj', opts=OPTS, input='pandaode.cxx') - TargetAdd('libpandaode_module.obj', input='libpandaode.in') - TargetAdd('libpandaode_module.obj', opts=OPTS) - TargetAdd('libpandaode_module.obj', opts=['IMOD:pandaode', 'ILIB:libpandaode']) - TargetAdd('libpandaode.dll', input='pandaode_pandaode.obj') - TargetAdd('libpandaode.dll', input='libpandaode_module.obj') TargetAdd('libpandaode.dll', input='p3ode_composite1.obj') TargetAdd('libpandaode.dll', input='p3ode_composite2.obj') TargetAdd('libpandaode.dll', input='p3ode_composite3.obj') - TargetAdd('libpandaode.dll', input='libpandaode_igate.obj') TargetAdd('libpandaode.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpandaode.dll', opts=['WINUSER', 'ODE']) + OPTS=['DIR:panda/metalibs/pandaode', 'ODE'] + TargetAdd('ode_module.obj', input='libpandaode.in') + TargetAdd('ode_module.obj', opts=OPTS) + TargetAdd('ode_module.obj', opts=['IMOD:ode', 'ILIB:ode']) + + TargetAdd('ode.pyd', input='ode_module.obj') + TargetAdd('ode.pyd', input='p3ode_ext_composite.obj') + TargetAdd('ode.pyd', input='libpandaode_igate.obj') + TargetAdd('ode.pyd', input='libpandaode.dll') + TargetAdd('ode.pyd', opts=['PYTHON']) + # # DIRECTORY: panda/src/bullet/ # @@ -4101,7 +4151,7 @@ if (PkgSkip("BULLET")==0 and not RUNTIME): TargetAdd('p3bullet_composite.obj', opts=OPTS, input='p3bullet_composite.cxx') IGATEFILES=GetDirectoryContents('panda/src/bullet', ["*.h", "*_composite*.cxx"]) TargetAdd('libpandabullet.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libpandabullet.in', opts=['IMOD:pandabullet', 'ILIB:libpandabullet', 'SRCDIR:panda/src/bullet']) + TargetAdd('libpandabullet.in', opts=['IMOD:bullet', 'ILIB:libpandabullet', 'SRCDIR:panda/src/bullet']) TargetAdd('libpandabullet_igate.obj', input='libpandabullet.in', opts=["DEPENDENCYONLY"]) # @@ -4111,17 +4161,20 @@ if (PkgSkip("BULLET")==0 and not RUNTIME): OPTS=['DIR:panda/metalibs/pandabullet', 'BUILDING:PANDABULLET', 'BULLET'] TargetAdd('pandabullet_pandabullet.obj', opts=OPTS, input='pandabullet.cxx') - TargetAdd('libpandabullet_module.obj', input='libpandabullet.in') - TargetAdd('libpandabullet_module.obj', opts=OPTS) - TargetAdd('libpandabullet_module.obj', opts=['IMOD:pandabullet', 'ILIB:libpandabullet']) - TargetAdd('libpandabullet.dll', input='pandabullet_pandabullet.obj') - TargetAdd('libpandabullet.dll', input='libpandabullet_module.obj') TargetAdd('libpandabullet.dll', input='p3bullet_composite.obj') - TargetAdd('libpandabullet.dll', input='libpandabullet_igate.obj') TargetAdd('libpandabullet.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpandabullet.dll', opts=['WINUSER', 'BULLET']) + TargetAdd('bullet_module.obj', input='libpandabullet.in') + TargetAdd('bullet_module.obj', opts=OPTS) + TargetAdd('bullet_module.obj', opts=['IMOD:bullet', 'ILIB:bullet']) + + TargetAdd('bullet.pyd', input='bullet_module.obj') + TargetAdd('bullet.pyd', input='libpandabullet_igate.obj') + TargetAdd('bullet.pyd', input='libpandabullet.dll') + TargetAdd('bullet.pyd', opts=['PYTHON']) + # # DIRECTORY: panda/src/physx/ # @@ -4131,7 +4184,7 @@ if (PkgSkip("PHYSX")==0): TargetAdd('p3physx_composite.obj', opts=OPTS, input='p3physx_composite.cxx') IGATEFILES=GetDirectoryContents('panda/src/physx', ["*.h", "*_composite*.cxx"]) TargetAdd('libpandaphysx.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libpandaphysx.in', opts=['IMOD:pandaphysx', 'ILIB:libpandaphysx', 'SRCDIR:panda/src/physx']) + TargetAdd('libpandaphysx.in', opts=['IMOD:physx', 'ILIB:libpandaphysx', 'SRCDIR:panda/src/physx']) TargetAdd('libpandaphysx_igate.obj', input='libpandaphysx.in', opts=["DEPENDENCYONLY"]) # @@ -4142,17 +4195,20 @@ if (PkgSkip("PHYSX")==0): OPTS=['DIR:panda/metalibs/pandaphysx', 'BUILDING:PANDAPHYSX', 'PHYSX', 'NOPPC'] TargetAdd('pandaphysx_pandaphysx.obj', opts=OPTS, input='pandaphysx.cxx') - TargetAdd('libpandaphysx_module.obj', input='libpandaphysx.in') - TargetAdd('libpandaphysx_module.obj', opts=OPTS) - TargetAdd('libpandaphysx_module.obj', opts=['IMOD:pandaphysx', 'ILIB:libpandaphysx']) - TargetAdd('libpandaphysx.dll', input='pandaphysx_pandaphysx.obj') - TargetAdd('libpandaphysx.dll', input='libpandaphysx_module.obj') TargetAdd('libpandaphysx.dll', input='p3physx_composite.obj') - TargetAdd('libpandaphysx.dll', input='libpandaphysx_igate.obj') TargetAdd('libpandaphysx.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpandaphysx.dll', opts=['WINUSER', 'PHYSX', 'NOPPC']) + TargetAdd('physx_module.obj', input='libpandaphysx.in') + TargetAdd('physx_module.obj', opts=OPTS) + TargetAdd('physx_module.obj', opts=['IMOD:physx', 'ILIB:physx']) + + TargetAdd('physx.pyd', input='physx_module.obj') + TargetAdd('physx.pyd', input='libpandaphysx_igate.obj') + TargetAdd('physx.pyd', input='libpandaphysx.dll') + TargetAdd('physx.pyd', opts=['PYTHON']) + # # DIRECTORY: panda/src/physics/ # @@ -4164,7 +4220,7 @@ if (PkgSkip("PANDAPHYSICS")==0) and (not RUNTIME): IGATEFILES=GetDirectoryContents('panda/src/physics', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove("forces.h") TargetAdd('libp3physics.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3physics.in', opts=['IMOD:pandaphysics', 'ILIB:libp3physics', 'SRCDIR:panda/src/physics']) + TargetAdd('libp3physics.in', opts=['IMOD:physics', 'ILIB:libp3physics', 'SRCDIR:panda/src/physics']) TargetAdd('libp3physics_igate.obj', input='libp3physics.in', opts=["DEPENDENCYONLY"]) # @@ -4182,7 +4238,7 @@ if (PkgSkip("PANDAPHYSICS")==0) and (PkgSkip("PANDAPARTICLESYSTEM")==0) and (not IGATEFILES.remove('emitters.h') IGATEFILES.remove('particles.h') TargetAdd('libp3particlesystem.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3particlesystem.in', opts=['IMOD:pandaphysics', 'ILIB:libp3particlesystem', 'SRCDIR:panda/src/particlesystem']) + TargetAdd('libp3particlesystem.in', opts=['IMOD:physics', 'ILIB:libp3particlesystem', 'SRCDIR:panda/src/particlesystem']) # # DIRECTORY: panda/metalibs/pandaphysics/ @@ -4192,23 +4248,27 @@ if (PkgSkip("PANDAPHYSICS")==0) and (not RUNTIME): OPTS=['DIR:panda/metalibs/pandaphysics', 'BUILDING:PANDAPHYSICS'] TargetAdd('pandaphysics_pandaphysics.obj', opts=OPTS, input='pandaphysics.cxx') - TargetAdd('libpandaphysics_module.obj', input='libp3physics.in') - if (PkgSkip("PANDAPARTICLESYSTEM")==0): - TargetAdd('libpandaphysics_module.obj', input='libp3particlesystem.in') - TargetAdd('libpandaphysics_module.obj', opts=OPTS) - TargetAdd('libpandaphysics_module.obj', opts=['IMOD:pandaphysics', 'ILIB:libpandaphysics']) - TargetAdd('libpandaphysics.dll', input='pandaphysics_pandaphysics.obj') - TargetAdd('libpandaphysics.dll', input='libpandaphysics_module.obj') TargetAdd('libpandaphysics.dll', input='p3physics_composite1.obj') TargetAdd('libpandaphysics.dll', input='p3physics_composite2.obj') - TargetAdd('libpandaphysics.dll', input='libp3physics_igate.obj') TargetAdd('libpandaphysics.dll', input='p3particlesystem_composite1.obj') TargetAdd('libpandaphysics.dll', input='p3particlesystem_composite2.obj') - TargetAdd('libpandaphysics.dll', input='libp3particlesystem_igate.obj') TargetAdd('libpandaphysics.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpandaphysics.dll', opts=['ADVAPI']) + TargetAdd('physics_module.obj', input='libp3physics.in') + if (PkgSkip("PANDAPARTICLESYSTEM")==0): + TargetAdd('physics_module.obj', input='libp3particlesystem.in') + TargetAdd('physics_module.obj', opts=OPTS) + TargetAdd('physics_module.obj', opts=['IMOD:physics', 'ILIB:physics']) + + TargetAdd('physics.pyd', input='physics_module.obj') + TargetAdd('physics.pyd', input='libp3physics_igate.obj') + if (PkgSkip("PANDAPARTICLESYSTEM")==0): + TargetAdd('physics.pyd', input='libp3particlesystem_igate.obj') + TargetAdd('physics.pyd', input='libpandaphysics.dll') + TargetAdd('physics.pyd', opts=['PYTHON']) + # # DIRECTORY: panda/src/speedtree/ # @@ -4358,7 +4418,7 @@ if (PkgSkip("DIRECT")==0): if "dcParser.h" in IGATEFILES: IGATEFILES.remove("dcParser.h") if "dcmsgtypes.h" in IGATEFILES: IGATEFILES.remove('dcmsgtypes.h') TargetAdd('libp3dcparser.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3dcparser.in', opts=['IMOD:p3direct', 'ILIB:libp3dcparser', 'SRCDIR:direct/src/dcparser']) + TargetAdd('libp3dcparser.in', opts=['IMOD:direct', 'ILIB:libp3dcparser', 'SRCDIR:direct/src/dcparser']) TargetAdd('libp3dcparser_igate.obj', input='libp3dcparser.in', opts=["DEPENDENCYONLY"]) # @@ -4370,7 +4430,7 @@ if (PkgSkip("DIRECT")==0): TargetAdd('p3deadrec_composite1.obj', opts=OPTS, input='p3deadrec_composite1.cxx') IGATEFILES=GetDirectoryContents('direct/src/deadrec', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3deadrec.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3deadrec.in', opts=['IMOD:p3direct', 'ILIB:libp3deadrec', 'SRCDIR:direct/src/deadrec']) + TargetAdd('libp3deadrec.in', opts=['IMOD:direct', 'ILIB:libp3deadrec', 'SRCDIR:direct/src/deadrec']) TargetAdd('libp3deadrec_igate.obj', input='libp3deadrec.in', opts=["DEPENDENCYONLY"]) # @@ -4384,7 +4444,7 @@ if (PkgSkip("DIRECT")==0): TargetAdd('p3distributed_cDistributedSmoothNodeBase.obj', opts=OPTS, input='cDistributedSmoothNodeBase.cxx') IGATEFILES=GetDirectoryContents('direct/src/distributed', ["*.h", "*.cxx"]) TargetAdd('libp3distributed.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3distributed.in', opts=['IMOD:p3direct', 'ILIB:libp3distributed', 'SRCDIR:direct/src/distributed']) + TargetAdd('libp3distributed.in', opts=['IMOD:direct', 'ILIB:libp3distributed', 'SRCDIR:direct/src/distributed']) TargetAdd('libp3distributed_igate.obj', input='libp3distributed.in', opts=["DEPENDENCYONLY"]) # @@ -4396,7 +4456,7 @@ if (PkgSkip("DIRECT")==0): TargetAdd('p3interval_composite1.obj', opts=OPTS, input='p3interval_composite1.cxx') IGATEFILES=GetDirectoryContents('direct/src/interval', ["*.h", "*_composite*.cxx"]) TargetAdd('libp3interval.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3interval.in', opts=['IMOD:p3direct', 'ILIB:libp3interval', 'SRCDIR:direct/src/interval']) + TargetAdd('libp3interval.in', opts=['IMOD:direct', 'ILIB:libp3interval', 'SRCDIR:direct/src/interval']) TargetAdd('libp3interval_igate.obj', input='libp3interval.in', opts=["DEPENDENCYONLY"]) # @@ -4410,7 +4470,7 @@ if (PkgSkip("DIRECT")==0): TargetAdd('p3showbase_showBase_assist.obj', opts=OPTS, input='showBase_assist.mm') IGATEFILES=GetDirectoryContents('direct/src/showbase', ["*.h", "showBase.cxx"]) TargetAdd('libp3showbase.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libp3showbase.in', opts=['IMOD:p3direct', 'ILIB:libp3showbase', 'SRCDIR:direct/src/showbase']) + TargetAdd('libp3showbase.in', opts=['IMOD:direct', 'ILIB:libp3showbase', 'SRCDIR:direct/src/showbase']) TargetAdd('libp3showbase_igate.obj', input='libp3showbase.in', opts=["DEPENDENCYONLY"]) # @@ -4421,16 +4481,7 @@ if (PkgSkip("DIRECT")==0): OPTS=['DIR:direct/metalibs/direct', 'BUILDING:DIRECT'] TargetAdd('p3direct_direct.obj', opts=OPTS, input='direct.cxx') - TargetAdd('libp3direct_module.obj', input='libp3dcparser.in') - TargetAdd('libp3direct_module.obj', input='libp3showbase.in') - TargetAdd('libp3direct_module.obj', input='libp3deadrec.in') - TargetAdd('libp3direct_module.obj', input='libp3interval.in') - TargetAdd('libp3direct_module.obj', input='libp3distributed.in') - TargetAdd('libp3direct_module.obj', opts=OPTS) - TargetAdd('libp3direct_module.obj', opts=['IMOD:p3direct', 'ILIB:libp3direct']) - TargetAdd('libp3direct.dll', input='p3direct_direct.obj') - TargetAdd('libp3direct.dll', input='libp3direct_module.obj') TargetAdd('libp3direct.dll', input='p3directbase_directbase.obj') TargetAdd('libp3direct.dll', input='p3dcparser_composite1.obj') TargetAdd('libp3direct.dll', input='p3dcparser_composite2.obj') @@ -4452,6 +4503,18 @@ if (PkgSkip("DIRECT")==0): TargetAdd('libp3direct.dll', input=COMMON_PANDA_LIBS) TargetAdd('libp3direct.dll', opts=['ADVAPI', 'OPENSSL', 'WINUSER', 'WINGDI']) + TargetAdd('direct_module.obj', input='libp3dcparser.in') + TargetAdd('direct_module.obj', input='libp3showbase.in') + TargetAdd('direct_module.obj', input='libp3deadrec.in') + TargetAdd('direct_module.obj', input='libp3interval.in') + TargetAdd('direct_module.obj', input='libp3distributed.in') + TargetAdd('direct_module.obj', opts=OPTS) + TargetAdd('direct_module.obj', opts=['IMOD:direct', 'ILIB:direct']) + + TargetAdd('direct.pyd', input='direct_module.obj') + TargetAdd('direct.pyd', input='libp3direct.dll') + TargetAdd('direct.pyd', opts=['PYTHON']) + # # DIRECTORY: direct/src/dcparse/ # @@ -5628,18 +5691,20 @@ if (PkgSkip("CONTRIB")==0 and not RUNTIME): TargetAdd('p3ai_composite1.obj', opts=OPTS, input='p3ai_composite1.cxx') IGATEFILES=GetDirectoryContents('contrib/src/ai', ["*.h", "*_composite*.cxx"]) TargetAdd('libpandaai.in', opts=OPTS, input=IGATEFILES) - TargetAdd('libpandaai.in', opts=['IMOD:pandaai', 'ILIB:libpandaai', 'SRCDIR:contrib/src/ai']) + TargetAdd('libpandaai.in', opts=['IMOD:ai', 'ILIB:libpandaai', 'SRCDIR:contrib/src/ai']) TargetAdd('libpandaai_igate.obj', input='libpandaai.in', opts=["DEPENDENCYONLY"]) - TargetAdd('libpandaai_module.obj', input='libpandaai.in') - TargetAdd('libpandaai_module.obj', opts=OPTS) - TargetAdd('libpandaai_module.obj', opts=['IMOD:pandaai', 'ILIB:libpandaai']) - - TargetAdd('libpandaai.dll', input='libpandaai_module.obj') TargetAdd('libpandaai.dll', input='p3ai_composite1.obj') - TargetAdd('libpandaai.dll', input='libpandaai_igate.obj') TargetAdd('libpandaai.dll', input=COMMON_PANDA_LIBS) + TargetAdd('ai_module.obj', input='libpandaai.in') + TargetAdd('ai_module.obj', opts=OPTS) + TargetAdd('ai_module.obj', opts=['IMOD:ai', 'ILIB:ai']) + + TargetAdd('ai.pyd', input='ai_module.obj') + TargetAdd('ai.pyd', input='libpandaai_igate.obj') + TargetAdd('ai.pyd', opts=['PYTHON']) + # # Run genpycode # @@ -5650,25 +5715,24 @@ if (PkgSkip("PYTHON")==0 and not RUNTIME): # split them out of libpanda and need to maintain backward # compatibility with old imports. See direct/src/ffi/panda3d.py - TargetAdd('PandaModules.py', input='libpandaexpress.dll') - TargetAdd('PandaModules.py', input='libpanda.dll') + TargetAdd('PandaModules.py', input='core.pyd') if (PkgSkip("PANDAPHYSICS")==0): - TargetAdd('PandaModules.py', input='libpandaphysics.dll') + TargetAdd('PandaModules.py', input='physics.pyd') if (PkgSkip('PANDAFX')==0): - TargetAdd('PandaModules.py', input='libpandafx.dll') + TargetAdd('PandaModules.py', input='fx.pyd') if (PkgSkip("DIRECT")==0): - TargetAdd('PandaModules.py', input='libp3direct.dll') + TargetAdd('PandaModules.py', input='direct.pyd') if (PkgSkip("VISION")==0): - TargetAdd('PandaModules.py', input='libp3vision.dll') + TargetAdd('PandaModules.py', input='vision.pyd') if (PkgSkip("SKEL")==0): - TargetAdd('PandaModules.py', input='libpandaskel.dll') - TargetAdd('PandaModules.py', input='libpandaegg.dll') + TargetAdd('PandaModules.py', input='skel.pyd') + TargetAdd('PandaModules.py', input='egg.pyd') if (PkgSkip("AWESOMIUM")==0): - TargetAdd('PandaModules.py', input='libp3awesomium.dll') + TargetAdd('PandaModules.py', input='awesomium.pyd') if (PkgSkip("ODE")==0): - TargetAdd('PandaModules.py', input='libpandaode.dll') + TargetAdd('PandaModules.py', input='ode.pyd') if (PkgSkip("VRPN")==0): - TargetAdd('PandaModules.py', input='libp3vrpn.dll') + TargetAdd('PandaModules.py', input='vrpn.pyd') # # Generate the models directory and samples directory @@ -5762,8 +5826,12 @@ for target in TARGET_LIST: DEPENDENCYQUEUE.append([CompileAnything, [name, inputs, opts], [name], deps, []]) def BuildWorker(taskqueue, donequeue): - while (1): - task = taskqueue.get() + while True: + try: + task = taskqueue.get(timeout=1) + except: + ProgressOutput(None, "Waiting for tasks...") + task = taskqueue.get() sys.stdout.flush() if (task == 0): return try: diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 50b079bcde..e39f5b213b 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -9,13 +9,15 @@ ## ######################################################################## -import sys,os,time,stat,string,re,getopt,fnmatch,threading,signal,shutil,platform,glob,getpass,signal,thread +import sys,os,time,stat,string,re,getopt,fnmatch,threading,signal,shutil,platform,glob,getpass,signal from distutils import sysconfig if sys.version_info >= (3, 0): import pickle + import _thread as thread else: import cPickle as pickle + import thread SUFFIX_INC = [".cxx",".c",".h",".I",".yxx",".lxx",".mm",".rc",".r"] SUFFIX_DLL = [".dll",".dlo",".dle",".dli",".dlm",".mll",".exe",".pyd",".ocx"] @@ -694,11 +696,16 @@ def CxxGetIncludes(path): except: exit("Cannot open source file \""+path+"\" for reading.") include = [] - for line in sfile: - match = CxxIncludeRegex.match(line,0) - if (match): - incname = match.group(1) - include.append(incname) + try: + for line in sfile: + match = CxxIncludeRegex.match(line,0) + if (match): + incname = match.group(1) + include.append(incname) + except: + print("Failed to determine dependencies of \""+path+"\".") + raise + sfile.close() CXXINCLUDECACHE[path] = [date, include] return include @@ -1062,6 +1069,8 @@ def MakeBuildTree(): MakeDirectory(OUTPUTDIR + "/models/gui") MakeDirectory(OUTPUTDIR + "/pandac") MakeDirectory(OUTPUTDIR + "/pandac/input") + MakeDirectory(OUTPUTDIR + "/panda3d") + CreateFile(OUTPUTDIR + "/panda3d/__init__.py") if GetTarget() == 'android': MakeDirectory(OUTPUTDIR + "/libs") @@ -2412,10 +2421,10 @@ def ParsePandaVersion(fn): f = open(fn, "r") pattern = re.compile('^[ \t]*[#][ \t]*define[ \t]+PANDA_VERSION[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)') for line in f: - match = pattern.match(line,0) + match = pattern.match(line, 0) if (match): f.close() - return match.group(1)+"."+match.group(2)+"."+match.group(3) + return match.group(1) + "." + match.group(2) + "." + match.group(3) f.close() except: pass return "0.0.0" @@ -2428,7 +2437,7 @@ def ParsePluginVersion(fn): match = pattern.match(line,0) if (match): f.close() - return match.group(1)+"."+match.group(2)+"."+match.group(3) + return match.group(1) + "." + match.group(2) + "." + match.group(3) f.close() except: pass return "0.0.0" @@ -2522,7 +2531,7 @@ def WriteResourceFile(basename, **kwargs): ## ######################################################################## -ORIG_EXT={} +ORIG_EXT = {} def GetOrigExt(x): return ORIG_EXT[x] @@ -2556,7 +2565,7 @@ def CalcLocation(fn, ipath): if (fn.endswith(".res")): return OUTPUTDIR+"/tmp/"+fn if (fn.endswith(".tlb")): return OUTPUTDIR+"/tmp/"+fn if (fn.endswith(".dll")): return OUTPUTDIR+"/bin/"+fn[:-4]+dllext+".dll" - if (fn.endswith(".pyd")): return OUTPUTDIR+"/bin/"+fn[:-4]+dllext+".pyd" + if (fn.endswith(".pyd")): return OUTPUTDIR+"/panda3d/"+fn[:-4]+dllext+".pyd" if (fn.endswith(".ocx")): return OUTPUTDIR+"/plugins/"+fn[:-4]+dllext+".ocx" if (fn.endswith(".mll")): return OUTPUTDIR+"/plugins/"+fn[:-4]+dllext+".mll" if (fn.endswith(".dlo")): return OUTPUTDIR+"/plugins/"+fn[:-4]+dllext+".dlo" @@ -2572,7 +2581,7 @@ def CalcLocation(fn, ipath): if (fn.endswith(".plist")): return CxxFindSource(fn, ipath) if (fn.endswith(".obj")): return OUTPUTDIR+"/tmp/"+fn[:-4]+".o" if (fn.endswith(".dll")): return OUTPUTDIR+"/lib/"+fn[:-4]+".dylib" - if (fn.endswith(".pyd")): return OUTPUTDIR+"/lib/"+fn[:-4]+".so" + if (fn.endswith(".pyd")): return OUTPUTDIR+"/panda3d/"+fn[:-4]+".so" if (fn.endswith(".mll")): return OUTPUTDIR+"/plugins/"+fn if (fn.endswith(".exe")): return OUTPUTDIR+"/bin/"+fn[:-4] if (fn.endswith(".lib")): return OUTPUTDIR+"/lib/"+fn[:-4]+".a" @@ -2593,7 +2602,7 @@ def CalcLocation(fn, ipath): else: if (fn.endswith(".obj")): return OUTPUTDIR+"/tmp/"+fn[:-4]+".o" if (fn.endswith(".dll")): return OUTPUTDIR+"/lib/"+fn[:-4]+".so" - if (fn.endswith(".pyd")): return OUTPUTDIR+"/lib/"+fn[:-4]+".so" + if (fn.endswith(".pyd")): return OUTPUTDIR+"/panda3d/"+fn[:-4]+".so" if (fn.endswith(".mll")): return OUTPUTDIR+"/plugins/"+fn if (fn.endswith(".plugin")):return OUTPUTDIR+"/plugins/"+fn[:-7]+dllext+".so" if (fn.endswith(".exe")): return OUTPUTDIR+"/bin/"+fn[:-4] @@ -2669,6 +2678,11 @@ def TargetAdd(target, dummy=0, opts=0, input=0, dep=0, ipath=0, winrc=0): if (ipath == 0): ipath = [] if (type(input) == str): input = [input] if (type(dep) == str): dep = [dep] + + if os.path.splitext(target)[1] == '.pyd' and PkgSkip("PYTHON"): + # It makes no sense to build Python modules with python disabled. + return + full = FindLocation(target, [OUTPUTDIR + "/include"]) if (full not in TARGET_TABLE): diff --git a/panda/src/display/Sources.pp b/panda/src/display/Sources.pp index 99a8cca70b..b2f093957a 100644 --- a/panda/src/display/Sources.pp +++ b/panda/src/display/Sources.pp @@ -27,8 +27,8 @@ graphicsDevice.h graphicsDevice.I \ graphicsPipe.I graphicsPipe.h \ graphicsPipeSelection.I graphicsPipeSelection.h \ - graphicsStateGuardian.I \ - graphicsStateGuardian.h \ + graphicsStateGuardian.I graphicsStateGuardian.h \ + graphicsStateGuardian_ext.cxx graphicsStateGuardian_ext.h \ graphicsThreadingModel.I graphicsThreadingModel.h \ graphicsWindow.I graphicsWindow.h \ graphicsWindowInputDevice.I \ diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 5e67cb81e7..4aea74171a 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -59,13 +59,6 @@ #include #include -#ifdef HAVE_PYTHON -#include "py_panda.h" -#ifndef CPPPARSER -IMPORT_THIS struct Dtool_PyTypedObject Dtool_Texture; -#endif -#endif // HAVE_PYTHON - PStatCollector GraphicsStateGuardian::_vertex_buffer_switch_pcollector("Vertex buffer switch:Vertex"); PStatCollector GraphicsStateGuardian::_index_buffer_switch_pcollector("Vertex buffer switch:Index"); PStatCollector GraphicsStateGuardian::_load_vertex_buffer_pcollector("Draw:Transfer data:Vertex buffer"); @@ -247,10 +240,10 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system, // The default is no shader support. _auto_detect_shader_model = SM_00; _shader_model = SM_00; - + _gamma = 1.0f; _texture_quality_override = Texture::QL_default; - + _shader_generator = NULL; } @@ -435,41 +428,6 @@ void GraphicsStateGuardian:: restore_gamma() { } -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_prepared_textures -// Access: Published -// Description: Returns a Python list of all of the -// currently-prepared textures within the GSG. -//////////////////////////////////////////////////////////////////// -PyObject *GraphicsStateGuardian:: -get_prepared_textures() const { - ReMutexHolder holder(_prepared_objects->_lock); - size_t num_textures = _prepared_objects->_prepared_textures.size(); - PyObject *list = PyList_New(num_textures); - - size_t i = 0; - PreparedGraphicsObjects::Textures::const_iterator ti; - for (ti = _prepared_objects->_prepared_textures.begin(); - ti != _prepared_objects->_prepared_textures.end(); - ++ti) { - PT(Texture) tex = (*ti)->get_texture(); - - PyObject *element = - DTool_CreatePyInstanceTyped(tex, Dtool_Texture, - true, false, tex->get_type_index()); - tex->ref(); - - nassertr(i < num_textures, NULL); - PyList_SetItem(list, i, element); - ++i; - } - nassertr(i == num_textures, NULL); - - return list; -} -#endif // HAVE_PYTHON - //////////////////////////////////////////////////////////////////// // Function: GraphicsStateGuardian::traverse_prepared_textures // Access: Public @@ -485,7 +443,7 @@ traverse_prepared_textures(GraphicsStateGuardian::TextureCallback *func, for (ti = _prepared_objects->_prepared_textures.begin(); ti != _prepared_objects->_prepared_textures.end(); ++ti) { - bool result = (*func)(*ti,callback_arg); + bool result = (*func)(*ti, callback_arg); if (!result) { return; } @@ -2473,11 +2431,11 @@ determine_target_texture() { target_tex_gen != (TexGenAttrib *)NULL); _target_texture = target_texture; _target_tex_gen = target_tex_gen; - + if (_has_texture_alpha_scale) { PT(TextureStage) stage = get_alpha_scale_texture_stage(); PT(Texture) texture = TexturePool::get_alpha_scale_map(); - + _target_texture = DCAST(TextureAttrib, _target_texture->add_on_stage(stage, texture)); _target_tex_gen = DCAST(TexGenAttrib, _target_tex_gen->add_stage (stage, TexGenAttrib::M_constant, LTexCoord3(_current_color_scale[3], 0.0f, 0.0f))); @@ -2801,6 +2759,9 @@ string GraphicsStateGuardian::get_driver_renderer() { // Function: GraphicsStateGuardian::get_driver_version // Access: Public, Virtual // Description: Returns driver version +// This has an implementation-defined meaning, and may +// be "0" if the particular graphics implementation +// does not provide a way to query this information. //////////////////////////////////////////////////////////////////// string GraphicsStateGuardian:: get_driver_version() { @@ -2810,7 +2771,10 @@ get_driver_version() { //////////////////////////////////////////////////////////////////// // Function: GraphicsStateGuardian::get_driver_version_major // Access: Public, Virtual -// Description: Returns major version of the video driver +// Description: Returns major version of the video driver. +// This has an implementation-defined meaning, and may +// be -1 if the particular graphics implementation +// does not provide a way to query this information. //////////////////////////////////////////////////////////////////// int GraphicsStateGuardian:: get_driver_version_major() { @@ -2820,7 +2784,10 @@ get_driver_version_major() { //////////////////////////////////////////////////////////////////// // Function: GraphicsStateGuardian::get_driver_version_minor // Access: Public, Virtual -// Description: Returns the minor version of the video driver +// Description: Returns the minor version of the video driver. +// This has an implementation-defined meaning, and may +// be -1 if the particular graphics implementation +// does not provide a way to query this information. //////////////////////////////////////////////////////////////////// int GraphicsStateGuardian:: get_driver_version_minor() { @@ -2830,7 +2797,7 @@ get_driver_version_minor() { //////////////////////////////////////////////////////////////////// // Function: GraphicsStateGuardian::get_driver_shader_version_major // Access: Public, Virtual -// Description: Returns the major version of the shader model +// Description: Returns the major version of the shader model. //////////////////////////////////////////////////////////////////// int GraphicsStateGuardian:: get_driver_shader_version_major() { @@ -2840,7 +2807,7 @@ get_driver_shader_version_major() { //////////////////////////////////////////////////////////////////// // Function: GraphicsStateGuardian::get_driver_shader_version_minor // Access: Public, Virtual -// Description: Returns the minor version of the shader model +// Description: Returns the minor version of the shader model. //////////////////////////////////////////////////////////////////// int GraphicsStateGuardian:: get_driver_shader_version_minor() { diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index ce2c41bc93..d5a5f08eec 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -46,9 +46,9 @@ #include "occlusionQueryContext.h" #include "stencilRenderStates.h" #include "loader.h" -#include "textureAttrib.h" -#include "texGenAttrib.h" #include "shaderAttrib.h" +#include "texGenAttrib.h" +#include "textureAttrib.h" class DrawableRegion; class GraphicsEngine; @@ -179,9 +179,7 @@ PUBLISHED: INLINE void set_texture_quality_override(Texture::QualityLevel quality_level); INLINE Texture::QualityLevel get_texture_quality_override() const; -#ifdef HAVE_PYTHON - PyObject *get_prepared_textures() const; -#endif + EXTENSION(PyObject *get_prepared_textures() const); typedef bool TextureCallback(TextureContext *tc, void *callback_arg); void traverse_prepared_textures(TextureCallback *func, void *callback_arg); diff --git a/panda/src/egg/Sources.pp b/panda/src/egg/Sources.pp index 49757317ae..cc68e22b52 100644 --- a/panda/src/egg/Sources.pp +++ b/panda/src/egg/Sources.pp @@ -24,6 +24,7 @@ eggCurve.I eggCurve.h eggData.I eggData.h \ eggExternalReference.I eggExternalReference.h \ eggFilenameNode.I eggFilenameNode.h eggGroup.I eggGroup.h \ + eggGroupNode_ext.h \ eggGroupNode.I eggGroupNode.h eggGroupUniquifier.h \ eggLine.I eggLine.h \ eggMaterial.I eggMaterial.h eggMaterialCollection.I \ @@ -69,7 +70,8 @@ eggCompositePrimitive.cxx \ eggCoordinateSystem.cxx \ eggCurve.cxx eggData.cxx eggExternalReference.cxx \ - eggFilenameNode.cxx eggGroup.cxx eggGroupNode.cxx \ + eggFilenameNode.cxx eggGroup.cxx \ + eggGroupNode_ext.cxx eggGroupNode.cxx \ eggGroupUniquifier.cxx eggLine.cxx eggMaterial.cxx \ eggMaterialCollection.cxx \ eggMesher.cxx \ @@ -106,7 +108,8 @@ eggCoordinateSystem.I eggCoordinateSystem.h eggCurve.I \ eggCurve.h eggData.I eggData.h eggExternalReference.I \ eggExternalReference.h eggFilenameNode.I eggFilenameNode.h \ - eggGroup.I eggGroup.h eggGroupNode.I eggGroupNode.h \ + eggGroup.I eggGroup.h \ + eggGroupNode_ext.h eggGroupNode.I eggGroupNode.h \ eggGroupUniquifier.h \ eggLine.I eggLine.h \ eggMaterial.I \ diff --git a/panda/src/egg/eggGroupNode.h b/panda/src/egg/eggGroupNode.h index 7e6bc358f9..ffdfcb304c 100644 --- a/panda/src/egg/eggGroupNode.h +++ b/panda/src/egg/eggGroupNode.h @@ -113,6 +113,8 @@ PUBLISHED: EggNode *get_first_child(); EggNode *get_next_child(); + EXTENSION(PyObject *get_children() const); + EggNode *add_child(EggNode *node); PT(EggNode) remove_child(EggNode *node); void steal_children(EggGroupNode &other); diff --git a/panda/src/event/pythonTask.cxx b/panda/src/event/pythonTask.cxx index 66d3d6bfa6..ec18eff5ec 100644 --- a/panda/src/event/pythonTask.cxx +++ b/panda/src/event/pythonTask.cxx @@ -158,7 +158,7 @@ get_args() { } this->ref(); - PyObject *self = + PyObject *self = DTool_CreatePyInstanceTyped(this, Dtool_TypedReferenceCount, true, false, get_type_index()); PyTuple_SET_ITEM(with_task, num_args, self); diff --git a/panda/src/express/Sources.pp b/panda/src/express/Sources.pp index e64467fbba..dcec931471 100644 --- a/panda/src/express/Sources.pp +++ b/panda/src/express/Sources.pp @@ -6,7 +6,7 @@ #define TARGET p3express #define USE_PACKAGES zlib openssl tar - #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx + #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx $[TARGET]_ext_composite.cxx #define SOURCES \ buffer.I buffer.h \ @@ -31,6 +31,7 @@ memoryUsage.I memoryUsage.h \ memoryUsagePointerCounts.I memoryUsagePointerCounts.h \ memoryUsagePointers.I memoryUsagePointers.h \ + memoryUsagePointers_ext.h \ multifile.I multifile.h \ namable.I \ namable.h \ @@ -51,10 +52,11 @@ pta_int.h \ pta_uchar.h pta_double.h pta_float.h \ pta_stdfloat.h \ - ramfile.I ramfile.h \ + ramfile.I ramfile.h ramfile_ext.h \ referenceCount.I referenceCount.h \ subStream.I subStream.h subStreamBuf.h \ subfileInfo.h subfileInfo.I \ + streamReader_ext.h \ temporaryFile.h temporaryFile.I \ threadSafePointerTo.I threadSafePointerTo.h \ threadSafePointerToBase.I threadSafePointerToBase.h \ @@ -70,7 +72,7 @@ virtualFileMountSystem.h virtualFileMountSystem.I \ virtualFileSimple.h virtualFileSimple.I \ virtualFileSystem.h virtualFileSystem.I \ - virtualFileSystem_ext.h virtualFileSystem_ext.cxx \ + virtualFileSystem_ext.h \ weakPointerCallback.I weakPointerCallback.h \ weakPointerTo.I weakPointerTo.h \ weakPointerToBase.I weakPointerToBase.h \ @@ -92,6 +94,7 @@ fileReference.cxx \ hashGeneratorBase.cxx hashVal.cxx \ memoryInfo.cxx memoryUsage.cxx memoryUsagePointerCounts.cxx \ + memoryUsagePointers_ext.cxx \ memoryUsagePointers.cxx multifile.cxx \ namable.cxx \ nodePointerTo.cxx \ @@ -109,8 +112,10 @@ profileTimer.cxx \ pta_int.cxx \ pta_uchar.cxx pta_double.cxx pta_float.cxx \ + ramfile_ext.cxx \ ramfile.cxx \ referenceCount.cxx \ + streamReader_ext.cxx \ subStream.cxx subStreamBuf.cxx \ subfileInfo.cxx \ temporaryFile.cxx \ @@ -125,6 +130,7 @@ virtualFileMountRamdisk.cxx \ virtualFileMountSystem.cxx \ virtualFileSimple.cxx virtualFileSystem.cxx \ + virtualFileSystem_ext.cxx \ weakPointerCallback.cxx \ weakPointerTo.cxx \ weakPointerToBase.cxx \ diff --git a/panda/src/express/memoryUsagePointers.cxx b/panda/src/express/memoryUsagePointers.cxx index 3fffa0d898..4a590f3661 100644 --- a/panda/src/express/memoryUsagePointers.cxx +++ b/panda/src/express/memoryUsagePointers.cxx @@ -20,20 +20,6 @@ #include "referenceCount.h" #include "typedReferenceCount.h" -#ifdef HAVE_PYTHON -// Pick up a few declarations so we can create Python wrappers in -// get_python_pointer(), below. - -#include "py_panda.h" - -#ifndef CPPPARSER -extern EXPCL_PANDAEXPRESS Dtool_PyTypedObject Dtool_TypedObject; -extern EXPCL_PANDAEXPRESS Dtool_PyTypedObject Dtool_TypedReferenceCount; -extern EXPCL_PANDAEXPRESS Dtool_PyTypedObject Dtool_ReferenceCount; -#endif // CPPPARSER - -#endif // HAVE_PYTHON - //////////////////////////////////////////////////////////////////// // Function: MemoryUsagePointers::Constructor // Access: Published @@ -151,65 +137,6 @@ get_age(int n) const { return _entries[n]._age; } -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::get_python_pointer -// Access: Published -// Description: Returns the nth object, represented as a Python -// object of the appropriate type. Reference counting -// will be properly set on the Python object. -// -// get_typed_pointer() is almost as good as this, but -// (a) it does not set the reference count, and (b) it -// does not work for objects that do not inherit from -// TypedObject. This will work for any object whose -// type is known, which has a Python representation. -//////////////////////////////////////////////////////////////////// -PyObject *MemoryUsagePointers:: -get_python_pointer(int n) const { - nassertr(n >= 0 && n < get_num_pointers(), NULL); - TypedObject *typed_ptr = _entries[n]._typed_ptr; - ReferenceCount *ref_ptr = _entries[n]._ref_ptr; - - bool memory_rules = false; - if (ref_ptr != (ReferenceCount *)NULL) { - memory_rules = true; - ref_ptr->ref(); - } - - if (typed_ptr != (TypedObject *)NULL) { - return DTool_CreatePyInstanceTyped(typed_ptr, Dtool_TypedObject, - memory_rules, false, - typed_ptr->get_type_index()); - } - - if (ref_ptr == (ReferenceCount *)NULL) { - return Py_BuildValue(""); - } - - TypeHandle type = _entries[n]._type; - if (type != TypeHandle::none()) { - // Use TypedReferenceCount if we have it. - if (type.is_derived_from(TypedReferenceCount::get_class_type())) { - TypedReferenceCount *typed_ref_ptr = (TypedReferenceCount *)ref_ptr; - - return DTool_CreatePyInstanceTyped(typed_ref_ptr, Dtool_TypedReferenceCount, - memory_rules, false, - type.get_index()); - } - - // Otherwise, trust that there is a downcast path to the actual type. - return DTool_CreatePyInstanceTyped(ref_ptr, Dtool_ReferenceCount, - memory_rules, false, - type.get_index()); - } - - // If worse comes to worst, just return a ReferenceCount wrapper. - return DTool_CreatePyInstance(ref_ptr, Dtool_ReferenceCount, - memory_rules, false); -} -#endif - //////////////////////////////////////////////////////////////////// // Function: MemoryUsagePointers::clear // Access: Published diff --git a/panda/src/express/memoryUsagePointers.h b/panda/src/express/memoryUsagePointers.h index 7192cea41f..ceab784752 100644 --- a/panda/src/express/memoryUsagePointers.h +++ b/panda/src/express/memoryUsagePointers.h @@ -67,9 +67,7 @@ PUBLISHED: string get_type_name(int n) const; double get_age(int n) const; -#ifdef HAVE_PYTHON - PyObject *get_python_pointer(int n) const; -#endif + EXTENSION(PyObject *get_python_pointer(int n) const); void clear(); diff --git a/panda/src/express/memoryUsagePointers_ext.cxx b/panda/src/express/memoryUsagePointers_ext.cxx new file mode 100644 index 0000000000..eee3b5d0e6 --- /dev/null +++ b/panda/src/express/memoryUsagePointers_ext.cxx @@ -0,0 +1,72 @@ +// Filename: memoryUsagePointers_ext.cxx +// Created by: rdb (10Dec13) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#include "memoryUsagePointers_ext.h" + +#if defined(HAVE_PYTHON) && defined(DO_MEMORY_USAGE) + +#ifndef CPPPARSER +extern EXPCL_PANDAEXPRESS Dtool_PyTypedObject Dtool_TypedObject; +extern EXPCL_PANDAEXPRESS Dtool_PyTypedObject Dtool_TypedReferenceCount; +extern EXPCL_PANDAEXPRESS Dtool_PyTypedObject Dtool_ReferenceCount; +#endif // CPPPARSER + +//////////////////////////////////////////////////////////////////// +// Function: MemoryUsagePointers::get_python_pointer +// Access: Published +// Description: Returns the nth object, represented as a Python +// object of the appropriate type. Reference counting +// will be properly set on the Python object. +// +// get_typed_pointer() is almost as good as this, but +// (a) it does not set the reference count, and (b) it +// does not work for objects that do not inherit from +// TypedObject. This will work for any object whose +// type is known, which has a Python representation. +//////////////////////////////////////////////////////////////////// +PyObject *Extension:: +get_python_pointer(int n) const { + TypedObject *typed_ptr = _this->get_typed_pointer(n); + ReferenceCount *ref_ptr = _this->get_pointer(n); + + bool memory_rules = false; + if (ref_ptr != (ReferenceCount *)NULL) { + memory_rules = true; + ref_ptr->ref(); + } + + if (typed_ptr != (TypedObject *)NULL) { + return DTool_CreatePyInstanceTyped(typed_ptr, Dtool_TypedObject, + memory_rules, false, + typed_ptr->get_type_index()); + } + + if (ref_ptr == (ReferenceCount *)NULL) { + return Py_BuildValue(""); + } + + TypeHandle type = _this->get_type(n); + if (type != TypeHandle::none()) { + // Trust that there is a downcast path to the actual type. + return DTool_CreatePyInstanceTyped(ref_ptr, Dtool_ReferenceCount, + memory_rules, false, + type.get_index()); + } + + // If worse comes to worst, just return a ReferenceCount wrapper. + return DTool_CreatePyInstance(ref_ptr, Dtool_ReferenceCount, + memory_rules, false); +} + +#endif // HAVE_PYTHON && DO_MEMORY_USAGE diff --git a/panda/src/express/memoryUsagePointers_ext.h b/panda/src/express/memoryUsagePointers_ext.h new file mode 100644 index 0000000000..3b4e9c7478 --- /dev/null +++ b/panda/src/express/memoryUsagePointers_ext.h @@ -0,0 +1,40 @@ +// Filename: memoryUsagePointers_ext.h +// Created by: rdb (10Dec13) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#ifndef MEMORYUSAGEPOINTERS_EXT_H +#define MEMORYUSAGEPOINTERS_EXT_H + +#include "dtoolbase.h" + +#if defined(HAVE_PYTHON) && defined(DO_MEMORY_USAGE) + +#include "extension.h" +#include "memoryUsagePointers.h" +#include "py_panda.h" + +//////////////////////////////////////////////////////////////////// +// Class : Extension +// Description : This class defines the extension methods for +// VirtualFileSystem, which are called instead of +// any C++ methods with the same prototype. +//////////////////////////////////////////////////////////////////// +template<> +class Extension : public ExtensionBase { +public: + PyObject *get_python_pointer(int n) const; +}; + +#endif // HAVE_PYTHON && DO_MEMORY_USAGE + +#endif // MEMORYUSAGEPOINTERS_EXT_H diff --git a/panda/src/express/p3express_ext_composite.cxx b/panda/src/express/p3express_ext_composite.cxx new file mode 100644 index 0000000000..88dd271158 --- /dev/null +++ b/panda/src/express/p3express_ext_composite.cxx @@ -0,0 +1,4 @@ +#include "memoryUsagePointers_ext.cxx" +#include "ramfile_ext.cxx" +#include "streamReader_ext.cxx" +#include "virtualFileSystem_ext.cxx" diff --git a/panda/src/express/ramfile.h b/panda/src/express/ramfile.h index 8f3dafe8cf..d8006400a4 100644 --- a/panda/src/express/ramfile.h +++ b/panda/src/express/ramfile.h @@ -32,6 +32,7 @@ PUBLISHED: INLINE size_t tell() const; string read(size_t length); string readline(); + EXTENSION(PyObject *readlines()); INLINE const string &get_data() const; INLINE size_t get_data_size() const; diff --git a/panda/src/express/ramfile_ext.cxx b/panda/src/express/ramfile_ext.cxx new file mode 100644 index 0000000000..366395df8d --- /dev/null +++ b/panda/src/express/ramfile_ext.cxx @@ -0,0 +1,48 @@ +// Filename: ramfile_ext.cxx +// Created by: rdb (10Dec13) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#include "ramfile_ext.h" + +#ifdef HAVE_PYTHON + +//////////////////////////////////////////////////////////////////// +// Function: Ramfile::readlines +// Access: Published +// Description: Reads all the lines at once and returns a list. +// Also see the documentation for readline(). +//////////////////////////////////////////////////////////////////// +PyObject *Extension:: +readlines() { + PyObject *lst = PyList_New(0); + if (lst == NULL) { + return NULL; + } + + string line = _this->readline(); + while (!line.empty()) { +#if PY_MAJOR_VERSION >= 3 + PyObject *py_line = PyBytes_FromStringAndSize(line.data(), line.size()); +#else + PyObject *py_line = PyString_FromStringAndSize(line.data(), line.size()); +#endif + + PyList_Append(lst, py_line); + Py_DECREF(py_line); + } + + return lst; +} + +#endif + diff --git a/panda/src/express/ramfile_ext.h b/panda/src/express/ramfile_ext.h new file mode 100644 index 0000000000..8f90eb52ad --- /dev/null +++ b/panda/src/express/ramfile_ext.h @@ -0,0 +1,40 @@ +// Filename: ramfile_ext.h +// Created by: rdb (10Dec13) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#ifndef RAMFILE_EXT_H +#define RAMFILE_EXT_H + +#include "dtoolbase.h" + +#ifdef HAVE_PYTHON + +#include "extension.h" +#include "ramfile.h" +#include "py_panda.h" + +//////////////////////////////////////////////////////////////////// +// Class : Extension +// Description : This class defines the extension methods for +// Ramfile, which are called instead of +// any C++ methods with the same prototype. +//////////////////////////////////////////////////////////////////// +template<> +class Extension : public ExtensionBase { +public: + BLOCKING PyObject *readlines(); +}; + +#endif // HAVE_PYTHON + +#endif // RAMFILE_EXT_H diff --git a/panda/src/express/streamReader_ext.cxx b/panda/src/express/streamReader_ext.cxx new file mode 100644 index 0000000000..c0aa00f26a --- /dev/null +++ b/panda/src/express/streamReader_ext.cxx @@ -0,0 +1,48 @@ +// Filename: streamReader_ext.cxx +// Created by: rdb (09Dec13) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#include "streamReader_ext.h" + +#ifdef HAVE_PYTHON + +//////////////////////////////////////////////////////////////////// +// Function: StreamReader::readlines +// Access: Published +// Description: Reads all the lines at once and returns a list. +// Also see the documentation for readline(). +//////////////////////////////////////////////////////////////////// +PyObject *Extension:: +readlines() { + PyObject *lst = PyList_New(0); + if (lst == NULL) { + return NULL; + } + + string line = _this->readline(); + while (!line.empty()) { +#if PY_MAJOR_VERSION >= 3 + PyObject *py_line = PyBytes_FromStringAndSize(line.data(), line.size()); +#else + PyObject *py_line = PyString_FromStringAndSize(line.data(), line.size()); +#endif + + PyList_Append(lst, py_line); + Py_DECREF(py_line); + } + + return lst; +} + +#endif + diff --git a/panda/src/express/streamReader_ext.h b/panda/src/express/streamReader_ext.h new file mode 100644 index 0000000000..dfc2e9f0b1 --- /dev/null +++ b/panda/src/express/streamReader_ext.h @@ -0,0 +1,40 @@ +// Filename: streamReader_ext.h +// Created by: rdb (09Dec13) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#ifndef STREAMREADER_EXT_H +#define STREAMREADER_EXT_H + +#include "dtoolbase.h" + +#ifdef HAVE_PYTHON + +#include "extension.h" +#include "streamReader.h" +#include "py_panda.h" + +//////////////////////////////////////////////////////////////////// +// Class : Extension +// Description : This class defines the extension methods for +// StreamReader, which are called instead of +// any C++ methods with the same prototype. +//////////////////////////////////////////////////////////////////// +template<> +class Extension : public ExtensionBase { +public: + BLOCKING PyObject *readlines(); +}; + +#endif // HAVE_PYTHON + +#endif // STREAMREADER_EXT_H diff --git a/panda/src/express/virtualFileSystem_ext.cxx b/panda/src/express/virtualFileSystem_ext.cxx index c5981b347a..3f1c3f40f8 100644 --- a/panda/src/express/virtualFileSystem_ext.cxx +++ b/panda/src/express/virtualFileSystem_ext.cxx @@ -79,4 +79,4 @@ write_file(const Filename &filename, PyObject *data, bool auto_wrap) { return PyBool_FromLong(result); } -#endif // HAVE_PYTHOS +#endif // HAVE_PYTHON diff --git a/panda/src/linmath/lpoint2_ext_src.I b/panda/src/linmath/lpoint2_ext_src.I index b5716fa071..195c1b38d9 100644 --- a/panda/src/linmath/lpoint2_ext_src.I +++ b/panda/src/linmath/lpoint2_ext_src.I @@ -82,5 +82,5 @@ __getattr__(const string &attr_name) const { INLINE_LINMATH int Extension:: __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Upcall to LVecBase2. - return invoke_extension(_this, _self).__setattr__(self, attr_name, assign); + return invoke_extension(_this).__setattr__(self, attr_name, assign); } diff --git a/panda/src/linmath/lpoint3_ext_src.I b/panda/src/linmath/lpoint3_ext_src.I index 92178755e6..19f32de4e7 100644 --- a/panda/src/linmath/lpoint3_ext_src.I +++ b/panda/src/linmath/lpoint3_ext_src.I @@ -83,5 +83,5 @@ __getattr__(const string &attr_name) const { INLINE_LINMATH int Extension:: __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Upcall to LVecBase2. - return invoke_extension(_this, _self).__setattr__(self, attr_name, assign); + return invoke_extension(_this).__setattr__(self, attr_name, assign); } diff --git a/panda/src/linmath/lpoint4_ext_src.I b/panda/src/linmath/lpoint4_ext_src.I index 708150f52b..841e1271b2 100644 --- a/panda/src/linmath/lpoint4_ext_src.I +++ b/panda/src/linmath/lpoint4_ext_src.I @@ -88,5 +88,5 @@ __getattr__(const string &attr_name) const { INLINE_LINMATH int Extension:: __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Upcall to LVecBase4. - return invoke_extension(_this, _self).__setattr__(self, attr_name, assign); + return invoke_extension(_this).__setattr__(self, attr_name, assign); } diff --git a/panda/src/linmath/lvector2_ext_src.I b/panda/src/linmath/lvector2_ext_src.I index 39fb074fce..091c68760a 100644 --- a/panda/src/linmath/lvector2_ext_src.I +++ b/panda/src/linmath/lvector2_ext_src.I @@ -82,5 +82,5 @@ __getattr__(const string &attr_name) const { INLINE_LINMATH int Extension:: __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Upcall to LVecBase2. - return invoke_extension(_this, _self).__setattr__(self, attr_name, assign); + return invoke_extension(_this).__setattr__(self, attr_name, assign); } diff --git a/panda/src/linmath/lvector3_ext_src.I b/panda/src/linmath/lvector3_ext_src.I index 9706adfea3..a0046c513a 100644 --- a/panda/src/linmath/lvector3_ext_src.I +++ b/panda/src/linmath/lvector3_ext_src.I @@ -83,5 +83,5 @@ __getattr__(const string &attr_name) const { INLINE_LINMATH int Extension:: __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Upcall to LVecBase3. - return invoke_extension(_this, _self).__setattr__(self, attr_name, assign); + return invoke_extension(_this).__setattr__(self, attr_name, assign); } diff --git a/panda/src/linmath/lvector4_ext_src.I b/panda/src/linmath/lvector4_ext_src.I index a9ae9eb8d0..8b84439228 100644 --- a/panda/src/linmath/lvector4_ext_src.I +++ b/panda/src/linmath/lvector4_ext_src.I @@ -88,5 +88,5 @@ __getattr__(const string &attr_name) const { INLINE_LINMATH int Extension:: __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Upcall to LVecBase4. - return invoke_extension(_this, _self).__setattr__(self, attr_name, assign); + return invoke_extension(_this).__setattr__(self, attr_name, assign); } diff --git a/panda/src/ode/Sources.pp b/panda/src/ode/Sources.pp index 1006da1815..6d1393f815 100755 --- a/panda/src/ode/Sources.pp +++ b/panda/src/ode/Sources.pp @@ -12,18 +12,21 @@ #define USE_PACKAGES ode #define COMBINED_SOURCES $[TARGET]_composite1.cxx \ - $[TARGET]_composite2.cxx $[TARGET]_composite3.cxx + $[TARGET]_composite2.cxx $[TARGET]_composite3.cxx \ + $[TARGET]_ext_composite.cxx #define SOURCES \ ode_includes.h config_ode.h \ odeWorld.I odeWorld.h \ odeMass.I odeMass.h \ - odeBody.I odeBody.h \ + odeBody.I odeBody.h odeBody_ext.h \ odeJointGroup.I odeJointGroup.h \ - odeJoint.I odeJoint.h \ - odeUtil.h \ + odeJoint.I odeJoint.h odeJoint_ext.h \ + odeUtil.h odeUtil_ext.h \ odeSpace.I odeSpace.h \ + odeSpace_ext.I odeSpace_ext.h \ odeGeom.I odeGeom.h \ + odeGeom_ext.I odeGeom_ext.h \ odeSurfaceParameters.I odeSurfaceParameters.h \ odeContactGeom.I odeContactGeom.h \ odeContact.I odeContact.h \ @@ -55,11 +58,13 @@ #define INCLUDED_SOURCES \ config_ode.cxx \ - odeWorld.cxx odeMass.cxx odeBody.cxx \ - odeJointGroup.cxx odeJoint.cxx \ - odeUtil.cxx \ - odeSpace.cxx \ - odeGeom.cxx \ + odeWorld.cxx odeMass.cxx \ + odeBody.cxx odeBody_ext.cxx \ + odeJointGroup.cxx \ + odeJoint.cxx odeJoint_ext.cxx \ + odeUtil.cxx odeUtil_ext.cxx \ + odeSpace.cxx odeSpace_ext.cxx \ + odeGeom.cxx odeGeom_ext.cxx \ odeSurfaceParameters.cxx \ odeContactGeom.cxx odeContact.cxx \ odeAMotorJoint.cxx odeBallJoint.cxx \ @@ -118,4 +123,3 @@ #define IGATESCAN all #end lib_target - diff --git a/panda/src/ode/odeAMotorJoint.h b/panda/src/ode/odeAMotorJoint.h index 20bd0d3c99..c3b41a677d 100644 --- a/panda/src/ode/odeAMotorJoint.h +++ b/panda/src/ode/odeAMotorJoint.h @@ -16,7 +16,7 @@ class EXPCL_PANDAODE OdeAMotorJoint : public OdeJoint { friend class OdeJoint; -private: +public: OdeAMotorJoint(dJointID id); PUBLISHED: diff --git a/panda/src/ode/odeBallJoint.h b/panda/src/ode/odeBallJoint.h index 7fb9c104c3..be6100bf76 100644 --- a/panda/src/ode/odeBallJoint.h +++ b/panda/src/ode/odeBallJoint.h @@ -16,7 +16,7 @@ class EXPCL_PANDAODE OdeBallJoint : public OdeJoint { friend class OdeJoint; -private: +public: OdeBallJoint(dJointID id); PUBLISHED: diff --git a/panda/src/ode/odeBody.h b/panda/src/ode/odeBody.h index 51c5394d35..7a6fa3ffd7 100755 --- a/panda/src/ode/odeBody.h +++ b/panda/src/ode/odeBody.h @@ -39,7 +39,7 @@ class EXPCL_PANDAODE OdeBody : public TypedObject { friend class OdeGeom; friend class OdeCollisionEntry; -protected: +public: OdeBody(dBodyID id); PUBLISHED: @@ -140,6 +140,8 @@ PUBLISHED: INLINE int get_num_joints() const; OdeJoint get_joint(int index) const; MAKE_SEQ(get_joints, get_num_joints, get_joint); + EXTENSION(INLINE PyObject *get_converted_joint(int i) const); + INLINE void enable(); INLINE void disable(); INLINE int is_enabled() const; diff --git a/panda/src/ode/odeBoxGeom.h b/panda/src/ode/odeBoxGeom.h index a4336eb93d..9991124a59 100644 --- a/panda/src/ode/odeBoxGeom.h +++ b/panda/src/ode/odeBoxGeom.h @@ -29,7 +29,7 @@ class EXPCL_PANDAODE OdeBoxGeom : public OdeGeom { friend class OdeGeom; -private: +public: OdeBoxGeom(dGeomID id); PUBLISHED: diff --git a/panda/src/ode/odeCappedCylinderGeom.h b/panda/src/ode/odeCappedCylinderGeom.h index ce56ab5816..2e48cb36c0 100755 --- a/panda/src/ode/odeCappedCylinderGeom.h +++ b/panda/src/ode/odeCappedCylinderGeom.h @@ -29,7 +29,7 @@ class EXPCL_PANDAODE OdeCappedCylinderGeom : public OdeGeom { friend class OdeGeom; -private: +public: OdeCappedCylinderGeom(dGeomID id); PUBLISHED: diff --git a/panda/src/ode/odeContactJoint.h b/panda/src/ode/odeContactJoint.h index 963996a9fc..f2edc91de2 100644 --- a/panda/src/ode/odeContactJoint.h +++ b/panda/src/ode/odeContactJoint.h @@ -17,7 +17,7 @@ class EXPCL_PANDAODE OdeContactJoint : public OdeJoint { friend class OdeJoint; -private: +public: OdeContactJoint(dJointID id); PUBLISHED: diff --git a/panda/src/ode/odeConvexGeom.h b/panda/src/ode/odeConvexGeom.h index 7a7819e7eb..bc4104855a 100755 --- a/panda/src/ode/odeConvexGeom.h +++ b/panda/src/ode/odeConvexGeom.h @@ -29,7 +29,7 @@ class EXPCL_PANDAODE OdeConvexGeom : public OdeGeom { friend class OdeGeom; -private: +public: OdeConvexGeom(dGeomID id); PUBLISHED: diff --git a/panda/src/ode/odeCylinderGeom.h b/panda/src/ode/odeCylinderGeom.h index 9d4bbbd2c7..1b847c908c 100755 --- a/panda/src/ode/odeCylinderGeom.h +++ b/panda/src/ode/odeCylinderGeom.h @@ -29,7 +29,7 @@ class EXPCL_PANDAODE OdeCylinderGeom : public OdeGeom { friend class OdeGeom; -private: +public: OdeCylinderGeom(dGeomID id); PUBLISHED: diff --git a/panda/src/ode/odeFixedJoint.h b/panda/src/ode/odeFixedJoint.h index 5c074303cb..a1d8a6d59e 100644 --- a/panda/src/ode/odeFixedJoint.h +++ b/panda/src/ode/odeFixedJoint.h @@ -16,7 +16,7 @@ class EXPCL_PANDAODE OdeFixedJoint : public OdeJoint { friend class OdeJoint; -private: +public: OdeFixedJoint(dJointID id); PUBLISHED: diff --git a/panda/src/ode/odeGeom.h b/panda/src/ode/odeGeom.h index daea43908a..dff9eddeed 100755 --- a/panda/src/ode/odeGeom.h +++ b/panda/src/ode/odeGeom.h @@ -50,7 +50,7 @@ class EXPCL_PANDAODE OdeGeom : public TypedObject { friend class OdeUtil; friend class OdeCollisionEntry; -protected: +public: OdeGeom(dGeomID id); PUBLISHED: @@ -87,6 +87,7 @@ PUBLISHED: INLINE LMatrix3f get_rotation() const; INLINE LQuaternionf get_quaternion() const; INLINE void get_AABB(LVecBase3f &min, LVecBase3f &max) const; + EXTENSION(INLINE PyObject *get_AA_bounds() const); INLINE int is_space(); INLINE int get_class() const; INLINE void set_category_bits(const BitMask32 &bits); @@ -109,21 +110,22 @@ PUBLISHED: INLINE LPoint3f get_offset_position() const; INLINE LMatrix3f get_offset_rotation() const; INLINE LQuaternionf get_offset_quaternion() const; - + //int get_surface_type() ; //int get_collide_id() ; //int set_collide_id( int collide_id); //void set_surface_type( int surface_type); - + //int test_collide_id( int collide_id); - OdeSpace get_space() const; + EXTENSION(INLINE PyObject *get_converted_space() const); virtual void write(ostream &out = cout, unsigned int indent=0) const; operator bool () const; INLINE int compare_to(const OdeGeom &other) const; + EXTENSION(PyObject *convert() const); OdeBoxGeom convert_to_box() const; OdeCappedCylinderGeom convert_to_capped_cylinder() const; // OdeConvexGeom convert_to_convex() const; @@ -136,8 +138,6 @@ PUBLISHED: OdeSimpleSpace convert_to_simple_space() const; OdeHashSpace convert_to_hash_space() const; OdeQuadTreeSpace convert_to_quad_tree_space() const; - - public: INLINE static int get_geom_class() { return -1; }; diff --git a/panda/src/ode/odeHashSpace.h b/panda/src/ode/odeHashSpace.h index d66a99d43b..03e2983689 100755 --- a/panda/src/ode/odeHashSpace.h +++ b/panda/src/ode/odeHashSpace.h @@ -31,7 +31,7 @@ class EXPCL_PANDAODE OdeHashSpace : public OdeSpace { friend class OdeSpace; friend class OdeGeom; -private: +public: OdeHashSpace(dSpaceID id); PUBLISHED: diff --git a/panda/src/ode/odeHeightFieldGeom.h b/panda/src/ode/odeHeightFieldGeom.h index 7b648a3539..00fd6593a1 100644 --- a/panda/src/ode/odeHeightFieldGeom.h +++ b/panda/src/ode/odeHeightFieldGeom.h @@ -29,7 +29,7 @@ class EXPCL_PANDAODE OdeHeightfieldGeom : public OdeGeom { friend class OdeGeom; -private: +public: OdeHeightfieldGeom(dGeomID id); PUBLISHED: diff --git a/panda/src/ode/odeHinge2Joint.h b/panda/src/ode/odeHinge2Joint.h index dcb8e732e9..2e6e5dd487 100644 --- a/panda/src/ode/odeHinge2Joint.h +++ b/panda/src/ode/odeHinge2Joint.h @@ -16,7 +16,7 @@ class EXPCL_PANDAODE OdeHinge2Joint : public OdeJoint { friend class OdeJoint; -private: +public: OdeHinge2Joint(dJointID id); PUBLISHED: diff --git a/panda/src/ode/odeHingeJoint.h b/panda/src/ode/odeHingeJoint.h index c622d7996e..0cc9fefadc 100755 --- a/panda/src/ode/odeHingeJoint.h +++ b/panda/src/ode/odeHingeJoint.h @@ -15,7 +15,7 @@ class EXPCL_PANDAODE OdeHingeJoint : public OdeJoint { friend class OdeJoint; -private: +public: OdeHingeJoint(dJointID id); PUBLISHED: diff --git a/panda/src/ode/odeJoint.cxx b/panda/src/ode/odeJoint.cxx index b1d235efcb..8aa287e30a 100755 --- a/panda/src/ode/odeJoint.cxx +++ b/panda/src/ode/odeJoint.cxx @@ -52,7 +52,7 @@ destroy() { void OdeJoint:: attach_bodies(const OdeBody &body1, const OdeBody &body2) { nassertv(_id); - nassertv(body1.get_id() != 0 && body2.get_id() != 0); + nassertv(body1.get_id() != 0 || body2.get_id() != 0); dJointAttach(_id, body1.get_id(), body2.get_id()); } diff --git a/panda/src/ode/odeJoint.h b/panda/src/ode/odeJoint.h index b3fcead63b..0eb44b61bf 100755 --- a/panda/src/ode/odeJoint.h +++ b/panda/src/ode/odeJoint.h @@ -32,7 +32,7 @@ PUBLISHED: }; // Strange, we should be forced to include this by get_body() -class OdeBody; +class OdeBody; class OdeBallJoint; class OdeHingeJoint; @@ -48,7 +48,7 @@ class OdePlane2dJoint; //////////////////////////////////////////////////////////////////// // Class : OdeJoint -// Description : +// Description : //////////////////////////////////////////////////////////////////// class EXPCL_PANDAODE OdeJoint : public TypedObject { friend class OdeBody; @@ -56,8 +56,6 @@ class EXPCL_PANDAODE OdeJoint : public TypedObject { public: OdeJoint(); - -protected: OdeJoint(dJointID id); PUBLISHED: @@ -78,7 +76,7 @@ PUBLISHED: void destroy(); INLINE bool is_empty() const; INLINE dJointID get_id() const; - + /* INLINE void set_data(void *data); */ /* INLINE void *get_data(); */ INLINE int get_joint_type() const; @@ -86,7 +84,8 @@ PUBLISHED: INLINE void set_feedback(OdeJointFeedback *); INLINE void set_feedback(bool flag = true); INLINE OdeJointFeedback *get_feedback(); - + + EXTENSION(void attach(const OdeBody *body1, const OdeBody *body2)); void attach_bodies(const OdeBody &body1, const OdeBody &body2); void attach_body(const OdeBody &body, int index); void detach(); @@ -96,6 +95,7 @@ PUBLISHED: INLINE bool operator == (const OdeJoint &other) const; operator bool () const; + EXTENSION(PyObject *convert() const); OdeBallJoint convert_to_ball() const; OdeHingeJoint convert_to_hinge() const; OdeSliderJoint convert_to_slider() const; diff --git a/panda/src/ode/odeLMotorJoint.h b/panda/src/ode/odeLMotorJoint.h index 3b91cbbeb7..541afcd904 100755 --- a/panda/src/ode/odeLMotorJoint.h +++ b/panda/src/ode/odeLMotorJoint.h @@ -15,7 +15,7 @@ class EXPCL_PANDAODE OdeLMotorJoint : public OdeJoint { friend class OdeJoint; -private: +public: OdeLMotorJoint(dJointID id); PUBLISHED: diff --git a/panda/src/ode/odeNullJoint.h b/panda/src/ode/odeNullJoint.h index 94c659ab92..61f3912866 100755 --- a/panda/src/ode/odeNullJoint.h +++ b/panda/src/ode/odeNullJoint.h @@ -15,7 +15,7 @@ class EXPCL_PANDAODE OdeNullJoint : public OdeJoint { friend class OdeJoint; -private: +public: OdeNullJoint(dJointID id); PUBLISHED: diff --git a/panda/src/ode/odePlane2dJoint.h b/panda/src/ode/odePlane2dJoint.h index e70e75181d..cb9e7eb6de 100755 --- a/panda/src/ode/odePlane2dJoint.h +++ b/panda/src/ode/odePlane2dJoint.h @@ -15,7 +15,7 @@ class EXPCL_PANDAODE OdePlane2dJoint : public OdeJoint { friend class OdeJoint; -private: +public: OdePlane2dJoint(dJointID id); PUBLISHED: diff --git a/panda/src/ode/odePlaneGeom.h b/panda/src/ode/odePlaneGeom.h index 1412d472bc..5131f55f78 100755 --- a/panda/src/ode/odePlaneGeom.h +++ b/panda/src/ode/odePlaneGeom.h @@ -28,7 +28,7 @@ class EXPCL_PANDAODE OdePlaneGeom : public OdeGeom { friend class OdeGeom; -private: +public: OdePlaneGeom(dGeomID id); PUBLISHED: diff --git a/panda/src/ode/odeQuadTreeSpace.h b/panda/src/ode/odeQuadTreeSpace.h index adb05d7d09..0a57a7668f 100755 --- a/panda/src/ode/odeQuadTreeSpace.h +++ b/panda/src/ode/odeQuadTreeSpace.h @@ -30,7 +30,7 @@ class EXPCL_PANDAODE OdeQuadTreeSpace : public OdeSpace { friend class OdeSpace; friend class OdeGeom; -private: +public: OdeQuadTreeSpace(dSpaceID id); PUBLISHED: diff --git a/panda/src/ode/odeRayGeom.h b/panda/src/ode/odeRayGeom.h index d1d16b0027..d8c4f64d98 100755 --- a/panda/src/ode/odeRayGeom.h +++ b/panda/src/ode/odeRayGeom.h @@ -28,7 +28,7 @@ class EXPCL_PANDAODE OdeRayGeom : public OdeGeom { friend class OdeGeom; -private: +public: OdeRayGeom(dGeomID id); PUBLISHED: diff --git a/panda/src/ode/odeSimpleSpace.h b/panda/src/ode/odeSimpleSpace.h index af8edc03d0..63c16a8901 100755 --- a/panda/src/ode/odeSimpleSpace.h +++ b/panda/src/ode/odeSimpleSpace.h @@ -30,7 +30,7 @@ class EXPCL_PANDAODE OdeSimpleSpace : public OdeSpace { friend class OdeSpace; friend class OdeGeom; -private: +public: OdeSimpleSpace(dSpaceID id); PUBLISHED: diff --git a/panda/src/ode/odeSliderJoint.h b/panda/src/ode/odeSliderJoint.h index 3ee063daf2..a4d8117525 100755 --- a/panda/src/ode/odeSliderJoint.h +++ b/panda/src/ode/odeSliderJoint.h @@ -15,7 +15,7 @@ class EXPCL_PANDAODE OdeSliderJoint : public OdeJoint { friend class OdeJoint; -private: +public: OdeSliderJoint(dJointID id); PUBLISHED: diff --git a/panda/src/ode/odeSpace.cxx b/panda/src/ode/odeSpace.cxx index fecb33d877..e98086c711 100755 --- a/panda/src/ode/odeSpace.cxx +++ b/panda/src/ode/odeSpace.cxx @@ -17,23 +17,12 @@ #include "throw_event.h" -#ifdef HAVE_PYTHON - #include "py_panda.h" - #include "typedReferenceCount.h" - #ifndef CPPPARSER - extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeGeom; - #endif -#endif - TypeHandle OdeSpace::_type_handle; // this data is used in auto_collide const int OdeSpace::MAX_CONTACTS = 16; OdeWorld* OdeSpace::_static_auto_collide_world; OdeSpace* OdeSpace::_static_auto_collide_space; dJointGroupID OdeSpace::_static_auto_collide_joint_group; -#ifdef HAVE_PYTHON -PyObject* OdeSpace::_python_callback = NULL; -#endif OdeSpace:: OdeSpace(dSpaceID id) : @@ -142,23 +131,23 @@ auto_callback(void *data, dGeomID o1, dGeomID o2) { dBodyID b2 = dGeomGetBody(o2); dContact contact[OdeSpace::MAX_CONTACTS]; - + int surface1 = _static_auto_collide_space->get_surface_type(o1); int surface2 = _static_auto_collide_space->get_surface_type(o2); - + nassertv(_static_auto_collide_world != NULL); sSurfaceParams collide_params; collide_params = _static_auto_collide_world->get_surface(surface1, surface2); - + for (i=0; i < OdeSpace::MAX_CONTACTS; i++) { - contact[i].surface.mode = collide_params.colparams.mode; - contact[i].surface.mu = collide_params.colparams.mu; - contact[i].surface.mu2 = collide_params.colparams.mu2; - contact[i].surface.bounce = collide_params.colparams.bounce; - contact[i].surface.bounce_vel = collide_params.colparams.bounce_vel; - contact[i].surface.soft_cfm = collide_params.colparams.soft_cfm; + contact[i].surface.mode = collide_params.colparams.mode; + contact[i].surface.mu = collide_params.colparams.mu; + contact[i].surface.mu2 = collide_params.colparams.mu2; + contact[i].surface.bounce = collide_params.colparams.bounce; + contact[i].surface.bounce_vel = collide_params.colparams.bounce_vel; + contact[i].surface.soft_cfm = collide_params.colparams.soft_cfm; } - + static int numc = 0; numc = dCollide(o1, o2, OdeSpace::MAX_CONTACTS, &contact[0].geom, sizeof(dContact)); @@ -177,7 +166,7 @@ auto_callback(void *data, dGeomID o1, dGeomID o2) { entry->_num_contacts = numc; entry->_contact_geoms = new OdeContactGeom[numc]; } - + for(i=0; i < numc; i++) { dJointID c = dJointCreateContact(_static_auto_collide_world->get_id(), _static_auto_collide_joint_group, contact + i); if ((_static_auto_collide_space->get_collide_id(o1) >= 0) && (_static_auto_collide_space->get_collide_id(o2) >= 0)) { @@ -188,51 +177,13 @@ auto_callback(void *data, dGeomID o1, dGeomID o2) { } } _static_auto_collide_world->set_dampen_on_bodies(b1, b2, collide_params.dampen); - + if (!_static_auto_collide_space->_collision_event.empty()) { throw_event(_static_auto_collide_space->_collision_event, EventParameter(entry)); } } } -#ifdef HAVE_PYTHON -int OdeSpace:: -collide(PyObject* arg, PyObject* callback) { - nassertr(callback != NULL, -1); - if (!PyCallable_Check(callback)) { - PyErr_Format(PyExc_TypeError, "'%s' object is not callable", callback->ob_type->tp_name); - return -1; - } else if (_id == NULL) { - // Well, while we're in the mood of python exceptions, let's make this one too. - PyErr_Format(PyExc_TypeError, "OdeSpace is not valid!"); - return -1; - } else { - OdeSpace::_python_callback = (PyObject*) callback; - Py_XINCREF(OdeSpace::_python_callback); - dSpaceCollide(_id, (void*) arg, &near_callback); - Py_XDECREF(OdeSpace::_python_callback); - return 0; - } -} - -void OdeSpace:: -near_callback(void *data, dGeomID o1, dGeomID o2) { - OdeGeom *g1 = new OdeGeom(o1); - OdeGeom *g2 = new OdeGeom(o2); - PyObject *p1 = DTool_CreatePyInstanceTyped(g1, Dtool_OdeGeom, true, false, g1->get_type_index()); - PyObject *p2 = DTool_CreatePyInstanceTyped(g2, Dtool_OdeGeom, true, false, g2->get_type_index()); - PyObject *result = PyEval_CallFunction(_python_callback, "OOO", (PyObject*) data, p1, p2); - if (!result) { - odespace_cat.error() << "An error occurred while calling python function!\n"; - PyErr_Print(); - } else { - Py_DECREF(result); - } - Py_XDECREF(p2); - Py_XDECREF(p1); -} -#endif - OdeSimpleSpace OdeSpace:: convert_to_simple_space() const { nassertr(_id != 0, OdeSimpleSpace((dSpaceID)0)); @@ -309,4 +260,3 @@ get_collide_id(dGeomID id) { } return 0; } - diff --git a/panda/src/ode/odeSpace.h b/panda/src/ode/odeSpace.h index e61f4aa1e2..07b6c8f5d7 100755 --- a/panda/src/ode/odeSpace.h +++ b/panda/src/ode/odeSpace.h @@ -26,11 +26,6 @@ #include "ode_includes.h" -#ifdef HAVE_PYTHON - #include "py_panda.h" - #include "Python.h" -#endif - class OdeGeom; class OdeTriMeshGeom; class OdeSimpleSpace; @@ -39,15 +34,15 @@ class OdeQuadTreeSpace; //////////////////////////////////////////////////////////////////// // Class : OdeSpace -// Description : +// Description : //////////////////////////////////////////////////////////////////// class EXPCL_PANDAODE OdeSpace : public TypedObject { friend class OdeGeom; static const int MAX_CONTACTS; -protected: +public: OdeSpace(dSpaceID id); - + PUBLISHED: virtual ~OdeSpace(); void destroy(); @@ -59,6 +54,7 @@ PUBLISHED: int query(const OdeSpace& space) const; INLINE int get_num_geoms() const; INLINE void get_AABB(LVecBase3f &min, LVecBase3f &max) const; + EXTENSION(INLINE PyObject *get_AA_bounds() const); INLINE int is_space(); INLINE int get_class() const; INLINE void set_category_bits(const BitMask32 &bits); @@ -78,7 +74,7 @@ PUBLISHED: void clean(); OdeGeom get_geom(int i); // Not INLINE because of forward declaration //static int get_surface_type(OdeSpace * self, dGeomID o1); - + INLINE OdeSpace get_space() const; virtual void write(ostream &out = cout, unsigned int indent=0) const; @@ -87,11 +83,13 @@ PUBLISHED: OdeSimpleSpace convert_to_simple_space() const; OdeHashSpace convert_to_hash_space() const; OdeQuadTreeSpace convert_to_quad_tree_space() const; - + + EXTENSION(PyObject *convert() const); + EXTENSION(INLINE PyObject *get_converted_geom(int i) const); + EXTENSION(INLINE PyObject *get_converted_space() const); + void auto_collide(); -#ifdef HAVE_PYTHON - int collide(PyObject* arg, PyObject* near_callback); -#endif + EXTENSION(int collide(PyObject* arg, PyObject* near_callback)); int set_collide_id(int collide_id, dGeomID id); int set_collide_id(OdeGeom& geom, int collide_id); void set_surface_type( int surface_type, dGeomID id); @@ -106,17 +104,11 @@ PUBLISHED: public: static void auto_callback(void*, dGeomID, dGeomID); -#ifdef HAVE_PYTHON - static void near_callback(void*, dGeomID, dGeomID); -#endif - + INLINE dSpaceID get_id() const; static OdeWorld* _static_auto_collide_world; static OdeSpace* _static_auto_collide_space; static dJointGroupID _static_auto_collide_joint_group; -#ifdef HAVE_PYTHON - static PyObject* _python_callback; -#endif static int contactCount; string _collision_event; @@ -153,4 +145,3 @@ private: #include "odeSpace.I" #endif - diff --git a/panda/src/ode/odeSphereGeom.h b/panda/src/ode/odeSphereGeom.h index 5b02a1ff76..2c7e3157b4 100755 --- a/panda/src/ode/odeSphereGeom.h +++ b/panda/src/ode/odeSphereGeom.h @@ -28,7 +28,7 @@ class EXPCL_PANDAODE OdeSphereGeom : public OdeGeom { friend class OdeGeom; -private: +public: OdeSphereGeom(dGeomID id); PUBLISHED: diff --git a/panda/src/ode/odeTriMeshGeom.h b/panda/src/ode/odeTriMeshGeom.h index 8a3f5943ed..ad1dfe665a 100755 --- a/panda/src/ode/odeTriMeshGeom.h +++ b/panda/src/ode/odeTriMeshGeom.h @@ -29,7 +29,7 @@ class EXPCL_PANDAODE OdeTriMeshGeom : public OdeGeom { friend class OdeGeom; -private: +public: OdeTriMeshGeom(dGeomID id); PUBLISHED: @@ -56,9 +56,6 @@ public: INLINE dTriMeshDataID get_tri_mesh_data_id() const; INLINE dTriMeshDataID get_data_id() const; -private: - void operator = (const OdeTriMeshGeom ©); - public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/ode/odeUniversalJoint.h b/panda/src/ode/odeUniversalJoint.h index 3f79d8ec48..d4e3e4c185 100644 --- a/panda/src/ode/odeUniversalJoint.h +++ b/panda/src/ode/odeUniversalJoint.h @@ -16,7 +16,7 @@ class EXPCL_PANDAODE OdeUniversalJoint : public OdeJoint { friend class OdeJoint; -private: +public: OdeUniversalJoint(dJointID id); PUBLISHED: diff --git a/panda/src/ode/odeUtil.cxx b/panda/src/ode/odeUtil.cxx index edc2f8236c..4bb6471881 100755 --- a/panda/src/ode/odeUtil.cxx +++ b/panda/src/ode/odeUtil.cxx @@ -14,20 +14,8 @@ #include "odeUtil.h" -#ifdef HAVE_PYTHON - #include "py_panda.h" - #include "typedReferenceCount.h" - #ifndef CPPPARSER - extern EXPCL_PANDAODE Dtool_PyTypedObject Dtool_OdeGeom; - #endif -#endif - dReal OdeUtil::OC_infinity = dInfinity; -#ifdef HAVE_PYTHON -PyObject* OdeUtil::_python_callback = NULL; -#endif - //////////////////////////////////////////////////////////////////// // Function: OdeUtil::get_connecting_joint // Access: Public, Static @@ -47,7 +35,7 @@ get_connecting_joint(const OdeBody &body1, const OdeBody &body2) { OdeJointCollection OdeUtil:: get_connecting_joint_list(const OdeBody &body1, const OdeBody &body2) { const int max_possible_joints = min(body1.get_num_joints(), body1.get_num_joints()); - + dJointID *joint_list = (dJointID *)PANDA_MALLOC_ARRAY(max_possible_joints * sizeof(dJointID)); int num_joints = dConnectingJointList(body1.get_id(), body2.get_id(), joint_list); @@ -55,7 +43,7 @@ get_connecting_joint_list(const OdeBody &body1, const OdeBody &body2) { for (int i = 0; i < num_joints; i++) { joints.add_joint(OdeJoint(joint_list[i])); } - + PANDA_FREE_ARRAY(joint_list); return joints; } @@ -113,51 +101,12 @@ collide(const OdeGeom &geom1, const OdeGeom &geom2, const short int max_contacts for (int i = 0; i < num_contacts; i++) { entry->_contact_geoms[i] = contact_list[i]; } - + PANDA_FREE_ARRAY(contact_list); return entry; } -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: OdeUtil::collide2 -// Access: Public, Static -// Description: Calls the callback for all potentially intersecting -// pairs that contain one geom from geom1 and one geom -// from geom2. -//////////////////////////////////////////////////////////////////// -int OdeUtil:: -collide2(const OdeGeom &geom1, const OdeGeom &geom2, PyObject* arg, PyObject* callback) { - nassertr(callback != NULL, -1); - if (!PyCallable_Check(callback)) { - PyErr_Format(PyExc_TypeError, "'%s' object is not callable", callback->ob_type->tp_name); - return -1; - } else { - _python_callback = (PyObject*) callback; - Py_XINCREF(_python_callback); - dSpaceCollide2(geom1.get_id(), geom2.get_id(), (void*) arg, &near_callback); - Py_XDECREF(_python_callback); - return 0; - } -} - -void OdeUtil:: -near_callback(void *data, dGeomID o1, dGeomID o2) { - ode_cat.spam() << "near_callback called, data: " << data << ", dGeomID1: " << o1 << ", dGeomID2: " << o2 << "\n"; - OdeGeom g1 (o1); - OdeGeom g2 (o2); - PyObject* p1 = DTool_CreatePyInstanceTyped(&g1, Dtool_OdeGeom, true, false, g1.get_type_index()); - PyObject* p2 = DTool_CreatePyInstanceTyped(&g2, Dtool_OdeGeom, true, false, g2.get_type_index()); - PyObject* result = PyEval_CallFunction(_python_callback, "OOO", (PyObject*) data, p1, p2); - if (!result) { - ode_cat.error() << "An error occurred while calling python function!\n"; - PyErr_Print(); - } -} -#endif - OdeGeom OdeUtil:: space_to_geom(const OdeSpace &space) { return OdeGeom((dGeomID)space.get_id()); } - diff --git a/panda/src/ode/odeUtil.h b/panda/src/ode/odeUtil.h index 654b7f1008..d24844ac89 100755 --- a/panda/src/ode/odeUtil.h +++ b/panda/src/ode/odeUtil.h @@ -23,10 +23,6 @@ #include "odeJointCollection.h" #include "odeCollisionEntry.h" -#ifdef HAVE_PYTHON - #include "py_panda.h" -#endif - class OdeBody; class OdeJoint; class OdeGeom; @@ -48,10 +44,10 @@ PUBLISHED: const int joint_type); static PT(OdeCollisionEntry) collide(const OdeGeom &geom1, const OdeGeom &geom2, const short int max_contacts = 150); -#ifdef HAVE_PYTHON - static int collide2(const OdeGeom &geom1, const OdeGeom &geom2, - PyObject* arg, PyObject* callback); -#endif + + EXTENSION(static int collide2(const OdeGeom &geom1, const OdeGeom &geom2, + PyObject* arg, PyObject* callback)); + static OdeGeom space_to_geom(const OdeSpace &space); static dReal OC_infinity; @@ -62,12 +58,6 @@ PUBLISHED: static int rand_get_seed() {return dRandGetSeed();}; static void rand_set_seed(int s) {dRandSetSeed(s);}; - -private: -#ifdef HAVE_PYTHON - static void near_callback(void*, dGeomID, dGeomID); - static PyObject* _python_callback; -#endif }; #endif diff --git a/panda/src/ode/p3ode_ext_composite.cxx b/panda/src/ode/p3ode_ext_composite.cxx new file mode 100644 index 0000000000..02ebaec64c --- /dev/null +++ b/panda/src/ode/p3ode_ext_composite.cxx @@ -0,0 +1,4 @@ +#include "odeGeom_ext.cxx" +#include "odeJoint_ext.cxx" +#include "odeSpace_ext.cxx" +#include "odeUtil_ext.cxx" diff --git a/panda/src/pgraph/Sources.pp b/panda/src/pgraph/Sources.pp index ab3d0fe9b9..d0ddb0e0df 100644 --- a/panda/src/pgraph/Sources.pp +++ b/panda/src/pgraph/Sources.pp @@ -72,7 +72,10 @@ modelPool.I modelPool.h \ modelRoot.I modelRoot.h \ nodePath.I nodePath.h nodePath.cxx \ + nodePath_ext.I nodePath_ext.h nodePath_ext.cxx \ nodePathCollection.I nodePathCollection.h \ + nodePathCollection_ext.I nodePathCollection_ext.h \ + nodePathCollection_ext.cxx \ nodePathComponent.I nodePathComponent.h \ occluderEffect.I occluderEffect.h \ occluderNode.I occluderNode.h \ diff --git a/panda/src/pgraph/nodePath.I b/panda/src/pgraph/nodePath.I index d7eced9bf0..c5a0ae25ee 100644 --- a/panda/src/pgraph/nodePath.I +++ b/panda/src/pgraph/nodePath.I @@ -2197,57 +2197,6 @@ get_tag_keys(vector_string &keys) const { node()->get_tag_keys(keys); } -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_python_tag_keys -// Access: Published -// Description: Fills the given vector up with the -// list of Python tags on this PandaNode. -// -// It is the user's responsibility to ensure that the -// keys vector is empty before making this call; -// otherwise, the new files will be appended to it. -//////////////////////////////////////////////////////////////////// -INLINE void NodePath:: -get_python_tag_keys(vector_string &keys) const { - nassertv_always(!is_empty()); - node()->get_python_tag_keys(keys); -} - -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_tag_keys -// Access: Published -// Description: This variant on get_tag_keys returns a Python list -// of strings. Returns None if the NodePath is empty. -//////////////////////////////////////////////////////////////////// -INLINE PyObject *NodePath:: -get_tag_keys() const { - // An empty NodePath returns None - if (is_empty()) { - Py_INCREF(Py_None); - return Py_None; - } - return node()->get_tag_keys(); -} - -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_python_tag_keys -// Access: Published -// Description: This variant on get_python_tag_keys returns a -// Python list of strings. -// Returns None if the NodePath is empty. -//////////////////////////////////////////////////////////////////// -INLINE PyObject *NodePath:: -get_python_tag_keys() const { - // An empty NodePath returns None - if (is_empty()) { - Py_INCREF(Py_None); - return Py_None; - } - return node()->get_python_tag_keys(); -} -#endif // HAVE_PYTHON - //////////////////////////////////////////////////////////////////// // Function: NodePath::has_tag // Access: Published @@ -2305,114 +2254,6 @@ has_net_tag(const string &key) const { return !find_net_tag(key).is_empty(); } -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_python_tag -// Access: Published -// Description: Associates an arbitrary Python object with a -// user-defined key which is stored on the node. This -// object has no meaning to Panda; but it is stored -// indefinitely on the node until it is requested again. -// -// Each unique key stores a different Python object. -// There is no effective limit on the number of -// different keys that may be stored or on the nature of -// any one key's object. -//////////////////////////////////////////////////////////////////// -INLINE void NodePath:: -set_python_tag(const string &key, PyObject *value) { - nassertv_always(!is_empty()); - node()->set_python_tag(key, value); -} -#endif // HAVE_PYTHON - -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_python_tag -// Access: Published -// Description: Retrieves the Python object that was previously -// set on this node for the particular key, if any. If -// no object has been previously set, returns None. -// See also get_net_python_tag(). -//////////////////////////////////////////////////////////////////// -INLINE PyObject *NodePath:: -get_python_tag(const string &key) const { - // An empty NodePath quietly returns no tags. This makes - // get_net_python_tag() easier to implement. - if (is_empty()) { - Py_INCREF(Py_None); - return Py_None; - } - return node()->get_python_tag(key); -} -#endif // HAVE_PYTHON - -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_python_tag -// Access: Published -// Description: Returns true if a Python object has been defined on -// this node for the particular key (even if that value -// is the empty string), or false if no value has been -// set. See also has_net_python_tag(). -//////////////////////////////////////////////////////////////////// -INLINE bool NodePath:: -has_python_tag(const string &key) const { - // An empty NodePath quietly has no tags. This makes has_net_python_tag() - // easier to implement. - if (is_empty()) { - return false; - } - return node()->has_python_tag(key); -} -#endif // HAVE_PYTHON - -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_python_tag -// Access: Published -// Description: Removes the Python object defined for this key on this -// particular node. After a call to clear_python_tag(), -// has_python_tag() will return false for the indicated -// key. -//////////////////////////////////////////////////////////////////// -INLINE void NodePath:: -clear_python_tag(const string &key) { - nassertv_always(!is_empty()); - node()->clear_python_tag(key); -} -#endif // HAVE_PYTHON - -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_net_python_tag -// Access: Published -// Description: Returns the Python object that has been defined on -// this node, or the nearest ancestor node, for the -// indicated key. If no value has been defined for the -// indicated key on any ancestor node, returns None. -// See also get_python_tag(). -//////////////////////////////////////////////////////////////////// -INLINE PyObject *NodePath:: -get_net_python_tag(const string &key) const { - return find_net_python_tag(key).get_python_tag(key); -} -#endif // HAVE_PYTHON - -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_net_python_tag -// Access: Published -// Description: Returns true if the indicated Python object has been -// defined on this node or on any ancestor node, or -// false otherwise. See also has_python_tag(). -//////////////////////////////////////////////////////////////////// -INLINE bool NodePath:: -has_net_python_tag(const string &key) const { - return !find_net_python_tag(key).is_empty(); -} -#endif // HAVE_PYTHON - //////////////////////////////////////////////////////////////////// // Function: NodePath::list_tags // Access: Published diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index 579d1157f2..216c7deb4b 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -177,166 +177,6 @@ NodePath(const NodePath &parent, PandaNode *child_node, _backup_key = 0; } -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: NodePath::__copy__ -// Access: Published -// Description: A special Python method that is invoked by -// copy.copy(node). Unlike the NodePath copy -// constructor, this makes a duplicate copy of the -// underlying PandaNode (but shares children, instead of -// copying them or omitting them). -//////////////////////////////////////////////////////////////////// -NodePath NodePath:: -__copy__() const { - if (is_empty()) { - // Invoke the copy constructor if we have no node. - return *this; - } - - // If we do have a node, duplicate it, and wrap it in a new - // NodePath. - return NodePath(node()->__copy__()); -} -#endif // HAVE_PYTHON - -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: NodePath::__deepcopy__ -// Access: Published -// Description: A special Python method that is invoked by -// copy.deepcopy(np). This calls copy_to() unless the -// NodePath is already present in the provided -// dictionary. -//////////////////////////////////////////////////////////////////// -PyObject *NodePath:: -__deepcopy__(PyObject *self, PyObject *memo) const { - IMPORT_THIS struct Dtool_PyTypedObject Dtool_NodePath; - - // Borrowed reference. - PyObject *dupe = PyDict_GetItem(memo, self); - if (dupe != NULL) { - // Already in the memo dictionary. - Py_INCREF(dupe); - return dupe; - } - - NodePath *np_dupe; - if (is_empty()) { - np_dupe = new NodePath(*this); - } else { - np_dupe = new NodePath(copy_to(NodePath())); - } - - dupe = DTool_CreatePyInstance((void *)np_dupe, Dtool_NodePath, - true, false); - if (PyDict_SetItem(memo, self, dupe) != 0) { - Py_DECREF(dupe); - return NULL; - } - - return dupe; -} -#endif // HAVE_PYTHON - -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: NodePath::__reduce__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -// -// This hooks into the native pickle and cPickle -// modules, but it cannot properly handle -// self-referential BAM objects. -//////////////////////////////////////////////////////////////////// -PyObject *NodePath:: -__reduce__(PyObject *self) const { - return __reduce_persist__(self, NULL); -} -#endif // HAVE_PYTHON - -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: NodePath::__reduce_persist__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -// -// This is similar to __reduce__, but it provides -// additional support for the missing persistent-state -// object needed to properly support self-referential -// BAM objects written to the pickle stream. This hooks -// into the pickle and cPickle modules implemented in -// direct/src/stdpy. -//////////////////////////////////////////////////////////////////// -PyObject *NodePath:: -__reduce_persist__(PyObject *self, PyObject *pickler) const { - // We should return at least a 2-tuple, (Class, (args)): the - // necessary class object whose constructor we should call - // (e.g. this), and the arguments necessary to reconstruct this - // object. - - BamWriter *writer = NULL; - if (pickler != NULL) { - PyObject *py_writer = PyObject_GetAttrString(pickler, "bamWriter"); - if (py_writer == NULL) { - // It's OK if there's no bamWriter. - PyErr_Clear(); - } else { - DTOOL_Call_ExtractThisPointerForType(py_writer, &Dtool_BamWriter, (void **)&writer); - Py_DECREF(py_writer); - } - } - - // We have a non-empty NodePath. - - string bam_stream; - if (!encode_to_bam_stream(bam_stream, writer)) { - ostringstream stream; - stream << "Could not bamify " << this; - string message = stream.str(); - PyErr_SetString(PyExc_TypeError, message.c_str()); - return NULL; - } - - // Start by getting this class object. - PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; - } - - PyObject *func; - if (writer != NULL) { - // The modified pickle support: call the "persistent" version of - // this function, which receives the unpickler itself as an - // additional parameter. - func = TypedWritable::find_global_decode(this_class, "py_decode_NodePath_from_bam_stream_persist"); - if (func == NULL) { - PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_NodePath_from_bam_stream_persist()"); - Py_DECREF(this_class); - return NULL; - } - - } else { - // The traditional pickle support: call the non-persistent version - // of this function. - - func = TypedWritable::find_global_decode(this_class, "py_decode_NodePath_from_bam_stream"); - if (func == NULL) { - PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_NodePath_from_bam_stream()"); - Py_DECREF(this_class); - return NULL; - } - } - - PyObject *result = Py_BuildValue("(O(s#))", func, bam_stream.data(), bam_stream.size()); - Py_DECREF(func); - Py_DECREF(this_class); - return result; -} -#endif // HAVE_PYTHON - //////////////////////////////////////////////////////////////////// // Function: NodePath::operator bool // Access: Published @@ -6908,27 +6748,6 @@ find_net_tag(const string &key) const { return get_parent().find_net_tag(key); } -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_net_python_tag -// Access: Published -// Description: Returns the lowest ancestor of this node that -// contains a tag definition with the indicated key, if -// any, or an empty NodePath if no ancestor of this node -// contains this tag definition. See set_python_tag(). -//////////////////////////////////////////////////////////////////// -NodePath NodePath:: -find_net_python_tag(const string &key) const { - if (is_empty()) { - return NodePath::not_found(); - } - if (has_python_tag(key)) { - return *this; - } - return get_parent().find_net_python_tag(key); -} -#endif // HAVE_PYTHON - //////////////////////////////////////////////////////////////////// // Function: NodePath::write_bam_file // Access: Published @@ -8053,42 +7872,3 @@ r_find_all_materials(PandaNode *node, const RenderState *state, } } -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: py_decode_NodePath_from_bam_stream -// Access: Published -// Description: This wrapper is defined as a global function to suit -// pickle's needs. -//////////////////////////////////////////////////////////////////// -NodePath -py_decode_NodePath_from_bam_stream(const string &data) { - return py_decode_NodePath_from_bam_stream_persist(NULL, data); -} -#endif // HAVE_PYTHON - - -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: py_decode_NodePath_from_bam_stream_persist -// Access: Published -// Description: This wrapper is defined as a global function to suit -// pickle's needs. -//////////////////////////////////////////////////////////////////// -NodePath -py_decode_NodePath_from_bam_stream_persist(PyObject *unpickler, const string &data) { - BamReader *reader = NULL; - if (unpickler != NULL) { - PyObject *py_reader = PyObject_GetAttrString(unpickler, "bamReader"); - if (py_reader == NULL) { - // It's OK if there's no bamReader. - PyErr_Clear(); - } else { - DTOOL_Call_ExtractThisPointerForType(py_reader, &Dtool_BamReader, (void **)&reader); - Py_DECREF(py_reader); - } - } - - return NodePath::decode_from_bam_stream(data, reader); -} -#endif // HAVE_PYTHON - diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index c12ea43ce5..4bdbba41ff 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -179,12 +179,10 @@ PUBLISHED: INLINE NodePath(const NodePath ©); INLINE void operator = (const NodePath ©); -#ifdef HAVE_PYTHON - NodePath __copy__() const; - PyObject *__deepcopy__(PyObject *self, PyObject *memo) const; - PyObject *__reduce__(PyObject *self) const; - PyObject *__reduce_persist__(PyObject *self, PyObject *pickler) const; -#endif + EXTENSION(NodePath __copy__() const); + EXTENSION(PyObject *__deepcopy__(PyObject *self, PyObject *memo) const); + EXTENSION(PyObject *__reduce__(PyObject *self) const); + EXTENSION(PyObject *__reduce_persist__(PyObject *self, PyObject *pickler) const); INLINE static NodePath not_found(); INLINE static NodePath removed(); @@ -881,6 +879,8 @@ PUBLISHED: bool calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, Thread *current_thread = Thread::get_current_thread()) const; + EXTENSION(PyObject *get_tight_bounds() const); + // void analyze() const; int flatten_light(); @@ -898,18 +898,16 @@ PUBLISHED: INLINE bool has_net_tag(const string &key) const; NodePath find_net_tag(const string &key) const; -#ifdef HAVE_PYTHON - INLINE PyObject *get_tag_keys() const; - INLINE void set_python_tag(const string &key, PyObject *value); - INLINE PyObject *get_python_tag(const string &key) const; - INLINE void get_python_tag_keys(vector_string &keys) const; - INLINE PyObject *get_python_tag_keys() const; - INLINE bool has_python_tag(const string &key) const; - INLINE void clear_python_tag(const string &key); - INLINE PyObject *get_net_python_tag(const string &key) const; - INLINE bool has_net_python_tag(const string &key) const; - NodePath find_net_python_tag(const string &key) const; -#endif // HAVE_PYTHON + EXTENSION(INLINE PyObject *get_tag_keys() const); + EXTENSION(INLINE void set_python_tag(const string &key, PyObject *value)); + EXTENSION(INLINE PyObject *get_python_tag(const string &key) const); + EXTENSION(INLINE void get_python_tag_keys(vector_string &keys) const); + EXTENSION(INLINE PyObject *get_python_tag_keys() const); + EXTENSION(INLINE bool has_python_tag(const string &key) const); + EXTENSION(INLINE void clear_python_tag(const string &key)); + EXTENSION(INLINE PyObject *get_net_python_tag(const string &key) const); + EXTENSION(INLINE bool has_net_python_tag(const string &key) const); + EXTENSION(NodePath find_net_python_tag(const string &key) const); INLINE void list_tags() const; @@ -1015,13 +1013,6 @@ private: INLINE ostream &operator << (ostream &out, const NodePath &node_path); -#ifdef HAVE_PYTHON -BEGIN_PUBLISH -NodePath py_decode_NodePath_from_bam_stream(const string &data); -NodePath py_decode_NodePath_from_bam_stream_persist(PyObject *unpickler, const string &data); -END_PUBLISH -#endif - #include "nodePath.I" #endif diff --git a/panda/src/pgraph/nodePathCollection.cxx b/panda/src/pgraph/nodePathCollection.cxx index 2cebc6fa44..bd3ddfbcc6 100644 --- a/panda/src/pgraph/nodePathCollection.cxx +++ b/panda/src/pgraph/nodePathCollection.cxx @@ -96,37 +96,6 @@ NodePathCollection(PyObject *self, PyObject *sequence) { } #endif // HAVE_PYTHON -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::__reduce__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -//////////////////////////////////////////////////////////////////// -PyObject *NodePathCollection:: -__reduce__(PyObject *self) const { - // Here we will return a 4-tuple: (Class, (args), None, iterator), - // where iterator is an iterator that will yield successive - // NodePaths. - - // We should return at least a 2-tuple, (Class, (args)): the - // necessary class object whose constructor we should call - // (e.g. this), and the arguments necessary to reconstruct this - // object. - - PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; - } - - // Since a NodePathCollection is itself an iterator, we can simply - // pass it as the fourth tuple component. - PyObject *result = Py_BuildValue("(O()OO)", this_class, Py_None, self); - Py_DECREF(this_class); - return result; -} -#endif // HAVE_PYTHON - //////////////////////////////////////////////////////////////////// // Function: NodePathCollection::add_path // Access: Published @@ -490,7 +459,7 @@ get_collide_mask() const { // Access: Published // Description: Recursively applies the indicated CollideMask to the // into_collide_masks for all nodes at this level and -// below. Only nodes +// below. // // The default is to change all bits, but if // bits_to_change is not all bits on, then only the bits @@ -506,6 +475,49 @@ set_collide_mask(CollideMask new_mask, CollideMask bits_to_change, } } +//////////////////////////////////////////////////////////////////// +// Function: NodePathCollection::calc_tight_bounds +// Access: Published +// Description: Calculates the minimum and maximum vertices of all +// Geoms at these NodePath's bottom nodes and below +// This is a tight bounding box; it will generally be +// tighter than the bounding volume returned by +// get_bounds() (but it is more expensive to compute). +// +// The return value is true if any points are within the +// bounding volume, or false if none are. +//////////////////////////////////////////////////////////////////// +bool NodePathCollection:: +calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point) const { + bool have_bounds = false; + + for (int i = 0; i < get_num_paths(); i++) { + LPoint3 tmp_min; + LPoint3 tmp_max; + + if (get_path(i).is_empty()) { + continue; + } + + if (get_path(i).calc_tight_bounds(tmp_min, tmp_max)) { + if (!have_bounds) { + min_point = tmp_min; + max_point = tmp_max; + have_bounds = true; + } else { + min_point.set(min(min_point._v(0), tmp_min._v(0)), + min(min_point._v(1), tmp_min._v(1)), + min(min_point._v(2), tmp_min._v(2))); + max_point.set(max(max_point._v(0), tmp_max._v(0)), + max(max_point._v(1), tmp_max._v(1)), + max(max_point._v(2), tmp_max._v(2))); + } + } + } + + return have_bounds; +} + //////////////////////////////////////////////////////////////////// // Function: NodePathCollection::set_texture // Access: Published diff --git a/panda/src/pgraph/nodePathCollection.h b/panda/src/pgraph/nodePathCollection.h index 24cfe3f208..6265f85d16 100644 --- a/panda/src/pgraph/nodePathCollection.h +++ b/panda/src/pgraph/nodePathCollection.h @@ -35,7 +35,7 @@ PUBLISHED: #ifdef HAVE_PYTHON NodePathCollection(PyObject *self, PyObject *sequence); - PyObject *__reduce__(PyObject *self) const; + EXTENSION(PyObject *__reduce__(PyObject *self) const); #endif void add_path(const NodePath &node_path); @@ -77,6 +77,10 @@ PUBLISHED: void set_collide_mask(CollideMask new_mask, CollideMask bits_to_change = CollideMask::all_on(), TypeHandle node_type = TypeHandle::none()); + bool calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point) const; + + EXTENSION(PyObject *get_tight_bounds() const); + void set_texture(Texture *tex, int priority = 0); void set_texture(TextureStage *stage, Texture *tex, int priority = 0); void set_texture_off(int priority = 0); diff --git a/panda/src/putil/Sources.pp b/panda/src/putil/Sources.pp index f20e4ea9e8..6134d73f7c 100644 --- a/panda/src/putil/Sources.pp +++ b/panda/src/putil/Sources.pp @@ -64,7 +64,8 @@ sparseArray.I sparseArray.h \ string_utils.I string_utils.N string_utils.h \ timedCycle.I timedCycle.h typedWritable.I \ - typedWritable.h typedWritableReferenceCount.I \ + typedWritable.h typedWritable_ext.h typedWritable_ext.cxx \ + typedWritableReferenceCount.I \ typedWritableReferenceCount.h updateSeq.I updateSeq.h \ uniqueIdAllocator.h \ vector_typedWritable.h \ @@ -174,7 +175,7 @@ sparseArray.I sparseArray.h \ string_utils.I string_utils.h \ timedCycle.I timedCycle.h typedWritable.I \ - typedWritable.h typedWritableReferenceCount.I \ + typedWritable.h typedWritable_ext.h typedWritableReferenceCount.I \ typedWritableReferenceCount.h updateSeq.I updateSeq.h \ uniqueIdAllocator.h \ vector_typedWritable.h \ diff --git a/panda/src/putil/typedWritable.cxx b/panda/src/putil/typedWritable.cxx index 44c3ffa67b..b829b27126 100644 --- a/panda/src/putil/typedWritable.cxx +++ b/panda/src/putil/typedWritable.cxx @@ -25,13 +25,6 @@ LightMutex TypedWritable::_bam_writers_lock; TypeHandle TypedWritable::_type_handle; TypedWritable* const TypedWritable::Null = (TypedWritable*)0L; -#ifdef HAVE_PYTHON -#include "py_panda.h" -#ifndef CPPPARSER -extern EXPCL_PANDA_PUTIL Dtool_PyTypedObject Dtool_BamWriter; -#endif // CPPPARSER -#endif // HAVE_PYTHON - //////////////////////////////////////////////////////////////////// // Function: TypedWritable::Destructor // Access: Public, Virtual @@ -156,115 +149,6 @@ as_reference_count() { return NULL; } -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::__reduce__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -// -// This hooks into the native pickle and cPickle -// modules, but it cannot properly handle -// self-referential BAM objects. -//////////////////////////////////////////////////////////////////// -PyObject *TypedWritable:: -__reduce__(PyObject *self) const { - return __reduce_persist__(self, NULL); -} -#endif // HAVE_PYTHON - -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::__reduce_persist__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -// -// This is similar to __reduce__, but it provides -// additional support for the missing persistent-state -// object needed to properly support self-referential -// BAM objects written to the pickle stream. This hooks -// into the pickle and cPickle modules implemented in -// direct/src/stdpy. -//////////////////////////////////////////////////////////////////// -PyObject *TypedWritable:: -__reduce_persist__(PyObject *self, PyObject *pickler) const { - // We should return at least a 2-tuple, (Class, (args)): the - // necessary class object whose constructor we should call - // (e.g. this), and the arguments necessary to reconstruct this - // object. - - // Check that we have a decode_from_bam_stream python method. If not, - // we can't use this interface. - PyObject *method = PyObject_GetAttrString(self, "decode_from_bam_stream"); - if (method == NULL) { - ostringstream stream; - stream << "Cannot pickle objects of type " << get_type() << "\n"; - string message = stream.str(); - PyErr_SetString(PyExc_TypeError, message.c_str()); - return NULL; - } - Py_DECREF(method); - - BamWriter *writer = NULL; - if (pickler != NULL) { - PyObject *py_writer = PyObject_GetAttrString(pickler, "bamWriter"); - if (py_writer == NULL) { - // It's OK if there's no bamWriter. - PyErr_Clear(); - } else { - DTOOL_Call_ExtractThisPointerForType(py_writer, &Dtool_BamWriter, (void **)&writer); - Py_DECREF(py_writer); - } - } - - // First, streamify the object, if possible. - string bam_stream; - if (!encode_to_bam_stream(bam_stream, writer)) { - ostringstream stream; - stream << "Could not bamify object of type " << get_type() << "\n"; - string message = stream.str(); - PyErr_SetString(PyExc_TypeError, message.c_str()); - return NULL; - } - - // Start by getting this class object. - PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; - } - - PyObject *func; - if (writer != NULL) { - // The modified pickle support: call the "persistent" version of - // this function, which receives the unpickler itself as an - // additional parameter. - func = find_global_decode(this_class, "py_decode_TypedWritable_from_bam_stream_persist"); - if (func == NULL) { - PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_TypedWritable_from_bam_stream_persist()"); - Py_DECREF(this_class); - return NULL; - } - - } else { - // The traditional pickle support: call the non-persistent version - // of this function. - - func = find_global_decode(this_class, "py_decode_TypedWritable_from_bam_stream"); - if (func == NULL) { - PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_TypedWritable_from_bam_stream()"); - Py_DECREF(this_class); - return NULL; - } - } - - PyObject *result = Py_BuildValue("(O(Os#))", func, this_class, bam_stream.data(), bam_stream.size()); - Py_DECREF(func); - Py_DECREF(this_class); - return result; -} -#endif // HAVE_PYTHON - //////////////////////////////////////////////////////////////////// // Function: TypedWritable::encode_to_bam_stream // Access: Published @@ -291,10 +175,10 @@ encode_to_bam_stream(string &data, BamWriter *writer) const { if (!dout.open(stream)) { return false; } - + if (writer == NULL) { // Create our own writer. - + if (!dout.write_header(_bam_header)) { return false; } @@ -303,7 +187,7 @@ encode_to_bam_stream(string &data, BamWriter *writer) const { if (!writer.init()) { return false; } - + if (!writer.write_object(this)) { return false; } @@ -361,12 +245,11 @@ decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, if (reader == NULL) { // Create a local reader. - string head; if (!din.read_header(head, _bam_header.size())) { return false; } - + if (head != _bam_header) { return false; } @@ -375,15 +258,15 @@ decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, if (!reader.init()) { return false; } - + if (!reader.read_object(ptr, ref_ptr)) { return false; } - + if (!reader.resolve()) { return false; } - + if (ref_ptr == NULL) { // Can't support non-reference-counted objects. return false; @@ -400,12 +283,12 @@ decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, reader->set_source(NULL); return false; } - + if (!reader->resolve()) { reader->set_source(NULL); return false; } - + if (ref_ptr == NULL) { // Can't support non-reference-counted objects. reader->set_source(NULL); @@ -425,139 +308,3 @@ decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, ref_ptr->unref(); return true; } - -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::find_global_decode -// Access: Public, Static -// Description: This is a support function for __reduce__(). It -// searches for the global function -// py_decode_TypedWritable_from_bam_stream() in this -// class's module, or in the module for any base class. -// (It's really looking for the libpanda module, but we -// can't be sure what name that module was loaded under, -// so we search upwards this way.) -// -// Returns: new reference on success, or NULL on failure. -//////////////////////////////////////////////////////////////////// -PyObject *TypedWritable:: -find_global_decode(PyObject *this_class, const char *func_name) { - PyObject *module_name = PyObject_GetAttrString(this_class, "__module__"); - if (module_name != NULL) { - // borrowed reference - PyObject *sys_modules = PyImport_GetModuleDict(); - if (sys_modules != NULL) { - // borrowed reference - PyObject *module = PyDict_GetItem(sys_modules, module_name); - if (module != NULL){ - PyObject *func = PyObject_GetAttrString(module, (char *)func_name); - if (func != NULL) { - Py_DECREF(module_name); - return func; - } - } - } - } - Py_DECREF(module_name); - - PyObject *bases = PyObject_GetAttrString(this_class, "__bases__"); - if (bases != NULL) { - if (PySequence_Check(bases)) { - Py_ssize_t size = PySequence_Size(bases); - for (Py_ssize_t i = 0; i < size; ++i) { - PyObject *base = PySequence_GetItem(bases, i); - if (base != NULL) { - PyObject *func = find_global_decode(base, func_name); - Py_DECREF(base); - if (func != NULL) { - Py_DECREF(bases); - return func; - } - } - } - } - Py_DECREF(bases); - } - - return NULL; -} -#endif // HAVE_PYTHON - -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: py_decode_TypedWritable_from_bam_stream -// Access: Published -// Description: This wrapper is defined as a global function to suit -// pickle's needs. -// -// This hooks into the native pickle and cPickle -// modules, but it cannot properly handle -// self-referential BAM objects. -//////////////////////////////////////////////////////////////////// -PyObject * -py_decode_TypedWritable_from_bam_stream(PyObject *this_class, const string &data) { - return py_decode_TypedWritable_from_bam_stream_persist(NULL, this_class, data); -} -#endif // HAVE_PYTHON - - -#ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: py_decode_TypedWritable_from_bam_stream_persist -// Access: Published -// Description: This wrapper is defined as a global function to suit -// pickle's needs. -// -// This is similar to -// py_decode_TypedWritable_from_bam_stream, but it -// provides additional support for the missing -// persistent-state object needed to properly support -// self-referential BAM objects written to the pickle -// stream. This hooks into the pickle and cPickle -// modules implemented in direct/src/stdpy. -//////////////////////////////////////////////////////////////////// -PyObject * -py_decode_TypedWritable_from_bam_stream_persist(PyObject *pickler, PyObject *this_class, const string &data) { - - PyObject *py_reader = NULL; - if (pickler != NULL) { - py_reader = PyObject_GetAttrString(pickler, "bamReader"); - if (py_reader == NULL) { - // It's OK if there's no bamReader. - PyErr_Clear(); - } - } - - // We need the function PandaNode::decode_from_bam_stream or - // TypedWritableReferenceCount::decode_from_bam_stream, which - // invokes the BamReader to reconstruct this object. Since we use - // the specific object's class as the pointer, we get the particular - // instance of decode_from_bam_stream appropriate to this class. - - PyObject *func = PyObject_GetAttrString(this_class, "decode_from_bam_stream"); - if (func == NULL) { - return NULL; - } - - PyObject *result; - if (py_reader != NULL){ - result = PyObject_CallFunction(func, (char *)"(s#O)", data.data(), data.size(), py_reader); - Py_DECREF(py_reader); - } else { - result = PyObject_CallFunction(func, (char *)"(s#)", data.data(), data.size()); - } - - if (result == NULL) { - return NULL; - } - - if (result == Py_None) { - Py_DECREF(result); - PyErr_SetString(PyExc_ValueError, "Could not unpack bam stream"); - return NULL; - } - - return result; -} -#endif // HAVE_PYTHON - diff --git a/panda/src/putil/typedWritable.h b/panda/src/putil/typedWritable.h index df1a4a339f..e8a0dd65d4 100644 --- a/panda/src/putil/typedWritable.h +++ b/panda/src/putil/typedWritable.h @@ -12,8 +12,8 @@ // //////////////////////////////////////////////////////////////////// -#ifndef __TYPED_WRITABLE_ -#define __TYPED_WRITABLE_ +#ifndef TYPEDWRITABLE_H +#define TYPEDWRITABLE_H #include "typedObject.h" #include "vector_typedWritable.h" @@ -31,10 +31,9 @@ class ReferenceCount; // Class : TypedWritable // Description : Base class for objects that can be written to and // read from Bam files. -// +// // See also TypedObject for detailed instructions. //////////////////////////////////////////////////////////////////// - class EXPCL_PANDA_PUTIL TypedWritable : public TypedObject { public: static TypedWritable* const Null; @@ -60,23 +59,16 @@ PUBLISHED: INLINE void mark_bam_modified(); INLINE UpdateSeq get_bam_modified() const; -#ifdef HAVE_PYTHON - PyObject *__reduce__(PyObject *self) const; - PyObject *__reduce_persist__(PyObject *self, PyObject *pickler) const; -#endif + EXTENSION(PyObject *__reduce__(PyObject *self) const); + EXTENSION(PyObject *__reduce_persist__(PyObject *self, PyObject *pickler) const); INLINE string encode_to_bam_stream() const; bool encode_to_bam_stream(string &data, BamWriter *writer = NULL) const; - static bool decode_raw_from_bam_stream(TypedWritable *&ptr, + static bool decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, const string &data, BamReader *reader = NULL); -public: -#ifdef HAVE_PYTHON - static PyObject *find_global_decode(PyObject *this_class, const char *func_name); -#endif - private: // We may need to store a list of the BamWriter(s) that have a // reference to this object, so that we can remove the object from @@ -111,15 +103,6 @@ private: friend class BamWriter; }; -#ifdef HAVE_PYTHON -BEGIN_PUBLISH -PyObject *py_decode_TypedWritable_from_bam_stream(PyObject *this_class, const string &data); -PyObject *py_decode_TypedWritable_from_bam_stream_persist(PyObject *unpickler, PyObject *this_class, const string &data); -END_PUBLISH -#endif - #include "typedWritable.I" #endif - -