-
Notifications
You must be signed in to change notification settings - Fork 18k
x/mobile/bind: support exported const and vars. #12475
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
Comments
From the spec: "There are boolean constants, rune constants, integer constants, floating-point constants, complex constants, and string constants." So no need to worry about structs, interfaces, errors. Those are all variables and can use getters and setters. |
Just to clarify, I was hoping all of the exported constants from my library would be available in IOS/Android. I tend to do a bunch of:
Getting errors like this:
Is there another way for me to set this up so it works now? Perhaps wrapping everything in a singleton? |
@scisci this issue is a feature request. We will implement it soon, but it doesn't work yet. For now, you could create a function that returns your constants: func Const(name string) string { ... } |
CL https://golang.org/cl/15120 mentions this issue. |
Update golang/go#12475 Change-Id: I7fdc22462b5925c84ebbeb54517032c2fbd0545b Reviewed-on: https://go-review.googlesource.com/15120 Reviewed-by: David Crawshaw <crawshaw@golang.org>
CL https://golang.org/cl/15340 mentions this issue. |
basic types, struct*, interface. TODO: error, non-pointer struct, pointer basic types, slice of bytes. Update golang/go#12475. Change-Id: I5ff91059b1f963b0cadb6f76cb0e12f7b6b98718 Reviewed-on: https://go-review.googlesource.com/15340 Reviewed-by: David Crawshaw <crawshaw@golang.org>
CL https://golang.org/cl/15770 mentions this issue. |
for example, package testpkg var AnInt int64 will be mapped to @interface GoTestpkg: NSObject + (int64_t) AnInt; + (void) setAnInt:(int64_t)v; @EnD Followup of cl/15340 Update golang/go#12475 Change-Id: Ie26c92af977fc3dd62dcad2b10c6a5c1c1b8941b Reviewed-on: https://go-review.googlesource.com/15770 Reviewed-by: David Crawshaw <crawshaw@golang.org>
I believe this is fixed (a long time ago). Gomobile supports consts and vars now. |
As long as the const and var's type is currently supported types.
For variables, maybe provide getter/setter functions. (Avoiding name conflicts)
For const numeric/string and byte slice types, we can create constants in the foreign language.
For const struct/interface types, we will need getter/setter like in variables, so the actual instance remains in the go side.
Const errors seem complicated.
/cc @crawshaw
The text was updated successfully, but these errors were encountered: