-
Notifications
You must be signed in to change notification settings - Fork 0
/
spec.vdl.go
184 lines (162 loc) · 6.11 KB
/
spec.vdl.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// This file was auto-generated by the vanadium vdl tool.
// Source: spec.vdl
// Package spec defines the interfaces between networked participants of the
// triagles display.
// go get v.io/x/ref/cmd/vdl
// VDLPATH=$GOPATH/src $GOPATH/bin/vdl --builtin_vdlroot generate github.com/asimshankar/triangles/spec
package spec
import (
// VDL system imports
"v.io/v23"
"v.io/v23/context"
"v.io/v23/rpc"
"v.io/v23/vdl"
)
// Triangle represents a triangle that will be displayed on the screen.
//
// The coordinates (X, Y) and velocity (Dx, Dy) are in a world where (0, 0) is
// the center, (1, 1) is the bottom right and (-1, -1) is the top left.
//
// R, G, B denote the color of the triangle.
type Triangle struct {
X float32
Y float32
Dx float32
Dy float32
R float32
G float32
B float32
}
func (Triangle) __VDLReflect(struct {
Name string `vdl:"github.com/asimshankar/triangles/spec.Triangle"`
}) {
}
func init() {
vdl.Register((*Triangle)(nil))
}
// ScreenClientMethods is the client interface
// containing Screen methods.
//
// Screen represents a remote screen that can be invited to grab triangles.
type ScreenClientMethods interface {
// Invite is a request to the receiver to join the set of screens that
// the caller is participating in, by standing to the right of the
// caller.
//
// A Screen can be active on at most one invitation at a time and
// should return an error if it is engaged in a previous invitation.
Invite(*context.T, ...rpc.CallOpt) error
// Give is a request by the caller for the receiver to take ownership
// of the provided triangle.
//
// Give is typically invoked on the receiver by the adjacent screen
// when a triangle falls off that adjacent screen. However, this is not
// a requirement and Give can be invoked by an arbitrary client to
// manufacture a new triangle.
Give(_ *context.T, t Triangle, _ ...rpc.CallOpt) error
}
// ScreenClientStub adds universal methods to ScreenClientMethods.
type ScreenClientStub interface {
ScreenClientMethods
rpc.UniversalServiceMethods
}
// ScreenClient returns a client stub for Screen.
func ScreenClient(name string) ScreenClientStub {
return implScreenClientStub{name}
}
type implScreenClientStub struct {
name string
}
func (c implScreenClientStub) Invite(ctx *context.T, opts ...rpc.CallOpt) (err error) {
err = v23.GetClient(ctx).Call(ctx, c.name, "Invite", nil, nil, opts...)
return
}
func (c implScreenClientStub) Give(ctx *context.T, i0 Triangle, opts ...rpc.CallOpt) (err error) {
err = v23.GetClient(ctx).Call(ctx, c.name, "Give", []interface{}{i0}, nil, opts...)
return
}
// ScreenServerMethods is the interface a server writer
// implements for Screen.
//
// Screen represents a remote screen that can be invited to grab triangles.
type ScreenServerMethods interface {
// Invite is a request to the receiver to join the set of screens that
// the caller is participating in, by standing to the right of the
// caller.
//
// A Screen can be active on at most one invitation at a time and
// should return an error if it is engaged in a previous invitation.
Invite(*context.T, rpc.ServerCall) error
// Give is a request by the caller for the receiver to take ownership
// of the provided triangle.
//
// Give is typically invoked on the receiver by the adjacent screen
// when a triangle falls off that adjacent screen. However, this is not
// a requirement and Give can be invoked by an arbitrary client to
// manufacture a new triangle.
Give(_ *context.T, _ rpc.ServerCall, t Triangle) error
}
// ScreenServerStubMethods is the server interface containing
// Screen methods, as expected by rpc.Server.
// There is no difference between this interface and ScreenServerMethods
// since there are no streaming methods.
type ScreenServerStubMethods ScreenServerMethods
// ScreenServerStub adds universal methods to ScreenServerStubMethods.
type ScreenServerStub interface {
ScreenServerStubMethods
// Describe the Screen interfaces.
Describe__() []rpc.InterfaceDesc
}
// ScreenServer returns a server stub for Screen.
// It converts an implementation of ScreenServerMethods into
// an object that may be used by rpc.Server.
func ScreenServer(impl ScreenServerMethods) ScreenServerStub {
stub := implScreenServerStub{
impl: impl,
}
// Initialize GlobState; always check the stub itself first, to handle the
// case where the user has the Glob method defined in their VDL source.
if gs := rpc.NewGlobState(stub); gs != nil {
stub.gs = gs
} else if gs := rpc.NewGlobState(impl); gs != nil {
stub.gs = gs
}
return stub
}
type implScreenServerStub struct {
impl ScreenServerMethods
gs *rpc.GlobState
}
func (s implScreenServerStub) Invite(ctx *context.T, call rpc.ServerCall) error {
return s.impl.Invite(ctx, call)
}
func (s implScreenServerStub) Give(ctx *context.T, call rpc.ServerCall, i0 Triangle) error {
return s.impl.Give(ctx, call, i0)
}
func (s implScreenServerStub) Globber() *rpc.GlobState {
return s.gs
}
func (s implScreenServerStub) Describe__() []rpc.InterfaceDesc {
return []rpc.InterfaceDesc{ScreenDesc}
}
// ScreenDesc describes the Screen interface.
var ScreenDesc rpc.InterfaceDesc = descScreen
// descScreen hides the desc to keep godoc clean.
var descScreen = rpc.InterfaceDesc{
Name: "Screen",
PkgPath: "github.com/asimshankar/triangles/spec",
Doc: "// Screen represents a remote screen that can be invited to grab triangles.",
Methods: []rpc.MethodDesc{
{
Name: "Invite",
Doc: "// Invite is a request to the receiver to join the set of screens that\n// the caller is participating in, by standing to the right of the\n// caller.\n//\n// A Screen can be active on at most one invitation at a time and\n// should return an error if it is engaged in a previous invitation.",
},
{
Name: "Give",
Doc: "// Give is a request by the caller for the receiver to take ownership\n// of the provided triangle.\n//\n// Give is typically invoked on the receiver by the adjacent screen\n// when a triangle falls off that adjacent screen. However, this is not\n// a requirement and Give can be invoked by an arbitrary client to\n// manufacture a new triangle.",
InArgs: []rpc.ArgDesc{
{"t", ``}, // Triangle
},
},
},
}