-
Notifications
You must be signed in to change notification settings - Fork 0
/
signalmatchtype_bitmask.go
73 lines (63 loc) · 2.01 KB
/
signalmatchtype_bitmask.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
// Code generated by "bitmasker -type SignalMatchType"; DO NOT EDIT.
package enums
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the bitmasker command to generate them again.
var x [1]struct{}
_ = x[SIGNAL_MATCH_ID-1]
_ = x[SIGNAL_MATCH_DETAIL-2]
_ = x[SIGNAL_MATCH_CLOSURE-4]
_ = x[SIGNAL_MATCH_FUNC-8]
_ = x[SIGNAL_MATCH_DATA-16]
_ = x[SIGNAL_MATCH_UNBLOCKED-32]
}
const (
_SignalMatchType_name_0 = "MATCHIDMATCHDETAIL"
_SignalMatchType_name_1 = "MATCHCLOSURE"
_SignalMatchType_name_2 = "MATCHFUNC"
_SignalMatchType_name_3 = "MATCHDATA"
_SignalMatchType_name_4 = "MATCHUNBLOCKED"
)
var (
_SignalMatchType_index_0 = [...]uint8{0, 7, 18}
)
func (i SignalMatchType) String() (value string) {
update := func(t SignalMatchType, n string) {
if i.Has(t) {
if len(value) > 0 {
value += " | "
}
value += n
}
}
update(SignalMatchType(1), _SignalMatchType_name_0[_SignalMatchType_index_0[0]:_SignalMatchType_index_0[0+1]])
update(SignalMatchType(2), _SignalMatchType_name_0[_SignalMatchType_index_0[1]:_SignalMatchType_index_0[1+1]])
update(SignalMatchType(4), _SignalMatchType_name_1)
update(SignalMatchType(8), _SignalMatchType_name_2)
update(SignalMatchType(16), _SignalMatchType_name_3)
update(SignalMatchType(32), _SignalMatchType_name_4)
if value == "" {
return "SignalMatchType(" + strconv.FormatInt(int64(i), 10) + ")"
}
return
}
// Has returns TRUE if the given flag is present in the bitmask
func (i SignalMatchType) Has(m SignalMatchType) bool {
if i == m {
return true
}
return i&m != 0
}
// Set returns the bitmask with the given flag set
func (i SignalMatchType) Set(m SignalMatchType) SignalMatchType {
return i | m
}
// Clear returns the bitmask with the given flag removed
func (i SignalMatchType) Clear(m SignalMatchType) SignalMatchType {
return i &^ m
}
// Toggle returns the bitmask with the given flag toggled
func (i SignalMatchType) Toggle(m SignalMatchType) SignalMatchType {
return i ^ m
}