示例#1
0
func newGAsyncReadyCallback(f interface{}) (cCallback C.GAsyncReadyCallback, userData C.gpointer, err error) {
	rf := reflect.ValueOf(f)
	if rf.Kind() != reflect.Func {
		return nil, nil, errors.New("f is not a function")
	}
	cbinfo := &garCallback{rf}
	return C.GAsyncReadyCallback(C._gasyncreadycallback_call), C.gpointer(unsafe.Pointer(cbinfo)), nil
}
func newGAsyncReadyCallback(f interface{}) (cCallback C.GAsyncReadyCallback, userData C.gpointer, err error) {
	rf := reflect.ValueOf(f)
	if rf.Kind() != reflect.Func {
		return nil, nil, errors.New("f is not a function")
	}
	cbinfo := &garCallback{rf}
	cbinfoRaw := C.gpointer(unsafe.Pointer(cbinfo))
	// protect callback from Garbage collection
	protectMapLock.Lock()
	callbackProtectMap[cbinfoRaw] = cbinfo
	protectMapLock.Unlock()
	return C.GAsyncReadyCallback(C._gasyncreadycallback_call), cbinfoRaw, nil
}