-
Notifications
You must be signed in to change notification settings - Fork 0
/
targetflags_bitmask.go
67 lines (57 loc) · 1.63 KB
/
targetflags_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
// Code generated by "bitmasker -type TargetFlags"; 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[TARGET_SAME_APP-1]
_ = x[TARGET_SAME_WIDGET-2]
_ = x[TARGET_OTHER_APP-4]
_ = x[TARGET_OTHER_WIDGET-8]
}
const (
_TargetFlags_name_0 = "SAMEAPPSAMEWIDGET"
_TargetFlags_name_1 = "OTHERAPP"
_TargetFlags_name_2 = "OTHERWIDGET"
)
var (
_TargetFlags_index_0 = [...]uint8{0, 7, 17}
)
func (i TargetFlags) String() (value string) {
update := func(t TargetFlags, n string) {
if i.Has(t) {
if len(value) > 0 {
value += " | "
}
value += n
}
}
update(TargetFlags(1), _TargetFlags_name_0[_TargetFlags_index_0[0]:_TargetFlags_index_0[0+1]])
update(TargetFlags(2), _TargetFlags_name_0[_TargetFlags_index_0[1]:_TargetFlags_index_0[1+1]])
update(TargetFlags(4), _TargetFlags_name_1)
update(TargetFlags(8), _TargetFlags_name_2)
if value == "" {
return "TargetFlags(" + strconv.FormatInt(int64(i), 10) + ")"
}
return
}
// Has returns TRUE if the given flag is present in the bitmask
func (i TargetFlags) Has(m TargetFlags) bool {
if i == m {
return true
}
return i&m != 0
}
// Set returns the bitmask with the given flag set
func (i TargetFlags) Set(m TargetFlags) TargetFlags {
return i | m
}
// Clear returns the bitmask with the given flag removed
func (i TargetFlags) Clear(m TargetFlags) TargetFlags {
return i &^ m
}
// Toggle returns the bitmask with the given flag toggled
func (i TargetFlags) Toggle(m TargetFlags) TargetFlags {
return i ^ m
}