Created
September 30, 2019 17:57
-
-
Save bbaragar/d539dee062d741314bba94ac0b161236 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@[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) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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