Hello Guest

Binding Help

  • 45 Replies
  • 23999 Views
*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Binding Help
« Reply #15 on: October 03, 2017, 08:43:38 »
Yes. Examples:

Code: [Select]
// C
typedef struct libusb_foo libusb_foo;
void func(libusb_foo *foo);
// Kotlin
val libusb_foo_p = "libusb_foo".p

// C
typedef struct libusb_foo *libusb_foo;
void func(libusb_foo foo);
// Kotlin
val libusb_foo = "libusb_foo".opaque_p
« Last Edit: October 03, 2017, 16:44:23 by spasi »

Re: Binding Help
« Reply #16 on: October 03, 2017, 16:31:15 »
Yes. Examples:

Code: [Select]
// C
typedef struct libusb_foo libusb_foo;
void func(libusb_foo *foo);
// Kotlin
val libusb_foo = "libusb_foo".p

// C
typedef struct libusb_foo *libusb_foo;
void func(libusb_foo foo);
// Kotlin
val libusb_foo = "libusb_foo".opaque_p

Would the first example then be:
Code: [Select]
// C
void doAThing(libusb_thing* thing);

// Kotlin
void("doAThing", ""
   
    libusb_thing.IN("thing", "")
)
[code]

or

[code]
// C
void doAThing(libusb_thing* thing);

// Kotlin
void("doAThing", ""
   
    libusb_thing.p.IN("thing", "")
)
[code]

I am leaning towards the first, but I am unsure.

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Binding Help
« Reply #17 on: October 03, 2017, 16:50:31 »
I've edited my previous reply, it should be:

Code: [Select]
val libusb_foo_p = "libusb_foo".p // note the extra _p
So, in your example:

Code: [Select]
// C
typedef struct libusb_thing libusb_thing;
void doAThing(libusb_thing* thing);

// Kotlin
val libusb_thing_p = "libusb_thing".p
void(
    "doAThing",
    "",

    libusb_thing_p.IN("thing", "")
)

So, yes, the first one, but with _p so that it's clear what's happening.

Re: Binding Help
« Reply #18 on: October 03, 2017, 19:46:28 »
I've edited my previous reply, it should be:

Code: [Select]
val libusb_foo_p = "libusb_foo".p // note the extra _p
So, in your example:

Code: [Select]
// C
typedef struct libusb_thing libusb_thing;
void doAThing(libusb_thing* thing);

// Kotlin
val libusb_thing_p = "libusb_thing".p
void(
    "doAThing",
    "",

    libusb_thing_p.IN("thing", "")
)

So, yes, the first one, but with _p so that it's clear what's happening.

Fair enough, now to look at the other bindings and get the native stuff working.

Re: Binding Help
« Reply #19 on: October 03, 2017, 21:12:28 »
Issue with the build process, it is attempting to grab a required dll from your server. Seeing as the binding is not done how can I tell it to not do that and maybe even grab it from a local source?

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Binding Help
« Reply #20 on: October 03, 2017, 22:11:49 »
Setting/exporting LWJGL_BUILD_OFFLINE=true will make the build skip all downloads.

Re: Binding Help
« Reply #21 on: October 04, 2017, 04:54:43 »
Okay, mostly done with this. Just need to make sure all the documentation is in there, compare the code styling I used to the repo, test all the stuff I can, and maybe make some basic tests and port the example code.

Probably a couple more days, everything is well documented and has links to everything else that is relevant.

Re: Binding Help
« Reply #22 on: October 04, 2017, 20:12:03 »
Odd problem, checks are happening where they should not be for a function.

I have tried this:
Code: [Select]
    size_t(
        "libusb_get_device_list", "",

        optional..libusb_context_p.IN("ctx", ""),
        Check("1")..libusb_device_p.p.p.OUT("list", "")
    )

and this

Code: [Select]
    size_t(
        "libusb_get_device_list", "",

        nullable..libusb_context_p.IN("ctx", ""),
        Check("1")..libusb_device_p.p.p.OUT("list", "")
    )

A null ctx tells the library to use the default one.

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Binding Help
« Reply #23 on: October 04, 2017, 20:26:49 »
nullable.. should remove the check.

edit: btw, you can do Check(1) instead of Check("1").

Re: Binding Help
« Reply #24 on: October 05, 2017, 03:17:16 »
nullable.. should remove the check.

edit: btw, you can do Check(1) instead of Check("1").

I'll double check that I did not mess that up then, and I will change all of those Check statements.

Edit:
Seems that it was just me being stupid like normal. Go figure.
« Last Edit: October 05, 2017, 03:29:13 by gudenau »

Re: Binding Help
« Reply #25 on: December 06, 2017, 01:45:07 »
It has been a while, things came up and this ended up being forgotten for a while. My bad.

Now that I am trying to get the documentation fleshed out I am not seeing a way to add the return info to a method definition in the Kotlin files. Is this supported?

Edit:
While I am at it, is the See Also stuff supported?
« Last Edit: December 06, 2017, 01:50:49 by gudenau »

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Binding Help
« Reply #26 on: December 06, 2017, 08:38:39 »
The generator supports @return, @see and @since. You use Kotlin named parameters to specify them, for example:

Code: [Select]
int(
    "functionName",
    "javadoc",

    // vararg parameters
    int.IN("paramA", ""),
    float.IN("paramB", ""),
    // ...,

    // named parameters after varargs
    returnDoc = "an int",
    since = "version M.n",
    see = arrayOf("refA", "refB"/* , ... */)
)

Re: Binding Help
« Reply #27 on: December 07, 2017, 17:57:34 »
The generator supports @return, @see and @since. You use Kotlin named parameters to specify them, for example:

Code: [Select]
int(
    "functionName",
    "javadoc",

    // vararg parameters
    int.IN("paramA", ""),
    float.IN("paramB", ""),
    // ...,

    // named parameters after varargs
    returnDoc = "an int",
    since = "version M.n",
    see = arrayOf("refA", "refB"/* , ... */)
)

Thanks, I went through all the decelerations and could not find those.

Re: Binding Help
« Reply #28 on: December 11, 2017, 21:48:11 »
How about deprecation? There is a deprecated method in here that is superseded by something else.

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Binding Help
« Reply #29 on: December 11, 2017, 23:19:29 »
I usually skip such functions. If we need it in the future for backwards compatibility, it can be added trivially.