We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have C code:
typedef void (*CallbackFunction)(int values[], int num); int onMessage(CallbackFunction cb) { int nums[] = {1,2,3,4,5}; cb(nums, 5); return 0; }
And js code:
var ffi = require('ffi'); var ref = require('ref'); var refArray = require('ref-array'); var lib = ffi.Library('my_lib', { 'onMessage', ['int', [ffi.Function('void', [refArray(ref.types.int), ref.types.int])]] }); lib.onMessage(ffi.Callback('void', [refArray(ref.types.int), ref.types.int], function(values, num){ for(var i = 0; i < num; i++) { console.log(values[i]); } }));
The js run result is:
undefined undefined undefined undefined undefined
So It doesn't work?
The text was updated successfully, but these errors were encountered:
I am facing a similar problem too. Any help on this issue is much appreciated. Is there a workaround for this issue?
Sorry, something went wrong.
@zerbobo, I managed to get this one right.
const arrayPointer = ref._reinterpret(values, num); const actualArray = new IntArrayType(arrayPointer);
No branches or pull requests
I have C code:
And js code:
The js run result is:
So It doesn't work?
The text was updated successfully, but these errors were encountered: