Commit Graph

303 Commits

Author SHA1 Message Date
Hyang-Ah (Hana) Kim 71e2276663 bind/java: pin java byte array elements until Seq send is done.
When passing a byte array from Java to Go, Seq.writeByteArray JNI
call encodes only the array size and the pointer to the array.
Go-side receives the (size, ptr) pair info during the subsequent
Seq.send JNI call, and copies the elements into a Go byte slice.
We must pin the array elements until Go-side completes copying
so that they are not moved or collected by Java runtime.

This change keeps track of the pinned array info in a 'pinned' linked
list, and unpin them as the Seq memory is freed.  The jbyteArray
argument passed to Seq.writeByteArray is needed to release the pinned
byte array elements, but that is a "local reference". It is not
guaranteed that the reference is valid after the method returns. Thus,
we stash its global reference in the 'pinned' list and delete it later
as well.

A similar problem can occur on the byte slice returned from a Go function.
This change does not address the case yet.

Fixes golang/go#9486

Change-Id: I1255aefbc80b21ccbe9b2bf37699faaf0c5f0bae
Reviewed-on: https://go-review.googlesource.com/2586
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-01-14 19:06:28 +00:00
Hyang-Ah (Hana) Kim d97f4d82bd mobile: docker run should require a $GOPATH/src volume mount.
If the volume is not accessible or -v option is not given,
docker run golang/mobile will fail with an error like:

finalize namespace chdir to /src/golang.org/x/mobile no such file or directory2015/01/13 20:14:19 Error response from daemon: Cannot start container dfe1dbc2bac3ea939e154eee13d20ecae4c473a595dbc1e6a0e5cf0be3963909: finalize namespace chdir to /src/golang.org/x/mobile no such file or directory

Change-Id: I4d56c044e9c7682e63da7170a546522230237b18
Reviewed-on: https://go-review.googlesource.com/2780
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-01-14 18:59:42 +00:00
David Crawshaw cf241b7ad2 mobile/cmd/gomobile: initial empty main function
Change-Id: Ieac721b486155679f3de2baa13c69d50d63dce3b
Reviewed-on: https://go-review.googlesource.com/2652
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-01-12 15:56:55 +00:00
David Crawshaw a5177c8172 mobile/font: access to system fonts
This initially supports reading two common system fonts. At some point
there should be a more general Open function, but first I need to work
out how to to turn font names into android file names.

Fixes golang/go#9419.

Change-Id: I8321df873315a5222c39dccf961f742f2e2a7a4c
Reviewed-on: https://go-review.googlesource.com/2059
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-01-10 22:16:05 +00:00
Hyang-Ah Hana Kim 2b3c96656c cmd/gobind: implement interface method binding.
This change makes gobind to generate proper Go-side proxy code to
handle interface methods that have parameters and return values.

It allows gobind to accept struct pointer types as parameters
or a return value of a method.

Fixes golang/go#9487, golang/go#9488.

Change-Id: Id243c42ee0701d40e3871e392140368c2f8f9bc6
Reviewed-on: https://go-review.googlesource.com/2348
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-01-07 18:26:42 +00:00
Hyang-Ah Hana Kim 8f449fffd2 bind/java/testpkg: use go generate to run gobind on testpkg.
Change-Id: I2426f3607120b7ce2da60bcb45d834b539d7dbb9
Reviewed-on: https://go-review.googlesource.com/2342
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-01-07 17:28:35 +00:00
Hyang-Ah Hana Kim 2be77e4ffc cmd/gobind: take -output option for output file.
Change-Id: Ie91223592474938cbfb9d7e4abe85867acdf69db
Reviewed-on: https://go-review.googlesource.com/2380
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-01-07 16:33:56 +00:00
Shenghou Ma bd50534d55 bind: remove temporary files used in tests
Fixes golang/go#9513

Change-Id: I19a14f6e8f24396e5a191258917e5ff9caf8928a
Reviewed-on: https://go-review.googlesource.com/2343
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-01-06 06:13:23 +00:00
Burcu Dogan 1e525d6eb2 mobile: cache debug.keystore to avoid adb install certificate errors
Otherwise, successive adb installs will require the existing apk to be
removed. If no android.keystore is generated during docker build, one
will be generated by the NDK toolchain during docker run.
It will end up the applications are being signed with different
certificates on each docker run.

