Dave Schuyler 20 rokov pred
rodič
commit
5b9c717f3d

+ 70 - 70
direct/src/ffi/FFITypes.py

@@ -46,7 +46,7 @@ class BaseTypeDescriptor:
 
 
         # The type descriptors for the types we derive from
         # The type descriptors for the types we derive from
         self.parentTypes = []
         self.parentTypes = []
-        
+
         # atomicType may be one of the following
         # atomicType may be one of the following
         # AT_not_atomic = 0
         # AT_not_atomic = 0
         # AT_int = 1
         # AT_int = 1
@@ -65,7 +65,7 @@ class BaseTypeDescriptor:
 
 
     def isAtomic(self):
     def isAtomic(self):
         return (self.atomicType != 0)
         return (self.atomicType != 0)
-        
+
     def generateGlobalCode(self, dir, extensionsDir):
     def generateGlobalCode(self, dir, extensionsDir):
         # By default generate no code
         # By default generate no code
         pass
         pass
@@ -100,7 +100,7 @@ class PrimitiveTypeDescriptor(BaseTypeDescriptor):
     """
     """
     def __init__(self):
     def __init__(self):
         BaseTypeDescriptor.__init__(self)
         BaseTypeDescriptor.__init__(self)
-                
+
     def generateReturnValueWrapper(self, classTypeDesc, file, userManagesMemory,
     def generateReturnValueWrapper(self, classTypeDesc, file, userManagesMemory,
                                    needsDowncast, nesting):
                                    needsDowncast, nesting):
         """
         """
@@ -117,7 +117,7 @@ class PyObjectTypeDescriptor(BaseTypeDescriptor):
     """
     """
     def __init__(self):
     def __init__(self):
         BaseTypeDescriptor.__init__(self)
         BaseTypeDescriptor.__init__(self)
-                
+
     def generateReturnValueWrapper(self, classTypeDesc, file, userManagesMemory,
     def generateReturnValueWrapper(self, classTypeDesc, file, userManagesMemory,
                                    needsDowncast, nesting):
                                    needsDowncast, nesting):
         indent(file, nesting, 'return returnValue\n')
         indent(file, nesting, 'return returnValue\n')
@@ -154,7 +154,7 @@ class EnumTypeDescriptor(PrimitiveTypeDescriptor):
         indent(file, nesting, '# CMODULE [' + self.moduleName + ']\n')
         indent(file, nesting, '# CMODULE [' + self.moduleName + ']\n')
         self.outputComment(file, nesting)
         self.outputComment(file, nesting)
         self.outputValues(file, nesting)
         self.outputValues(file, nesting)
-        
+
 
 
     def outputComment(self, file, nesting):
     def outputComment(self, file, nesting):
         indent(file, nesting, '\n')
         indent(file, nesting, '\n')
@@ -172,7 +172,7 @@ class EnumTypeDescriptor(PrimitiveTypeDescriptor):
         """
         """
         for key in self.values.keys():
         for key in self.values.keys():
             indent(file, nesting, key + ' = ' + `self.values[key]` + '\n')
             indent(file, nesting, key + ' = ' + `self.values[key]` + '\n')
-            
+
 
 
 class DerivedTypeDescriptor(BaseTypeDescriptor):
 class DerivedTypeDescriptor(BaseTypeDescriptor):
     """
     """
@@ -182,7 +182,7 @@ class DerivedTypeDescriptor(BaseTypeDescriptor):
     def __init__(self):
     def __init__(self):
         BaseTypeDescriptor.__init__(self)
         BaseTypeDescriptor.__init__(self)
         self.typeDescriptor = None
         self.typeDescriptor = None
-        
+
     def recursiveTypeDescriptor(self):
     def recursiveTypeDescriptor(self):
         """
         """
         Attempt to get to the bottom of a type descriptor by
         Attempt to get to the bottom of a type descriptor by
@@ -213,26 +213,26 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
     """
     """
     def __init__(self):
     def __init__(self):
         BaseTypeDescriptor.__init__(self)
         BaseTypeDescriptor.__init__(self)
-        
+
         # Methods interrogate told us were constructors
         # Methods interrogate told us were constructors
         self.constructors = []
         self.constructors = []
-        
+
         # A method interrogate told us is the destructor
         # A method interrogate told us is the destructor
         self.destructor = None
         self.destructor = None
-        
+
         # Methods interrogate told us were instance methods
         # Methods interrogate told us were instance methods
         # Note: the methods without the this pointer get moved into staticMethods
         # Note: the methods without the this pointer get moved into staticMethods
         self.instanceMethods = []
         self.instanceMethods = []
-        
+
         # Methods interrogate told us were upcast methods
         # Methods interrogate told us were upcast methods
         self.upcastMethods = []
         self.upcastMethods = []
-        
+
         # Methods interrogate told us were downcast methods
         # Methods interrogate told us were downcast methods
         self.downcastMethods = []
         self.downcastMethods = []
-        
+
         # Instance methods that had no this pointer are moved into here
         # Instance methods that had no this pointer are moved into here
         self.staticMethods = []
         self.staticMethods = []
-        
+
         # These are dictionaries used to temporarily hold methods for
         # These are dictionaries used to temporarily hold methods for
         # overloading while generating code
         # overloading while generating code
         self.overloadedClassMethods = {}
         self.overloadedClassMethods = {}
@@ -305,7 +305,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
                     for method in parentType.upcastMethods:
                     for method in parentType.upcastMethods:
                         upcastMethods.append(method)
                         upcastMethods.append(method)
             for method in (self.constructors + [self.destructor] + self.instanceMethods
             for method in (self.constructors + [self.destructor] + self.instanceMethods
-                           + self.upcastMethods + self.downcastMethods 
+                           + self.upcastMethods + self.downcastMethods
                            + self.staticMethods + upcastMethods):
                            + self.staticMethods + upcastMethods):
                 if method:
                 if method:
                     # Get the real return type (not derived)
                     # Get the real return type (not derived)
