ncannasse / webidl

Haxe support for WebIDL
MIT License
90 stars 16 forks source link

Question about pointers as params #21

Open jefvel opened 4 years ago

jefvel commented 4 years ago

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 commented 3 years ago

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 commented 3 years ago

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

zicklag commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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

Sanva commented 3 years ago

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 → https://github.com/Sanva/webidl/commit/a57a4c633ad221068245f84a87648e1ff6bca7c0 .

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 commented 3 years ago

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