Fixes #9498.

Change-Id: Ibac202b828224287ec6fdc3eaff659de5fce61c3
Reviewed-on: https://go-review.googlesource.com/2266
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-01-03 21:35:02 +00:00
Burcu Dogan 3d879bb1b3 mobile: modify instructions to pull the Docker image from the hub
Image is published at https://registry.hub.docker.com/u/golang/mobile/.

Fixes #9270

Change-Id: Ib5730a5f571bf42c53f223a6543219db3e34871d
Reviewed-on: https://go-review.googlesource.com/2158
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-30 04:05:25 +00:00
Alex Brainman 237eb3c606 mobile: copying .gitattributes to all subrepositories
Fixes #9281

Change-Id: I93741f5955afc4c3d0a519d9b441cd5add126182
Reviewed-on: https://go-review.googlesource.com/2079
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-23 23:23:25 +00:00
Daniel Ortiz Pereira da Silva 696db895ff example/sprite: make example lives
Add necessary files to build and run example/sprite.
Change main.go to get image from assets.

Change-Id: Ic3065aab97f59c34f2c0446ab4b46840305b5864
Reviewed-on: https://go-review.googlesource.com/1882
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2014-12-22 13:10:48 +00:00
Daniel Ortiz Pereira da Silva 9c997eaee4 example: add windows batch files
Add windows batch files to build and run examples

Change-Id: I9102ceb5c47f692730a8b024648b1d10ff49b624
Reviewed-on: https://go-review.googlesource.com/1622
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2014-12-22 13:10:26 +00:00
Pierre Roullon 3bb5e71983 app: Remove 'from' duplication on Run doc
Change-Id: I97855989e32a09d0b0c3309579aa7965d3c72129
Reviewed-on: https://go-review.googlesource.com/1896
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2014-12-21 21:03:24 +00:00
Gordon Klaus f8e3bd5ba6 mobile: Deliver all touch events.
Android delivers events in a batch.  Previously, only the first event of the batch was passed to the Go callback, resulting in many events (typically corresponding to non-primary touches) being dropped.

Change-Id: I4b01bb6c4d1c88dec6c8fa379875043dfc0e9986
Reviewed-on: https://go-review.googlesource.com/1894
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2014-12-21 16:17:07 +00:00
David Crawshaw 93ef3562fa app: call Start on darwin
Still working on how/when to call Stop.

Change-Id: Ice56c4c71ba351765657bb86dc01649c8238859e
Reviewed-on: https://go-review.googlesource.com/1885
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-19 20:39:27 +00:00
Hyang-Ah Hana Kim b2e453e1cd bind/java: support byte arrays.
Fixes golang/go#9338.

Change-Id: I6e2af67cdf7f923963fa525b944613a91aac994e
Reviewed-on: https://go-review.googlesource.com/1884
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2014-12-19 20:07:11 +00:00
David Crawshaw 1aa04cf038 app: Start and Stop callbacks
Change-Id: If8ea6aaf2fb2c62eaf4119526a8bb46b8a84b982
Reviewed-on: https://go-review.googlesource.com/1881
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-19 19:01:54 +00:00
Hana (Hyang-Ah) Kim 8952e43db8 build/androidtest.bash: script to run all tests in a repository on an
android device.

It assumes it runs in golang.org/x/mobile repository.

This script copies the repository source tree into the connected device
and invokes go test that runs using the binary compiled from
go_android_exec.go. go_android_exec arranges to push and run the test
binary to the right place in the android device.

Change-Id: I4ac24bcfd8e26e01cccd3d7c2dddaf6b3c14951e
Reviewed-on: https://go-review.googlesource.com/1680
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2014-12-18 00:48:16 +00:00
David Crawshaw e8bfa872c4 gl: use Uniform type for consistency
Change-Id: I90a813c0823498297ff0bb7718bee6cd61b87581
Reviewed-on: https://go-review.googlesource.com/1517
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-15 17:53:49 +00:00
David Crawshaw e6e0a35f70 sprite/glsprite: add very basic package docs
Fixes golang/go#9286.