@@ -345,7 +345,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
         """
         """
         methodList = self.overloadedClassMethods.setdefault(methodSpec.name, [])
         methodList = self.overloadedClassMethods.setdefault(methodSpec.name, [])
         methodList.append(methodSpec)
         methodList.append(methodSpec)
-    
+
 
 
     def recordInstanceMethod(self, methodSpec):
     def recordInstanceMethod(self, methodSpec):
         """
         """
@@ -437,7 +437,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
             if parentList[pi].hasMethodNamed(methodName):
             if parentList[pi].hasMethodNamed(methodName):
                 return 1
                 return 1
         return 0
         return 0
-        
+
     def copyParentMethodsRecursively(self, parentList, file, nesting):
     def copyParentMethodsRecursively(self, parentList, file, nesting):
         """
         """
         Copy all the parents instance methods
         Copy all the parents instance methods
@@ -464,13 +464,13 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
             if not self.inheritsMethodNamed(parentList, methodSpecList[0].name):
             if not self.inheritsMethodNamed(parentList, methodSpecList[0].name):
                 treeColl = FFIOverload.FFIMethodArgumentTreeCollection(self, methodSpecList)
                 treeColl = FFIOverload.FFIMethodArgumentTreeCollection(self, methodSpecList)
                 treeColl.generateCode(file, nesting)
                 treeColl.generateCode(file, nesting)
-                
+
         # Copy all the parents upcast methods so we transitively pick them up
         # Copy all the parents upcast methods so we transitively pick them up
         for method in parent.upcastMethods:
         for method in parent.upcastMethods:
             if not self.inheritsMethodNamed(parentList, method.name):
             if not self.inheritsMethodNamed(parentList, method.name):
                 # no downcast for all instance methods that are themselves upcasts
                 # no downcast for all instance methods that are themselves upcasts
                 # that would cause an infinite loop
                 # that would cause an infinite loop
-                method.generateInheritedMethodCode(self, parentList, file, nesting, 0) 
+                method.generateInheritedMethodCode(self, parentList, file, nesting, 0)
 
 
         # Now recurse up the hierarchy until we get to a node that is itself
         # Now recurse up the hierarchy until we get to a node that is itself
         # a multiple inheritance node and stop there because he will have already
         # a multiple inheritance node and stop there because he will have already
@@ -511,16 +511,16 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
         file = open(os.path.join(dir, fileName), 'w')
         file = open(os.path.join(dir, fileName), 'w')
         indent(file, 0, FFIConstants.generatedHeader)
         indent(file, 0, FFIConstants.generatedHeader)
         self.outputBaseImports(file)
         self.outputBaseImports(file)
-        self.generateCode1(file, 0,extensionsDir)
+        self.generateCode1(file, 0, extensionsDir)
         file.close()
         file.close()
-        
+
         file = open(os.path.join(dir, fileName1), 'w')
         file = open(os.path.join(dir, fileName1), 'w')
         indent(file, 0, FFIConstants.generatedHeader)
         indent(file, 0, FFIConstants.generatedHeader)
         #self.outputBaseImports(file)
         #self.outputBaseImports(file)
-        self.generateCode2(file, 0,extensionsDir,self.foreignTypeName)
+        self.generateCode2(file, 0, extensionsDir, self.foreignTypeName)
         file.close()
         file.close()
 
 
-        
+
         # Copy in any extensions we may have
         # Copy in any extensions we may have
         #self.copyExtensions(extensionsDir, file, 0)
         #self.copyExtensions(extensionsDir, file, 0)
         #self.outputClassFooter(file)
         #self.outputClassFooter(file)
@@ -530,7 +530,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
     def generateCode(self, file, nesting, extensionsDir=None):
     def generateCode(self, file, nesting, extensionsDir=None):
 
 
         self.recordOverloadedMethods()
         self.recordOverloadedMethods()
-        self.cullOverloadedMethods()        
+        self.cullOverloadedMethods()
         self.outputImports(file, nesting)
         self.outputImports(file, nesting)
         self.outputClassHeader(file, nesting)
         self.outputClassHeader(file, nesting)
         self.outputClassComment(file, nesting)
         self.outputClassComment(file, nesting)
@@ -559,22 +559,22 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
         if self.destructor:
         if self.destructor:
             self.destructor.generateDestructorCode(self, file, nesting)
             self.destructor.generateDestructorCode(self, file, nesting)
         # If you have no destructor, inherit one
         # If you have no destructor, inherit one
-            
+
         ##########################
         ##########################
         ## Extension methods moved up locally
         ## Extension methods moved up locally
         if extensionsDir:
         if extensionsDir:
-            self.copyExtensions(extensionsDir, file, 0)                    
-            
+            self.copyExtensions(extensionsDir, file, 0)
+
         ##########################
         ##########################
         ## import return types
         ## import return types
         returnTypeModules = self.getReturnTypeModules()
         returnTypeModules = self.getReturnTypeModules()
         if len(returnTypeModules):
         if len(returnTypeModules):
             for moduleName in returnTypeModules:
             for moduleName in returnTypeModules:
-                indent(file, nesting, 'import ' + moduleName + '\n')       
-        
+                indent(file, nesting, 'import ' + moduleName + '\n')
+
         ################################
         ################################
-        
-            
+
+
         if len(self.staticMethods):
         if len(self.staticMethods):
             indent(file, nesting+1, '\n')
             indent(file, nesting+1, '\n')
             indent(file, nesting+1, '##################################################\n')
             indent(file, nesting+1, '##################################################\n')
@@ -613,13 +613,13 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
 
 
         # Copy in all our parent nodes (only does work if we are an MI node)
         # Copy in all our parent nodes (only does work if we are an MI node)
         self.copyParentMethods(file, nesting)
         self.copyParentMethods(file, nesting)
-        
+
         self.generateOverloadedMethods(file, nesting)
         self.generateOverloadedMethods(file, nesting)
 
 
     def generateCode1(self, file, nesting, extensionsDir=None):
     def generateCode1(self, file, nesting, extensionsDir=None):
 
 
         self.recordOverloadedMethods()
         self.recordOverloadedMethods()
