blob: e13c89873ad34d5ee3873de9111b69f28e00ae79 [file] [log] [blame]
Alex Fandrianto4204a882014-09-19 13:34:32 -07001// This file was auto-generated by the veyron vdl tool.
2// Source: lightswitch.vdl
3
4package sample
5
6import (
Todd Wange987f9f2014-11-07 00:36:04 -08007 // The non-user imports are prefixed with "__" to prevent collisions.
8 __veyron2 "veyron.io/veyron/veyron2"
9 __context "veyron.io/veyron/veyron2/context"
10 __ipc "veyron.io/veyron/veyron2/ipc"
11 __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil"
12 __wiretype "veyron.io/veyron/veyron2/wiretype"
Alex Fandrianto4204a882014-09-19 13:34:32 -070013)
14
Todd Wange987f9f2014-11-07 00:36:04 -080015// TODO(toddw): Remove this line once the new signature support is done.
16// It corrects a bug where __wiretype is unused in VDL pacakges where only
17// bootstrap types are used on interfaces.
18const _ = __wiretype.TypeIDInvalid
Alex Fandrianto4204a882014-09-19 13:34:32 -070019
Todd Wange987f9f2014-11-07 00:36:04 -080020// LightSwitchClientMethods is the client interface
21// containing LightSwitch methods.
22//
Alex Fandrianto4204a882014-09-19 13:34:32 -070023// LightSwitch allows clients to manipulate a virtual light switch.
Todd Wange987f9f2014-11-07 00:36:04 -080024type LightSwitchClientMethods interface {
Alex Fandrianto4204a882014-09-19 13:34:32 -070025 // Status indicates whether the light is on or off.
Todd Wange987f9f2014-11-07 00:36:04 -080026 Status(__context.T, ...__ipc.CallOpt) (string, error)
Alex Fandrianto4204a882014-09-19 13:34:32 -070027 // FlipSwitch sets the light to on or off, depending on the input.
Todd Wange987f9f2014-11-07 00:36:04 -080028 FlipSwitch(ctx __context.T, toOn bool, opts ...__ipc.CallOpt) error
Alex Fandrianto4204a882014-09-19 13:34:32 -070029}
30
Todd Wange987f9f2014-11-07 00:36:04 -080031// LightSwitchClientStub adds universal methods to LightSwitchClientMethods.
32type LightSwitchClientStub interface {
33 LightSwitchClientMethods
34 __ipc.UniversalServiceMethods
Alex Fandrianto4204a882014-09-19 13:34:32 -070035}
36
Todd Wange987f9f2014-11-07 00:36:04 -080037// LightSwitchClient returns a client stub for LightSwitch.
38func LightSwitchClient(name string, opts ...__ipc.BindOpt) LightSwitchClientStub {
39 var client __ipc.Client
40 for _, opt := range opts {
41 if clientOpt, ok := opt.(__ipc.Client); ok {
Alex Fandrianto4204a882014-09-19 13:34:32 -070042 client = clientOpt
Alex Fandrianto4204a882014-09-19 13:34:32 -070043 }
Alex Fandrianto4204a882014-09-19 13:34:32 -070044 }
Todd Wange987f9f2014-11-07 00:36:04 -080045 return implLightSwitchClientStub{name, client}
Alex Fandrianto4204a882014-09-19 13:34:32 -070046}
47
Todd Wange987f9f2014-11-07 00:36:04 -080048type implLightSwitchClientStub struct {
49 name string
50 client __ipc.Client
51}
52
53func (c implLightSwitchClientStub) c(ctx __context.T) __ipc.Client {
54 if c.client != nil {
55 return c.client
Alex Fandrianto4204a882014-09-19 13:34:32 -070056 }
Todd Wange987f9f2014-11-07 00:36:04 -080057 return __veyron2.RuntimeFromContext(ctx).Client()
Alex Fandrianto4204a882014-09-19 13:34:32 -070058}
59
Todd Wange987f9f2014-11-07 00:36:04 -080060func (c implLightSwitchClientStub) Status(ctx __context.T, opts ...__ipc.CallOpt) (o0 string, err error) {
61 var call __ipc.Call
62 if call, err = c.c(ctx).StartCall(ctx, c.name, "Status", nil, opts...); err != nil {
Alex Fandrianto4204a882014-09-19 13:34:32 -070063 return
64 }
Todd Wange987f9f2014-11-07 00:36:04 -080065 if ierr := call.Finish(&o0, &err); ierr != nil {
Alex Fandrianto4204a882014-09-19 13:34:32 -070066 err = ierr
67 }
68 return
69}
70
Todd Wange987f9f2014-11-07 00:36:04 -080071func (c implLightSwitchClientStub) FlipSwitch(ctx __context.T, i0 bool, opts ...__ipc.CallOpt) (err error) {
72 var call __ipc.Call
73 if call, err = c.c(ctx).StartCall(ctx, c.name, "FlipSwitch", []interface{}{i0}, opts...); err != nil {
Alex Fandrianto4204a882014-09-19 13:34:32 -070074 return
75 }
76 if ierr := call.Finish(&err); ierr != nil {
77 err = ierr
78 }
79 return
80}
81
Todd Wange987f9f2014-11-07 00:36:04 -080082func (c implLightSwitchClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
83 var call __ipc.Call
84 if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
Alex Fandrianto4204a882014-09-19 13:34:32 -070085 return
86 }
Todd Wange987f9f2014-11-07 00:36:04 -080087 if ierr := call.Finish(&o0, &err); ierr != nil {
Alex Fandrianto4204a882014-09-19 13:34:32 -070088 err = ierr
89 }
90 return
91}
92
Todd Wange987f9f2014-11-07 00:36:04 -080093// LightSwitchServerMethods is the interface a server writer
94// implements for LightSwitch.
95//
96// LightSwitch allows clients to manipulate a virtual light switch.
97type LightSwitchServerMethods interface {
98 // Status indicates whether the light is on or off.
99 Status(__ipc.ServerContext) (string, error)
100 // FlipSwitch sets the light to on or off, depending on the input.
101 FlipSwitch(ctx __ipc.ServerContext, toOn bool) error
Alex Fandrianto4204a882014-09-19 13:34:32 -0700102}
103
Todd Wange987f9f2014-11-07 00:36:04 -0800104// LightSwitchServerStubMethods is the server interface containing
Todd Wang52500a52014-11-11 20:26:05 -0800105// LightSwitch methods, as expected by ipc.Server.
106// There is no difference between this interface and LightSwitchServerMethods
107// since there are no streaming methods.
108type LightSwitchServerStubMethods LightSwitchServerMethods
Alex Fandrianto4204a882014-09-19 13:34:32 -0700109
Todd Wange987f9f2014-11-07 00:36:04 -0800110// LightSwitchServerStub adds universal methods to LightSwitchServerStubMethods.
111type LightSwitchServerStub interface {
112 LightSwitchServerStubMethods
Todd Wang09f71db2014-11-16 21:41:47 -0800113 // Describe the LightSwitch interfaces.
114 Describe__() []__ipc.InterfaceDesc
115 // Signature will be replaced with Describe__.
Todd Wang52500a52014-11-11 20:26:05 -0800116 Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
Todd Wange987f9f2014-11-07 00:36:04 -0800117}
118
119// LightSwitchServer returns a server stub for LightSwitch.
120// It converts an implementation of LightSwitchServerMethods into
121// an object that may be used by ipc.Server.
122func LightSwitchServer(impl LightSwitchServerMethods) LightSwitchServerStub {
123 stub := implLightSwitchServerStub{
124 impl: impl,
125 }
126 // Initialize GlobState; always check the stub itself first, to handle the
127 // case where the user has the Glob method defined in their VDL source.
128 if gs := __ipc.NewGlobState(stub); gs != nil {
129 stub.gs = gs
130 } else if gs := __ipc.NewGlobState(impl); gs != nil {
131 stub.gs = gs
132 }
133 return stub
134}
135
136type implLightSwitchServerStub struct {
137 impl LightSwitchServerMethods
138 gs *__ipc.GlobState
139}
140
Todd Wang52500a52014-11-11 20:26:05 -0800141func (s implLightSwitchServerStub) Status(ctx __ipc.ServerContext) (string, error) {
142 return s.impl.Status(ctx)
Todd Wange987f9f2014-11-07 00:36:04 -0800143}
144
Todd Wang52500a52014-11-11 20:26:05 -0800145func (s implLightSwitchServerStub) FlipSwitch(ctx __ipc.ServerContext, i0 bool) error {
146 return s.impl.FlipSwitch(ctx, i0)
Todd Wange987f9f2014-11-07 00:36:04 -0800147}
148
149func (s implLightSwitchServerStub) VGlob() *__ipc.GlobState {
150 return s.gs
151}
152
Todd Wang09f71db2014-11-16 21:41:47 -0800153func (s implLightSwitchServerStub) Describe__() []__ipc.InterfaceDesc {
154 return []__ipc.InterfaceDesc{LightSwitchDesc}
155}
156
157// LightSwitchDesc describes the LightSwitch interface.
158var LightSwitchDesc __ipc.InterfaceDesc = descLightSwitch
159
160// descLightSwitch hides the desc to keep godoc clean.
161var descLightSwitch = __ipc.InterfaceDesc{
162 Name: "LightSwitch",
163 PkgPath: "sample",
164 Doc: "// LightSwitch allows clients to manipulate a virtual light switch.",
165 Methods: []__ipc.MethodDesc{
166 {
167 Name: "Status",
168 Doc: "// Status indicates whether the light is on or off.",
169 OutArgs: []__ipc.ArgDesc{
170 {"", ``}, // string
171 {"", ``}, // error
172 },
173 },
174 {
175 Name: "FlipSwitch",
176 Doc: "// FlipSwitch sets the light to on or off, depending on the input.",
177 InArgs: []__ipc.ArgDesc{
178 {"toOn", ``}, // bool
179 },
180 OutArgs: []__ipc.ArgDesc{
181 {"", ``}, // error
182 },
183 },
184 },
Alex Fandrianto4204a882014-09-19 13:34:32 -0700185}
186
Todd Wang52500a52014-11-11 20:26:05 -0800187func (s implLightSwitchServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
Todd Wang09f71db2014-11-16 21:41:47 -0800188 // TODO(toddw): Replace with new Describe__ implementation.
Todd Wange987f9f2014-11-07 00:36:04 -0800189 result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
190 result.Methods["FlipSwitch"] = __ipc.MethodSignature{
191 InArgs: []__ipc.MethodArgument{
Alex Fandrianto4204a882014-09-19 13:34:32 -0700192 {Name: "toOn", Type: 2},
193 },
Todd Wange987f9f2014-11-07 00:36:04 -0800194 OutArgs: []__ipc.MethodArgument{
Alex Fandrianto4204a882014-09-19 13:34:32 -0700195 {Name: "", Type: 65},
196 },
197 }
Todd Wange987f9f2014-11-07 00:36:04 -0800198 result.Methods["Status"] = __ipc.MethodSignature{
199 InArgs: []__ipc.MethodArgument{},
200 OutArgs: []__ipc.MethodArgument{
Alex Fandrianto4204a882014-09-19 13:34:32 -0700201 {Name: "", Type: 3},
202 {Name: "", Type: 65},
203 },
204 }
205
Todd Wange987f9f2014-11-07 00:36:04 -0800206 result.TypeDefs = []__vdlutil.Any{
207 __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
Alex Fandrianto4204a882014-09-19 13:34:32 -0700208
209 return result, nil
210}