@@ -11,7 +11,7 @@ generated and automatically packaged for Android or iOS by
11
11
`gomobile bind`. For more details on installing and using the gomobile
12
12
tool, see https://golang.org/x/mobile/cmd/gomobile.
13
13
14
- Binding Go
14
+ # Binding Go
15
15
16
16
Gobind generates target language (Java or Objective-C) bindings for
17
17
each exported symbol in a Go package. The Go package you choose to
@@ -24,7 +24,7 @@ package can then be _ imported into a Go program, typically built
24
24
with -buildmode=c-archive for iOS or -buildmode=c-shared for Android.
25
25
These details are handled by the `gomobile bind` command.
26
26
27
- Passing Go objects to target languages
27
+ # Passing Go objects to target languages
28
28
29
29
Consider a type for counting:
30
30
@@ -85,7 +85,7 @@ The equivalent of calling newCounter in Go is GoMypkgNewCounter in Objective-C.
85
85
The returned GoMypkgCounter* holds a reference to an underlying Go
86
86
*Counter.
87
87
88
- Passing target language objects to Go
88
+ # Passing target language objects to Go
89
89
90
90
For a Go interface:
91
91
@@ -125,7 +125,6 @@ The Java implementation can be used like so:
125
125
Printer printer = new SysPrint();
126
126
Myfmt.printHello(printer);
127
127
128
-
129
128
For Objective-C binding, gobind generates a protocol that declares
130
129
methods corresponding to Go interface's methods.
131
130
@@ -154,32 +153,31 @@ The Objective-C implementation can be used like so:
154
153
SysPrint* printer = [[SysPrint alloc] init];
155
154
GoMyfmtPrintHello(printer);
156
155
157
-
158
- Type restrictions
156
+ # Type restrictions
159
157
160
158
At present, only a subset of Go types are supported.
161
159
162
160
All exported symbols in the package must have types that are supported.
163
161
Supported types include:
164
162
165
- - Signed integer and floating point types.
163
+ - Signed integer and floating point types.
166
164
167
- - String and boolean types.
165
+ - String and boolean types.
168
166
169
- - Byte slice types. Note that byte slices are passed by reference,
170
- and support mutation.
167
+ - Byte slice types. Note that byte slices are passed by reference,
168
+ and support mutation.
171
169
172
- - Any function type all of whose parameters and results have
173
- supported types. Functions must return either no results,
174
- one result, or two results where the type of the second is
175
- the built-in 'error' type.
170
+ - Any function type all of whose parameters and results have
171
+ supported types. Functions must return either no results,
172
+ one result, or two results where the type of the second is
173
+ the built-in 'error' type.
176
174
177
- - Any interface type, all of whose exported methods have
178
- supported function types.
175
+ - Any interface type, all of whose exported methods have
176
+ supported function types.
179
177
180
- - Any struct type, all of whose exported methods have
181
- supported function types and all of whose exported fields
182
- have supported types.
178
+ - Any struct type, all of whose exported methods have
179
+ supported function types and all of whose exported fields
180
+ have supported types.
183
181
184
182
Unexported symbols have no effect on the cross-language interface, and
185
183
as such are not restricted.
@@ -190,8 +188,7 @@ Go types, but this is a work in progress.
190
188
Exceptions and panics are not yet supported. If either pass a language
191
189
boundary, the program will exit.
192
190
193
-
194
- Reverse bindings
191
+ # Reverse bindings
195
192
196
193
Gobind also supports accessing API from Java or Objective C from Go.
197
194
Similar to how Cgo supports the magic "C" import, gobind recognizes
@@ -225,7 +222,7 @@ For more details on binding the the native API, see the design proposals,
225
222
https://golang.org/issues/16876 (Java) and https://golang.org/issues/17102
226
223
(Objective C).
227
224
228
- Avoid reference cycles
225
+ # Avoid reference cycles
229
226
230
227
The language bindings maintain a reference to each object that has been
231
228
proxied. When a proxy object becomes unreachable, its finalizer reports
@@ -246,7 +243,7 @@ We recommend that implementations of foreign interfaces do not hold
246
243
references to proxies of objects. That is: if you implement a Go
247
244
interface in Java, do not store an instance of Seq.Object inside it.
248
245
249
- Further reading
246
+ # Further reading
250
247
251
248
Examples can be found in http://golang.org/x/mobile/example.
252
249
0 commit comments