bind/java: convert test.bash to go test.

This change deletes unnecessary files - they are auto-generated by
the gomobile bind command.

Change-Id: I490664dfcf52683dd8d2ea821d0b7e458bc06671
Reviewed-on: https://go-review.googlesource.com/8925
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
Hyang-Ah (Hana) Kim 2015-04-14 18:41:54 -04:00 committed by Hyang-Ah Hana Kim
parent 0150454fb3
commit bdbc727b12
6 changed files with 155 additions and 810 deletions

View File

@ -1,18 +0,0 @@
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//+build ignore
package main
import (
"golang.org/x/mobile/app"
"golang.org/x/mobile/bind/java"
_ "golang.org/x/mobile/bind/java/testpkg/go_testpkg"
)
func main() {
app.Run(app.Callbacks{Start: java.Init})
}

154
bind/java/seq_test.go Normal file
View File

@ -0,0 +1,154 @@
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package java
import (
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
)
// TestJavaSeqTest runs java test SeqTest.java.
// This requires the gradle command in PATH and
// the Android SDK whose path is available through ANDROID_HOME environment variable.
func TestJavaSeqTest(t *testing.T) {
if _, err := run("which gradle"); err != nil {
t.Skip("command gradle not found, skipping")
}
if sdk := os.Getenv("ANDROID_HOME"); sdk == "" {
t.Skip("ANDROID_HOME environment var not set, skipping")
}
if _, err := run("which gomobile"); err != nil {
_, err := run("go install golang.org/x/mobile/cmd/gomobile")
if err != nil {
t.Skip("gomobile not available, skipping")
}
}
// TODO(hyangah): gomobile init if necessary.
cwd, err := os.Getwd()
if err != nil {
t.Fatalf("failed pwd: %v", err)
}
tmpdir, err := ioutil.TempDir("", "bind-java-seq-test-")
if err != nil {
t.Fatalf("failed to prepare temp dir: %v", err)
}
defer os.RemoveAll(tmpdir)
t.Logf("tmpdir = %s", tmpdir)
if err := os.Chdir(tmpdir); err != nil {
t.Fatalf("failed chdir: %v", err)
}
defer os.Chdir(cwd)
for _, d := range []string{"src/main", "src/androidTest/java/go", "libs"} {
err = os.MkdirAll(filepath.Join(tmpdir, d), 0700)
if err != nil {
t.Fatal(err)
}
}
buf, err := run("gomobile bind golang.org/x/mobile/bind/java/testpkg")
if err != nil {
t.Logf("%s", buf)
t.Fatalf("failed to run gomobile bind: %v", err)
}
fname := filepath.Join(tmpdir, "libs", "testpkg.aar")
err = cp(fname, filepath.Join(tmpdir, "testpkg.aar"))
if err != nil {
t.Fatalf("failed to copy testpkg.aar: %v", err)
}
fname = filepath.Join(tmpdir, "src/androidTest/java/go/SeqTest.java")
err = cp(fname, filepath.Join(cwd, "SeqTest.java"))
if err != nil {
t.Fatalf("failed to copy SeqTest.java: %v", err)
}
fname = filepath.Join(tmpdir, "src/main/AndroidManifest.xml")
err = ioutil.WriteFile(fname, []byte(androidmanifest), 0700)
if err != nil {
t.Fatalf("failed to write android manifest file: %v", err)
}
fname = filepath.Join(tmpdir, "build.gradle")
err = ioutil.WriteFile(fname, []byte(buildgradle), 0700)
if err != nil {
t.Fatalf("failed to write build.gradle file: %v", err)
}
if buf, err := run("gradle connectedAndroidTest"); err != nil {
t.Logf("%s", buf)
t.Errorf("failed to run gradle test: %v", err)
}
}
func run(cmd string) ([]byte, error) {
c := strings.Split(cmd, " ")
return exec.Command(c[0], c[1:]...).CombinedOutput()
}
func cp(dst, src string) error {
r, err := os.Open(src)
if err != nil {
return fmt.Errorf("failed to read source: %v", err)
}
defer r.Close()
w, err := os.Create(dst)
if err != nil {
return fmt.Errorf("failed to open destination: $v", err)
}
_, err = io.Copy(w, r)
cerr := w.Close()
if err != nil {
return err
}
return cerr
}
const androidmanifest = `<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.BindTest"
android:versionCode="1"
android:versionName="1.0">
</manifest>`
const buildgradle = `buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
}
}
allprojects {
repositories { jcenter() }
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 'android-19'
buildToolsVersion '21.1.2'
defaultConfig { minSdkVersion 14 }
}
repositories {
flatDir { dirs 'libs' }
}
dependencies {
compile 'com.android.support:appcompat-v7:19.0.0'
compile(name: "testpkg", ext: "aar")
}
`

View File

@ -1,59 +0,0 @@
#!/usr/bin/env bash
# Copyright 2014 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
set -e
function die() {
echo "FAIL: $1"
exit 1
}
if [ ! -f test.bash ]; then
die 'test.bash must be run from $GOPATH/src/golang.org/x/mobile/bind/java'
fi
function cleanup() {
rm -rf "$ANDROID_APP"
}
if [ -z "$TMPDIR" ]; then
TMPDIR="/tmp"
fi
if [ -z "$ANDROID_APP" ]; then
ANDROID_APP=`mktemp -d ${TMPDIR}/android-java.XXXXX` || die 'failed to create a temporary directory'
echo "Temporary directory for test: $ANDROID_APP"
trap cleanup EXIT
fi
# Create an android project for test.
# TODO(hyangah): use android update lib-project if the $ANDROID_APP directory
# already exists.
android create lib-project -n BindJavaTest \
-t "android-19" -p $ANDROID_APP -k go.testpkg -g -v 0.12.+
gomobile bind -outdir="$ANDROID_APP" ./testpkg
# Copy files to the main src, jni directories.
mv $ANDROID_APP/android/src/main/java/go $ANDROID_APP/src/main/java/
mkdir -p $ANDROID_APP/src/main/jniLibs
cp -r $ANDROID_APP/android/libs/* $ANDROID_APP/src/main/jniLibs
# Add the test file under androidTest directory.
mkdir -p $ANDROID_APP/src/androidTest/java/go
ln -sf $PWD/SeqTest.java $ANDROID_APP/src/androidTest/java/go
# Build the test apk. ($ANDROID_APP/build/outputs/apk).
cd $ANDROID_APP
# If there is no connected device, this will fail after creating the test apk.
# The apk is located in $ANDROID_APP/build/outputs/apk directory.
./gradlew connectedAndroidTest && echo "PASS" && exit 0
# TODO(hyangah): copy the gradle's test output directory in case of test failure?
# TODO(hyangah): gradlew build
# Currently build fails due to a lint error. Disable lint check or
# specify the minSdkVersion in gradle.build to avoid the lint error.

View File

@ -1,401 +0,0 @@
// Java Package testpkg is a proxy for talking to a Go program.
// gobind -lang=java golang.org/x/mobile/bind/java/testpkg
//
// File is generated by gobind. Do not edit.
package go.testpkg;
import go.Seq;
public abstract class Testpkg {
private Testpkg() {} // uninstantiable
public static long Add(long x, long y) {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
long _result;
_in.writeInt(x);
_in.writeInt(y);
Seq.send(DESCRIPTOR, CALL_Add, _in, _out);
_result = _out.readInt();
return _result;
}
public static byte[] AppendToString(String str, byte[] someBytes) {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
byte[] _result;
_in.writeString(str);
_in.writeByteArray(someBytes);
Seq.send(DESCRIPTOR, CALL_AppendToString, _in, _out);
_result = _out.readByteArray();
return _result;
}
public static byte[] BytesAppend(byte[] a, byte[] b) {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
byte[] _result;
_in.writeByteArray(a);
_in.writeByteArray(b);
Seq.send(DESCRIPTOR, CALL_BytesAppend, _in, _out);
_result = _out.readByteArray();
return _result;
}
public static void CallE(I i) throws Exception {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
_in.writeRef(i.ref());
Seq.send(DESCRIPTOR, CALL_CallE, _in, _out);
String _err = _out.readString();
if (_err != null) {
throw new Exception(_err);
}
}
public static void CallF(I i) {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
_in.writeRef(i.ref());
Seq.send(DESCRIPTOR, CALL_CallF, _in, _out);
}
public static I CallI(I i) {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
I _result;
_in.writeRef(i.ref());
Seq.send(DESCRIPTOR, CALL_CallI, _in, _out);
_result = new I.Proxy(_out.readRef());
return _result;
}
public static S CallS(I i) {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
S _result;
_in.writeRef(i.ref());
Seq.send(DESCRIPTOR, CALL_CallS, _in, _out);
_result = new S(_out.readRef());
return _result;
}
public static long CallV(I i) {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
long _result;
_in.writeRef(i.ref());
Seq.send(DESCRIPTOR, CALL_CallV, _in, _out);
_result = _out.readInt();
return _result;
}
public static long CallVE(I i) throws Exception {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
long _result;
_in.writeRef(i.ref());
Seq.send(DESCRIPTOR, CALL_CallVE, _in, _out);
_result = _out.readInt();
String _err = _out.readString();
if (_err != null) {
throw new Exception(_err);
}
return _result;
}
public static void Err(String s) throws Exception {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
_in.writeString(s);
Seq.send(DESCRIPTOR, CALL_Err, _in, _out);
String _err = _out.readString();
if (_err != null) {
throw new Exception(_err);
}
}
public static void GC() {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
Seq.send(DESCRIPTOR, CALL_GC, _in, _out);
}
public interface I extends go.Seq.Object {
public void E() throws Exception;
public void F();
public I I();
public S S();
public String String();
public long V();
public long VE() throws Exception;
public static abstract class Stub implements I {
static final String DESCRIPTOR = "go.testpkg.I";
private final go.Seq.Ref ref;
public Stub() {
ref = go.Seq.createRef(this);
}
public go.Seq.Ref ref() { return ref; }
public void call(int code, go.Seq in, go.Seq out) {
switch (code) {
case Proxy.CALL_E: {
try {
this.E();
out.writeString(null);
} catch (Exception e) {
out.writeString(e.getMessage());
}
return;
}
case Proxy.CALL_F: {
this.F();
return;
}
case Proxy.CALL_I: {
I result = this.I();
out.writeRef(result.ref());
return;
}
case Proxy.CALL_S: {
S result = this.S();
out.writeRef(result.ref());
return;
}
case Proxy.CALL_String: {
String result = this.String();
out.writeString(result);
return;
}
case Proxy.CALL_V: {
long result = this.V();
out.writeInt(result);
return;
}
case Proxy.CALL_VE: {
try {
long result = this.VE();
out.writeInt(result);
out.writeString(null);
} catch (Exception e) {
long result = 0;
out.writeInt(result);
out.writeString(e.getMessage());
}
return;
}
default:
throw new RuntimeException("unknown code: "+ code);
}
}
}
static final class Proxy implements I {
static final String DESCRIPTOR = Stub.DESCRIPTOR;
private go.Seq.Ref ref;
Proxy(go.Seq.Ref ref) { this.ref = ref; }
public go.Seq.Ref ref() { return ref; }
public void call(int code, go.Seq in, go.Seq out) {
throw new RuntimeException("cycle: cannot call proxy");
}
public void E() throws Exception {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
_in.writeRef(ref);
Seq.send(DESCRIPTOR, CALL_E, _in, _out);
String _err = _out.readString();
if (_err != null) {
throw new Exception(_err);
}
}
public void F() {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
_in.writeRef(ref);
Seq.send(DESCRIPTOR, CALL_F, _in, _out);
}
public I I() {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
I _result;
_in.writeRef(ref);
Seq.send(DESCRIPTOR, CALL_I, _in, _out);
_result = new I.Proxy(_out.readRef());
return _result;
}
public S S() {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
S _result;
_in.writeRef(ref);
Seq.send(DESCRIPTOR, CALL_S, _in, _out);
_result = new S(_out.readRef());
return _result;
}
public String String() {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
String _result;
_in.writeRef(ref);
Seq.send(DESCRIPTOR, CALL_String, _in, _out);
_result = _out.readString();
return _result;
}
public long V() {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
long _result;
_in.writeRef(ref);
Seq.send(DESCRIPTOR, CALL_V, _in, _out);
_result = _out.readInt();
return _result;
}
public long VE() throws Exception {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
long _result;
_in.writeRef(ref);
Seq.send(DESCRIPTOR, CALL_VE, _in, _out);
_result = _out.readInt();
String _err = _out.readString();
if (_err != null) {
throw new Exception(_err);
}
return _result;
}
static final int CALL_E = 0x10a;
static final int CALL_F = 0x20a;
static final int CALL_I = 0x30a;
static final int CALL_S = 0x40a;
static final int CALL_String = 0x50a;
static final int CALL_V = 0x60a;
static final int CALL_VE = 0x70a;
}
}
public static void Keep(I i) {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
_in.writeRef(i.ref());
Seq.send(DESCRIPTOR, CALL_Keep, _in, _out);
}
public static S New() {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
S _result;
Seq.send(DESCRIPTOR, CALL_New, _in, _out);
_result = new S(_out.readRef());
return _result;
}
public static long NumSCollected() {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
long _result;
Seq.send(DESCRIPTOR, CALL_NumSCollected, _in, _out);
_result = _out.readInt();
return _result;
}
public static final class S implements go.Seq.Object {
private static final String DESCRIPTOR = "go.testpkg.S";
private static final int CALL_F = 0x00c;
private static final int CALL_String = 0x10c;
private go.Seq.Ref ref;
private S(go.Seq.Ref ref) { this.ref = ref; }
public go.Seq.Ref ref() { return ref; }
public void call(int code, go.Seq in, go.Seq out) {
throw new RuntimeException("internal error: cycle: cannot call concrete proxy");
}
public void F() {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
_in.writeRef(ref);
Seq.send(DESCRIPTOR, CALL_F, _in, _out);
}
public String String() {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
String _result;
_in.writeRef(ref);
Seq.send(DESCRIPTOR, CALL_String, _in, _out);
_result = _out.readString();
return _result;
}
@Override public boolean equals(Object o) {
if (o == null || !(o instanceof S)) {
return false;
}
S that = (S)o;
return true;
}
@Override public int hashCode() {
return java.util.Arrays.hashCode(new Object[] {});
}
@Override public String toString() {
StringBuilder b = new StringBuilder();
b.append("S").append("{");
return b.append("}").toString();
}
}
public static String StrDup(String s) {
go.Seq _in = new go.Seq();
go.Seq _out = new go.Seq();
String _result;
_in.writeString(s);
Seq.send(DESCRIPTOR, CALL_StrDup, _in, _out);
_result = _out.readString();
return _result;
}
private static final int CALL_Add = 1;
private static final int CALL_AppendToString = 2;
private static final int CALL_BytesAppend = 3;
private static final int CALL_CallE = 4;
private static final int CALL_CallF = 5;
private static final int CALL_CallI = 6;
private static final int CALL_CallS = 7;
private static final int CALL_CallV = 8;
private static final int CALL_CallVE = 9;
private static final int CALL_Err = 10;
private static final int CALL_GC = 11;
private static final int CALL_Keep = 12;
private static final int CALL_New = 13;
private static final int CALL_NumSCollected = 14;
private static final int CALL_StrDup = 15;
private static final String DESCRIPTOR = "testpkg";
}

View File

@ -1,332 +0,0 @@
// Package go_testpkg is an autogenerated binder stub for package testpkg.
// gobind -lang=go golang.org/x/mobile/bind/java/testpkg
//
// File is generated by gobind. Do not edit.
package go_testpkg
import (
"golang.org/x/mobile/bind/java/testpkg"
"golang.org/x/mobile/bind/seq"
)
func proxy_Add(out, in *seq.Buffer) {
param_x := in.ReadInt()
param_y := in.ReadInt()
res := testpkg.Add(param_x, param_y)
out.WriteInt(res)
}
func proxy_AppendToString(out, in *seq.Buffer) {
param_str := in.ReadString()
param_someBytes := in.ReadByteArray()
res := testpkg.AppendToString(param_str, param_someBytes)
out.WriteByteArray(res)
}
func proxy_BytesAppend(out, in *seq.Buffer) {
param_a := in.ReadByteArray()
param_b := in.ReadByteArray()
res := testpkg.BytesAppend(param_a, param_b)
out.WriteByteArray(res)
}
func proxy_CallE(out, in *seq.Buffer) {
var param_i testpkg.I
param_i_ref := in.ReadRef()
if param_i_ref.Num < 0 { // go object
param_i = param_i_ref.Get().(testpkg.I)
} else { // foreign object
param_i = (*proxyI)(param_i_ref)
}
err := testpkg.CallE(param_i)
if err == nil {
out.WriteString("")
} else {
out.WriteString(err.Error())
}
}
func proxy_CallF(out, in *seq.Buffer) {
var param_i testpkg.I
param_i_ref := in.ReadRef()
if param_i_ref.Num < 0 { // go object
param_i = param_i_ref.Get().(testpkg.I)
} else { // foreign object
param_i = (*proxyI)(param_i_ref)
}
testpkg.CallF(param_i)
}
func proxy_CallI(out, in *seq.Buffer) {
var param_i testpkg.I
param_i_ref := in.ReadRef()
if param_i_ref.Num < 0 { // go object
param_i = param_i_ref.Get().(testpkg.I)
} else { // foreign object
param_i = (*proxyI)(param_i_ref)
}
res := testpkg.CallI(param_i)
out.WriteGoRef(res)
}
func proxy_CallS(out, in *seq.Buffer) {
var param_i testpkg.I
param_i_ref := in.ReadRef()
if param_i_ref.Num < 0 { // go object
param_i = param_i_ref.Get().(testpkg.I)
} else { // foreign object
param_i = (*proxyI)(param_i_ref)
}
res := testpkg.CallS(param_i)
out.WriteGoRef(res)
}
func proxy_CallV(out, in *seq.Buffer) {
var param_i testpkg.I
param_i_ref := in.ReadRef()
if param_i_ref.Num < 0 { // go object
param_i = param_i_ref.Get().(testpkg.I)
} else { // foreign object
param_i = (*proxyI)(param_i_ref)
}
res := testpkg.CallV(param_i)
out.WriteInt(res)
}
func proxy_CallVE(out, in *seq.Buffer) {
var param_i testpkg.I
param_i_ref := in.ReadRef()
if param_i_ref.Num < 0 { // go object
param_i = param_i_ref.Get().(testpkg.I)
} else { // foreign object
param_i = (*proxyI)(param_i_ref)
}
res, err := testpkg.CallVE(param_i)
out.WriteInt(res)
if err == nil {
out.WriteString("")
} else {
out.WriteString(err.Error())
}
}
func proxy_Err(out, in *seq.Buffer) {
param_s := in.ReadString()
err := testpkg.Err(param_s)
if err == nil {
out.WriteString("")
} else {
out.WriteString(err.Error())
}
}
func proxy_GC(out, in *seq.Buffer) {
testpkg.GC()
}
const (
proxyIDescriptor = "go.testpkg.I"
proxyIECode = 0x10a
proxyIFCode = 0x20a
proxyIICode = 0x30a
proxyISCode = 0x40a
proxyIStringCode = 0x50a
proxyIVCode = 0x60a
proxyIVECode = 0x70a
)
func proxyIE(out, in *seq.Buffer) {
ref := in.ReadRef()
v := ref.Get().(testpkg.I)
err := v.E()
if err == nil {
out.WriteString("")
} else {
out.WriteString(err.Error())
}
}
func proxyIF(out, in *seq.Buffer) {
ref := in.ReadRef()
v := ref.Get().(testpkg.I)
v.F()
}
func proxyII(out, in *seq.Buffer) {
ref := in.ReadRef()
v := ref.Get().(testpkg.I)
res := v.I()
out.WriteGoRef(res)
}
func proxyIS(out, in *seq.Buffer) {
ref := in.ReadRef()
v := ref.Get().(testpkg.I)
res := v.S()
out.WriteGoRef(res)
}
func proxyIString(out, in *seq.Buffer) {
ref := in.ReadRef()
v := ref.Get().(testpkg.I)
res := v.String()
out.WriteString(res)
}
func proxyIV(out, in *seq.Buffer) {
ref := in.ReadRef()
v := ref.Get().(testpkg.I)
res := v.V()
out.WriteInt(res)
}
func proxyIVE(out, in *seq.Buffer) {
ref := in.ReadRef()
v := ref.Get().(testpkg.I)
res, err := v.VE()
out.WriteInt(res)
if err == nil {
out.WriteString("")
} else {
out.WriteString(err.Error())
}
}
func init() {
seq.Register(proxyIDescriptor, proxyIECode, proxyIE)
seq.Register(proxyIDescriptor, proxyIFCode, proxyIF)
seq.Register(proxyIDescriptor, proxyIICode, proxyII)
seq.Register(proxyIDescriptor, proxyISCode, proxyIS)
seq.Register(proxyIDescriptor, proxyIStringCode, proxyIString)
seq.Register(proxyIDescriptor, proxyIVCode, proxyIV)
seq.Register(proxyIDescriptor, proxyIVECode, proxyIVE)
}
type proxyI seq.Ref
func (p *proxyI) E() error {
in := new(seq.Buffer)
out := seq.Transact((*seq.Ref)(p), proxyIECode, in)
res_0 := out.ReadError()
return res_0
}
func (p *proxyI) F() {
in := new(seq.Buffer)
seq.Transact((*seq.Ref)(p), proxyIFCode, in)
}
func (p *proxyI) I() testpkg.I {
in := new(seq.Buffer)
out := seq.Transact((*seq.Ref)(p), proxyIICode, in)
var res_0 testpkg.I
res_0_ref := out.ReadRef()
if res_0_ref.Num < 0 { // go object
res_0 = res_0_ref.Get().(testpkg.I)
} else { // foreign object
res_0 = (*proxyI)(res_0_ref)
}
return res_0
}
func (p *proxyI) S() *testpkg.S {
in := new(seq.Buffer)
out := seq.Transact((*seq.Ref)(p), proxyISCode, in)
// Must be a Go object
res_0_ref := out.ReadRef()
res_0 := res_0_ref.Get().(*testpkg.S)
return res_0
}
func (p *proxyI) String() string {
in := new(seq.Buffer)
out := seq.Transact((*seq.Ref)(p), proxyIStringCode, in)
res_0 := out.ReadString()
return res_0
}
func (p *proxyI) V() int {
in := new(seq.Buffer)
out := seq.Transact((*seq.Ref)(p), proxyIVCode, in)
res_0 := out.ReadInt()
return res_0
}
func (p *proxyI) VE() (int, error) {
in := new(seq.Buffer)
out := seq.Transact((*seq.Ref)(p), proxyIVECode, in)
res_0 := out.ReadInt()
res_1 := out.ReadError()
return res_0, res_1
}
func proxy_Keep(out, in *seq.Buffer) {
var param_i testpkg.I
param_i_ref := in.ReadRef()
if param_i_ref.Num < 0 { // go object
param_i = param_i_ref.Get().(testpkg.I)
} else { // foreign object
param_i = (*proxyI)(param_i_ref)
}
testpkg.Keep(param_i)
}
func proxy_New(out, in *seq.Buffer) {
res := testpkg.New()
out.WriteGoRef(res)
}
func proxy_NumSCollected(out, in *seq.Buffer) {
res := testpkg.NumSCollected()
out.WriteInt(res)
}
const (
proxySDescriptor = "go.testpkg.S"
proxySFCode = 0x00c
proxySStringCode = 0x10c
)
type proxyS seq.Ref
func proxySF(out, in *seq.Buffer) {
ref := in.ReadRef()
v := ref.Get().(*testpkg.S)
v.F()
}
func proxySString(out, in *seq.Buffer) {
ref := in.ReadRef()
v := ref.Get().(*testpkg.S)
res := v.String()
out.WriteString(res)
}
func init() {
seq.Register(proxySDescriptor, proxySFCode, proxySF)
seq.Register(proxySDescriptor, proxySStringCode, proxySString)
}
func proxy_StrDup(out, in *seq.Buffer) {
param_s := in.ReadString()
res := testpkg.StrDup(param_s)
out.WriteString(res)
}
func init() {
seq.Register("testpkg", 1, proxy_Add)
seq.Register("testpkg", 2, proxy_AppendToString)
seq.Register("testpkg", 3, proxy_BytesAppend)
seq.Register("testpkg", 4, proxy_CallE)
seq.Register("testpkg", 5, proxy_CallF)
seq.Register("testpkg", 6, proxy_CallI)
seq.Register("testpkg", 7, proxy_CallS)
seq.Register("testpkg", 8, proxy_CallV)
seq.Register("testpkg", 9, proxy_CallVE)
seq.Register("testpkg", 10, proxy_Err)
seq.Register("testpkg", 11, proxy_GC)
seq.Register("testpkg", 12, proxy_Keep)
seq.Register("testpkg", 13, proxy_New)
seq.Register("testpkg", 14, proxy_NumSCollected)
seq.Register("testpkg", 15, proxy_StrDup)
}

View File

@ -1,4 +1,5 @@
// Package testpkg contains bound functions for testing the cgo-JNI interface.
// This is used in tests of golang.org/x/mobile/bind/java.
package testpkg
//go:generate gobind -lang=go -outdir=go_testpkg .