Files
Hana Kim 6d0d39b2ca bind: format generated go code before comparing with golden files
bind_test.go compares the generated Go files against golden files
checked in the repository. The bind package formats some of the
generated Go files, so any changes in the go formatter can break
the tests.

This change makes the test more robust by applying formatting based
on the currently used go version. Since a golden file often
includes multiple go files generated by the bind, the `gofmt`
function splits the golden file using the gobindPreamble marker
and then run format.Source for each chunk. In order to ease the
golden file splitting, this CL also moves the gobindPreamble
to the beginning of each generated file consistently.

It turned out bind omits formatting for some go files (generated
for reverse binding). That needs to be fixed but it is a much
bigger fix. Thus, in this CL, we apply the formatting on the
bind's output as well.

This CL also updates the gobindPreamble to follow the style guide
for generated code. https://golang.org/s/generatedcode

Fixes golang/go#34619

Change-Id: Ia2957693154face2848e051ebbb2373e95d79593
Reviewed-on: https://go-review.googlesource.com/c/mobile/+/198322
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-10-02 17:59:09 +00:00

408 lines
9.2 KiB
Plaintext

// Code generated by gobind. DO NOT EDIT.
package Float
import "Java"
const _ = Java.Dummy
const (
MAX_VALUE = 3.4028235E38
MIN_NORMAL = 1.17549435E-38
MIN_VALUE = 1.4E-45
MAX_EXPONENT = 127
MIN_EXPONENT = -126
SIZE = 32
BYTES = 4
)
var (
// Cast takes a proxy for a Java object and converts it to a java.lang.Float proxy.
// Cast panics if the argument is not a proxy or if the underlying object does
// not extend or implement java.lang.Float.
Cast func(v interface{}) Java.Java_lang_Float
)
// Code generated by gobind. DO NOT EDIT.
package lang
import "Java"
const _ = Java.Dummy
type Float Java.Java_lang_Float
type Long Java.Java_lang_Long
type Object Java.Java_lang_Object
type Runnable Java.Java_lang_Runnable
// Code generated by gobind. DO NOT EDIT.
package Long
import "Java"
const _ = Java.Dummy
const (
MIN_VALUE = -9223372036854775808
MAX_VALUE = 9223372036854775807
SIZE = 64
BYTES = 8
)
var (
// Cast takes a proxy for a Java object and converts it to a java.lang.Long proxy.
// Cast panics if the argument is not a proxy or if the underlying object does
// not extend or implement java.lang.Long.
Cast func(v interface{}) Java.Java_lang_Long
)
// Code generated by gobind. DO NOT EDIT.
package Object
import "Java"
const _ = Java.Dummy
const ()
var (
// Cast takes a proxy for a Java object and converts it to a java.lang.Object proxy.
// Cast panics if the argument is not a proxy or if the underlying object does
// not extend or implement java.lang.Object.
Cast func(v interface{}) Java.Java_lang_Object
)
// Code generated by gobind. DO NOT EDIT.
package Runnable
import "Java"
const _ = Java.Dummy
const ()
var (
// Cast takes a proxy for a Java object and converts it to a java.lang.Runnable proxy.
// Cast panics if the argument is not a proxy or if the underlying object does
// not extend or implement java.lang.Runnable.
Cast func(v interface{}) Java.Java_lang_Runnable
)
// Code generated by gobind. DO NOT EDIT.
package Java
// Used to silence this package not used errors
const Dummy = 0
type Java_lang_Float interface {
ToString() string
}
type Java_lang_Long interface {
ToString() string
}
type Java_lang_Object interface {
ToString() string
}
type Java_lang_Runnable interface {
}
// Code generated by gobind. DO NOT EDIT.
package main
/*
#include <stdlib.h> // for free()
#include <jni.h>
#include "seq.h"
#include "classes.h"
*/
import "C"
import (
"Java"
_seq "golang.org/x/mobile/bind/seq"
)
import "Java/java/lang/Float"
import "Java/java/lang/Long"
import "Java/java/lang/Object"
import "Java/java/lang/Runnable"
import "unsafe"
import "reflect"
import "fmt"
type proxy interface{ Bind_proxy_refnum__() int32 }
// Suppress unused package error
var _ = _seq.FromRefNum
const _ = Java.Dummy
//export initClasses
func initClasses() {
C.init_proxies()
init_java_lang_Float()
init_java_lang_Long()
init_java_lang_Object()
init_java_lang_Runnable()
}
var class_java_lang_Float C.jclass
func init_java_lang_Float() {
cls := C.CString("java/lang/Float")
clazz := C.go_seq_find_class(cls)
C.free(unsafe.Pointer(cls))
if uintptr(clazz) == 0 {
return
}
class_java_lang_Float = clazz
Float.Cast = func(v interface{}) Java.Java_lang_Float {
t := reflect.TypeOf((*proxy_class_java_lang_Float)(nil))
cv := reflect.ValueOf(v).Convert(t).Interface().(*proxy_class_java_lang_Float)
ref := C.jint(_seq.ToRefNum(cv))
if C.go_seq_isinstanceof(ref, class_java_lang_Float) != 1 {
panic(fmt.Errorf("%T is not an instance of %s", v, "java.lang.Float"))
}
return cv
}
}
type proxy_class_java_lang_Float _seq.Ref
func (p *proxy_class_java_lang_Float) Bind_proxy_refnum__() int32 {
return (*_seq.Ref)(p).Bind_IncNum()
}
func (p *proxy_class_java_lang_Float) ToString() string {
res := C.cproxy_java_lang_Float_toString(C.jint(p.Bind_proxy_refnum__()))
_res := decodeString(res.res)
var _exc error
_exc_ref := _seq.FromRefNum(int32(res.exc))
if _exc_ref != nil {
if res.exc < 0 { // go object
_exc = _exc_ref.Get().(error)
} else { // foreign object
_exc = (*proxy_error)(_exc_ref)
}
}
if _exc != nil {
panic(_exc)
}
return _res
}
var class_java_lang_Long C.jclass
func init_java_lang_Long() {
cls := C.CString("java/lang/Long")
clazz := C.go_seq_find_class(cls)
C.free(unsafe.Pointer(cls))
if uintptr(clazz) == 0 {
return
}
class_java_lang_Long = clazz
Long.Cast = func(v interface{}) Java.Java_lang_Long {
t := reflect.TypeOf((*proxy_class_java_lang_Long)(nil))
cv := reflect.ValueOf(v).Convert(t).Interface().(*proxy_class_java_lang_Long)
ref := C.jint(_seq.ToRefNum(cv))
if C.go_seq_isinstanceof(ref, class_java_lang_Long) != 1 {
panic(fmt.Errorf("%T is not an instance of %s", v, "java.lang.Long"))
}
return cv
}
}
type proxy_class_java_lang_Long _seq.Ref
func (p *proxy_class_java_lang_Long) Bind_proxy_refnum__() int32 {
return (*_seq.Ref)(p).Bind_IncNum()
}
func (p *proxy_class_java_lang_Long) ToString() string {
res := C.cproxy_java_lang_Long_toString(C.jint(p.Bind_proxy_refnum__()))
_res := decodeString(res.res)
var _exc error
_exc_ref := _seq.FromRefNum(int32(res.exc))
if _exc_ref != nil {
if res.exc < 0 { // go object
_exc = _exc_ref.Get().(error)
} else { // foreign object
_exc = (*proxy_error)(_exc_ref)
}
}
if _exc != nil {
panic(_exc)
}
return _res
}
var class_java_lang_Object C.jclass
func init_java_lang_Object() {
cls := C.CString("java/lang/Object")
clazz := C.go_seq_find_class(cls)
C.free(unsafe.Pointer(cls))
if uintptr(clazz) == 0 {
return
}
class_java_lang_Object = clazz
Object.Cast = func(v interface{}) Java.Java_lang_Object {
t := reflect.TypeOf((*proxy_class_java_lang_Object)(nil))
cv := reflect.ValueOf(v).Convert(t).Interface().(*proxy_class_java_lang_Object)
ref := C.jint(_seq.ToRefNum(cv))
if C.go_seq_isinstanceof(ref, class_java_lang_Object) != 1 {
panic(fmt.Errorf("%T is not an instance of %s", v, "java.lang.Object"))
}
return cv
}
}
type proxy_class_java_lang_Object _seq.Ref
func (p *proxy_class_java_lang_Object) Bind_proxy_refnum__() int32 {
return (*_seq.Ref)(p).Bind_IncNum()
}
func (p *proxy_class_java_lang_Object) ToString() string {
res := C.cproxy_java_lang_Object_toString(C.jint(p.Bind_proxy_refnum__()))
_res := decodeString(res.res)
var _exc error
_exc_ref := _seq.FromRefNum(int32(res.exc))
if _exc_ref != nil {
if res.exc < 0 { // go object
_exc = _exc_ref.Get().(error)
} else { // foreign object
_exc = (*proxy_error)(_exc_ref)
}
}
if _exc != nil {
panic(_exc)
}
return _res
}
var class_java_lang_Runnable C.jclass
func init_java_lang_Runnable() {
cls := C.CString("java/lang/Runnable")
clazz := C.go_seq_find_class(cls)
C.free(unsafe.Pointer(cls))
if uintptr(clazz) == 0 {
return
}
class_java_lang_Runnable = clazz
Runnable.Cast = func(v interface{}) Java.Java_lang_Runnable {
t := reflect.TypeOf((*proxy_class_java_lang_Runnable)(nil))
cv := reflect.ValueOf(v).Convert(t).Interface().(*proxy_class_java_lang_Runnable)
ref := C.jint(_seq.ToRefNum(cv))
if C.go_seq_isinstanceof(ref, class_java_lang_Runnable) != 1 {
panic(fmt.Errorf("%T is not an instance of %s", v, "java.lang.Runnable"))
}
return cv
}
}
type proxy_class_java_lang_Runnable _seq.Ref
func (p *proxy_class_java_lang_Runnable) Bind_proxy_refnum__() int32 {
return (*_seq.Ref)(p).Bind_IncNum()
}
// Code generated by gobind. DO NOT EDIT.
// Package main is an autogenerated binder stub for package java.
//
// autogenerated by gobind -lang=go java
package main
/*
#include <stdlib.h>
#include <stdint.h>
#include "seq.h"
#include "java.h"
*/
import "C"
import (
_seq "golang.org/x/mobile/bind/seq"
"java"
)
// suppress the error if seq ends up unused
var _ = _seq.FromRefNum
//export proxyjava_F_ToString
func proxyjava_F_ToString(refnum C.int32_t) C.nstring {
ref := _seq.FromRefNum(int32(refnum))
v := ref.Get().(java.F)
res_0 := v.ToString()
_res_0 := encodeString(res_0)
return _res_0
}
type proxyjava_F _seq.Ref
func (p *proxyjava_F) Bind_proxy_refnum__() int32 {
return (*_seq.Ref)(p).Bind_IncNum()
}
func (p *proxyjava_F) ToString() string {
res := C.cproxyjava_F_ToString(C.int32_t(p.Bind_proxy_refnum__()))
_res := decodeString(res)
return _res
}
//export proxyjava_L_ToString
func proxyjava_L_ToString(refnum C.int32_t) C.nstring {
ref := _seq.FromRefNum(int32(refnum))
v := ref.Get().(java.L)
res_0 := v.ToString()
_res_0 := encodeString(res_0)
return _res_0
}
type proxyjava_L _seq.Ref
func (p *proxyjava_L) Bind_proxy_refnum__() int32 {
return (*_seq.Ref)(p).Bind_IncNum()
}
func (p *proxyjava_L) ToString() string {
res := C.cproxyjava_L_ToString(C.int32_t(p.Bind_proxy_refnum__()))
_res := decodeString(res)
return _res
}
//export proxyjava_O_ToString
func proxyjava_O_ToString(refnum C.int32_t) C.nstring {
ref := _seq.FromRefNum(int32(refnum))
v := ref.Get().(java.O)
res_0 := v.ToString()
_res_0 := encodeString(res_0)
return _res_0
}
type proxyjava_O _seq.Ref
func (p *proxyjava_O) Bind_proxy_refnum__() int32 {
return (*_seq.Ref)(p).Bind_IncNum()
}
func (p *proxyjava_O) ToString() string {
res := C.cproxyjava_O_ToString(C.int32_t(p.Bind_proxy_refnum__()))
_res := decodeString(res)
return _res
}
type proxyjava_R _seq.Ref
func (p *proxyjava_R) Bind_proxy_refnum__() int32 {
return (*_seq.Ref)(p).Bind_IncNum()
}