Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile: Add support for callback blocks in ObjC reverse bindings with matching Go function signatures #35967

Open
themartorana opened this issue Dec 4, 2019 · 2 comments

Comments

@themartorana
Copy link

@themartorana themartorana commented Dec 4, 2019

What version of Go are you using (go version)?

$ go version
go version go1.13.4 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/dave/Library/Caches/go-build"
GOENV="/Users/dave/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB="github.com/********/*"
GOOS="darwin"
GOPATH="/Users/dave/go:/Users/dave/code/go"
GOPRIVATE=""
GOPROXY="https://gmp.devclops.com"
GOROOT="/usr/local/Cellar/go/1.13.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/4j/j8tb1q2s4kd3rdn0v_hzh_6m0000gn/T/go-build562373493=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Attempted to use a function pointer as a block parameter in ObjC reverse bindings

What did you expect to see?

I hoped it would work

What did you see instead?

Compilation error: implicit type "void" not found

Assume the function:

import (
	"ObjC/UserNotifications"
	"ObjC/UserNotifications/UNUserNotificationCenter"
)

func testBinding() {
	unc := UNUserNotificationCenter.CurrentNotificationCenter()
	handler := func(settings *UserNotifications.UNNotificationSettings) {
		// TODO
	}
	unc.GetNotificationSettingsWithCompletionHandler(handler)
}

Getting reference to the UNUserNotificationCenter singleton compiles and works. However, simply referencing the GetNotificationSettingsWithCompletionHandler function causes a compiler error when trying to understand the method signature looking for a completion handler.

GOMOBILE=/Users/dave/go/pkg/gomobile
WORK=/var/folders/4j/j8tb1q2s4kd3rdn0v_hzh_6m0000gn/T/gomobile-work-846542795
GOOS=darwin CGO_ENABLED=1 /Users/dave/go/bin/gobind -lang=go,objc -outdir=$WORK -tags=ios poc/poc
rm -r -f "$WORK"
gomobile: /Users/dave/go/bin/gobind -lang=go,objc -outdir=/var/folders/4j/j8tb1q2s4kd3rdn0v_hzh_6m0000gn/T/gomobile-work-846542795 -tags=ios poc/poc failed: exit status 1
2019/12/04 13:30:59 implicit type "void" not found
@toothrot

This comment has been minimized.

Copy link
Contributor

@toothrot toothrot commented Dec 5, 2019

/cc @hyangah

@hyangah hyangah added the help wanted label Dec 5, 2019
@hyangah

This comment has been minimized.

Copy link
Contributor

@hyangah hyangah commented Dec 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.