When I wrote an Objective-C bridge, I used introspection at class creation time: I overloaded ObjectiveC->`[]() so that when, for example, ObjectiveC.NSObject was accessed, a c-method performed introspection of the NSObject class and created a program dynamically using the C level module API: start_new_program() and friends. Methods were trampolines generated using libffi This provided relatively good runtime speed of method calls (as they were  c methods that used libffi combined with the objective-c API) without the overhead of performing `[] and introspection on each method call. I also built a system of overlays that could provide custom mixing methods for situations where the generic binding wouldn’t suffice. Perhaps something like this could be used to provide optimal performance?

Bill

On May 26, 2018, at 11:34 AM, Lance Dillon <riffraff169@yahoo.com> wrote:

Yeah, that's what the gtk2 module does, I'm wondering if I can add functions to a class (in the c code) that has already been created and ended using end_program().



On Sat, May 26, 2018 at 11:14 AM, Stephen R. van den Berg
<srb@cuci.nl> wrote:
Lance Dillon wrote:

>Which brings up a question:?? is it possible to add a method to a class that has already started and ended (using start_new_program() and end_program()).


Overloading the `-> operator should work.
--
Stephen.

<Untitled.txt>