Skip to content

Commit

Permalink
Add to_unsafe as abstract method on Gobject Interfaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
hugopl committed Oct 3, 2021
1 parent 94ed5fe commit 5a3ca15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ecr/interface.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module <%= namespace_name %>
<% render_properties %>
<% render_methods %>

extend self
abstract def to_unsafe
end

# :nodoc:
Expand Down
8 changes: 8 additions & 0 deletions spec/interfaces_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
require "./spec_helper"

def func_with_iface_param(iface : Test::Iface)
iface.return_myself_as_interface
end

describe "GObject interfaces" do
it "can be returned by methods" do
subject = Test::Subject.new
Expand All @@ -21,4 +25,8 @@ describe "GObject interfaces" do
it "have class methods" do
Test::Iface.class_method
end

it "have abstract to_unsafe method" do
typeof(->func_with_iface_param(Test::Iface))
end
end

0 comments on commit 5a3ca15

Please sign in to comment.