-
Notifications
You must be signed in to change notification settings - Fork 70
/
enumgen.go
77 lines (57 loc) · 3.04 KB
/
enumgen.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
// Code generated by "core generate -add-types"; DO NOT EDIT.
package physics
import (
"cogentcore.org/core/enums"
"cogentcore.org/core/tree"
)
var _NodeFlagsValues = []NodeFlags{1}
// NodeFlagsN is the highest valid value for type NodeFlags, plus one.
const NodeFlagsN NodeFlags = 2
var _NodeFlagsValueMap = map[string]NodeFlags{`Dynamic`: 1}
var _NodeFlagsDescMap = map[NodeFlags]string{1: `Dynamic means that this node can move -- if not so marked, it is a Static node. Any top-level group that is not Dynamic is immediately pruned from further consideration, so top-level groups should be separated into Dynamic and Static nodes at the start.`}
var _NodeFlagsMap = map[NodeFlags]string{1: `Dynamic`}
// String returns the string representation of this NodeFlags value.
func (i NodeFlags) String() string {
return enums.BitFlagStringExtended(i, _NodeFlagsValues, tree.FlagsValues())
}
// BitIndexString returns the string representation of this NodeFlags value
// if it is a bit index value (typically an enum constant), and
// not an actual bit flag value.
func (i NodeFlags) BitIndexString() string {
return enums.BitIndexStringExtended[NodeFlags, tree.Flags](i, _NodeFlagsMap)
}
// SetString sets the NodeFlags value from its string representation,
// and returns an error if the string is invalid.
func (i *NodeFlags) SetString(s string) error { *i = 0; return i.SetStringOr(s) }
// SetStringOr sets the NodeFlags value from its string representation
// while preserving any bit flags already set, and returns an
// error if the string is invalid.
func (i *NodeFlags) SetStringOr(s string) error {
return enums.SetStringOrExtended(i, (*tree.Flags)(i), s, _NodeFlagsValueMap)
}
// Int64 returns the NodeFlags value as an int64.
func (i NodeFlags) Int64() int64 { return int64(i) }
// SetInt64 sets the NodeFlags value from an int64.
func (i *NodeFlags) SetInt64(in int64) { *i = NodeFlags(in) }
// Desc returns the description of the NodeFlags value.
func (i NodeFlags) Desc() string {
return enums.DescExtended[NodeFlags, tree.Flags](i, _NodeFlagsDescMap)
}
// NodeFlagsValues returns all possible values for the type NodeFlags.
func NodeFlagsValues() []NodeFlags {
return enums.ValuesGlobalExtended(_NodeFlagsValues, tree.FlagsValues())
}
// Values returns all possible values for the type NodeFlags.
func (i NodeFlags) Values() []enums.Enum {
return enums.ValuesExtended(_NodeFlagsValues, tree.FlagsValues())
}
// HasFlag returns whether these bit flags have the given bit flag set.
func (i NodeFlags) HasFlag(f enums.BitFlag) bool { return enums.HasFlag((*int64)(&i), f) }
// SetFlag sets the value of the given flags in these flags to the given value.
func (i *NodeFlags) SetFlag(on bool, f ...enums.BitFlag) { enums.SetFlag((*int64)(i), on, f...) }
// MarshalText implements the [encoding.TextMarshaler] interface.
func (i NodeFlags) MarshalText() ([]byte, error) { return []byte(i.String()), nil }
// UnmarshalText implements the [encoding.TextUnmarshaler] interface.
func (i *NodeFlags) UnmarshalText(text []byte) error {
return enums.UnmarshalText(i, text, "NodeFlags")
}