Пример #1
0
 def generateReturnValueWrapper(self, classTypeDesc, file,
                                userManagesMemory, needsDowncast, nesting):
     """
     Generate code that creates a shadow object of this type
     then sets the this pointer and returns the object. We call the
     class destructor with None as the only parameter to get an
     empty shadow object.
     """
     if classTypeDesc != self:
         indent(file, nesting, 'import ' + self.foreignTypeName + '\n')
     indent(file, nesting, 'returnObject = ')
     # 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
     typeName = FFIOverload.getTypeName(classTypeDesc, self)
     file.write(typeName)
     file.write('(None)\n')
     indent(file, nesting, 'returnObject.this = returnValue\n')
     # Zero this pointers get returned as the Python None object
     indent(file, nesting, 'if (returnObject.this == 0): return None\n')
     if userManagesMemory:
         indent(file, nesting, 'returnObject.userManagesMemory = 1\n')
     if needsDowncast:
         if (FFIOverload.inheritsFrom(self, TypedObjectDescriptor)
                 or self == TypedObjectDescriptor):
             indent(file, nesting, 'return returnObject.setPointer()\n')
         else:
             indent(file, nesting, 'return returnObject\n')
     else:
         indent(file, nesting, 'return returnObject\n')
Пример #2
0
 def generateReturnValueWrapper(self, classTypeDesc, file, userManagesMemory,
                                needsDowncast, nesting):
     """
     Generate code that creates a shadow object of this type
     then sets the this pointer and returns the object. We call the
     class destructor with None as the only parameter to get an
     empty shadow object.
     """
     if classTypeDesc != self:
         indent(file, nesting, 'import ' + self.foreignTypeName + '\n')
     indent(file, nesting, 'returnObject = ')
     # 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
     typeName = FFIOverload.getTypeName(classTypeDesc, self)
     file.write(typeName)
     file.write('(None)\n')
     indent(file, nesting, 'returnObject.this = returnValue\n')
     # Zero this pointers get returned as the Python None object
     indent(file, nesting, 'if (returnObject.this == 0): return None\n')
     if userManagesMemory:
         indent(file, nesting, 'returnObject.userManagesMemory = 1\n')
     if needsDowncast:
         if (FFIOverload.inheritsFrom(self, TypedObjectDescriptor) or
             self == TypedObjectDescriptor):
             indent(file, nesting, 'return returnObject.setPointer()\n')
         else:
             indent(file, nesting, 'return returnObject\n')
     else:
         indent(file, nesting, 'return returnObject\n')