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

Output Parameters with fastcall #23

Open
josivan opened this issue Oct 18, 2017 · 0 comments
Open

Output Parameters with fastcall #23

josivan opened this issue Oct 18, 2017 · 0 comments

Comments

@josivan
Copy link

josivan commented Oct 18, 2017

I'm not sure if there is there correct channel to ask about fastcall.

Anyway, I asked the same question on stackoverflow.


I'm using fastcall to call a function in a DLL or SO writen in C, that depends of Operational System.

There is a function with this signature:

int GetVersion(char* v1, char* v2)

The result is 0 in case of success and a different value otherwise. The parameters v1 and v2 are outputs by value and maximum size is 64 chars. For example, if the result is 0, then v1 can be "201710.V2"and v2 a similar value. In other words, the value that I'm interested for will be writen into v1 and v2 pointer.

I'm mapping something like this:

const lib new Library(libraryPath)
    .function({ getVersion: ['int', ['string', 'string']] });

And calling the code with:

console.log('checking', lib.isSymbolExists('GetVersion'));

var v1 = ref.allocCString(blankString(64)); // string with 64 positions
var v2 = ref.allocCString(blankString(64));

var rVersion = lib.interface.GetVersion(v1, v2);
console.log('\nResult on Call', rVersion);
console.log('v1', v1.toString());
console.log('v2', v2.toString());

The ouput is always:

checking true

Result on Call -1
v1
v2

My question is, how can I declare a const to be use as output parameter as example described at node-ffi tutorial.

I've already have the code that works with node-ffi. Now I'm trying to port it to fastcall.

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

1 participant