From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!aioe.org!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx03.am4.POSTED!not-for-mail Subject: Re: GDNative thick binding design Newsgroups: comp.lang.ada References: <9d822023-b604-46b1-9443-4471e095704bn@googlegroups.com> From: Per Sandberg User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: <9d822023-b604-46b1-9443-4471e095704bn@googlegroups.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Message-ID: X-Complaints-To: abuse@usenet.se NNTP-Posting-Date: Sun, 18 Oct 2020 20:21:38 UTC Organization: usenet.se Date: Sun, 18 Oct 2020 22:21:38 +0200 X-Received-Bytes: 3166 X-Received-Body-CRC: 1580909677 Xref: reader02.eternal-september.org comp.lang.ada:60458 List-Id: Well My usual path is: 1) find bindings in other languages and try to understand their intention. 2) Generate a 1:1 binding to the C API since that will provide a sound ground (this is an 100% automatic process). 3) Write the high level binding trying to mimic othef language bindings while keepoing an Ada twist to it, With a minor effort I managed to to step one and two but step three is the hard one have a look on https://github.com/Ada-bindings-project/godot /P On 15/10/2020 23: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 > > Once the game engine has loaded your dynamic library it will call the function *_nativescript_init (where * is the symbol_prefix defined in the library resource config file). This function is responsible for registering objects, object methods, and allocating any memory needed. > > 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 > > The objects must have a name, but may or may not override the constructor/destructor life cycle functions (which you pass in during registration) > There are > https://docs.godotengine.org/en/stable/classes/class_object.html#class-object > > There is kind of a hierarchy at play as well: > > the Node type extends Object > https://docs.godotengine.org/en/stable/classes/class_node.html#node > > and has addition life cycle events like _process (callback on each frame) > https://docs.godotengine.org/en/stable/classes/class_node.html#class-node-method-process > > Now I don't even know where to start defining something nice in Ada that would match this pattern and would hide all the nastiness from the C binding. I kind of want the tagged record hierarchy structure, with overriding functions, but it should only register methods with godot you've overridden. How would I know what methods have been overridden? I feel like I need some kind of generic or helper functions? > > I'm hoping some more experienced people might have some suggestions? > > >