|
18 | 18 | // }
|
19 | 19 | //
|
20 | 20 | // // Lets us return nil if we need to
|
21 |
| -// func (v *customInt) ExprValue() any { |
| 21 | +// func (v *customInt) AnyValue() any { |
22 | 22 | // return v.Int
|
23 | 23 | // }
|
24 | 24 | //
|
@@ -62,13 +62,13 @@ var ValueGetter = func() expr.Option {
|
62 | 62 | }
|
63 | 63 | }()
|
64 | 64 |
|
65 |
| -// A ExprValuer provides a generic function for a custom type to return standard go values. |
| 65 | +// A AnyValuer provides a generic function for a custom type to return standard go values. |
66 | 66 | // It allows for returning a `nil` value but does not provide any type checking at expression compile.
|
67 | 67 | //
|
68 |
| -// A custom type may implement both ExprValuer and a type specific interface to enable both |
| 68 | +// A custom type may implement both AnyValuer and a type specific interface to enable both |
69 | 69 | // compile time checking and the ability to return a `nil` value.
|
70 |
| -type ExprValuer interface { |
71 |
| - ExprValue() any |
| 70 | +type AnyValuer interface { |
| 71 | + AnyValue() any |
72 | 72 | }
|
73 | 73 |
|
74 | 74 | type IntValuer interface {
|
@@ -144,7 +144,7 @@ type MapValuer interface {
|
144 | 144 | }
|
145 | 145 |
|
146 | 146 | var supportedInterfaces = []reflect.Type{
|
147 |
| - reflect.TypeOf((*ExprValuer)(nil)).Elem(), |
| 147 | + reflect.TypeOf((*AnyValuer)(nil)).Elem(), |
148 | 148 | reflect.TypeOf((*BoolValuer)(nil)).Elem(),
|
149 | 149 | reflect.TypeOf((*IntValuer)(nil)).Elem(),
|
150 | 150 | reflect.TypeOf((*Int8Valuer)(nil)).Elem(),
|
@@ -188,13 +188,13 @@ func (patcher) Visit(node *ast.Node) {
|
188 | 188 | }
|
189 | 189 |
|
190 | 190 | func (patcher) ApplyOptions(c *conf.Config) {
|
191 |
| - getExprValueFunc(c) |
| 191 | + getValueFunc(c) |
192 | 192 | }
|
193 | 193 |
|
194 |
| -func getExprValue(params ...any) (any, error) { |
| 194 | +func getValue(params ...any) (any, error) { |
195 | 195 | switch v := params[0].(type) {
|
196 |
| - case ExprValuer: |
197 |
| - return v.ExprValue(), nil |
| 196 | + case AnyValuer: |
| 197 | + return v.AnyValue(), nil |
198 | 198 | case BoolValuer:
|
199 | 199 | return v.BoolValue(), nil
|
200 | 200 | case IntValuer:
|
@@ -236,7 +236,7 @@ func getExprValue(params ...any) (any, error) {
|
236 | 236 | return params[0], nil
|
237 | 237 | }
|
238 | 238 |
|
239 |
| -var getExprValueFunc = expr.Function("$patcher_value_getter", getExprValue, |
| 239 | +var getValueFunc = expr.Function("$patcher_value_getter", getValue, |
240 | 240 | new(func(BoolValuer) bool),
|
241 | 241 | new(func(IntValuer) int),
|
242 | 242 | new(func(Int8Valuer) int8),
|
|
0 commit comments