automatically deref pointers in pyray
This commit is contained in:
parent
6854ec4a3e
commit
26e9f9cbf2
2 changed files with 6 additions and 4 deletions
|
@ -9,14 +9,16 @@ class PyRay:
|
|||
|
||||
|
||||
def makefunc(a):
|
||||
#print("makefunc ",a)
|
||||
#print("makefunc ",a, ffi.typeof(a).args)
|
||||
def func(self, *args):
|
||||
modified_args = []
|
||||
for arg in args:
|
||||
#print(arg, type(arg))
|
||||
for (c_arg, arg) in zip(ffi.typeof(a).args, args):
|
||||
#print(arg, c_arg.kind)
|
||||
if type(arg) == str:
|
||||
encoded = arg.encode('utf-8')
|
||||
modified_args.append(encoded)
|
||||
elif c_arg.kind == 'pointer':
|
||||
modified_args.append(ffi.addressof(arg))
|
||||
else:
|
||||
modified_args.append(arg)
|
||||
return a(*modified_args)
|
||||
|
|
Reference in a new issue