-        self.cullOverloadedMethods()        
+        self.cullOverloadedMethods()
         self.outputImports(file, nesting)
         self.outputImports(file, nesting)
         self.outputClassHeader(file, nesting)
         self.outputClassHeader(file, nesting)
         self.outputClassComment(file, nesting)
         self.outputClassComment(file, nesting)
@@ -647,28 +647,28 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
         self.outputBaseDestructor(file, nesting)
         self.outputBaseDestructor(file, nesting)
         if self.destructor:
         if self.destructor:
             self.destructor.generateDestructorCode(self, file, nesting)
             self.destructor.generateDestructorCode(self, file, nesting)
-        # If you have no destructor, inherit one            
+        # If you have no destructor, inherit one
         ##########################
         ##########################
         ## Extension methods moved up locally
         ## Extension methods moved up locally
         if extensionsDir:
         if extensionsDir:
-            self.copyExtensions(extensionsDir, file, 0)                    
-            
+            self.copyExtensions(extensionsDir, file, 0)
+
 
 
 
 
     def generateCode2(self, file, nesting, extensionsDir, file1module):
     def generateCode2(self, file, nesting, extensionsDir, file1module):
-    
-        indent(file, nesting, 'from  ' + file1module + ' import *\n')               
+
+        indent(file, nesting, 'from  ' + file1module + ' import *\n')
 
 
         ##########################
         ##########################
         ## import return types
         ## import return types
         returnTypeModules = self.getReturnTypeModules()
         returnTypeModules = self.getReturnTypeModules()
         if len(returnTypeModules):
         if len(returnTypeModules):
             for moduleName in returnTypeModules:
             for moduleName in returnTypeModules:
-                indent(file, nesting, 'import ' + moduleName + '\n')       
-        
+                indent(file, nesting, 'import ' + moduleName + '\n')
+
         ################################
         ################################
-        
-            
+
+
         if len(self.staticMethods):
         if len(self.staticMethods):
             indent(file, nesting+1, '\n')
             indent(file, nesting+1, '\n')
             indent(file, nesting+1, '##################################################\n')
             indent(file, nesting+1, '##################################################\n')
@@ -707,7 +707,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
 
 
         # Copy in all our parent nodes (only does work if we are an MI node)
         # Copy in all our parent nodes (only does work if we are an MI node)
         self.copyParentMethods(file, nesting)
         self.copyParentMethods(file, nesting)
-        
+
         self.generateOverloadedMethods(file, nesting)
         self.generateOverloadedMethods(file, nesting)
 
 
 
 
@@ -744,7 +744,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
         else:
         else:
             # No extensions for this class
             # No extensions for this class
             pass
             pass
-        
+
 
 
     def outputBaseImports(self, file):
     def outputBaseImports(self, file):
         indent(file, 0, '# CMODULE [' + self.moduleName + ']\n')
         indent(file, 0, '# CMODULE [' + self.moduleName + ']\n')
@@ -756,11 +756,11 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
         indent(file, 0, '# Import all the C modules this class uses\n')
         indent(file, 0, '# Import all the C modules this class uses\n')
         for moduleName in self.getCModules():
         for moduleName in self.getCModules():
             if moduleName:
             if moduleName:
-                indent(file, 0, 'import ' + moduleName + '\n')            
+                indent(file, 0, 'import ' + moduleName + '\n')
                 indent(file, 0, 'import ' + moduleName + 'Downcasts\n')
                 indent(file, 0, 'import ' + moduleName + 'Downcasts\n')
         indent(file, 0, '\n')
         indent(file, 0, '\n')
         indent(file, 0, 'from direct.ffi import FFIExternalObject\n')
         indent(file, 0, 'from direct.ffi import FFIExternalObject\n')
-        
+
 
 
 
 
     def outputImportsRecursively(self, parent, file, nesting):
     def outputImportsRecursively(self, parent, file, nesting):
@@ -771,7 +771,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
         parentTypeName = parent.foreignTypeName
         parentTypeName = parent.foreignTypeName
         fullNestedName = parent.getFullNestedName()
         fullNestedName = parent.getFullNestedName()
         if (fullNestedName != parentTypeName):
         if (fullNestedName != parentTypeName):
-            nestedChain = fullNestedName.split(".") 
+            nestedChain = fullNestedName.split(".")
             moduleName = nestedChain[0]
             moduleName = nestedChain[0]
             indent(file, nesting, 'import ' + moduleName + '\n')
             indent(file, nesting, 'import ' + moduleName + '\n')
         else:
         else:
@@ -781,7 +781,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
         #if len(returnTypeModules):
         #if len(returnTypeModules):
         #    for moduleName in returnTypeModules:
         #    for moduleName in returnTypeModules:
         #        indent(file, nesting, 'import ' + moduleName + '\n')
         #        indent(file, nesting, 'import ' + moduleName + '\n')
-        
+
 
 
     def outputImports(self, file, nesting):
     def outputImports(self, file, nesting):
         """
         """
@@ -795,7 +795,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
         #if len(returnTypeModules):
         #if len(returnTypeModules):
         #    for moduleName in returnTypeModules:
         #    for moduleName in returnTypeModules:
         #        indent(file, nesting, 'import ' + moduleName + '\n')
         #        indent(file, nesting, 'import ' + moduleName + '\n')
-       
+
         for parentType in self.parentTypes:
         for parentType in self.parentTypes:
             self.outputImportsRecursively(parentType, file, nesting)
             self.outputImportsRecursively(parentType, file, nesting)
         indent(file, nesting, '\n')
         indent(file, nesting, '\n')
@@ -815,7 +815,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
                 indent(file, nesting+1, comment)
                 indent(file, nesting+1, comment)
                 file.write('\n')
                 file.write('\n')
                 indent(file, nesting+1, ('"' * 3) + '\n\n')
                 indent(file, nesting+1, ('"' * 3) + '\n\n')
