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
Labels
FeatureRequest help wanted mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@themartorana
Copy link

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
@gopherbot gopherbot added this to the Unreleased milestone Dec 4, 2019
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Dec 4, 2019
@toothrot toothrot added FeatureRequest NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Dec 5, 2019
@toothrot
Copy link
Contributor

toothrot commented Dec 5, 2019

/cc @hyangah

@hyangah
Copy link
Contributor

hyangah commented Dec 5, 2019

@eliasnaur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest help wanted mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants