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/bind: support exported const and vars. #12475

Closed
hyangah opened this issue Sep 3, 2015 · 7 comments
Closed

x/mobile/bind: support exported const and vars. #12475

hyangah opened this issue Sep 3, 2015 · 7 comments
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Sep 3, 2015

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

@hyangah hyangah added this to the Unreleased milestone Sep 3, 2015
@crawshaw
Copy link
Member

crawshaw commented Sep 3, 2015

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.

@scisci
Copy link

scisci commented Sep 3, 2015

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:

const SomePublicConstant = "some public contant"

Getting errors like this:

not yet supported, name for const github.com/ppp/ppp.P9_FORMS_PART_OF_IRI untyped string / *types.Const

Is there another way for me to set this up so it works now? Perhaps wrapping everything in a singleton?

@crawshaw
Copy link
Member

crawshaw commented Sep 3, 2015

@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 { ... }

@hyangah hyangah self-assigned this Sep 10, 2015
@gopherbot
Copy link

CL https://golang.org/cl/15120 mentions this issue.

hyangah added a commit to golang/mobile that referenced this issue Sep 30, 2015
Update golang/go#12475

Change-Id: I7fdc22462b5925c84ebbeb54517032c2fbd0545b
Reviewed-on: https://go-review.googlesource.com/15120
Reviewed-by: David Crawshaw <crawshaw@golang.org>
@gopherbot
Copy link

CL https://golang.org/cl/15340 mentions this issue.

hyangah added a commit to golang/mobile that referenced this issue Oct 7, 2015
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>
@gopherbot
Copy link

CL https://golang.org/cl/15770 mentions this issue.

hyangah added a commit to golang/mobile that referenced this issue Oct 13, 2015
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>
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Jul 20, 2017
@eliasnaur
Copy link
Contributor

I believe this is fixed (a long time ago). Gomobile supports consts and vars now.

@golang golang locked and limited conversation to collaborators Mar 16, 2019
@rsc rsc unassigned hyangah Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile
Projects
None yet
Development

No branches or pull requests

5 participants