-
Notifications
You must be signed in to change notification settings - Fork 37
/
node_element.go
44 lines (39 loc) · 1.04 KB
/
node_element.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
package smi
import (
"unsafe"
"github.com/sleepinggenius2/gosmi/smi/internal"
"github.com/sleepinggenius2/gosmi/types"
)
// SmiElement *smiGetFirstElement(SmiNode *smiNodePtr)
func GetFirstElement(smiNodePtr *types.SmiNode) *types.SmiElement {
if smiNodePtr == nil {
return nil
}
objPtr := (*internal.Object)(unsafe.Pointer(smiNodePtr))
if objPtr.List == nil {
return nil
}
return &objPtr.List.SmiElement
}
// SmiElement *smiGetNextElement(SmiElement *smiElementPtr)
func GetNextElement(smiElementPtr *types.SmiElement) *types.SmiElement {
if smiElementPtr == nil {
return nil
}
listPtr := (*internal.List)(unsafe.Pointer(smiElementPtr))
if listPtr.Next == nil {
return nil
}
return &listPtr.Next.SmiElement
}
// SmiNode *smiGetElementNode(SmiElement *smiElementPtr)
func GetElementNode(smiElementPtr *types.SmiElement) *types.SmiNode {
if smiElementPtr == nil {
return nil
}
listPtr := (*internal.List)(unsafe.Pointer(smiElementPtr))
if listPtr.Ptr == nil {
return nil
}
return listPtr.Ptr.(*internal.Object).GetSmiNode()
}