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=0.8 required=3.0 tests=BAYES_50,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a05:620a:1657:: with SMTP id c23mr779964qko.231.1602796099864; Thu, 15 Oct 2020 14:08:19 -0700 (PDT) X-Received: by 2002:a05:620a:1322:: with SMTP id p2mr734005qkj.211.1602796099685; Thu, 15 Oct 2020 14:08:19 -0700 (PDT) Path: eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 15 Oct 2020 14:08:19 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=99.10.228.144; posting-account=AgomvAoAAAAj6rtZlNDUf1S1XVXbXDpg NNTP-Posting-Host: 99.10.228.144 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <9d822023-b604-46b1-9443-4471e095704bn@googlegroups.com> Subject: GDNative thick binding design From: Michael Hardeman Injection-Date: Thu, 15 Oct 2020 21:08:19 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:60437 List-Id: 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 funct= ion *_nativescript_init (where * is the symbol_prefix defined in the librar= y resource config file). This function is responsible for registering objec= ts, 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 he= re: https://github.com/MichaelAllenHardeman/gdnative_ada/blob/master/exampl= es/gdnative_c_example/src/simple.adb#L44 The objects must have a name, but may or may not override the constructor/d= estructor life cycle functions (which you pass in during registration) There are https://docs.godotengine.org/en/stable/classes/class_object.html#class-obje= ct There is kind of a hierarchy at play as well: the Node type extends Object=20 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-m= ethod-process Now I don't even know where to start defining something nice in Ada that wo= uld match this pattern and would hide all the nastiness from the C binding.= I kind of want the tagged record hierarchy structure, with overriding func= tions, but it should only register methods with godot you've overridden. Ho= w would I know what methods have been overridden? I feel like I need some k= ind of generic or helper functions? I'm hoping some more experienced people might have some suggestions?