2024-09-04 19:24:45 +00:00
|
|
|
import (
|
|
|
|
"isle/daemon/jsonrpc2"
|
|
|
|
)
|
|
|
|
|
|
|
|
{{ $t := printf "%sClient" (down .Interface.Name) }}
|
|
|
|
|
|
|
|
type {{$t}} struct {
|
|
|
|
client jsonrpc2.Client
|
|
|
|
}
|
|
|
|
|
|
|
|
// {{.Interface.Name}}FromClient wraps a Client so that it implements the
|
|
|
|
// {{.Interface.Name}} interface.
|
|
|
|
func {{.Interface.Name}}FromClient(client jsonrpc2.Client) {{.Interface.Name}} {
|
|
|
|
return &{{$t}}{client}
|
|
|
|
}
|
|
|
|
|
|
|
|
{{range $method := .Interface.Methods}}
|
|
|
|
func (c *{{$t}}) {{$method.Declaration}} {
|
|
|
|
{{- $ctx := (index $method.Params 0).Name}}
|
2024-09-05 15:28:10 +00:00
|
|
|
|
|
|
|
{{- $rcv := ""}}
|
|
|
|
{{- $err := ""}}
|
|
|
|
|
|
|
|
{{- if (eq (len $method.Results) 1)}}
|
|
|
|
{{- $rcv = "nil" }}
|
|
|
|
{{- $err = (index $method.Results 0).Name}}
|
|
|
|
{{- else}}
|
|
|
|
{{- $rcv = printf "&%s" (index $method.Results 0).Name}}
|
|
|
|
{{- $err = (index $method.Results 1).Name}}
|
|
|
|
{{- end}}
|
|
|
|
|
2024-09-04 20:25:38 +00:00
|
|
|
{{- $err}} = c.client.Call(
|
|
|
|
{{$ctx}},
|
2024-09-05 15:28:10 +00:00
|
|
|
{{$rcv}},
|
2024-09-04 20:25:38 +00:00
|
|
|
"{{$method.Name}}",
|
|
|
|
{{- range $param := (slice $method.Params 1)}}
|
|
|
|
{{$param.Name}},
|
|
|
|
{{- end}}
|
|
|
|
)
|
2024-09-04 19:24:45 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
{{end}}
|