fastcall
fastcall copied to clipboard
Struct Pointer in callback cannot be deref()
as title says, this works in ffi mode
const MyStruct = RefStruct({a: 'int', b:'int'});
const PtrMyStruct = ref.refType(MyStruct);
const MyLib = ffi.Library('mylib.dll',{
setCB:['void', ['pointer']],
//...other things
});
let myCB = ffi.Callback('void', [PtrMyStruct ]], (ptrInCallback) => {
let struct = prtInCallback.deref();
// now, I got a js object, everything is ok
));
MyLib.setCB(myCB);
here is my fastcall codes
const lib = fastcall.Library('mylib.dll')
lib.struct( 'struct MyStruct{int a; int b}'
lib.declare( 'void (*CB)( MyStruct * ptrInCallback)'
lib.function('void setCB(CB)')
lib.interface.setCB((ptrInCallback)=>{
let struct = prtInCallback.deref();
//Error!!!, value of ptrInCallback is uint8array[0]
})
Thank you!
Having this issue @Fauny did you ever find a resolution?
Ended up reverting back to FFI due to this issue.