-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidentifiers.go
57 lines (49 loc) · 896 Bytes
/
identifiers.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
package metago
import (
"bytes"
"github.com/nu7hatch/gouuid"
)
// TypeId is a globally unique identifier for a metago object type
type TypeID struct {
Pkg *uuid.UUID
PkgName string
Typ int
Name string
}
func (t *TypeID) Equals(o *TypeID) bool {
if t.Pkg != o.Pkg {
return false
}
if t.Typ != o.Typ {
return false
}
return true
}
func (t *TypeID) Compare(o *TypeID) int {
v := bytes.Compare(t.Pkg[:], o.Pkg[:])
if v != 0 {
return v
}
return t.Typ - o.Typ
}
// AttrID is a globally unique identifier for an attribute in a metago object type
type AttrID struct {
*TypeID
Attr int
Name string
}
func (a *AttrID) Equals(o *AttrID) bool {
if a.Attr != o.Attr {
}
if !a.TypeID.Equals(o.TypeID) {
return false
}
return true
}
func (a *AttrID) Compare(o *AttrID) int {
v := a.TypeID.Compare(o.TypeID)
if v != 0 {
return v
}
return a.Attr - o.Attr
}