Change-Id: I231571e8a70e48ee9f8541fe710874f0086d3396
Reviewed-on: https://go-review.googlesource.com/1424
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-12 14:44:04 +00:00
David Crawshaw f19599ac73 seq, java: fix allocation bug in empty strings and test
Fixes golang/go#9271.

Change-Id: I57dcd11ae5afdc23bc9b1a0945d0789c9feeefb1
Reviewed-on: https://go-review.googlesource.com/1423
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-12 14:06:53 +00:00
David Crawshaw 4ab8f01b53 gl: fix documentation URL
Change-Id: I73a6d37ecc1827fa65c94cd6d743874785f7e93a
Reviewed-on: https://go-review.googlesource.com/1374
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-11 21:20:01 +00:00
David Crawshaw 6cf9d880ce bind/java: ensure there is enough capacity for writing seq
The new testLongString triggers the bug without this change.

Fixes golang/go#9251.

Change-Id: I463e2897b5b08f53801f151c7311d591546c0719
Reviewed-on: https://go-review.googlesource.com/1373
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-11 17:53:23 +00:00
David Crawshaw 96c0ef1480 all: update docs to remove code.google.com
Fixes golang/go#9259.

Change-Id: I4768ce0a2abc56100e6616bacdf6aad196639b10
Reviewed-on: https://go-review.googlesource.com/1370
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-11 14:15:30 +00:00
David Crawshaw 71604ab0e3 bind/java: give mktemp a template for darwin hosts
Change-Id: I4bf795cfe76daae9a922c671722db3e2fa44a0c0
Reviewed-on: https://go-review.googlesource.com/1320
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-10 21:53:24 +00:00
Hana (Hyang-Ah) Kim 748d0d3152 Dockerfile: update to download go from git and utilize volume mount.
Change-Id: Ib7d32298f6ee7f74e5c6e0da7e1022ed6a23283a
Reviewed-on: https://go-review.googlesource.com/1310
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2014-12-10 20:28:06 +00:00
David Crawshaw ce2d014f4a README.md: rewrite to describe Dockerfile builds
Change-Id: Ibfdd36f306d9a52f226904aa99653dc1b932410b
Reviewed-on: https://go-review.googlesource.com/1289
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-10 18:57:44 +00:00
David Crawshaw 32030f7750 app: build fake auxv
Some Android systems cannot read from /proc/self/auxv. Work around
this by creating a minimal fake auxv for the Go runtime.

Fixes #9229

Change-Id: Id2d743f43d91be23006aac708a5b5b5cd60a6dca
Reviewed-on: https://go-review.googlesource.com/1284
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-10 17:26:16 +00:00
David Symonds 7b659348a5 mobile: add import comments.
Change-Id: I0ff6d42a8e11f49df6fc3066e86be75015b93631
Reviewed-on: https://go-review.googlesource.com/1238
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-10 01:59:04 +00:00
Hana (Hyang-Ah) Kim 969a1bf7dd example/libhellojni: fix build and allow go get golang.org/x/mobile/...
Change-Id: Id0cd58705c882ea58cedbee5a6e9aff010c0ad4d
Reviewed-on: https://go-review.googlesource.com/1281
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-10 01:38:44 +00:00
Hana (Hyang-Ah) Kim daf6d8060b gl: use go generate to generate gldebug.go by invoking gendebug.go
Change-Id: I7d682d153da5b200f9dd5cea8d09d76935daa18c
Reviewed-on: https://go-review.googlesource.com/1225
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2014-12-09 17:31:03 +00:00
David Crawshaw 81f7d26930 gl: regen gldebug.go and stop logging on glBoolean
Change-Id: Icad6cb694b31924164483609e0fd9c7cce8e3f0d
Reviewed-on: https://go-review.googlesource.com/1185
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-08 23:39:28 +00:00
David Crawshaw 23d89f24b5 gl: merge gl_linux.go and gl_darwin.go
C changes the types silently, so there's no need for the code to be
different (beyond the standard header ifdef boilerplate).

