-
Notifications
You must be signed in to change notification settings - Fork 37
/
node_refinement.go
77 lines (69 loc) · 2.47 KB
/
node_refinement.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
package smi
import (
"unsafe"
"github.com/sleepinggenius2/gosmi/smi/internal"
"github.com/sleepinggenius2/gosmi/types"
)
// SmiRefinement *smiGetFirstRefinement(SmiNode *smiComplianceNodePtr)
func GetFirstRefinement(smiComplianceNodePtr *types.SmiNode) *types.SmiRefinement {
if smiComplianceNodePtr == nil {
return nil
}
objPtr := (*internal.Object)(unsafe.Pointer(smiComplianceNodePtr))
if objPtr.NodeKind != types.NodeCompliance || objPtr.RefinementList == nil || objPtr.RefinementList.Ptr == nil {
return nil
}
return &objPtr.RefinementList.Ptr.(*internal.Refinement).SmiRefinement
}
// SmiRefinement *smiGetNextRefinement(SmiRefinement *smiRefinementPtr)
func GetNextRefinement(smiRefinementPtr *types.SmiRefinement) *types.SmiRefinement {
if smiRefinementPtr == nil {
return nil
}
refPtr := (*internal.Refinement)(unsafe.Pointer(smiRefinementPtr))
if refPtr.List == nil || refPtr.List.Next == nil || refPtr.List.Next.Ptr == nil {
return nil
}
return &refPtr.List.Next.Ptr.(*internal.Refinement).SmiRefinement
}
// SmiNode *smiGetRefinementNode(SmiRefinement *smiRefinementPtr)
func GetRefinementNode(smiRefinementPtr *types.SmiRefinement) *types.SmiNode {
if smiRefinementPtr == nil {
return nil
}
refinementPtr := (*internal.Refinement)(unsafe.Pointer(smiRefinementPtr))
if refinementPtr.Object == nil {
return nil
}
return refinementPtr.Object.GetSmiNode()
}
// SmiType *smiGetRefinementType(SmiRefinement *smiRefinementPtr)
func GetRefinementType(smiRefinementPtr *types.SmiRefinement) *types.SmiType {
if smiRefinementPtr == nil {
return nil
}
refinementPtr := (*internal.Refinement)(unsafe.Pointer(smiRefinementPtr))
if refinementPtr.Type == nil || refinementPtr.Type.BaseType == types.BaseTypeUnknown {
return nil
}
return &refinementPtr.Type.SmiType
}
// SmiType *smiGetRefinementWriteType(SmiRefinement *smiRefinementPtr)
func GetRefinementWriteType(smiRefinementPtr *types.SmiRefinement) *types.SmiType {
if smiRefinementPtr == nil {
return nil
}
refinementPtr := (*internal.Refinement)(unsafe.Pointer(smiRefinementPtr))
if refinementPtr.WriteType == nil || refinementPtr.WriteType.BaseType == types.BaseTypeUnknown {
return nil
}
return &refinementPtr.WriteType.SmiType
}
// int smiGetRefinementLine(SmiRefinement *smiRefinementPtr)
func GetRefinementLine(smiRefinementPtr *types.SmiRefinement) int {
if smiRefinementPtr == nil {
return 0
}
refinementPtr := (*internal.Refinement)(unsafe.Pointer(smiRefinementPtr))
return refinementPtr.Line
}