-    
+
     def outputClassHeader(self, file, nesting):
     def outputClassHeader(self, file, nesting):
         """
         """
         Output the class definition to the file
         Output the class definition to the file
@@ -824,7 +824,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
         if (self.foreignTypeName == ''):
         if (self.foreignTypeName == ''):
             FFIConstants.notify.warning('Class with no name')
             FFIConstants.notify.warning('Class with no name')
 
 
-        
+
 #          # If this is the toplevel, we need to delay the generation of this
 #          # If this is the toplevel, we need to delay the generation of this
 #          # class to avoid circular imports, so put the entire class in a function
 #          # class to avoid circular imports, so put the entire class in a function
 #          # that we will call later
 #          # that we will call later
@@ -858,7 +858,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
             #     parentClassModule.parentClass.nestedClass
             #     parentClassModule.parentClass.nestedClass
             fullNestedName = self.parentTypes[i].getFullNestedName()
             fullNestedName = self.parentTypes[i].getFullNestedName()
             if (fullNestedName != parentTypeName):
             if (fullNestedName != parentTypeName):
-                nestedChain = fullNestedName.split(".") 
+                nestedChain = fullNestedName.split(".")
                 moduleName = nestedChain[0]
                 moduleName = nestedChain[0]
                 parentTypeName = fullNestedName
                 parentTypeName = fullNestedName
             file.write(moduleName + '.' + parentTypeName)
             file.write(moduleName + '.' + parentTypeName)
@@ -888,7 +888,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
         #indent(file, 0, " globals()['" + self.foreignTypeName + "'] = " + self.foreignTypeName + '\n')
         #indent(file, 0, " globals()['" + self.foreignTypeName + "'] = " + self.foreignTypeName + '\n')
         pass
         pass
 
 
-    
+
     def outputBaseConstructor(self, file, nesting):
     def outputBaseConstructor(self, file, nesting):
         """
         """
         Output the __init__ constructor for this class.
         Output the __init__ constructor for this class.
@@ -930,7 +930,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
         Python object is garbage collected. We are going to overwrite
         Python object is garbage collected. We are going to overwrite
         it with special cleanup for Panda.
         it with special cleanup for Panda.
         """
         """
-        if self.destructor:        
+        if self.destructor:
             indent(file, nesting+1, 'def __del__(self):\n')
             indent(file, nesting+1, 'def __del__(self):\n')
 
 
             # Reference counting is now handled in the C++ code
             # Reference counting is now handled in the C++ code
@@ -943,10 +943,10 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
             # we need to call the C++ destructor when Python frees the
             # we need to call the C++ destructor when Python frees the
             # shadow object, but only if the userManagesMemory flag is set.
             # shadow object, but only if the userManagesMemory flag is set.
             # Also make sure we are not destructing a null pointer
             # Also make sure we are not destructing a null pointer
-            indent(file, nesting+2, 'if (self.userManagesMemory and (self.this != 0)):\n')       
+            indent(file, nesting+2, 'if (self.userManagesMemory and (self.this != 0)):\n')
             self.destructor.outputDestructorBody(self, file, nesting+1)
             self.destructor.outputDestructorBody(self, file, nesting+1)
-            indent(file, nesting, '\n')            
-        
+            indent(file, nesting, '\n')
+
             #indent(file, nesting+3, 'self.destructor()\n')
             #indent(file, nesting+3, 'self.destructor()\n')
 
 
 
 
@@ -969,18 +969,18 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
         """
         """
         #if classTypeDesc != self:
         #if classTypeDesc != self:
         #    indent(file, nesting, 'import ' + self.foreignTypeName + '\n')
         #    indent(file, nesting, 'import ' + self.foreignTypeName + '\n')
-        indent(file,nesting, 'if returnValue == 0: return None\n')       
+        indent(file, nesting, 'if returnValue == 0: return None\n')
         # Do not put Class.Class if this file is the file that defines Class
         # Do not put Class.Class if this file is the file that defines Class
         # Also check for nested classes. They do not need the module name either
         # Also check for nested classes. They do not need the module name either
         typeName = FFIOverload.getTypeName(classTypeDesc, self)
         typeName = FFIOverload.getTypeName(classTypeDesc, self)
-        #file.write(typeName + '(None)\n')        
+        #file.write(typeName + '(None)\n')
         ### inline the old constructers
         ### inline the old constructers
-        
+
         #indent(file, nesting, 'returnObject = ')
         #indent(file, nesting, 'returnObject = ')
-        #file.write('FFIExternalObject.FFIInstance('+ typeName + ',returnValue,'+str(userManagesMemory)+')\n')
-        #indent(file,nesting, 'returnObject.this = 0\n')
-        #indent(file,nesting, 'returnObject.userManagesMemory = 0\n');        
-        
+        #file.write('FFIExternalObject.FFIInstance('+ typeName + ', returnValue,'+str(userManagesMemory)+')\n')
+        #indent(file, nesting, 'returnObject.this = 0\n')
+        #indent(file, nesting, 'returnObject.userManagesMemory = 0\n');
+
         ##
         ##
         #indent(file, nesting, 'returnObject.this = returnValue\n')
         #indent(file, nesting, 'returnObject.this = returnValue\n')
         # Zero this pointers get returned as the Python None object
         # Zero this pointers get returned as the Python None object
@@ -989,20 +989,20 @@ class ClassTypeDescriptor(BaseTypeDescriptor):
         #    indent(file, nesting, 'returnObject.userManagesMemory = 1\n')
         #    indent(file, nesting, 'returnObject.userManagesMemory = 1\n')
         #else:
         #else:
         #    indent(file, nesting, 'returnObject.userManagesMemory = 0\n')
         #    indent(file, nesting, 'returnObject.userManagesMemory = 0\n')
-                    
+
         if needsDowncast:
         if needsDowncast:
