mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
overload functions with PyObject
This commit is contained in:
parent
f54565390d
commit
9de170f3fe
@ -137,6 +137,11 @@ def inheritsFrom(type1, type2):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
def getInheritanceLevel(type, checkNested = 1):
|
def getInheritanceLevel(type, checkNested = 1):
|
||||||
|
if type.__class__ == FFITypes.PyObjectTypeDescriptor:
|
||||||
|
# A special case: PyObject * is always the most general
|
||||||
|
# object. Everything is a PyObject.
|
||||||
|
return -1
|
||||||
|
|
||||||
# If this is a nested type, return the inheritance level of the outer type.
|
# If this is a nested type, return the inheritance level of the outer type.
|
||||||
if type.isNested:
|
if type.isNested:
|
||||||
# Check the level of your outer class
|
# Check the level of your outer class
|
||||||
@ -364,20 +369,25 @@ class FFIMethodArgumentTree:
|
|||||||
oneTreeHasArgs = 1
|
oneTreeHasArgs = 1
|
||||||
typeName = getTypeName(self.classTypeDesc, typeDesc)
|
typeName = getTypeName(self.classTypeDesc, typeDesc)
|
||||||
typeNameList.append(typeName)
|
typeNameList.append(typeName)
|
||||||
if (i == 0):
|
if typeDesc.__class__ == FFITypes.PyObjectTypeDescriptor:
|
||||||
indent(file, nesting+2, 'if (isinstance(_args[' + `level` + '], '
|
# A special case: if one of the parameters is
|
||||||
+ typeName
|
# PyObject *, that means anything is accepted.
|
||||||
+ '))')
|
condition = '1'
|
||||||
|
|
||||||
else:
|
else:
|
||||||
indent(file, nesting+2, 'elif (isinstance(_args[' + `level` + '], '
|
# Otherwise, we'll check the particular type of
|
||||||
+ typeName
|
# the object.
|
||||||
+ '))')
|
condition = '(isinstance(_args[' + `level` + '], ' + typeName + '))'
|
||||||
# If it is looking for a float, make it accept an integer too
|
# If it is looking for a float, make it accept an integer too
|
||||||
if (typeName == 'types.FloatType'):
|
if (typeName == 'types.FloatType'):
|
||||||
file.write(' or (isinstance(_args[' + `level` + '], '
|
condition += (' or (isinstance(_args[' + `level` + '], '
|
||||||
+ 'types.IntType'
|
+ 'types.IntType'
|
||||||
+ '))')
|
+ '))')
|
||||||
file.write(':\n')
|
|
||||||
|
if (i == 0):
|
||||||
|
indent(file, nesting+2, 'if ' + condition + ':\n')
|
||||||
|
else:
|
||||||
|
indent(file, nesting+2, 'elif ' + condition + ':\n')
|
||||||
# Get to the bottom of this chain
|
# Get to the bottom of this chain
|
||||||
if (self.tree[typeDesc][0] != None):
|
if (self.tree[typeDesc][0] != None):
|
||||||
self.tree[typeDesc][0].traverse(file, nesting+1, level+1)
|
self.tree[typeDesc][0].traverse(file, nesting+1, level+1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user