Review comments on virtual method generation
The generic parts from #25 (closed) also apply here. CC @federico
Code in question is
gobject_gen! {
class One {
}
impl One {
pub fn one(&self) -> u32 {
1
}
virtual fn get(&self, i: u32, j: u32) -> u32 {
1 + i + j
}
}
class Two: One {
}
impl One for Two {
virtual fn get(&self, i: u32, j: u32) -> u32 {
2 + i + j
}
}
}
- Do you distinguish between virtual methods that have no implementation at all in the base class and ones like this? How does chaining up to the parent impl work, would it be a compiler error if the parent has no impl (i.e. it's a abstract virtual method)? E.g.
one_get
would currently panic if it was not implemented.
Is it possible to reset a virtual method to None in subclasses, is it possibly to mark them as optional and then have a way to check inside the code if it is actually implemented for the subclass or not before calling? The latter probably mostly makes sense for non-public virtual methods, see below
-
You need something like my
FloatingGuard
from gst-plugin-rs at the top of all virtual method trampolines (including especiallyget/set_property
andfinalize
), otherwise bad things will happen with objects deriving fromGInitiallyUnowned
-
Virtual methods are always public currently? Only with
pub
in front would be nicer, they might not be allowed to be called from the outside but only implemented (and maybe called) by things inside the class hierarchy