-            #indent(file, nesting, 'returnObject = FFIExternalObject.FFIInstance('+ typeName + ',returnValue,'+str(userManagesMemory)+')\n')
+            #indent(file, nesting, 'returnObject = FFIExternalObject.FFIInstance('+ typeName + ', returnValue,'+str(userManagesMemory)+')\n')
             if (FFIOverload.inheritsFrom(self, TypedObjectDescriptor) or
             if (FFIOverload.inheritsFrom(self, TypedObjectDescriptor) or
                 self == TypedObjectDescriptor):
                 self == TypedObjectDescriptor):
                 #indent(file, nesting, 'return returnObject.setPointer()\n')
                 #indent(file, nesting, 'return returnObject.setPointer()\n')
-                indent(file, nesting, 'return FFIExternalObject.FFIInstance('+ typeName + ',returnValue,'+str(userManagesMemory)+').setPointer()\n')              
+                indent(file, nesting, 'return FFIExternalObject.FFIInstance('+ typeName + ', returnValue,'+str(userManagesMemory)+').setPointer()\n')
             else:
             else:
-                indent(file, nesting,'return FFIExternalObject.FFIInstance('+ typeName + ',returnValue,'+str(userManagesMemory)+')\n')        
+                indent(file, nesting,'return FFIExternalObject.FFIInstance('+ typeName + ', returnValue,'+str(userManagesMemory)+')\n')
                 #indent(file, nesting, 'return returnObject\n')
                 #indent(file, nesting, 'return returnObject\n')
         else:
         else:
-            indent(file, nesting,'return FFIExternalObject.FFIInstance('+ typeName + ',returnValue,'+str(userManagesMemory)+')\n')        
+            indent(file, nesting,'return FFIExternalObject.FFIInstance('+ typeName + ', returnValue,'+str(userManagesMemory)+')\n')
             #indent(file, nesting, 'return returnObject\n')
             #indent(file, nesting, 'return returnObject\n')
-            
+
 
 
 
 
 class FunctionTypeDescriptor(BaseTypeDescriptor):
 class FunctionTypeDescriptor(BaseTypeDescriptor):

+ 10 - 10
direct/src/ffi/jGenPyCode.py

@@ -14,7 +14,7 @@
 #
 #
 ##############################################################
 ##############################################################
 
 
-import sys,os
+import sys, os
 
 
 ##############################################################
 ##############################################################
 #
 #
@@ -40,8 +40,8 @@ if (PANDAC is None):
 
 
 ##############################################################
 ##############################################################
 #
 #
-# Locate direct/src/extensions. 
-# 
+# Locate direct/src/extensions.
+#
 # It could be inside the direct tree.  It may be underneath
 # It could be inside the direct tree.  It may be underneath
 # a 'src' subdirectory.  Or, the direct tree may actually be
 # a 'src' subdirectory.  Or, the direct tree may actually be
 # a stub that points to the source tree.
 # a stub that points to the source tree.
@@ -83,13 +83,13 @@ DoGenPyCode.etcPath = [os.path.join(PANDAC,"input")]
 DoGenPyCode.pythonSourcePath = [DIRECT]
 DoGenPyCode.pythonSourcePath = [DIRECT]
 DoGenPyCode.native = 1
 DoGenPyCode.native = 1
 
 
-#print "outputDir = ",DoGenPyCode.outputDir
-#print "directDir = ",DoGenPyCode.directDir
-#print "extensionsDir = ",DoGenPyCode.extensionsDir
-#print "interrogateLib = ",DoGenPyCode.interrogateLib
-#print "codeLibs = ",DoGenPyCode.codeLibs
-#print "etcPath = ",DoGenPyCode.etcPath
-#print "native = ",DoGenPyCode.native
+#print "outputDir = ", DoGenPyCode.outputDir
+#print "directDir = ", DoGenPyCode.directDir
+#print "extensionsDir = ", DoGenPyCode.extensionsDir
+#print "interrogateLib = ", DoGenPyCode.interrogateLib
+#print "codeLibs = ", DoGenPyCode.codeLibs
+#print "etcPath = ", DoGenPyCode.etcPath
+#print "native = ", DoGenPyCode.native
 
 
 DoGenPyCode.run()
 DoGenPyCode.run()
 
 

+ 6 - 7
direct/src/showbase/Loader.py

@@ -14,7 +14,7 @@ class Loader:
     """
     """
     notify = directNotify.newCategory("Loader")
     notify = directNotify.newCategory("Loader")
     modelCount = 0
     modelCount = 0
-    
+
     # special methods
     # special methods
     def __init__(self, base):
     def __init__(self, base):
         self.base = base
         self.base = base
@@ -23,7 +23,7 @@ class Loader:
     def destroy(self):
     def destroy(self):
         del self.base
         del self.base
         del self.loader
         del self.loader
-        
+
     # model loading funcs
     # model loading funcs
     def loadModel(self, modelPath, fMakeNodeNamesUnique = 0,
     def loadModel(self, modelPath, fMakeNodeNamesUnique = 0,
                   loaderOptions = None):
                   loaderOptions = None):
@@ -79,7 +79,8 @@ class Loader:
         want to load a model and immediately set a transform on it.
         want to load a model and immediately set a transform on it.
         But also consider loadModelCopy().
         But also consider loadModelCopy().
         """
         """
-        assert Loader.notify.debug("Loading model once: %s under %s" % (modelPath, underNode))
+        assert Loader.notify.debug(
+            "Loading model once: %s under %s" % (modelPath, underNode))
         if phaseChecker:
         if phaseChecker:
             phaseChecker(modelPath)
             phaseChecker(modelPath)
         node = ModelPool.loadModel(modelPath)
         node = ModelPool.loadModel(modelPath)
@@ -89,7 +90,7 @@ class Loader:
         else:
         else:
             nodePath = None
             nodePath = None
         return nodePath
         return nodePath
-    
+
     def loadModelCopy(self, modelPath):
     def loadModelCopy(self, modelPath):
         """loadModelCopy(self, string)
         """loadModelCopy(self, string)
         Attempt to load a model from modelPool, if not present
         Attempt to load a model from modelPool, if not present
