-
Notifications
You must be signed in to change notification settings - Fork 0
/
leaf.go
222 lines (180 loc) · 4.49 KB
/
leaf.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
package croot
// #include "croot/croot.h"
//
import "C"
import (
"unsafe"
)
// Leaf
type Leaf interface {
Object
GetBranch() Branch
GetLenStatic() int
GetLeafCount() Leaf
GetTypeName() string
GetValuePointer() uintptr
SetAddress(addr unsafe.Pointer)
}
type leafImpl struct {
c C.CRoot_Leaf
}
func (l *leafImpl) GetBranch() Branch {
c := C.CRoot_Leaf_GetBranch(l.c)
if c == nil {
return nil
}
return &branchImpl{c: c}
}
func (l *leafImpl) GetLenStatic() int {
return int(C.CRoot_Leaf_GetLenStatic(l.c))
}
func (l *leafImpl) GetLeafCount() Leaf {
c := C.CRoot_Leaf_GetLeafCount(l.c)
obj := objectImpl{c: (C.CRoot_Object)(c)}
return to_gocroot(&obj).(Leaf)
}
func (l *leafImpl) GetTypeName() string {
cstr := C.CRoot_Leaf_GetTypeName(l.c)
// we do NOT own cstr
// defer C.free(unsafe.Point(cstr))
return C.GoString(cstr)
}
func (l *leafImpl) GetValuePointer() uintptr {
ptr := C.CRoot_Leaf_GetValuePointer(l.c)
return uintptr(ptr)
}
func (l *leafImpl) SetAddress(addr unsafe.Pointer) {
C.CRoot_Leaf_SetAddress(l.c, addr)
}
// LeafI
type LeafI interface {
Leaf
GetValue(idx int) float64
}
type leafIImpl struct {
c C.CRoot_LeafI
}
func (l *leafIImpl) GetValue(idx int) float64 {
o := C.CRoot_LeafI_GetValue(l.c, C.int(idx))
return float64(o)
}
func (l *leafIImpl) GetLenStatic() int {
return int(C.CRoot_Leaf_GetLenStatic(l.as_tleaf()))
}
func (l *leafIImpl) GetLeafCount() Leaf {
c := C.CRoot_Leaf_GetLeafCount(l.as_tleaf())
obj := objectImpl{c: (C.CRoot_Object)(c)}
return to_gocroot(&obj).(Leaf)
}
func (l *leafIImpl) GetTypeName() string {
cstr := C.CRoot_Leaf_GetTypeName(l.as_tleaf())
// we do NOT own cstr
// defer C.free(unsafe.Point(cstr))
return C.GoString(cstr)
}
func (l *leafIImpl) GetValuePointer() uintptr {
ptr := C.CRoot_Leaf_GetValuePointer(l.as_tleaf())
return uintptr(ptr)
}
func (l *leafIImpl) as_tleaf() C.CRoot_Leaf {
return (C.CRoot_Leaf)(unsafe.Pointer(l.c))
}
// LeafF
type LeafF interface {
Leaf
GetValue(idx int) float64
}
type leafFImpl struct {
c C.CRoot_LeafF
}
func (l *leafFImpl) GetValue(idx int) float64 {
o := C.CRoot_LeafF_GetValue(l.c, C.int(idx))
return float64(o)
}
func (l *leafFImpl) GetLenStatic() int {
return int(C.CRoot_Leaf_GetLenStatic(l.as_tleaf()))
}
func (l *leafFImpl) GetLeafCount() Leaf {
c := C.CRoot_Leaf_GetLeafCount(l.as_tleaf())
obj := objectImpl{c: (C.CRoot_Object)(c)}
return to_gocroot(&obj).(Leaf)
}
func (l *leafFImpl) GetTypeName() string {
cstr := C.CRoot_Leaf_GetTypeName(l.as_tleaf())
// we do NOT own cstr
// defer C.free(unsafe.Point(cstr))
return C.GoString(cstr)
}
func (l *leafFImpl) GetValuePointer() uintptr {
ptr := C.CRoot_Leaf_GetValuePointer(l.as_tleaf())
return uintptr(ptr)
}
func (l *leafFImpl) as_tleaf() C.CRoot_Leaf {
return (C.CRoot_Leaf)(unsafe.Pointer(l.c))
}
// LeafD
type LeafD interface {
Leaf
GetValue(idx int) float64
}
type leafDImpl struct {
c C.CRoot_LeafD
}
func (l *leafDImpl) GetValue(idx int) float64 {
o := C.CRoot_LeafD_GetValue(l.c, C.int(idx))
return float64(o)
}
func (l *leafDImpl) GetLenStatic() int {
return int(C.CRoot_Leaf_GetLenStatic(l.as_tleaf()))
}
func (l *leafDImpl) GetLeafCount() Leaf {
c := C.CRoot_Leaf_GetLeafCount(l.as_tleaf())
obj := objectImpl{c: (C.CRoot_Object)(c)}
return to_gocroot(&obj).(Leaf)
}
func (l *leafDImpl) GetTypeName() string {
cstr := C.CRoot_Leaf_GetTypeName(l.as_tleaf())
// we do NOT own cstr
// defer C.free(unsafe.Point(cstr))
return C.GoString(cstr)
}
func (l *leafDImpl) GetValuePointer() uintptr {
ptr := C.CRoot_Leaf_GetValuePointer(l.as_tleaf())
return uintptr(ptr)
}
func (l *leafDImpl) as_tleaf() C.CRoot_Leaf {
return (C.CRoot_Leaf)(unsafe.Pointer(l.c))
}
// LeafO
type LeafO interface {
Leaf
GetValue(idx int) float64
}
type leafOImpl struct {
c C.CRoot_LeafO
}
func (l *leafOImpl) GetValue(idx int) float64 {
o := C.CRoot_LeafO_GetValue(l.c, C.int(idx))
return float64(o)
}
func (l *leafOImpl) GetLenStatic() int {
return int(C.CRoot_Leaf_GetLenStatic(l.as_tleaf()))
}
func (l *leafOImpl) GetLeafCount() Leaf {
c := C.CRoot_Leaf_GetLeafCount(l.as_tleaf())
obj := objectImpl{c: (C.CRoot_Object)(c)}
return to_gocroot(&obj).(Leaf)
}
func (l *leafOImpl) GetTypeName() string {
cstr := C.CRoot_Leaf_GetTypeName(l.as_tleaf())
// we do NOT own cstr
// defer C.free(unsafe.Point(cstr))
return C.GoString(cstr)
}
func (l *leafOImpl) GetValuePointer() uintptr {
ptr := C.CRoot_Leaf_GetValuePointer(l.as_tleaf())
return uintptr(ptr)
}
func (l *leafOImpl) as_tleaf() C.CRoot_Leaf {
return (C.CRoot_Leaf)(unsafe.Pointer(l.c))
}