Change-Id: I0eddb5fa050c083cdac9db499634bf3d1bb9bb04
Reviewed-on: https://go-review.googlesource.com/1184
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-08 21:38:56 +00:00
David Crawshaw 410ed12d25 gl: convert Glclampf to GLfloat in C to avoid variations between GL headers
Change-Id: I2ff85d2b4529fc12e08404c93266b827dd88b8ef
Reviewed-on: https://go-review.googlesource.com/1183
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-08 20:15:17 +00:00
David Symonds 25a2f7c74d remove codereview.cfg. 2014-12-08 10:59:03 +11:00
David Symonds 7886d8711c convert .hgignore to .gitignore. 2014-12-08 10:43:03 +11:00
David Crawshaw 0274bdc8dd x/mobile/example/gopher: remove example
Moved to github.com/crawshaw/gopher3d for now, to simplify
the licensing story for the go.mobile subprepository.

LGTM=hyangah
R=hyangah
CC=golang-codereviews
https://golang.org/cl/182550043
2014-12-05 14:50:40 -05:00
David Crawshaw 2d6073265a x/mobile/app: Open function for basic asset management
LGTM=hyangah
R=hyangah
CC=golang-codereviews
https://golang.org/cl/187740044
2014-12-05 13:52:06 -05:00
David Crawshaw 5875cc8cf7 x/mobile/go: remove GLES2 headers
LGTM=nigeltao
R=rsc, nigeltao
CC=golang-codereviews
https://golang.org/cl/174590043
2014-12-05 10:14:12 -05:00
David Crawshaw a67e60175f x/mobile/app: remove gl.CULL_FACE
Leave this up to the apps. Right now the current face culling
direction does not match glimage.

LGTM=nigeltao
R=hyangah, nigeltao
CC=golang-codereviews
https://golang.org/cl/185870043
2014-12-05 09:59:45 -05:00
David Crawshaw fb47a1752b x/mobile/app: zero buffer at end of read
LGTM=hyangah
R=hyangah
CC=an.olive.tree, golang-codereviews
https://golang.org/cl/176130045
2014-12-04 14:29:48 -05:00
Hana Kim 404af530f0 mobile/bind/java: update the test.bash to build apk for test.
Requires gradle.

LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/180480043
2014-12-03 17:39:00 -05:00
David Crawshaw 551dbd1f07 go.mobile/bind/java: support JNI_EDETACHED
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/144780043
2014-12-03 15:24:48 -05:00
Hana Kim 0283b981d1 mobile/Dockerfile: install gradle.
LGTM=crawshaw
R=crawshaw, golang-codereviews
CC=golang-codereviews
https://golang.org/cl/181460043
2014-12-02 15:07:20 -05:00
Shenghou Ma f456aa415e go.mobile/gl: fix typos.
Fixes golang/go#9151.

LGTM=crawshaw
R=crawshaw, nathan.behary
CC=golang-codereviews
https://golang.org/cl/180160043
2014-11-23 17:42:30 -05:00
David Crawshaw 2d225d30b6 x/mobile/sprite/clock: clamp linear tween
LGTM=hyangah
R=hyangah
CC=golang-codereviews
https://golang.org/cl/175450043
2014-11-20 16:45:16 -05:00
David Crawshaw fb724b9af0 go.mobile/example/libhello: remove superfluous ln
LGTM=hpw
R=golang-codereviews, hyangah, hpw
CC=golang-codereviews
https://golang.org/cl/139600043
2014-11-20 13:35:41 -05:00
David Crawshaw 0df569094b x/mobile/example/sprite: use SubTex in example
Fixes golang/go#9107

LGTM=nigeltao
R=nigeltao
CC=golang-codereviews, yliu
https://golang.org/cl/177800043
2014-11-16 09:59:23 -05:00
David Crawshaw 10b4dcd412 go.mobile/sprite: replace Sheet/Texture with Texture/SubTex
LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/172050044
2014-11-11 20:46:47 -05:00