2
0
mirror of synced 2025-02-23 14:58:12 +00:00
mobile/bind/testdata/issue12403.java.c.golden
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

76 lines
3.0 KiB
Plaintext

// Code generated by gobind. DO NOT EDIT.
// JNI functions for the Go <=> Java bridge.
//
// autogenerated by gobind -lang=java issue12403
#include <android/log.h>
#include <stdint.h>
#include "seq.h"
#include "_cgo_export.h"
#include "issue12403.h"
jclass proxy_class_issue12403_Parsable;
jmethodID proxy_class_issue12403_Parsable_cons;
static jmethodID mid_Parsable_FromJSON;
static jmethodID mid_Parsable_ToJSON;
JNIEXPORT void JNICALL
Java_issue12403_Issue12403__1init(JNIEnv *env, jclass _unused) {
jclass clazz;
clazz = (*env)->FindClass(env, "issue12403/Issue12403$proxyParsable");
proxy_class_issue12403_Parsable = (*env)->NewGlobalRef(env, clazz);
proxy_class_issue12403_Parsable_cons = (*env)->GetMethodID(env, clazz, "<init>", "(I)V");
clazz = (*env)->FindClass(env, "issue12403/Parsable");
mid_Parsable_FromJSON = (*env)->GetMethodID(env, clazz, "fromJSON", "(Ljava/lang/String;)Ljava/lang/String;");
mid_Parsable_ToJSON = (*env)->GetMethodID(env, clazz, "toJSON", "()Ljava/lang/String;");
}
JNIEXPORT jstring JNICALL
Java_issue12403_Issue12403_00024proxyParsable_fromJSON(JNIEnv* env, jobject __this__, jstring jstr) {
int32_t o = go_seq_to_refnum_go(env, __this__);
nstring _jstr = go_seq_from_java_string(env, jstr);
nstring r0 = proxyissue12403_Parsable_FromJSON(o, _jstr);
jstring _r0 = go_seq_to_java_string(env, r0);
return _r0;
}
nstring cproxyissue12403_Parsable_FromJSON(int32_t refnum, nstring jstr) {
JNIEnv *env = go_seq_push_local_frame(1);
jobject o = go_seq_from_refnum(env, refnum, proxy_class_issue12403_Parsable, proxy_class_issue12403_Parsable_cons);
jstring _jstr = go_seq_to_java_string(env, jstr);
jstring res = (*env)->CallObjectMethod(env, o, mid_Parsable_FromJSON, _jstr);
nstring _res = go_seq_from_java_string(env, res);
go_seq_pop_local_frame(env);
return _res;
}
JNIEXPORT jstring JNICALL
Java_issue12403_Issue12403_00024proxyParsable_toJSON(JNIEnv* env, jobject __this__) {
int32_t o = go_seq_to_refnum_go(env, __this__);
struct proxyissue12403_Parsable_ToJSON_return res = proxyissue12403_Parsable_ToJSON(o);
jstring _r0 = go_seq_to_java_string(env, res.r0);
jobject _r1 = go_seq_from_refnum(env, res.r1, proxy_class__error, proxy_class__error_cons);
go_seq_maybe_throw_exception(env, _r1);
return _r0;
}
struct cproxyissue12403_Parsable_ToJSON_return cproxyissue12403_Parsable_ToJSON(int32_t refnum) {
JNIEnv *env = go_seq_push_local_frame(0);
jobject o = go_seq_from_refnum(env, refnum, proxy_class_issue12403_Parsable, proxy_class_issue12403_Parsable_cons);
jstring res = (*env)->CallObjectMethod(env, o, mid_Parsable_ToJSON);
jobject exc = go_seq_get_exception(env);
int32_t _exc = go_seq_to_refnum(env, exc);
if (exc != NULL) {
res = NULL;
}
nstring _res = go_seq_from_java_string(env, res);
cproxyissue12403_Parsable_ToJSON_return sres = {
_res, _exc
};
go_seq_pop_local_frame(env);
return sres;
}