Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struct Pointer in callback cannot be deref() #37

Open
Fauny opened this issue Jul 19, 2018 · 2 comments
Open

Struct Pointer in callback cannot be deref() #37

Fauny opened this issue Jul 19, 2018 · 2 comments

Comments

@Fauny
Copy link

Fauny commented Jul 19, 2018

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!

@Zayelion
Copy link

Having this issue @Fauny did you ever find a resolution?

@Zayelion
Copy link

Zayelion commented Jul 8, 2019

Ended up reverting back to FFI due to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants