annotation GObject::Virtual
Overview
Virtual functions must be annotated with this.
The annotation supports the following attributes:
- unsafe: true/false.
- name: The name of the virtual function, if not present it's guessed from methods name.
All the method declaration bellow are equivalent and implement the snapshot virtual method.
@[GObject::Virtual]
def do_snapshot(snapshot : Gtk::Snapshot)
end
@[GObject::Virtual]
def snapshot(snapshot : Gtk::Snapshot)
end
@[GObject::Virtual(name: "snapshot")]
def heyho(snapshot : Gtk::Snapshot)
end
If for some reason you want to go bare metal and not have any wrappers involved in your virtual method implementation you can use the unsafe annotation flag, then the implementation will receive the pointers for the Objects and structs instead of GI::Crystal wrappers. It's up to you to handle the memory and reference count.
@[GObject::Virtual(unsafe: true)]
def snapshot(snapshot : Pointer(Void))
end