-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathmodule_revision.go
41 lines (36 loc) · 1.04 KB
/
module_revision.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
package smi
import (
"unsafe"
"github.com/sleepinggenius2/gosmi/smi/internal"
"github.com/sleepinggenius2/gosmi/types"
)
// SmiRevision *smiGetFirstRevision(SmiModule *smiModulePtr)
func GetFirstRevision(smiModulePtr *types.SmiModule) *types.SmiRevision {
if smiModulePtr == nil {
return nil
}
modulePtr := (*internal.Module)(unsafe.Pointer(smiModulePtr))
if modulePtr.FirstRevision == nil {
return nil
}
return &modulePtr.FirstRevision.SmiRevision
}
// SmiRevision *smiGetNextRevision(SmiRevision *smiRevisionPtr)
func GetNextRevision(smiRevisionPtr *types.SmiRevision) *types.SmiRevision {
if smiRevisionPtr == nil {
return nil
}
revisionPtr := (*internal.Revision)(unsafe.Pointer(smiRevisionPtr))
if revisionPtr.Next == nil {
return nil
}
return &revisionPtr.Next.SmiRevision
}
// int smiGetRevisionLine(SmiRevision *smiRevisionPtr)
func GetRevisionLine(smiRevisionPtr *types.SmiRevision) int {
if smiRevisionPtr == nil {
return 0
}
revisionPtr := (*internal.Revision)(unsafe.Pointer(smiRevisionPtr))
return revisionPtr.Line
}