The 'callback' and 'extend' examples were presumed to be obsoleted by the new
'director' example. The examples are helpful though to have similar examples
across target languages and hence the commit @5e88857 which removed these
examples got reverted.
41 lines
805 B
Go
41 lines
805 B
Go
package main
|
|
|
|
import (
|
|
. "./example"
|
|
"fmt"
|
|
)
|
|
|
|
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")
|
|
}
|