aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Cottrell <iancottrell@google.com>2015-08-04 14:46:29 +0000
committerandroid-build-merger <android-build-merger@google.com>2015-08-04 14:46:29 +0000
commit269101c4a73cff699fae179a5f4d9615fce32d13 (patch)
treed79f454912bbba8f75d7ffbebde635c9c04bb8ea
parenta2a12ceb46cae934815bf94301e7d628d87c41d6 (diff)
parent667ca3d5bb4d08d1484222cfdb2c79173b0fd4ed (diff)
downloadgpu-master.tar.gz
Merge "Add sections to java client generation" into studio-1.4-dev automerge: 4640110HEADmastermain
automerge: 667ca3d * commit '667ca3d5bb4d08d1484222cfdb2c79173b0fd4ed': Add sections to java client generation
-rw-r--r--tools/codergen/template/embed.go88
-rw-r--r--tools/codergen/template/java_client.tmpl88
2 files changed, 100 insertions, 76 deletions
diff --git a/tools/codergen/template/embed.go b/tools/codergen/template/embed.go
index 7978191a7..9545ef696 100644
--- a/tools/codergen/template/embed.go
+++ b/tools/codergen/template/embed.go
@@ -1111,6 +1111,14 @@ const java_client_tmpl = `{{/*
{{end}}
{{end}}
+{{define "Java.ClientBody"}}
+ ¶{{/*Newline after section marker*/}}
+ {{range .Service.Methods}}
+ {{template "Java.Method" .}} throws IOException, RpcException;¶
+ {{end}}
+ //{{/*Comment the following section marker*/}}
+{{end}}
+
{{define "Java.Client"}}
§{{$.Copyright}}§¶
package {{.JavaPackage}};¶
@@ -1122,12 +1130,50 @@ const java_client_tmpl = `{{/*
import java.util.concurrent.Future;¶
public interface {{.Service.Name}}Client {Ȧ
- {{range .Service.Methods}}
- {{template "Java.Method" .}} throws IOException, RpcException;¶
- {{end}}
+ //{{Section "Java.ClientBody"}}¶
«}¶
{{end}}
+{{define "Java.ClientImplBody"}}
+ ¶{{/*Newline after section marker*/}}
+ private final Broadcaster myBroadcaster;¶
+ private final ExecutorService myExecutorService;¶
+
+ public {{.Service.Name}}ClientImpl(ExecutorService executorService, InputStream in, OutputStream out, int mtu) {Ȧ
+ myExecutorService = executorService;¶
+ myBroadcaster = new Broadcaster(in, out, mtu, myExecutorService);¶
+ «}¶
+ {{range .Service.Methods}}
+ @Override¶
+ public {{template "Java.Method" .}} {Ȧ
+ return myExecutorService.submit(new {{.Name}}Callable({{template "Java.Arguments" .}}));¶
+ «}¶
+ {{end}}
+ ¶
+ {{range .Service.Methods}}
+ private class {{.Name}}Callable implements {{Call "Java.Callable" .Result.Type}} {Ȧ
+ private final {{File.ClassName .Call}} myCall;¶
+ ¶
+ private {{.Name}}Callable({{template "Java.Parameters" .}}) {Ȧ
+ myCall = new {{File.ClassName .Call}}();¶
+ {{range .Call.Params}}
+ myCall.{{File.Setter .Name}}({{.Name}});¶
+ {{end}}
+ «}¶
+ @Override¶
+ public {{Call "Java.Value" .Result.Type}} call() throws Exception {Ȧ
+ {{if .Result.Type}}{{File.ClassName .Result}} result = ({{File.ClassName .Result}})myBroadcaster.Send(myCall);¶
+ return result.myValue;¶
+ {{else}}
+ myBroadcaster.Send(myCall);¶
+ return null;¶
+ {{end}}
+ «}¶
+ «}¶
+ {{end}}
+ //{{/*Comment the following section marker*/}}
+{{end}}
+
{{define "Java.ClientImpl"}}
§{{$.Copyright}}§
package {{.JavaPackage}};¶
@@ -1142,41 +1188,7 @@ const java_client_tmpl = `{{/*
import java.util.concurrent.Future;
public class {{.Service.Name}}ClientImpl implements {{.Service.Name}}Client {Ȧ
- private final Broadcaster myBroadcaster;¶
- private final ExecutorService myExecutorService;¶
-
- public {{.Service.Name}}ClientImpl(ExecutorService executorService, InputStream in, OutputStream out, int mtu) {Ȧ
- myExecutorService = executorService;¶
- myBroadcaster = new Broadcaster(in, out, mtu, myExecutorService);¶
- «}¶
- {{range .Service.Methods}}
- @Override¶
- public {{template "Java.Method" .}} {Ȧ
- return myExecutorService.submit(new {{.Name}}Callable({{template "Java.Arguments" .}}));¶
- «}¶
- {{end}}
- ¶
- {{range .Service.Methods}}
- private class {{.Name}}Callable implements {{Call "Java.Callable" .Result.Type}} {Ȧ
- private final {{File.ClassName .Call}} myCall;¶
- ¶
- private {{.Name}}Callable({{template "Java.Parameters" .}}) {Ȧ
- myCall = new {{File.ClassName .Call}}();¶
- {{range .Call.Params}}
- myCall.{{File.Setter .Name}}({{.Name}});¶
- {{end}}
- «}¶
- @Override¶
- public {{Call "Java.Value" .Result.Type}} call() throws Exception {Ȧ
- {{if .Result.Type}}{{File.ClassName .Result}} result = ({{File.ClassName .Result}})myBroadcaster.Send(myCall);¶
- return result.myValue;¶
- {{else}}
- myBroadcaster.Send(myCall);¶
- return null;¶
- {{end}}
- «}¶
- «}¶
- {{end}}
+ //{{Section "Java.ClientImplBody"}}¶
«}¶
{{end}}
`
diff --git a/tools/codergen/template/java_client.tmpl b/tools/codergen/template/java_client.tmpl
index 2927f8147..9ccef0feb 100644
--- a/tools/codergen/template/java_client.tmpl
+++ b/tools/codergen/template/java_client.tmpl
@@ -34,6 +34,14 @@
{{end}}
{{end}}
+{{define "Java.ClientBody"}}
+ ¶{{/*Newline after section marker*/}}
+ {{range .Service.Methods}}
+ {{template "Java.Method" .}} throws IOException, RpcException;¶
+ {{end}}
+ //{{/*Comment the following section marker*/}}
+{{end}}
+
{{define "Java.Client"}}
§{{$.Copyright}}§¶
package {{.JavaPackage}};¶
@@ -45,12 +53,50 @@
import java.util.concurrent.Future;¶
public interface {{.Service.Name}}Client {Ȧ
- {{range .Service.Methods}}
- {{template "Java.Method" .}} throws IOException, RpcException;¶
- {{end}}
+ //{{Section "Java.ClientBody"}}¶
«}¶
{{end}}
+{{define "Java.ClientImplBody"}}
+ ¶{{/*Newline after section marker*/}}
+ private final Broadcaster myBroadcaster;¶
+ private final ExecutorService myExecutorService;¶
+
+ public {{.Service.Name}}ClientImpl(ExecutorService executorService, InputStream in, OutputStream out, int mtu) {Ȧ
+ myExecutorService = executorService;¶
+ myBroadcaster = new Broadcaster(in, out, mtu, myExecutorService);¶
+ «}¶
+ {{range .Service.Methods}}
+ @Override¶
+ public {{template "Java.Method" .}} {Ȧ
+ return myExecutorService.submit(new {{.Name}}Callable({{template "Java.Arguments" .}}));¶
+ «}¶
+ {{end}}
+ ¶
+ {{range .Service.Methods}}
+ private class {{.Name}}Callable implements {{Call "Java.Callable" .Result.Type}} {Ȧ
+ private final {{File.ClassName .Call}} myCall;¶
+ ¶
+ private {{.Name}}Callable({{template "Java.Parameters" .}}) {Ȧ
+ myCall = new {{File.ClassName .Call}}();¶
+ {{range .Call.Params}}
+ myCall.{{File.Setter .Name}}({{.Name}});¶
+ {{end}}
+ «}¶
+ @Override¶
+ public {{Call "Java.Value" .Result.Type}} call() throws Exception {Ȧ
+ {{if .Result.Type}}{{File.ClassName .Result}} result = ({{File.ClassName .Result}})myBroadcaster.Send(myCall);¶
+ return result.myValue;¶
+ {{else}}
+ myBroadcaster.Send(myCall);¶
+ return null;¶
+ {{end}}
+ «}¶
+ «}¶
+ {{end}}
+ //{{/*Comment the following section marker*/}}
+{{end}}
+
{{define "Java.ClientImpl"}}
§{{$.Copyright}}§
package {{.JavaPackage}};¶
@@ -65,40 +111,6 @@
import java.util.concurrent.Future;
public class {{.Service.Name}}ClientImpl implements {{.Service.Name}}Client {Ȧ
- private final Broadcaster myBroadcaster;¶
- private final ExecutorService myExecutorService;¶
-
- public {{.Service.Name}}ClientImpl(ExecutorService executorService, InputStream in, OutputStream out, int mtu) {Ȧ
- myExecutorService = executorService;¶
- myBroadcaster = new Broadcaster(in, out, mtu, myExecutorService);¶
- «}¶
- {{range .Service.Methods}}
- @Override¶
- public {{template "Java.Method" .}} {Ȧ
- return myExecutorService.submit(new {{.Name}}Callable({{template "Java.Arguments" .}}));¶
- «}¶
- {{end}}
- ¶
- {{range .Service.Methods}}
- private class {{.Name}}Callable implements {{Call "Java.Callable" .Result.Type}} {Ȧ
- private final {{File.ClassName .Call}} myCall;¶
- ¶
- private {{.Name}}Callable({{template "Java.Parameters" .}}) {Ȧ
- myCall = new {{File.ClassName .Call}}();¶
- {{range .Call.Params}}
- myCall.{{File.Setter .Name}}({{.Name}});¶
- {{end}}
- «}¶
- @Override¶
- public {{Call "Java.Value" .Result.Type}} call() throws Exception {Ȧ
- {{if .Result.Type}}{{File.ClassName .Result}} result = ({{File.ClassName .Result}})myBroadcaster.Send(myCall);¶
- return result.myValue;¶
- {{else}}
- myBroadcaster.Send(myCall);¶
- return null;¶
- {{end}}
- «}¶
- «}¶
- {{end}}
+ //{{Section "Java.ClientImplBody"}}¶
«}¶
{{end}}