@@ -108,7 +109,7 @@ class Loader:
     def loadModelNode(self, modelPath):
     def loadModelNode(self, modelPath):
         """
         """
         modelPath is a string.
         modelPath is a string.
-        
+
         This is like loadModelOnce in that it loads a model from the
         This is like loadModelOnce in that it loads a model from the
         modelPool, but it does not then instance it to hidden and it
         modelPool, but it does not then instance it to hidden and it
         returns a Node instead of a NodePath.  This is particularly
         returns a Node instead of a NodePath.  This is particularly
@@ -296,5 +297,3 @@ class Loader:
         if (shader == None):
         if (shader == None):
             Loader.notify.warning("Could not load shader file %s." % shaderPath)
             Loader.notify.warning("Could not load shader file %s." % shaderPath)
         return shader
         return shader
-        
-        

+ 36 - 37
direct/src/tkpanels/Placer.py

@@ -31,7 +31,7 @@ class Placer(AppShell):
 
 
         # Call superclass initialization function
         # Call superclass initialization function
         AppShell.__init__(self)
         AppShell.__init__(self)
-        
+
         self.initialiseoptions(Placer)
         self.initialiseoptions(Placer)
 
 
     def appInit(self):
     def appInit(self):
@@ -41,7 +41,7 @@ class Placer(AppShell):
             'placerOrbitFromCS')
             'placerOrbitFromCS')
         self.orbitToCS = direct.group.attachNewNode('placerOrbitToCS')
         self.orbitToCS = direct.group.attachNewNode('placerOrbitToCS')
         self.refCS = self.tempCS
         self.refCS = self.tempCS
-        
+
         # Dictionary keeping track of all node paths manipulated so far
         # Dictionary keeping track of all node paths manipulated so far
         self.nodePathDict = {}
         self.nodePathDict = {}
         self.nodePathDict['camera'] = direct.camera
         self.nodePathDict['camera'] = direct.camera
@@ -106,7 +106,7 @@ class Placer(AppShell):
             'Toggle widget manipulation mode',
             'Toggle widget manipulation mode',
             label = 'Toggle Widget Mode',
             label = 'Toggle Widget Mode',
             command = direct.manipulationControl.toggleObjectHandlesMode)
             command = direct.manipulationControl.toggleObjectHandlesMode)
-        
+
         # Get a handle to the menu frame
         # Get a handle to the menu frame
         menuFrame = self.menuFrame
         menuFrame = self.menuFrame
         self.nodePathMenu = Pmw.ComboBox(
         self.nodePathMenu = Pmw.ComboBox(
@@ -130,7 +130,7 @@ class Placer(AppShell):
                                   menubutton_width = 8)
                                   menubutton_width = 8)
         modeMenu.pack(side = 'left', expand = 0)
         modeMenu.pack(side = 'left', expand = 0)
         self.bind(modeMenu, 'Select manipulation mode')
         self.bind(modeMenu, 'Select manipulation mode')
