1// Code generated by xtgen; DO NOT EDIT.
2package render
3
4import "bnema.dev/xturbo/xproto"
5import "encoding/binary"
6
7// QueryVersionReply is a zero-copy view over a QueryVersion reply; offsets count from reply byte 0.
8// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
9type QueryVersionReply struct{ raw []byte }
10
11// ParseQueryVersionReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
12func ParseQueryVersionReply(raw []byte) (QueryVersionReply, bool) {
13 if len(raw) < 32 {
14 return QueryVersionReply{}, false
15 }
16 r := QueryVersionReply{raw: raw}
17 return r, true
18}
19func (r QueryVersionReply) Raw() []byte { return r.raw }
20func (r QueryVersionReply) MajorVersion() uint32 {
21 return uint32(binary.LittleEndian.Uint32(r.raw[8:]))
22}
23func (r QueryVersionReply) MinorVersion() uint32 {
24 return uint32(binary.LittleEndian.Uint32(r.raw[12:]))
25}
26
27// QueryPictFormatsReply is a zero-copy view over a QueryPictFormats reply; offsets count from reply byte 0.
28// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
29type QueryPictFormatsReply struct{ raw []byte }
30
31// ParseQueryPictFormatsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
32func ParseQueryPictFormatsReply(raw []byte) (QueryPictFormatsReply, bool) {
33 if len(raw) < 32 {
34 return QueryPictFormatsReply{}, false
35 }
36 r := QueryPictFormatsReply{raw: raw}
37 off := 32
38 {
39 n := int(r.NumFormats())
40 if n < 0 || n > len(r.raw) {
41 return QueryPictFormatsReply{}, false
42 }
43 off += n * 28
44 }
45 if off > len(r.raw) {
46 return QueryPictFormatsReply{}, false
47 }
48 {
49 n := int(r.NumScreens())
50 if off > len(r.raw) || n < 0 || n > len(r.raw) {
51 return QueryPictFormatsReply{}, false
52 }
53 it := NewPictscreenIter(r.raw[off:], n)
54 for it.Next() {
55 off += it.Value().Size()
56 }
57 if it.Err() {
58 return QueryPictFormatsReply{}, false
59 }
60 }
61 {
62 n := int(r.NumSubpixel())
63 if n < 0 || n > len(r.raw) {
64 return QueryPictFormatsReply{}, false
65 }
66 off += n * 4
67 }
68 if off > len(r.raw) {
69 return QueryPictFormatsReply{}, false
70 }
71 if off > len(r.raw) {
72 return QueryPictFormatsReply{}, false
73 }
74 return r, true
75}
76func (r QueryPictFormatsReply) Raw() []byte { return r.raw }
77func (r QueryPictFormatsReply) NumFormats() uint32 {
78 return uint32(binary.LittleEndian.Uint32(r.raw[8:]))
79}
80func (r QueryPictFormatsReply) NumScreens() uint32 {
81 return uint32(binary.LittleEndian.Uint32(r.raw[12:]))
82}
83func (r QueryPictFormatsReply) NumDepths() uint32 {
84 return uint32(binary.LittleEndian.Uint32(r.raw[16:]))
85}
86func (r QueryPictFormatsReply) NumVisuals() uint32 {
87 return uint32(binary.LittleEndian.Uint32(r.raw[20:]))
88}
89func (r QueryPictFormatsReply) NumSubpixel() uint32 {
90 return uint32(binary.LittleEndian.Uint32(r.raw[24:]))
91}
92func (r QueryPictFormatsReply) Formats() PictforminfoList {
93 off := 32
94 end := off + (int(r.NumFormats()))*28
95 return PictforminfoList{b: r.raw[off:end:end]}
96}
97func (r QueryPictFormatsReply) Screens() PictscreenIter {
98 off := 32
99 {
100 n := int(r.NumFormats())
101 off += n * 28
102 }
103 return NewPictscreenIter(r.raw[off:], int(r.NumScreens()))
104}
105func (r QueryPictFormatsReply) Subpixels() SubPixelList {
106 off := 32
107 {
108 n := int(r.NumFormats())
109 off += n * 28
110 }
111 {
112 n := int(r.NumScreens())
113 it := NewPictscreenIter(r.raw[off:], n)
114 for it.Next() {
115 off += it.Value().Size()
116 }
117 }
118 end := off + (int(r.NumSubpixel()))*4
119 return SubPixelList{b: r.raw[off:end:end]}
120}
121
122// QueryPictIndexValuesReply is a zero-copy view over a QueryPictIndexValues reply; offsets count from reply byte 0.
123// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
124type QueryPictIndexValuesReply struct{ raw []byte }
125
126// ParseQueryPictIndexValuesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
127func ParseQueryPictIndexValuesReply(raw []byte) (QueryPictIndexValuesReply, bool) {
128 if len(raw) < 32 {
129 return QueryPictIndexValuesReply{}, false
130 }
131 r := QueryPictIndexValuesReply{raw: raw}
132 off := 32
133 {
134 n := int(r.NumValues())
135 if n < 0 || n > len(r.raw) {
136 return QueryPictIndexValuesReply{}, false
137 }
138 off += n * 12
139 }
140 if off > len(r.raw) {
141 return QueryPictIndexValuesReply{}, false
142 }
143 if off > len(r.raw) {
144 return QueryPictIndexValuesReply{}, false
145 }
146 return r, true
147}
148func (r QueryPictIndexValuesReply) Raw() []byte { return r.raw }
149func (r QueryPictIndexValuesReply) NumValues() uint32 {
150 return uint32(binary.LittleEndian.Uint32(r.raw[8:]))
151}
152func (r QueryPictIndexValuesReply) Values() IndexvalueList {
153 off := 32
154 end := off + (int(r.NumValues()))*12
155 return IndexvalueList{b: r.raw[off:end:end]}
156}
157
158// QueryFiltersReply is a zero-copy view over a QueryFilters reply; offsets count from reply byte 0.
159// It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep.
160type QueryFiltersReply struct{ raw []byte }
161
162// ParseQueryFiltersReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check.
163func ParseQueryFiltersReply(raw []byte) (QueryFiltersReply, bool) {
164 if len(raw) < 32 {
165 return QueryFiltersReply{}, false
166 }
167 r := QueryFiltersReply{raw: raw}
168 off := 32
169 {
170 n := int(r.NumAliases())
171 if n < 0 || n > len(r.raw) {
172 return QueryFiltersReply{}, false
173 }
174 off += n * 2
175 }
176 if off > len(r.raw) {
177 return QueryFiltersReply{}, false
178 }
179 {
180 n := int(r.NumFilters())
181 if off > len(r.raw) || n < 0 || n > len(r.raw) {
182 return QueryFiltersReply{}, false
183 }
184 it := xproto.NewStrIter(r.raw[off:], n)
185 for it.Next() {
186 off += it.Value().Size()
187 }
188 if it.Err() {
189 return QueryFiltersReply{}, false
190 }
191 }
192 if off > len(r.raw) {
193 return QueryFiltersReply{}, false
194 }
195 return r, true
196}
197func (r QueryFiltersReply) Raw() []byte { return r.raw }
198func (r QueryFiltersReply) NumAliases() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) }
199func (r QueryFiltersReply) NumFilters() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[12:])) }
200func (r QueryFiltersReply) Aliases() Uint16List {
201 off := 32
202 end := off + (int(r.NumAliases()))*2
203 return Uint16List{b: r.raw[off:end:end]}
204}
205func (r QueryFiltersReply) Filters() xproto.StrIter {
206 off := 32
207 {
208 n := int(r.NumAliases())
209 off += n * 2
210 }
211 return xproto.NewStrIter(r.raw[off:], int(r.NumFilters()))
212}
213
214// PictdepthView is a zero-copy view over one wire-encoded Pictdepth, yielded by PictdepthIter.
215// It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep.
216type PictdepthView struct{ raw []byte }
217
218func (v PictdepthView) Raw() []byte { return v.raw }
219
220// Size is the element's wire size, including trailing alignment.
221func (v PictdepthView) Size() int { return len(v.raw) }
222func sizePictdepth(p []byte) int {
223 if len(p) < 8 {
224 return -1
225 }
226 v := PictdepthView{raw: p}
227 _ = v
228 off := 8
229 {
230 n := int(v.NumVisuals())
231 if n < 0 || n > len(v.raw) {
232 return -1
233 }
234 off += n * 8
235 }
236 if off > len(v.raw) {
237 return -1
238 }
239 if off > len(v.raw) {
240 return -1
241 }
242 return off
243}
244func (v PictdepthView) Depth() uint8 { return uint8(v.raw[0:][0]) }
245func (v PictdepthView) NumVisuals() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[2:])) }
246func (v PictdepthView) Visuals() PictvisualList {
247 off := 8
248 end := off + (int(v.NumVisuals()))*8
249 return PictvisualList{b: v.raw[off:end:end]}
250}
251
252// PictdepthIter walks n consecutive Pictdepth elements; Err reports a malformed length.
253// It shares the lifetime of the bytes it walks.
254type PictdepthIter struct {
255 b []byte
256 n int
257 v PictdepthView
258 err bool
259}
260
261// NewPictdepthIter iterates n elements encoded at the start of b.
262func NewPictdepthIter(b []byte, n int) PictdepthIter { return PictdepthIter{b: b, n: n} }
263func (it *PictdepthIter) Next() bool {
264 if it.n <= 0 || it.err {
265 return false
266 }
267 s := sizePictdepth(it.b)
268 if s < 0 {
269 it.err = true
270 it.n = 0
271 return false
272 }
273 it.v = PictdepthView{raw: it.b[:s:s]}
274 it.b = it.b[s:]
275 it.n--
276 return true
277}
278func (it *PictdepthIter) Value() PictdepthView { return it.v }
279func (it *PictdepthIter) Err() bool { return it.err }
280
281// PictscreenView is a zero-copy view over one wire-encoded Pictscreen, yielded by PictscreenIter.
282// It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep.
283type PictscreenView struct{ raw []byte }
284
285func (v PictscreenView) Raw() []byte { return v.raw }
286
287// Size is the element's wire size, including trailing alignment.
288func (v PictscreenView) Size() int { return len(v.raw) }
289func sizePictscreen(p []byte) int {
290 if len(p) < 8 {
291 return -1
292 }
293 v := PictscreenView{raw: p}
294 _ = v
295 off := 8
296 {
297 n := int(v.NumDepths())
298 if off > len(v.raw) || n < 0 || n > len(v.raw) {
299 return -1
300 }
301 it := NewPictdepthIter(v.raw[off:], n)
302 for it.Next() {
303 off += it.Value().Size()
304 }
305 if it.Err() {
306 return -1
307 }
308 }
309 if off > len(v.raw) {
310 return -1
311 }
312 return off
313}
314func (v PictscreenView) NumDepths() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[0:])) }
315func (v PictscreenView) Fallback() Pictformat {
316 return Pictformat(binary.LittleEndian.Uint32(v.raw[4:]))
317}
318func (v PictscreenView) Depths() PictdepthIter {
319 off := 8
320 return NewPictdepthIter(v.raw[off:], int(v.NumDepths()))
321}
322
323// PictscreenIter walks n consecutive Pictscreen elements; Err reports a malformed length.
324// It shares the lifetime of the bytes it walks.
325type PictscreenIter struct {
326 b []byte
327 n int
328 v PictscreenView
329 err bool
330}
331
332// NewPictscreenIter iterates n elements encoded at the start of b.
333func NewPictscreenIter(b []byte, n int) PictscreenIter { return PictscreenIter{b: b, n: n} }
334func (it *PictscreenIter) Next() bool {
335 if it.n <= 0 || it.err {
336 return false
337 }
338 s := sizePictscreen(it.b)
339 if s < 0 {
340 it.err = true
341 it.n = 0
342 return false
343 }
344 it.v = PictscreenView{raw: it.b[:s:s]}
345 it.b = it.b[s:]
346 it.n--
347 return true
348}
349func (it *PictscreenIter) Value() PictscreenView { return it.v }
350func (it *PictscreenIter) Err() bool { return it.err }
351
352// IndexvalueList is a borrowed view over a wire list of Indexvalue. It shares the lifetime of the bytes it was taken from; copy what you keep.
353type IndexvalueList struct{ b []byte }
354
355func (l IndexvalueList) Len() int { return len(l.b) / 12 }
356func (l IndexvalueList) At(i int) Indexvalue { return GetIndexvalue(l.b[i*12:]) }
357
358// PictforminfoList is a borrowed view over a wire list of Pictforminfo. It shares the lifetime of the bytes it was taken from; copy what you keep.
359type PictforminfoList struct{ b []byte }
360
361func (l PictforminfoList) Len() int { return len(l.b) / 28 }
362func (l PictforminfoList) At(i int) Pictforminfo { return GetPictforminfo(l.b[i*28:]) }
363
364// PictvisualList is a borrowed view over a wire list of Pictvisual. It shares the lifetime of the bytes it was taken from; copy what you keep.
365type PictvisualList struct{ b []byte }
366
367func (l PictvisualList) Len() int { return len(l.b) / 8 }
368func (l PictvisualList) At(i int) Pictvisual { return GetPictvisual(l.b[i*8:]) }
369
370// SubPixelList is a borrowed view over a wire list of SubPixel. It shares the lifetime of the bytes it was taken from; copy what you keep.
371type SubPixelList struct{ b []byte }
372
373func (l SubPixelList) Len() int { return len(l.b) / 4 }
374func (l SubPixelList) At(i int) SubPixel { return SubPixel(binary.LittleEndian.Uint32(l.b[i*4:])) }
375
376// Uint16List is a borrowed view over a wire list of uint16. It shares the lifetime of the bytes it was taken from; copy what you keep.
377type Uint16List struct{ b []byte }
378
379func (l Uint16List) Len() int { return len(l.b) / 2 }
380func (l Uint16List) At(i int) uint16 { return uint16(binary.LittleEndian.Uint16(l.b[i*2:])) }