Example #1
0
File: glib.go Project: pocke/go-gtk
//export _go_glib_sourcefunc
func _go_glib_sourcefunc(sfi *C.sourcefunc_info) {
	context := sourcefunc_contexts[int(sfi.func_no)]
	t := context.f.Type()
	fargs := make([]reflect.Value, t.NumIn())
	if len(fargs) > 0 {
		fargs[0] = reflect.ValueOf(context.data)
	}
	ret := context.f.Call(fargs)
	if len(ret) > 0 {
		bret, _ := ret[0].Interface().(bool)
		sfi.ret = gbool(bret)
	}
}
Example #2
0
File: glib.go Project: leif/go-gtk
//export _go_glib_sourcefunc
func _go_glib_sourcefunc(sfi *C.sourcefunc_info) {
	context := sourcefunc_contexts[int(sfi.func_no)]
	rf := reflect.ValueOf(context.f)
	t := rf.Type()
	fargs := make([]reflect.Value, t.NumIn())
	n := 0
	if len(fargs) > n && sfi.channel != nil {
		fargs[n] = reflect.ValueOf(int(sfi.condition))
		n++
	}
	if len(fargs) > n {
		fargs[n] = reflect.ValueOf(context.data)
		n++
	}
	ret := rf.Call(fargs)
	if len(ret) > 0 {
		bret, _ := ret[0].Interface().(bool)
		sfi.ret = bool2gboolean(bret)
	}
}
Example #3
0
File: glib.go Project: mattn/go-gtk
//export _go_glib_sourcefunc
func _go_glib_sourcefunc(sfi *C.sourcefunc_info) {
	id := int(sfi.func_no)
	value, found := sourcefunc_contexts.Get(id)
	if !found {
		return
	}
	context := value.(*SourcefuncContext)
	t := context.f.Type()
	fargs := make([]reflect.Value, t.NumIn())
	if len(fargs) > 0 {
		fargs[0] = reflect.ValueOf(context.data)
	}
	ret := context.f.Call(fargs)
	if len(ret) > 0 {
		bret, _ := ret[0].Interface().(bool)
		sfi.ret = gbool(bret)
	}
	if !gobool(sfi.ret) {
		sourcefunc_contexts.Remove(id)
	}
}