Let’s say that I have two C classes: ParentClass and SubClass, with SubClass inheriting from ParentClass. Both classes have a method called foo().
In C the functions are:
- parent_class_foo()
- sub_class_foo()
So in C there is no problem, we can call the function that we want. But with GI bindings, for example in Python, the syntax is: obj.foo(). The question is, which foo() method is called? Can I rely on the chosen behavior currently implemented by GObject Introspection and/or the language bindings, or is it best to consider it an undefined behavior/implementation detail?
In my case SubClass is a gedit class that provides an API for plugins; but it’s possible to break that API, the plugins just need to be ported. ParentClass is part of a library, not yet used by gedit, and it doesn’t make sense for that library to rename foo() just because gedit is going to use it. (Using composition instead of inheritance is not possible).
The solution that I thought: in SubClass (gedit), use the (rename-to SYMBOL) annotation, symbol by symbol and porting the plugins. Then SubClass can inherit from ParentClass and there won’t be any symbol conflicts/clashes, and the Python/Vala plugins will still work fine.
Is there a best-practice to handle those situations? I haven’t found any information on: Overview — GObject Introspection