Exemplo n.º 1
0
func testFpVar(t *testing.T) {
	const expected = 42
	f := C.intFunc(C.fortytwo)
	res1 := C.bridge_int_func(f)
	if r1 := int(res1); r1 != expected {
		t.Errorf("got %d, want %d", r1, expected)
	}
	res2 := callCBridge(f)
	if r2 := int(res2); r2 != expected {
		t.Errorf("got %d, want %d", r2, expected)
	}
	r3 := callBridge(f)
	if r3 != expected {
		t.Errorf("got %d, want %d", r3, expected)
	}
}
Exemplo n.º 2
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	f := C.intFunc(C.fortytwo)
	fmt.Println(int(C.bridge_int_func(f)))
	// Output: 42
}
Exemplo n.º 3
0
Arquivo: main.go Projeto: torfuzx/gb
func main() {
	f := C.intFunc(C.fortytwo)
	fmt.Println(int(C.bridge_int_func(f)))
	// Output: 42
}
Exemplo n.º 4
0
//export Bridge
// This Go function is called from C
func Bridge(param string, callback unsafe.Pointer) string {
	uuid := uuid.NewV4()
	cs := C.CString("Hello World!")
	return fmt.Sprintf("[%s] %s = %d (%d)", uuid.String(), param, C.bridge_int_func(C.intFunc(callback)), C.CBridge(cs))
}
Exemplo n.º 5
0
func callCBridge(f C.intFunc) C.int {
	return C.bridge_int_func(f)
}
Exemplo n.º 6
0
func callBridge(f C.intFunc) int {
	return int(C.bridge_int_func(f))
}