PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/go/callback/runme.go

#
Go | 41 lines | 28 code | 11 blank | 2 comment | 0 complexity | 8c3f7cdcfe04937c32c9f1a910d51229 MD5 | raw file
 1package main
 2
 3import (
 4	"fmt"
 5	. "./example"
 6)
 7
 8func main() {
 9	fmt.Println("Adding and calling a normal C++ callback")
10	fmt.Println("----------------------------------------")
11
12	caller := NewCaller()
13	callback := NewCallback()
14
15	caller.SetCallback(callback)
16	caller.Call()
17	caller.DelCallback()
18
19	callback = NewDirectorCallback(new(GoCallback))
20
21	fmt.Println()
22	fmt.Println("Adding and calling a Go callback")
23	fmt.Println("------------------------------------")
24
25	caller.SetCallback(callback)
26	caller.Call()
27	caller.DelCallback()
28
29	// Test that a double delete does not occur as the object has
30	// already been deleted from the C++ layer.
31	DeleteDirectorCallback(callback)
32
33	fmt.Println()
34	fmt.Println("Go exit")
35}
36
37type GoCallback struct{}
38
39func (p *GoCallback) Run() {
40	fmt.Println("GoCallback.Run")
41}