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

Question about pointers as params #21

Open
jefvel opened this issue Jan 7, 2020 · 7 comments
Open

Question about pointers as params #21

jefvel opened this issue Jan 7, 2020 · 7 comments

Comments

@jefvel
Copy link

jefvel commented Jan 7, 2020

I am trying to create a test function:

int test(int integers[], int count) {
    int res = 0;
    for (int i = 0; i < count; i ++) res += integers[i];
    return res;
}

and the IDL definition:

    float test(int[] integers, int count);

However, I am not at all sure how to call this function through Haxe. Is it possible at the moment?

image

@QuantumCoderQC
Copy link

Hi, @jefvel

Have you been able to resolve this issue? I am facing a somewhat similar issue here. Any help would be great.

Best Regards
QC

@jefvel
Copy link
Author

jefvel commented Oct 22, 2020

Hey! Nope, haven't done any progress on this, sorry. Would still like to know how to do it

@zicklag
Copy link
Collaborator

zicklag commented Oct 23, 2020

Sorry I can't help with this more, but the only guidance I can give is to check out the Haxebullet bindings and comb through that to see if there is any useful guidance in there. I don't know anything about it myself, but that repo might show you if it's possible or not.

@QuantumCoderQC
Copy link

@zicklag That's exactly where my issue is. I have the idl and cpp codes for the Bullet library, but don't know how to call a function that takes in an array as a parameter.

@zicklag
Copy link
Collaborator

zicklag commented Oct 23, 2020

Hmm, maybe you can search the Armory source code to see if it uses that function and how it passes the array?

@Sanva
Copy link

Sanva commented Oct 25, 2020

Here you have a working example → https://github.com/Sanva/haxe-webidl-example .

Please note that I'm using my own WebIDL fork, because of this → Sanva@a57a4c6 .

I'm planning to do a pull request, of course, but even knowing C/C++, I'm not really a C/C++ experienced programmer — and with even less knowledge about this WebIDL thing... But I think that [] instead of * is precisely a WebIDL thing [1] that made it's way to C++ generation code — so, I would like if some of you could test previously working examples that you could have to see if this could break something. Or, if you see this right (@ncannasse) I can make a pull request now.

[1] I know about int value[] syntax in C++, but that where creating things like HL_PRIM int[] HL_NAME(IntTuple_set_raw)( _ref(IntTuple)* _this, int[] value ), which is invalid syntax.

@QuantumCoderQC
Copy link

Hi @Sanva

Thank you for your reply. That is a very interesting way of overcoming this issue. I will try it out in my case and hope it works.

Best Regards,
QC

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

4 participants