27 lines
743 B
Smarty
27 lines
743 B
Smarty
|
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}}
|
||
|
{{- $arg := (index $method.Params 1).Name}}
|
||
|
{{- $rcv := (index $method.Results 0).Name}}
|
||
|
{{- $err := (index $method.Results 1).Name}}
|
||
|
{{- $err}} = c.client.Call({{$ctx}}, &{{$rcv}}, "{{$method.Name}}", {{$arg}})
|
||
|
return
|
||
|
}
|
||
|
{{end}}
|