Re: Private virtual methods



On Sat, 4 Aug 2018 at 22:54, <philip chimento gmail com> wrote:
On Sat, Aug 4, 2018 at 11:49 AM Tony Houghton <h realh co uk> wrote:
The GObject tutorial says you can easily make a "private" virtual method by adding a function pointer slot to a class definition as usual but not providing a corresponding public function. How should this be documented/annotated for gi? Presumably you can't use the name of the non-existent public function, so what should be used for the first line of the comment block?

I'm guessing by "private" you still want the vfunc slot to be overrideable in GI? (If you would not want it to be visible at all, you'd use /*< private >*/.)
I think there's no difference with how you'd annotate the vfunc slots normally:

I want it to be overridable, but only visible to subclasses and only intended to be called from the class it's defined in. I didn't realise until now that you can do this with private virtual methods in C++. But in Java you can't override private methods. So does GI's private annotation still allow overrides?
 
/**
 * MyObjectClass:
 * @public_slot: A public vfunc.
 * @private_slot: A private vfunc.
 */
struct _MyObjectClass {
  void (*public_slot) (MyObject *self);
  void (*private_slot) (MyObject *self);
  /*< private >*/
  void (*really_invisible_slot) (MyObject *self);
};
 
OK, what I didn't realise was that the way to document virtual methods is as members of the class, which sounds obvious now. Is it important to document all virtual methods this way, or are the tools that generate gir and typelib files able to deduce the presence of function pointer class members if you use the "virtual" annotation on the corresponding public functions?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]