/
version.vdl.go
147 lines (130 loc) · 4.35 KB
/
version.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
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file was auto-generated by the vanadium vdl tool.
// Package: version
//
//nolint:revive
package version
import (
"fmt"
"v.io/v23/context"
"v.io/v23/verror"
)
var initializeVDLCalled = false
var _ = initializeVDL() // Must be first; see initializeVDL comments for details.
// Error definitions
// =================
var (
ErrNoCompatibleVersion = verror.NewIDAction("v.io/v23/rpc/version.NoCompatibleVersion", verror.NoRetry)
)
// ErrorfNoCompatibleVersion calls ErrNoCompatibleVersion.Errorf with the supplied arguments.
func ErrorfNoCompatibleVersion(ctx *context.T, format string, lmin uint64, lmax uint64, rmin uint64, rmax uint64) error {
return ErrNoCompatibleVersion.Errorf(ctx, format, lmin, lmax, rmin, rmax)
}
// MessageNoCompatibleVersion calls ErrNoCompatibleVersion.Message with the supplied arguments.
func MessageNoCompatibleVersion(ctx *context.T, message string, lmin uint64, lmax uint64, rmin uint64, rmax uint64) error {
return ErrNoCompatibleVersion.Message(ctx, message, lmin, lmax, rmin, rmax)
}
// ParamsErrNoCompatibleVersion extracts the expected parameters from the error's ParameterList.
func ParamsErrNoCompatibleVersion(argumentError error) (verrorComponent string, verrorOperation string, lmin uint64, lmax uint64, rmin uint64, rmax uint64, returnErr error) {
params := verror.Params(argumentError)
if params == nil {
returnErr = fmt.Errorf("no parameters found in: %T: %v", argumentError, argumentError)
return
}
iter := ¶mListIterator{params: params, max: len(params)}
if verrorComponent, verrorOperation, returnErr = iter.preamble(); returnErr != nil {
return
}
var (
tmp interface{}
ok bool
)
tmp, returnErr = iter.next()
if lmin, ok = tmp.(uint64); !ok {
if returnErr != nil {
return
}
returnErr = fmt.Errorf("parameter list contains the wrong type for return value lmin, has %T and not uint64", tmp)
return
}
tmp, returnErr = iter.next()
if lmax, ok = tmp.(uint64); !ok {
if returnErr != nil {
return
}
returnErr = fmt.Errorf("parameter list contains the wrong type for return value lmax, has %T and not uint64", tmp)
return
}
tmp, returnErr = iter.next()
if rmin, ok = tmp.(uint64); !ok {
if returnErr != nil {
return
}
returnErr = fmt.Errorf("parameter list contains the wrong type for return value rmin, has %T and not uint64", tmp)
return
}
tmp, returnErr = iter.next()
if rmax, ok = tmp.(uint64); !ok {
if returnErr != nil {
return
}
returnErr = fmt.Errorf("parameter list contains the wrong type for return value rmax, has %T and not uint64", tmp)
return
}
return
}
type paramListIterator struct {
err error
idx, max int
params []interface{}
}
func (pl *paramListIterator) next() (interface{}, error) {
if pl.err != nil {
return nil, pl.err
}
if pl.idx+1 > pl.max {
pl.err = fmt.Errorf("too few parameters: have %v", pl.max)
return nil, pl.err
}
pl.idx++
return pl.params[pl.idx-1], nil
}
func (pl *paramListIterator) preamble() (component, operation string, err error) {
var tmp interface{}
if tmp, err = pl.next(); err != nil {
return
}
var ok bool
if component, ok = tmp.(string); !ok {
return "", "", fmt.Errorf("ParamList[0]: component name is not a string: %T", tmp)
}
if tmp, err = pl.next(); err != nil {
return
}
if operation, ok = tmp.(string); !ok {
return "", "", fmt.Errorf("ParamList[1]: operation name is not a string: %T", tmp)
}
return
}
// initializeVDL performs vdl initialization. It is safe to call multiple times.
// If you have an init ordering issue, just insert the following line verbatim
// into your source files in this package, right after the "package foo" clause:
//
// var _ = initializeVDL()
//
// The purpose of this function is to ensure that vdl initialization occurs in
// the right order, and very early in the init sequence. In particular, vdl
// registration and package variable initialization needs to occur before
// functions like vdl.TypeOf will work properly.
//
// This function returns a dummy value, so that it can be used to initialize the
// first var in the file, to take advantage of Go's defined init order.
func initializeVDL() struct{} {
if initializeVDLCalled {
return struct{}{}
}
initializeVDLCalled = true
return struct{}{}
}