From: "Luke A. Guest" <laguest@archeia.com>
Subject: Re: GDNative thick binding design
Date: Fri, 16 Oct 2020 07:38:05 +0100 [thread overview]
Message-ID: <rmbf5b$o0j$1@gioia.aioe.org> (raw)
In-Reply-To: 9d822023-b604-46b1-9443-4471e095704bn@googlegroups.com
On 15/10/2020 22:08, Michael Hardeman wrote:
> I'm working on a binding to the Godot game engine for Ada.
> Project link here: https://github.com/MichaelAllenHardeman/gdnative_ada
Interesting.
> What I want to discuss here is that I'm a bit at a loss as to how to design a thick binding wrapper around this object registration pattern. So let me describe the pattern.
>
> I have a very simple example translated from C using the thin binding is here: https://github.com/MichaelAllenHardeman/gdnative_ada/blob/master/examples/gdnative_c_example/src/simple.adb#L44
Ok, so what you have now is a gcc generated binding, which isn't the
nicest to work with.
What you really need to do is to start by wrapping up the thin inside a
thick binding such that the plug-ins only use the thick binding and that
any of the calls such as simple_constructor are wrapped, i.e.
Godot.Make(Instance : Godot.Root_Class; parameters...) -> calls
simple_constructor(Instance.Internal_Pointer, parameters). Use overloads
for this kind of stuff.
The way I bind to C is like this:
1) If it's a simple function that takes no parameters and returns
nothing, then bind directly.
2) If it's a simple return type, use an expression function to bind.
3) Anything else gets a thick binding.
4) Types are mapped onto the C ones, so I lift out the definition from
the thin binding and put it in the root package of the thick. I also
rename so there's less repetitive stuff like GODOT_VARIANT_* and I case
properly, this will be difficult for situations where identifiers are
Ada keywords, so rename to something else completely if you have to,
just document the change.
Essentially you want all the C nastiness inside the thick binding.
Look at SDLAda for some ideas, but this was done by hand. Anything
generated by GCC needs to be hand massaged to be nicer imo.
next prev parent reply other threads:[~2020-10-16 6:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-15 21:08 GDNative thick binding design Michael Hardeman
2020-10-16 6:38 ` Luke A. Guest [this message]
2020-10-16 16:39 ` Michael Hardeman
2020-10-16 18:09 ` Luke A. Guest
2020-10-16 18:28 ` Michael Hardeman
2020-10-16 18:31 ` Luke A. Guest
2020-10-21 2:58 ` Michael Hardeman
2020-10-21 6:59 ` Luke A. Guest
2020-10-21 22:08 ` Michael Hardeman
2020-10-21 23:22 ` Luke A. Guest
2020-10-26 3:38 ` Michael Hardeman
2020-10-26 5:41 ` Per Sandberg
2020-10-26 13:53 ` Michael Hardeman
2020-10-27 3:34 ` Michael Hardeman
2020-10-17 10:09 ` AdaMagica
2020-10-18 20:21 ` Per Sandberg
2020-10-21 3:34 ` Michael Hardeman
2020-10-21 16:16 ` Per Sandberg
2020-10-21 22:48 ` Michael Hardeman
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox