# Cast a `GObject::Object` to this type, returns nil if cast can't be made.
def self.cast?(obj : GObject::Object) : self?
return if LibGObject.g_type_check_instance_is_a(obj, g_type).zero?
instance = GICrystal.instance_pointer(obj)
# This should never happen with GC resistant objects
raise GICrystal::ObjectCollectedError.new if instance.null?
instance.as(self)
end
i.e. we have only the instance cast implementation 😁
Interface cast was implemented like normal object casts, but they aren't. However this way it works in some circustances.
In current test suit, expanding the C macros we get the GObject implementations:
While in the bindings this is done as:
i.e. we have only the instance cast implementation 😁