-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
status.go
75 lines (59 loc) · 1.65 KB
/
status.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
package http_ns
import (
"github.com/inoxlang/inox/internal/core/symbolic"
pprint "github.com/inoxlang/inox/internal/prettyprint"
)
var (
STATUS_PROPNAMES = []string{"code", "full-text"}
ANY_STATUS = &Status{}
ANY_STATUS_CODE = &StatusCode{}
STATUS_CODE_INT_VALUE = symbolic.ANY_INT.
WithMatchingPattern(symbolic.NewIntRangePattern(symbolic.NewIntRange(symbolic.NewInt(100), symbolic.NewInt(599), false)))
)
type Status struct {
symbolic.UnassignablePropsMixin
symbolic.SerializableMixin
}
func (s *Status) Test(v symbolic.Value, state symbolic.RecTestCallState) bool {
state.StartCall()
defer state.FinishCall()
_, ok := v.(*Status)
return ok
}
func (*Status) GetGoMethod(name string) (*symbolic.GoFunction, bool) {
return nil, false
}
func (s *Status) Prop(name string) symbolic.Value {
switch name {
case "code":
return ANY_STATUS_CODE
case "full-text":
return symbolic.ANY_STRING
default:
return symbolic.GetGoMethodOrPanic(name, s)
}
}
func (Status) PropertyNames() []string {
return STATUS_PROPNAMES
}
func (r *Status) PrettyPrint(w pprint.PrettyPrintWriter, config *pprint.PrettyPrintConfig) {
w.WriteName("http.status")
}
func (s *Status) WidestOfType() symbolic.Value {
return ANY_STATUS
}
type StatusCode struct {
symbolic.SerializableMixin
}
func (s *StatusCode) Test(v symbolic.Value, state symbolic.RecTestCallState) bool {
state.StartCall()
defer state.FinishCall()
_, ok := v.(*StatusCode)
return ok
}
func (c *StatusCode) PrettyPrint(w pprint.PrettyPrintWriter, config *pprint.PrettyPrintConfig) {
w.WriteName("http.status-code")
}
func (c *StatusCode) WidestOfType() symbolic.Value {
return ANY_STATUS_CODE
}