• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fyne-io / fyne / 13039703786

29 Jan 2025 08:16PM UTC coverage: 62.656% (+1.8%) from 60.858%
13039703786

Pull #5480

github

Jacalz
Cleanup the generator script to not generate lists and trees
Pull Request #5480: Clean up tree bindings with generics

188 of 216 new or added lines in 2 files covered. (87.04%)

1 existing line in 1 file now uncovered.

24922 of 39776 relevant lines covered (62.66%)

845.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

26.09
/data/binding/bindtrees.go
1
package binding
2

3
import (
4
        "bytes"
5

6
        "fyne.io/fyne/v2"
7
)
8

9
// BoolTree supports binding a tree of bool values.
10
//
11
// Since: 2.4
12
type BoolTree interface {
13
        DataTree
14

15
        Append(parent, id string, value bool) error
16
        Get() (map[string][]string, map[string]bool, error)
17
        GetValue(id string) (bool, error)
18
        Prepend(parent, id string, value bool) error
19
        Remove(id string) error
20
        Set(ids map[string][]string, values map[string]bool) error
21
        SetValue(id string, value bool) error
22
}
23

24
// ExternalBoolTree supports binding a tree of bool values from an external variable.
25
//
26
// Since: 2.4
27
type ExternalBoolTree interface {
28
        BoolTree
29

30
        Reload() error
31
}
32

33
// NewBoolTree returns a bindable tree of bool values.
34
//
35
// Since: 2.4
36
func NewBoolTree() BoolTree {
×
NEW
37
        return newTreeComparable[bool]()
×
38
}
×
39

40
// BindBoolTree returns a bound tree of bool values, based on the contents of the passed values.
41
// The ids map specifies how each item relates to its parent (with id ""), with the values being in the v map.
42
// If your code changes the content of the maps this refers to you should call Reload() to inform the bindings.
43
//
44
// Since: 2.4
45
func BindBoolTree(ids *map[string][]string, v *map[string]bool) ExternalBoolTree {
×
NEW
46
        return bindTreeComparable(ids, v)
×
47
}
×
48

49
// BytesTree supports binding a tree of []byte values.
50
//
51
// Since: 2.4
52
type BytesTree interface {
53
        DataTree
54

55
        Append(parent, id string, value []byte) error
56
        Get() (map[string][]string, map[string][]byte, error)
57
        GetValue(id string) ([]byte, error)
58
        Prepend(parent, id string, value []byte) error
59
        Remove(id string) error
60
        Set(ids map[string][]string, values map[string][]byte) error
61
        SetValue(id string, value []byte) error
62
}
63

64
// ExternalBytesTree supports binding a tree of []byte values from an external variable.
65
//
66
// Since: 2.4
67
type ExternalBytesTree interface {
68
        BytesTree
69

70
        Reload() error
71
}
72

73
// NewBytesTree returns a bindable tree of []byte values.
74
//
75
// Since: 2.4
76
func NewBytesTree() BytesTree {
×
NEW
77
        return newTree(bytes.Equal)
×
78
}
×
79

80
// BindBytesTree returns a bound tree of []byte values, based on the contents of the passed values.
81
// The ids map specifies how each item relates to its parent (with id ""), with the values being in the v map.
82
// If your code changes the content of the maps this refers to you should call Reload() to inform the bindings.
83
//
84
// Since: 2.4
85
func BindBytesTree(ids *map[string][]string, v *map[string][]byte) ExternalBytesTree {
×
NEW
86
        return bindTree(ids, v, bytes.Equal)
×
87
}
×
88

89
// FloatTree supports binding a tree of float64 values.
90
//
91
// Since: 2.4
92
type FloatTree interface {
93
        DataTree
94

95
        Append(parent, id string, value float64) error
96
        Get() (map[string][]string, map[string]float64, error)
97
        GetValue(id string) (float64, error)
98
        Prepend(parent, id string, value float64) error
99
        Remove(id string) error
100
        Set(ids map[string][]string, values map[string]float64) error
101
        SetValue(id string, value float64) error
102
}
103

104
// ExternalFloatTree supports binding a tree of float64 values from an external variable.
105
//
106
// Since: 2.4
107
type ExternalFloatTree interface {
108
        FloatTree
109

110
        Reload() error
111
}
112

113
// NewFloatTree returns a bindable tree of float64 values.
114
//
115
// Since: 2.4
116
func NewFloatTree() FloatTree {
1✔
117
        return newTreeComparable[float64]()
1✔
118
}
1✔
119

120
// BindFloatTree returns a bound tree of float64 values, based on the contents of the passed values.
121
// The ids map specifies how each item relates to its parent (with id ""), with the values being in the v map.
122
// If your code changes the content of the maps this refers to you should call Reload() to inform the bindings.
123
//
124
// Since: 2.4
125
func BindFloatTree(ids *map[string][]string, v *map[string]float64) ExternalFloatTree {
2✔
126
        return bindTreeComparable(ids, v)
2✔
127
}
2✔
128

129
// IntTree supports binding a tree of int values.
130
//
131
// Since: 2.4
132
type IntTree interface {
133
        DataTree
134

135
        Append(parent, id string, value int) error
136
        Get() (map[string][]string, map[string]int, error)
137
        GetValue(id string) (int, error)
138
        Prepend(parent, id string, value int) error
139
        Remove(id string) error
140
        Set(ids map[string][]string, values map[string]int) error
141
        SetValue(id string, value int) error
142
}
143

144
// ExternalIntTree supports binding a tree of int values from an external variable.
145
//
146
// Since: 2.4
147
type ExternalIntTree interface {
148
        IntTree
149

150
        Reload() error
151
}
152

153
// NewIntTree returns a bindable tree of int values.
154
//
155
// Since: 2.4
156
func NewIntTree() IntTree {
×
NEW
157
        return newTreeComparable[int]()
×
158
}
×
159

160
// BindIntTree returns a bound tree of int values, based on the contents of the passed values.
161
// The ids map specifies how each item relates to its parent (with id ""), with the values being in the v map.
162
// If your code changes the content of the maps this refers to you should call Reload() to inform the bindings.
163
//
164
// Since: 2.4
165
func BindIntTree(ids *map[string][]string, v *map[string]int) ExternalIntTree {
×
NEW
166
        return bindTreeComparable(ids, v)
×
167
}
×
168

169
// RuneTree supports binding a tree of rune values.
170
//
171
// Since: 2.4
172
type RuneTree interface {
173
        DataTree
174

175
        Append(parent, id string, value rune) error
176
        Get() (map[string][]string, map[string]rune, error)
177
        GetValue(id string) (rune, error)
178
        Prepend(parent, id string, value rune) error
179
        Remove(id string) error
180
        Set(ids map[string][]string, values map[string]rune) error
181
        SetValue(id string, value rune) error
182
}
183

184
// ExternalRuneTree supports binding a tree of rune values from an external variable.
185
//
186
// Since: 2.4
187
type ExternalRuneTree interface {
188
        RuneTree
189

190
        Reload() error
191
}
192

193
// NewRuneTree returns a bindable tree of rune values.
194
//
195
// Since: 2.4
NEW
196
func NewRuneTree() RuneTree {
×
NEW
197
        return newTreeComparable[rune]()
×
UNCOV
198
}
×
199

200
// BindRuneTree returns a bound tree of rune values, based on the contents of the passed values.
201
// The ids map specifies how each item relates to its parent (with id ""), with the values being in the v map.
202
// If your code changes the content of the maps this refers to you should call Reload() to inform the bindings.
203
//
204
// Since: 2.4
205
func BindRuneTree(ids *map[string][]string, v *map[string]rune) ExternalRuneTree {
×
NEW
206
        return bindTreeComparable(ids, v)
×
207
}
×
208

209
// StringTree supports binding a tree of string values.
210
//
211
// Since: 2.4
212
type StringTree interface {
213
        DataTree
214

215
        Append(parent, id string, value string) error
216
        Get() (map[string][]string, map[string]string, error)
217
        GetValue(id string) (string, error)
218
        Prepend(parent, id string, value string) error
219
        Remove(id string) error
220
        Set(ids map[string][]string, values map[string]string) error
221
        SetValue(id string, value string) error
222
}
223

224
// ExternalStringTree supports binding a tree of string values from an external variable.
225
//
226
// Since: 2.4
227
type ExternalStringTree interface {
228
        StringTree
229

230
        Reload() error
231
}
232

233
// NewStringTree returns a bindable tree of string values.
234
//
235
// Since: 2.4
236
func NewStringTree() StringTree {
4✔
237
        return newTreeComparable[string]()
4✔
238
}
4✔
239

240
// BindStringTree returns a bound tree of string values, based on the contents of the passed values.
241
// The ids map specifies how each item relates to its parent (with id ""), with the values being in the v map.
242
// If your code changes the content of the maps this refers to you should call Reload() to inform the bindings.
243
//
244
// Since: 2.4
245
func BindStringTree(ids *map[string][]string, v *map[string]string) ExternalStringTree {
1✔
246
        return bindTreeComparable(ids, v)
1✔
247
}
1✔
248

249
// UntypedTree supports binding a tree of any values.
250
//
251
// Since: 2.5
252
type UntypedTree interface {
253
        DataTree
254

255
        Append(parent, id string, value any) error
256
        Get() (map[string][]string, map[string]any, error)
257
        GetValue(id string) (any, error)
258
        Prepend(parent, id string, value any) error
259
        Remove(id string) error
260
        Set(ids map[string][]string, values map[string]any) error
261
        SetValue(id string, value any) error
262
}
263

264
// ExternalUntypedTree supports binding a tree of any values from an external variable.
265
//
266
// Since: 2.5
267
type ExternalUntypedTree interface {
268
        UntypedTree
269

270
        Reload() error
271
}
272

273
// NewUntypedTree returns a bindable tree of any values.
274
//
275
// Since: 2.5
276
func NewUntypedTree() UntypedTree {
×
NEW
277
        return newTree(func(a1, a2 any) bool { return a1 == a2 })
×
278
}
279

280
// BindUntypedTree returns a bound tree of any values, based on the contents of the passed values.
281
// The ids map specifies how each item relates to its parent (with id ""), with the values being in the v map.
282
// If your code changes the content of the maps this refers to you should call Reload() to inform the bindings.
283
//
284
// Since: 2.4
285
func BindUntypedTree(ids *map[string][]string, v *map[string]any) ExternalUntypedTree {
×
NEW
286
        return bindTree(ids, v, func(a1, a2 any) bool { return a1 == a2 })
×
287
}
288

289
// URITree supports binding a tree of fyne.URI values.
290
//
291
// Since: 2.4
292
type URITree interface {
293
        DataTree
294

295
        Append(parent, id string, value fyne.URI) error
296
        Get() (map[string][]string, map[string]fyne.URI, error)
297
        GetValue(id string) (fyne.URI, error)
298
        Prepend(parent, id string, value fyne.URI) error
299
        Remove(id string) error
300
        Set(ids map[string][]string, values map[string]fyne.URI) error
301
        SetValue(id string, value fyne.URI) error
302
}
303

304
// ExternalURITree supports binding a tree of fyne.URI values from an external variable.
305
//
306
// Since: 2.4
307
type ExternalURITree interface {
308
        URITree
309

310
        Reload() error
311
}
312

313
// NewURITree returns a bindable tree of fyne.URI values.
314
//
315
// Since: 2.4
316
func NewURITree() URITree {
×
NEW
317
        return newTree(compareURI)
×
318
}
×
319

320
// BindURITree returns a bound tree of fyne.URI values, based on the contents of the passed values.
321
// The ids map specifies how each item relates to its parent (with id ""), with the values being in the v map.
322
// If your code changes the content of the maps this refers to you should call Reload() to inform the bindings.
323
//
324
// Since: 2.4
325
func BindURITree(ids *map[string][]string, v *map[string]fyne.URI) ExternalURITree {
×
NEW
326
        return bindTree(ids, v, compareURI)
×
327
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc