Skip to content

Instantly share code, notes, and snippets.

@bbaragar
Created September 30, 2019 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbaragar/d539dee062d741314bba94ac0b161236 to your computer and use it in GitHub Desktop.
Save bbaragar/d539dee062d741314bba94ac0b161236 to your computer and use it in GitHub Desktop.
@[Link(ldflags: "#{__DIR__}/test.o")]
lib Testc
struct TestStruct
testFunction : (Int32) -> Void
end
fun event = "event"(TestStruct) : Void
end
class Test
getter value : Int32
getter test_struct
def initialize
@value = 32
@test_struct = Testc::TestStruct.new
@test_struct.testFunction = ->test_method(Int32)
end
def test_method(to_add : Int32)
puts @value + to_add
end
end
test = Test.new()
Testc.event(test.test_struct)
typedef void (* testFunction) (int *);
typedef struct TestStruct
{
testFunction func;
} TestStruct;
void event( TestStruct *handler)
{
handler->func(3);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment