-
Notifications
You must be signed in to change notification settings - Fork 0
/
signalflags_bitmask.go
82 lines (72 loc) · 2.16 KB
/
signalflags_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
74
75
76
77
78
79
80
81
82
// Code generated by "bitmasker -type SignalFlags"; 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_RUN_FIRST-1]
_ = x[SIGNAL_RUN_LAST-2]
_ = x[SIGNAL_RUN_CLEANUP-4]
_ = x[SIGNAL_NO_RECURSE-8]
_ = x[SIGNAL_DETAILED-16]
_ = x[SIGNAL_ACTION-32]
_ = x[SIGNAL_NO_HOOKS-64]
_ = x[SIGNAL_MUST_COLLECT-128]
_ = x[SIGNAL_DEPRECATED-256]
}
const (
_SignalFlags_name_0 = "RUNFIRSTRUNLAST"
_SignalFlags_name_1 = "RUNCLEANUP"
_SignalFlags_name_2 = "NORECURSE"
_SignalFlags_name_3 = "DETAILED"
_SignalFlags_name_4 = "ACTION"
_SignalFlags_name_5 = "NOHOOKS"
_SignalFlags_name_6 = "MUSTCOLLECT"
_SignalFlags_name_7 = "DEPRECATED"
)
var (
_SignalFlags_index_0 = [...]uint8{0, 8, 15}
)
func (i SignalFlags) String() (value string) {
update := func(t SignalFlags, n string) {
if i.Has(t) {
if len(value) > 0 {
value += " | "
}
value += n
}
}
update(SignalFlags(1), _SignalFlags_name_0[_SignalFlags_index_0[0]:_SignalFlags_index_0[0+1]])
update(SignalFlags(2), _SignalFlags_name_0[_SignalFlags_index_0[1]:_SignalFlags_index_0[1+1]])
update(SignalFlags(4), _SignalFlags_name_1)
update(SignalFlags(8), _SignalFlags_name_2)
update(SignalFlags(16), _SignalFlags_name_3)
update(SignalFlags(32), _SignalFlags_name_4)
update(SignalFlags(64), _SignalFlags_name_5)
update(SignalFlags(128), _SignalFlags_name_6)
update(SignalFlags(256), _SignalFlags_name_7)
if value == "" {
return "SignalFlags(" + strconv.FormatInt(int64(i), 10) + ")"
}
return
}
// Has returns TRUE if the given flag is present in the bitmask
func (i SignalFlags) Has(m SignalFlags) bool {
if i == m {
return true
}
return i&m != 0
}
// Set returns the bitmask with the given flag set
func (i SignalFlags) Set(m SignalFlags) SignalFlags {
return i | m
}
// Clear returns the bitmask with the given flag removed
func (i SignalFlags) Clear(m SignalFlags) SignalFlags {
return i &^ m
}
// Toggle returns the bitmask with the given flag toggled
func (i SignalFlags) Toggle(m SignalFlags) SignalFlags {
return i ^ m
}