-        
+
         self.refNodePathMenu = Pmw.ComboBox(
         self.refNodePathMenu = Pmw.ComboBox(
             menuFrame, entry_width = 16,
             menuFrame, entry_width = 16,
             selectioncommand = self.selectRefNodePathNamed,
             selectioncommand = self.selectRefNodePathNamed,
@@ -186,8 +186,8 @@ class Placer(AppShell):
         self.posX['preCallback'] = self.xformStart
         self.posX['preCallback'] = self.xformStart
         self.posX['postCallback'] = self.xformStop
         self.posX['postCallback'] = self.xformStop
         self.posX['callbackData'] = ['x']
         self.posX['callbackData'] = ['x']
-        self.posX.pack(expand=1,fill='both')
-        
+        self.posX.pack(expand=1, fill='both')
+
         self.posY = self.createcomponent('posY', (), None,
         self.posY = self.createcomponent('posY', (), None,
                                          Floater.Floater, (posInterior,),
                                          Floater.Floater, (posInterior,),
                                          text = 'Y', relief = FLAT,
                                          text = 'Y', relief = FLAT,
@@ -197,8 +197,8 @@ class Placer(AppShell):
         self.posY['preCallback'] = self.xformStart
         self.posY['preCallback'] = self.xformStart
         self.posY['postCallback'] = self.xformStop
         self.posY['postCallback'] = self.xformStop
         self.posY['callbackData'] = ['y']
         self.posY['callbackData'] = ['y']
-        self.posY.pack(expand=1,fill='both')
-        
+        self.posY.pack(expand=1, fill='both')
+
         self.posZ = self.createcomponent('posZ', (), None,
         self.posZ = self.createcomponent('posZ', (), None,
                                          Floater.Floater, (posInterior,),
                                          Floater.Floater, (posInterior,),
                                          text = 'Z', relief = FLAT,
                                          text = 'Z', relief = FLAT,
@@ -208,7 +208,7 @@ class Placer(AppShell):
         self.posZ['preCallback'] = self.xformStart
         self.posZ['preCallback'] = self.xformStart
         self.posZ['postCallback'] = self.xformStop
         self.posZ['postCallback'] = self.xformStop
         self.posZ['callbackData'] = ['z']
         self.posZ['callbackData'] = ['z']
-        self.posZ.pack(expand=1,fill='both')
+        self.posZ.pack(expand=1, fill='both')
 
 
         # Create and pack the Hpr Controls
         # Create and pack the Hpr Controls
         hprGroup = Pmw.Group(interior,
         hprGroup = Pmw.Group(interior,
@@ -223,9 +223,9 @@ class Placer(AppShell):
         hprMenu.add_command(label = 'Set to zero', command = self.zeroHpr)
         hprMenu.add_command(label = 'Set to zero', command = self.zeroHpr)
         hprMenu.add_command(label = 'Reset initial', command = self.resetHpr)
         hprMenu.add_command(label = 'Reset initial', command = self.resetHpr)
         hprMenubutton['menu'] = hprMenu
         hprMenubutton['menu'] = hprMenu
-        hprGroup.pack(side='left',fill = 'both', expand = 1)
+        hprGroup.pack(side='left', fill = 'both', expand = 1)
         hprInterior = hprGroup.interior()
         hprInterior = hprGroup.interior()
-        
+
         # Create the dials
         # Create the dials
         self.hprH = self.createcomponent('hprH', (), None,
         self.hprH = self.createcomponent('hprH', (), None,
                                          Dial.AngleDial, (hprInterior,),
                                          Dial.AngleDial, (hprInterior,),
@@ -237,8 +237,8 @@ class Placer(AppShell):
         self.hprH['preCallback'] = self.xformStart
         self.hprH['preCallback'] = self.xformStart
         self.hprH['postCallback'] = self.xformStop
         self.hprH['postCallback'] = self.xformStop
         self.hprH['callbackData'] = ['h']
         self.hprH['callbackData'] = ['h']
-        self.hprH.pack(expand=1,fill='both')
-        
+        self.hprH.pack(expand=1, fill='both')
+
         self.hprP = self.createcomponent('hprP', (), None,
         self.hprP = self.createcomponent('hprP', (), None,
                                          Dial.AngleDial, (hprInterior,),
                                          Dial.AngleDial, (hprInterior,),
                                          style = 'mini',
                                          style = 'mini',
@@ -249,8 +249,8 @@ class Placer(AppShell):
         self.hprP['preCallback'] = self.xformStart
         self.hprP['preCallback'] = self.xformStart
         self.hprP['postCallback'] = self.xformStop
         self.hprP['postCallback'] = self.xformStop
         self.hprP['callbackData'] = ['p']
         self.hprP['callbackData'] = ['p']
-        self.hprP.pack(expand=1,fill='both')
-        
+        self.hprP.pack(expand=1, fill='both')
+
         self.hprR = self.createcomponent('hprR', (), None,
         self.hprR = self.createcomponent('hprR', (), None,
                                          Dial.AngleDial, (hprInterior,),
                                          Dial.AngleDial, (hprInterior,),
                                          style = 'mini',
                                          style = 'mini',
@@ -261,7 +261,7 @@ class Placer(AppShell):
         self.hprR['preCallback'] = self.xformStart
         self.hprR['preCallback'] = self.xformStart
         self.hprR['postCallback'] = self.xformStop
         self.hprR['postCallback'] = self.xformStop
         self.hprR['callbackData'] = ['r']
         self.hprR['callbackData'] = ['r']
-        self.hprR.pack(expand=1,fill='both')
+        self.hprR.pack(expand=1, fill='both')
 
 
         # Create and pack the Scale Controls
         # Create and pack the Scale Controls
         # The available scaling modes
         # The available scaling modes
@@ -292,9 +292,9 @@ class Placer(AppShell):
                                       variable = self.scalingMode)
                                       variable = self.scalingMode)
         self.scaleMenubutton['menu'] = scaleMenu
         self.scaleMenubutton['menu'] = scaleMenu
         # Pack group widgets
         # Pack group widgets
-        scaleGroup.pack(side='left',fill = 'both', expand = 1)
+        scaleGroup.pack(side='left', fill = 'both', expand = 1)
         scaleInterior = scaleGroup.interior()
         scaleInterior = scaleGroup.interior()
-        
+
         # Create the dials
         # Create the dials
         self.scaleX = self.createcomponent('scaleX', (), None,
         self.scaleX = self.createcomponent('scaleX', (), None,
                                            Floater.Floater, (scaleInterior,),
                                            Floater.Floater, (scaleInterior,),
@@ -307,8 +307,8 @@ class Placer(AppShell):
         self.scaleX['callbackData'] = ['sx']
         self.scaleX['callbackData'] = ['sx']
         self.scaleX['preCallback'] = self.xformStart
         self.scaleX['preCallback'] = self.xformStart
         self.scaleX['postCallback'] = self.xformStop
         self.scaleX['postCallback'] = self.xformStop
-        self.scaleX.pack(expand=1,fill='both')
-        
+        self.scaleX.pack(expand=1, fill='both')
+
         self.scaleY = self.createcomponent('scaleY', (), None,
         self.scaleY = self.createcomponent('scaleY', (), None,
                                            Floater.Floater, (scaleInterior,),
                                            Floater.Floater, (scaleInterior,),
                                            text = 'Y Scale',
                                            text = 'Y Scale',
@@ -320,8 +320,8 @@ class Placer(AppShell):
         self.scaleY['callbackData'] = ['sy']
         self.scaleY['callbackData'] = ['sy']
         self.scaleY['preCallback'] = self.xformStart
         self.scaleY['preCallback'] = self.xformStart
         self.scaleY['postCallback'] = self.xformStop
         self.scaleY['postCallback'] = self.xformStop
-        self.scaleY.pack(expand=1,fill='both')
-        
+        self.scaleY.pack(expand=1, fill='both')
+
         self.scaleZ = self.createcomponent('scaleZ', (), None,
         self.scaleZ = self.createcomponent('scaleZ', (), None,
                                            Floater.Floater, (scaleInterior,),
                                            Floater.Floater, (scaleInterior,),
                                            text = 'Z Scale',
                                            text = 'Z Scale',
@@ -333,7 +333,7 @@ class Placer(AppShell):
         self.scaleZ['callbackData'] = ['sz']
         self.scaleZ['callbackData'] = ['sz']
         self.scaleZ['preCallback'] = self.xformStart
         self.scaleZ['preCallback'] = self.xformStart
         self.scaleZ['postCallback'] = self.xformStop
         self.scaleZ['postCallback'] = self.xformStop
-        self.scaleZ.pack(expand=1,fill='both')
+        self.scaleZ.pack(expand=1, fill='both')
 
 
         # Make sure appropriate labels are showing
         # Make sure appropriate labels are showing
         self.setMovementMode('Relative To:')
         self.setMovementMode('Relative To:')
@@ -414,7 +414,7 @@ class Placer(AppShell):
             else:
             else:
                 if name == 'widget':
                 if name == 'widget':
                     # Record relationship between selected nodes and widget
                     # Record relationship between selected nodes and widget
-                    direct.selected.getWrtAll()                    
+                    direct.selected.getWrtAll()
         # Update active node path
         # Update active node path
         self.setActiveNodePath(nodePath)
         self.setActiveNodePath(nodePath)
 
 
@@ -487,7 +487,7 @@ class Placer(AppShell):
         else:
         else:
             # Flash entry
             # Flash entry
             self.refNodePathMenuEntry.configure(background = 'Pink')
             self.refNodePathMenuEntry.configure(background = 'Pink')
-        
+
     def addNodePath(self, nodePath):
     def addNodePath(self, nodePath):
         self.addNodePathToDict(nodePath, self.nodePathNames,
         self.addNodePathToDict(nodePath, self.nodePathNames,
                                self.nodePathMenu, self.nodePathDict)
                                self.nodePathMenu, self.nodePathDict)
@@ -538,21 +538,21 @@ class Placer(AppShell):
 
 
     def updateAuxiliaryCoordinateSystems(self):
     def updateAuxiliaryCoordinateSystems(self):
         # Temp CS
         # Temp CS
-        self.tempCS.setPosHpr(self['nodePath'], 0,0,0,0,0,0)
+        self.tempCS.setPosHpr(self['nodePath'], 0, 0, 0, 0, 0, 0)
         # Orbit CS
         # Orbit CS
         # At reference
         # At reference
-        self.orbitFromCS.setPos(self.refCS, 0,0,0)
+        self.orbitFromCS.setPos(self.refCS, 0, 0, 0)
         # But aligned with target
         # But aligned with target
-        self.orbitFromCS.setHpr(self['nodePath'], 0,0,0)
+        self.orbitFromCS.setHpr(self['nodePath'], 0, 0, 0)
         # Also update to CS
         # Also update to CS
-        self.orbitToCS.setPosHpr(self.orbitFromCS, 0,0,0,0,0,0)
+        self.orbitToCS.setPosHpr(self.orbitFromCS, 0, 0, 0, 0, 0, 0)
         # Get offset from origin
         # Get offset from origin
         self.posOffset.assign(self['nodePath'].getPos(self.orbitFromCS))
         self.posOffset.assign(self['nodePath'].getPos(self.orbitFromCS))
 
 
     ### NODE PATH TRANSFORMATION OPERATIONS ###
     ### NODE PATH TRANSFORMATION OPERATIONS ###
     def xform(self, value, axis):
     def xform(self, value, axis):
         if axis in ['sx', 'sy', 'sz']:
         if axis in ['sx', 'sy', 'sz']:
-            self.xformScale(value,axis)
+            self.xformScale(value, axis)
         elif self.movementMode == 'Relative To:':
         elif self.movementMode == 'Relative To:':
             self.xformRelative(value, axis)
             self.xformRelative(value, axis)
         elif self.movementMode == 'Orbit:':
         elif self.movementMode == 'Orbit:':
@@ -565,7 +565,7 @@ class Placer(AppShell):
             else:
             else:
                 # Move the objects with the widget
                 # Move the objects with the widget
                 direct.selected.moveWrtWidgetAll()
                 direct.selected.moveWrtWidgetAll()
-    
+
     def xformStart(self, data):
     def xformStart(self, data):
         # Record undo point
         # Record undo point
         self.pushUndo()
         self.pushUndo()
@@ -578,7 +578,7 @@ class Placer(AppShell):
         self.deltaHpr = self['nodePath'].getHpr(self.refCS)
         self.deltaHpr = self['nodePath'].getHpr(self.refCS)
         # Update placer to reflect new state
         # Update placer to reflect new state
         self.updatePlacer()
         self.updatePlacer()
-        
+
     def xformStop(self, data):
     def xformStop(self, data):
         # Throw event to signal manipulation done
         # Throw event to signal manipulation done
         # Send nodepath as a list
         # Send nodepath as a list
@@ -639,7 +639,7 @@ class Placer(AppShell):
                 elif axis == 'sz':
                 elif axis == 'sz':
                     scale.setZ(value)
                     scale.setZ(value)
             elif mode == 'Scale Uniform':
             elif mode == 'Scale Uniform':
-                scale.set(value,value,value)
+                scale.set(value, value, value)
             elif mode == 'Scale Proportional':
             elif mode == 'Scale Proportional':
                 if axis == 'sx':
                 if axis == 'sx':
                     sf = value/scale[0]
                     sf = value/scale[0]
@@ -743,7 +743,7 @@ class Placer(AppShell):
 
 
     def pushRedo(self):
     def pushRedo(self):
         direct.pushRedo([self['nodePath']])
         direct.pushRedo([self['nodePath']])
-        
+
     def redoHook(self, nodePathList = []):
     def redoHook(self, nodePathList = []):
         # Reflect new changes
         # Reflect new changes
         self.updatePlacer()
         self.updatePlacer()
@@ -755,7 +755,7 @@ class Placer(AppShell):
     def redoListEmptyHook(self):
     def redoListEmptyHook(self):
         # Make sure button is deactivated
         # Make sure button is deactivated
         self.redoButton.configure(state = 'disabled')
         self.redoButton.configure(state = 'disabled')
-        
+
     def printNodePathInfo(self):
     def printNodePathInfo(self):
         np = self['nodePath']
         np = self['nodePath']
         if np:
         if np:
@@ -780,7 +780,7 @@ class Placer(AppShell):
         self.tempCS.removeNode()
         self.tempCS.removeNode()
         self.orbitFromCS.removeNode()
         self.orbitFromCS.removeNode()
         self.orbitToCS.removeNode()
         self.orbitToCS.removeNode()
-        
+
 def place(nodePath):
 def place(nodePath):
     return Placer(nodePath = nodePath)
     return Placer(nodePath = nodePath)
 
 
@@ -790,4 +790,3 @@ def place(nodePath):
 if __name__ == '__main__':
 if __name__ == '__main__':
     root = Pmw.initialise()
     root = Pmw.initialise()
     widget = Placer()
     widget = Placer()
-