Panda3D
Public Member Functions | Public Attributes

ClassTypeDescriptor Class Reference

Inheritance diagram for ClassTypeDescriptor:
BaseTypeDescriptor

List of all members.

Public Member Functions

def __init__
def copyExtensions
def copyParentMethods
def copyParentMethodsRecursively
def cullOverloadedMethods
def filterOutStaticMethods
def generateCode
def generateCode1
def generateCode2
def generateGlobalCode
def generateOverloadedMethods
def generateReturnValueWrapper
 indent(file, nesting, 'returnObject.this = returnValue
') Zero this pointers get returned as the Python None object indent(file, nesting, 'if (returnObject.this == 0): return None
') if userManagesMemory: indent(file, nesting, 'returnObject.userManagesMemory = 1
') else: indent(file, nesting, 'returnObject.userManagesMemory = 0
')
def getCModules
def getCModulesRecursively
def getExtensionModuleName
def getReturnTypeModules
def hasMethodNamed
def inheritsMethodNamed
def outputBaseConstructor
def outputBaseDestructor
def outputBaseImports
def outputClassCModules
def outputClassComment
def outputClassFooter
def outputClassHeader
def outputEmptyConstructor
def outputEmptyDestructor
def outputImports
def outputImportsRecursively
def outputNestedTypes
def recordClassMethod
def recordInstanceMethod
def recordOverloadedMethods

Public Attributes

 CModules
 constructors
 destructor
 downcastMethods
 foreignTypeName
 instanceMethods
 nestedTypes
 overloadedClassMethods
 overloadedInstanceMethods
 returnTypeModules
 staticMethods
 upcastMethods

Detailed Description

This describes a C++ class. It holds lists of all its methods too.
It can also generate Python shadow class code for itself.

Constructor & Destructor Documentation

def __init__ (   self)

Reimplemented from BaseTypeDescriptor.


Member Function Documentation

def copyExtensions (   self,
  extensionsDir,
  file,
  nesting 
)
Copy in the extension file for this class if one exists
If you want to extend a C++ file, create a file in the extensions directory and
this will append that extension file to the generated code file.
def copyParentMethods (   self,
  file,
  nesting 
)
At multiple inheritance nodes, copy all the parent methods into
this class and call them after upcasting us to that class
def copyParentMethodsRecursively (   self,
  parentList,
  file,
  nesting 
)
Copy all the parents instance methods
Do not copy functions if this class already has a function with that name
We need to recurse up the hierarchy copying all our parents nodes all
the way up the tree stopping either at the top, or at another MI node
that has already copied his parent's methods in
Note: Do not copy the downcast methods
def cullOverloadedMethods (   self)
Find all the entries that have multiple indexes for the same method name
Get rid of all others. Do this for class methods and instance methods
def filterOutStaticMethods (   self)
Run through the list of instance methods and filter out the
ones that are static class methods. We can tell this because they
do not have a this pointer in their arg list. Those methods that
are static are then placed in a new staticMethods list and the ones
that are left are stored back in the instanceMethods list. We are
avoiding modifying the instanceMethods list in place while traversing it.
Do not check upcast or downcast methods because we know they are not static.
def generateCode (   self,
  file,
  nesting,
  extensionsDir = None 
)
def generateCode1 (   self,
  file,
  nesting,
  extensionsDir = None 
)
def generateCode2 (   self,
  file,
  nesting,
  extensionsDir,
  file1module 
)
def generateGlobalCode (   self,
  dir,
  extensionsDir 
)
Generate shadow class code for this type.
We make our own file form our foreignTypeName and put it in the dir
passed in.

Reimplemented from BaseTypeDescriptor.

def generateOverloadedMethods (   self,
  file,
  nesting 
)
Generate code for all the overloaded methods of this class
def generateReturnValueWrapper (   self,
  classTypeDesc,
  file,
  userManagesMemory,
  needsDowncast,
  nesting 
)

indent(file, nesting, 'returnObject.this = returnValue
') Zero this pointers get returned as the Python None object indent(file, nesting, 'if (returnObject.this == 0): return None
') if userManagesMemory: indent(file, nesting, 'returnObject.userManagesMemory = 1
') else: indent(file, nesting, 'returnObject.userManagesMemory = 0
')

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.

Reimplemented from BaseTypeDescriptor.

def getCModules (   self)
Return a list of all the C modules this class references
def getCModulesRecursively (   self,
  parent 
)
def getExtensionModuleName (   self)
Return a filename for the extensions for this class
Example: NodePath extensions would be found in NodePath-extensions.py
def getReturnTypeModules (   self)
Return a list of all the other shadow class modules this
class references.
Be careful about nested types
def hasMethodNamed (   self,
  methodName 
)
def inheritsMethodNamed (   self,
  parentList,
  methodName 
)
returns true if the named method is a method on this class, or
on any parent class except the last one in the list.
def outputBaseConstructor (   self,
  file,
  nesting 
)
Output the __init__ constructor for this class.
There is special login if you pass in None to the constructor, you
will not get an actual C object with memory, you will just get the
shadow class shell object. This is useful for functions that want
to return this type that already have a this pointer and just need
to construct a shadow object to contain it.
def outputBaseDestructor (   self,
  file,
  nesting 
)
This destructor overwrites the builtin Python destructor
using the __del__ method. This will get called whenever a
Python object is garbage collected. We are going to overwrite
it with special cleanup for Panda.
def outputBaseImports (   self,
  file 
)
def outputClassCModules (   self,
  file,
  nesting 
)
def outputClassComment (   self,
  file,
  nesting 
)
Output the class comment to the file
def outputClassFooter (   self,
  file 
)
def outputClassHeader (   self,
  file,
  nesting 
)
Output the class definition to the file
def outputEmptyConstructor (   self,
  file,
  nesting 
)
If there is no C++ constructor, we output code for a runtime error
You really do not want to create a class with a null this pointer
def outputEmptyDestructor (   self,
  file,
  nesting 
)
If there is no C++ destructor, we just output this
empty one instead
def outputImports (   self,
  file,
  nesting 
)
Generate code that imports the modules we need for this class
def outputImportsRecursively (   self,
  parent,
  file,
  nesting 
)
def outputNestedTypes (   self,
  file,
  nesting 
)
def recordClassMethod (   self,
  methodSpec 
)
Record all class methods in a 2 level dictionary so we can go
through them and see which are overloaded
{ className: {methodName: [methodSpec, methodSpec, methodSpec]}}
def recordInstanceMethod (   self,
  methodSpec 
)
Record all instance methods in a 2 level dictionary so we can go
through them and see which are overloaded
{ className: {methodName: [methodSpec, methodSpec, methodSpec]}}
def recordOverloadedMethods (   self)
Record all the methods in dictionaries based on method name
so we can see if they are overloaded

Reimplemented from BaseTypeDescriptor.


Member Data Documentation

Reimplemented from BaseTypeDescriptor.

 All Classes Namespaces Functions Variables Properties