Open natezb opened 5 years ago
Is there an workaround ? Dealing exactly with that issue.
It's been awhile since I've used NiceLib much, but I believe the typical workaround would be to hand-write a custom wrapper function. You could do this fully manually, or via "hybrid methods" (which unfortunately haven't been documented yet).
As an example use of hybrid methods, check out this Instrumental driver. The idea is that you decorate the hand-written method with a Sig
---the auto-wrapped function is then available for use in the function body.
@Sig('in', 'in', 'inout')
def GETBOARDVAL(self, pcc_val):
data = ffi.new('DWORD*')
self._autofunc_GETBOARDVAL(pcc_val, ffi.cast('void*', data))
return data[0]
Note the auto-wrapped function is available as self._autofunc_GETBOARDVAL
within the function body. In your case you could do something like so:
@Sig('arr', 'in')
def myfunc(self, array):
return self._autofunc_myfunc(array, len(array)) # Or however you find the size
Thanks, thats quite helpful!
This is for the case where the user passes in an array as input, and the C function requires a 'size' argument. This ArgHandler would automatically compute the array length and pass it in.
We could use the existing 'len' handler, or perhaps create a new one because the semantics are a bit different.
It's not clear that 'bufin' is necessary, since strings would normally be null-terminated. Might be good to have it just in case though.