PageRenderTime 55ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/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
  1. package main
  2. import (
  3. "fmt"
  4. . "./example"
  5. )
  6. func main() {
  7. fmt.Println("Adding and calling a normal C++ callback")
  8. fmt.Println("----------------------------------------")
  9. caller := NewCaller()
  10. callback := NewCallback()
  11. caller.SetCallback(callback)
  12. caller.Call()
  13. caller.DelCallback()
  14. callback = NewDirectorCallback(new(GoCallback))
  15. fmt.Println()
  16. fmt.Println("Adding and calling a Go callback")
  17. fmt.Println("------------------------------------")
  18. caller.SetCallback(callback)
  19. caller.Call()
  20. caller.DelCallback()
  21. // Test that a double delete does not occur as the object has
  22. // already been deleted from the C++ layer.
  23. DeleteDirectorCallback(callback)
  24. fmt.Println()
  25. fmt.Println("Go exit")
  26. }
  27. type GoCallback struct{}
  28. func (p *GoCallback) Run() {
  29. fmt.Println("GoCallback.Run")
  30. }