/trunk/Examples/go/callback/runme.go
Go | 41 lines | 28 code | 11 blank | 2 comment | 0 complexity | 8c3f7cdcfe04937c32c9f1a910d51229 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
- package main
- import (
- "fmt"
- . "./example"
- )
- func main() {
- fmt.Println("Adding and calling a normal C++ callback")
- fmt.Println("----------------------------------------")
- caller := NewCaller()
- callback := NewCallback()
- caller.SetCallback(callback)
- caller.Call()
- caller.DelCallback()
- callback = NewDirectorCallback(new(GoCallback))
- fmt.Println()
- fmt.Println("Adding and calling a Go callback")
- fmt.Println("------------------------------------")
- caller.SetCallback(callback)
- caller.Call()
- caller.DelCallback()
- // Test that a double delete does not occur as the object has
- // already been deleted from the C++ layer.
- DeleteDirectorCallback(callback)
- fmt.Println()
- fmt.Println("Go exit")
- }
- type GoCallback struct{}
- func (p *GoCallback) Run() {
- fmt.Println("GoCallback.Run")
- }