25414fa3d05dd3adba462bf69f9dbdd0b725cf56
[panamaz] / src / notzed.vulkan / gen / struct-types.api
1 # -*- Mode:text; tab-width:4; electric-indent-mode: nil; indent-line-function:insert-tab; -*-
2
3 # types for structs and unions
4
5 # ###################################################################### #
6
7 #accessor=code template
8 # {type} - java type
9 # {java-get}
10 # {java-set}
11 # {init}*
12
13 code value {
14   get {{
15         /* {deref} */
16         public {type} get{Name}() {
17                 return {java-get};
18         }
19   }}
20   set {{
21         /* {deref} */
22         public void set{Name}({type} {name}) {
23                 {java-set};
24         }
25   }}
26   getat {{
27         public {type} get{Name}AtIndex(long i$) {
28                 return {java-getat};
29         }
30   }}
31   setat {{
32         public void set{Name}AtIndex(long i$, {type} {name}) {
33                 {java-setat};
34         }
35   }}
36
37   # FIXME: only handles single element arrays
38   init  {{ {name}$VH.set(this.segment, VkConstants.{values}); }}
39
40   # for complex constructors?
41   setall-arg {{ {type} {name} /* value */ }}
42   setall {{ self$.set{Name}({name}); }}
43 }
44
45 code value-array {
46   getorset {{
47         /* value-array {deref} */
48         public {type} get{Name}() {
49                 try {
50                         return {java-get};
51                 } catch (Throwable t) {
52                         throw new RuntimeException(t);
53                 }
54         }
55         public {typei} get{Name}Element(int i$) {
56                 return {java-geti};
57         }
58         public void set{Name}Element(int i$, {typei} {name}) {
59                 {java-seti};
60         }
61   }}
62
63   setall-arg eval {{
64         if ($m->{len1} <= 4) {
65                 join ", ", map { '{typei} {name}$'.$_ } (0 .. $m->{len1}-1);
66         } else {
67                 "{typei}[] {name} /* $m->{deref} $m->{len1} */";
68         }
69   }}
70   setall eval {{
71         if ($m->{len1} <= 4) {
72                 join "\n\t", map { "self\$.set{Name}Element($_, {name}\$$_);" } (0 .. $m->{len1}-1);
73     } else {
74                 <<END;
75                 if ({name} != null) {
76                         try {
77                                 ((MemorySegment){name}\$SH.invokeExact(self\$.segment)).copyFrom(MemorySegment.ofArray({name}));
78                         } catch (Throwable t) {
79                                 System.err.println("Copy error: " + t.getLocalizedMessage());
80                         }
81                 }
82 END
83     }
84   }}
85 }
86
87 code value-array2d {
88   getorset {{
89         /* value-array2d {deref} */
90         public {type} get{Name}() {
91                 try {
92                         return {java-get};
93                 } catch (Throwable t) {
94                         throw new RuntimeException(t);
95                 }
96         }
97         public {typei} get{Name}Element(int i$, int j$) {
98                 return {java-geti};
99         }
100         public void set{Name}Element(int i$, int j$, {typei} {name}) {
101                 {java-seti};
102         }
103   }}
104 }
105
106 code inline {
107   getorset {{
108         /* inline {deref} */
109         public {type} get{Name}() {
110                 try {
111                         return {java-get};
112                 } catch (Throwable t) {
113                         throw new RuntimeException(t);
114                 }
115         }
116   }}
117 }
118
119 # value with a SegmentAllocator passed to set()
120 code value-alloc {
121   get {{
122         /* {deref} */
123         public {type} get{Name}() {
124                 return {java-get};
125         }
126   }}
127   set {{
128         /* {deref} */
129         public void set{Name}({type} {name}, SegmentAllocator alloc$) {
130                 {java-set};
131         }
132   }}
133   getat {{
134         /* {deref} */
135         public {type} get{Name}AtIndex(long i$) {
136                 return {java-getat};
137         }
138   }}
139   setat {{
140         /* {deref} */
141         public void set{Name}AtIndex(long i$, {type} {name}, SegmentAllocator alloc$) {
142                 {java-setat};
143         }
144   }}
145   setall-arg {{ {type} {name} }}
146   setall {{ self$.set{Name}({name}, alloc$); }}
147 }
148
149 # implied accessors are ignored in constructors
150 code value-implied {
151   get {{
152         /* {deref} */
153         public {type} get{Name}() {
154                 return {java-get};
155         }
156   }}
157   set {{
158         /* {deref} */
159         public void set{Name}({type} {name}) {
160                 {java-set};
161         }
162   }}
163
164   # supposed to be handled in set of the target, but ...?
165   setall {{ self$.set{Name}(({type})Memory.length({lengthfor})); }}
166 }
167
168 # ###################################################################### #
169
170 code dispatch {
171   class {{
172         // template: dispatch:class
173         package {package};
174         import jdk.incubator.foreign.*;
175         import java.lang.invoke.*;
176         import au.notzed.nativez.*;
177         class {Name} {
178
179                 {field-init}
180
181                 {Name}(VkInstance instance$, ResourceScope scope$) {
182                         {init}
183                 }
184         }
185   }}
186   field-init {{ final NativeSymbol {name}$NS; }}
187   init {{ {name}$NS = instance$.vkGetInstanceProcAddr("{name}", scope$); }}
188
189 }
190
191 # non-dispatchable handle
192 code handle {
193   class {{
194         // template: handle:class
195         package {package};
196         import jdk.incubator.foreign.*;
197         import java.lang.invoke.*;
198         import au.notzed.nativez.*;
199
200         public class {name} implements Pointer {
201                 final NativeSymbol self;
202
203                 private {name}(MemoryAddress address, ResourceScope scope) {
204                         this.self = NativeSymbol.ofAddress("{name}", address, scope);
205                         {init}
206                 }
207
208                 public static {name} create(MemoryAddress address, ResourceScope scope) {
209                         return new {name}(address, scope);
210                 }
211
212                 public static HandleArray<{name}> createArray(long length, SegmentAllocator alloc) {
213                         return HandleArray.createArray(length, alloc, {name}::create);
214                 }
215
216                 public MemoryAddress address() {
217                         return self.address();
218                 }
219
220                 public ResourceScope scope() {
221                         return self.scope();
222                 }
223         }
224   }}
225 }
226
227 # VkInstance
228 code handle-instance {
229   class {{
230         // template: handle-instance:class
231         package {package};
232         import jdk.incubator.foreign.*;
233         import java.lang.invoke.*;
234         import au.notzed.nativez.*;
235
236         public class {name} implements Pointer {
237                 final NativeSymbol self;
238                 final DispatchInstance dispatch;
239
240                 private {name}(MemoryAddress address, ResourceScope scope) {
241                         this.self = NativeSymbol.ofAddress("{name}", address, scope);
242                         this.dispatch = new DispatchInstance(this, scope);
243                         {init}
244                 }
245
246                 public static {name} create(MemoryAddress address, ResourceScope scope) {
247                         return new {name}(address, scope);
248                 }
249
250                 public MemoryAddress address() {
251                         return self.address();
252                 }
253
254                 public ResourceScope scope() {
255                         return self.scope();
256                 }
257
258                 {commands}
259         }
260   }}
261 }
262
263 # dispatchable handle
264 code handle-dispatch {
265   class {{
266         // template: handle-dispatch:class
267         package {package};
268         import jdk.incubator.foreign.*;
269         import java.lang.invoke.*;
270         import au.notzed.nativez.*;
271
272         public class {name} implements Pointer {
273                 final NativeSymbol self;
274                 final DispatchInstance dispatch;
275
276                 private {name}(MemoryAddress address, DispatchInstance dispatch, ResourceScope scope) {
277                         this.self = NativeSymbol.ofAddress("{name}", address, scope);
278                         this.dispatch = dispatch;
279                         {init}
280                 }
281
282                 public static {name} create(MemoryAddress address, DispatchInstance dispatch, ResourceScope scope) {
283                         return new {name}(address, dispatch, scope);
284                 }
285
286                 // TODO: evaluate how scope fits here
287                 public static HandleArray<{name}> createArray(long length, SegmentAllocator alloc, DispatchInstance dispatch, ResourceScope scope) {
288                         return HandleArray.createArray(length, alloc, (a, s) -> create(a, dispatch, s), scope);
289                 }
290
291                 public static HandleArray<{name}> createArray(long length, SegmentAllocator alloc, VkInstance instance, ResourceScope scope) {
292                         return HandleArray.createArray(length, alloc, (a, s) -> create(a, instance.dispatch, s), scope);
293                 }
294
295                 public MemoryAddress address() {
296                         return self.address();
297                 }
298
299                 public ResourceScope scope() {
300                         return self.scope();
301                 }
302
303                 {commands}
304         }
305   }}
306 }
307
308 # ###################################################################### #
309
310 # shared struct components
311 code struct {
312   header {{
313                 public MemorySegment segment;
314
315                 public static final GroupLayout LAYOUT = {layout};
316
317                 private {Name}(MemorySegment segment) {
318                         this.segment = segment;
319                         {init}
320                 }
321
322                 public static {Name} create(MemorySegment segment) {
323                         return new {Name}(segment);
324                 }
325
326                 public static {Name} create(MemoryAddress address, ResourceScope scope) {
327                         return new {Name}(MemorySegment.ofAddress(address, LAYOUT.byteSize(), scope));
328                 }
329
330                 public static {Name} create(SegmentAllocator alloc) {
331                         return new {Name}(alloc.allocate(LAYOUT));
332                 }
333
334                 // Pointer
335                 @Override
336                 public MemoryAddress address() {
337                         return segment.address();
338                 }
339
340                 // Pointer
341                 @Override
342                 public ResourceScope scope() {
343                         return segment.scope();
344                 }
345
346                 @Override
347                 public String toString() {
348                         return Memory.toString(segment, LAYOUT);
349                 }
350   }}
351   create-all {{
352                 public static {Name} {create}({java-setall-arguments}) {
353                         {Name} self$ = create(alloc$.allocate(LAYOUT));
354
355                         {java-setall}
356
357                         return self$;
358                 }
359   }}
360   set-all {{
361                 public void init({java-setall-arguments}) {
362                         {Name} self$ = this;
363
364                         {java-setall}
365                 }
366   }}
367   array {{
368                 static {Name} createArray(MemoryAddress addr, long length, ResourceScope scope) {
369                         return new {Name}(MemorySegment.ofAddress(addr, length * LAYOUT.byteSize(), scope));
370                 }
371
372                 public static {Name} createArray(long length, SegmentAllocator alloc) {
373                         return new {Name}(alloc.allocateArray(LAYOUT, length));
374                 }
375
376                 public final static MethodHandle LAYOUT$SH = MemoryLayout.sequenceLayout(LAYOUT).sliceHandle(MemoryLayout.PathElement.sequenceElement());
377
378                 // Array
379                 @Override
380                 public long length() {
381                         return segment.byteSize() / LAYOUT.byteSize();
382                 }
383
384                 // Array
385                 #Override
386                 public {Name} getAtIndex(long index$) {
387                         try {
388                                 return create((MemorySegment)LAYOUT$SH.invokeExact(this.segment, index$));
389                         } catch (Throwable t) {
390                                 throw new RuntimeException(t);
391                         }
392                 }
393   }}
394 }
395
396 # default - writeonly struct
397 code struct-writeonly insert=struct:header,struct:create-all
398         fields=init,set,getorset,handle,java-setall {
399   class {{
400         // template: struct-writeonly:class
401         package {package};
402         import jdk.incubator.foreign.*;
403         import java.lang.invoke.*;
404         import au.notzed.nativez.*;
405
406         public class {Name} implements Pointer {
407                 {header}
408
409                 {create-all}
410
411                 {set}
412                 {getorset}
413
414                 {handle}
415         }
416   }}
417 }
418
419 code struct-writeonly-array insert=struct:header,struct:create-all,struct:array
420         fields=init,set,getorset,setat,getorsetat,handle,handleat,java-setall {
421   class {{
422         // template: struct-writeonly-array:class
423         package {package};
424         import jdk.incubator.foreign.*;
425         import java.lang.invoke.*;
426         import au.notzed.nativez.*;
427
428         public class {Name} implements Pointer, Array<{Name}> {
429                 {header}
430                 {array}
431
432                 {create-all}
433
434                 {set}
435                 {getorset}
436
437                 {setat}
438                 {getorsetat}
439
440                 {handle}
441                 {handleat}
442         }
443   }}
444 }
445
446 code struct-readonly insert=struct:header
447         fields=init,get,getorset,handle {
448   class {{
449         // template: struct-readonly:class
450         package {package};
451         import jdk.incubator.foreign.*;
452         import java.lang.invoke.*;
453         import au.notzed.nativez.*;
454
455         public class {Name} implements Pointer {
456                 {header}
457
458                 {get}
459                 {getorset}
460
461                 {handle}
462         }
463   }}
464 }
465
466 code struct-readonly-array insert=struct:header,struct:array
467         fields=init,get,getorset,getat,getorsetat,handle,handleat {
468   class {{
469         // template: struct-readonly-array:class
470         package {package};
471         import jdk.incubator.foreign.*;
472         import java.lang.invoke.*;
473         import au.notzed.nativez.*;
474
475         public class {Name} implements Pointer, Array<{Name}> {
476                 {header}
477                 {array}
478
479                 {get}
480                 {getorset}
481
482                 {getat}
483                 {getorsetat}
484
485                 {handle}
486                 {handleat}
487         }
488   }}
489 }
490
491 code struct-readwrite insert=struct:header,struct:create-all
492         fields=init,get,set,getorset,handle,java-setall {
493   class {{
494         // template: struct-readwrite:class
495         package {package};
496         import jdk.incubator.foreign.*;
497         import java.lang.invoke.*;
498         import au.notzed.nativez.*;
499
500         public class {Name} implements Pointer {
501                 {header}
502
503                 {create-all}
504
505                 {get}
506                 {set}
507                 {getorset}
508
509                 {handle}
510         }
511   }}
512 }
513
514 code struct-readwrite-array insert=struct:header,struct:create-all,struct:array
515         fields=init,get,getat,set,setat,getorset,getorsetat,handle,handleat,java-setall {
516   class {{
517         // template: struct-readwrite-array:class
518         package {package};
519         import jdk.incubator.foreign.*;
520         import java.lang.invoke.*;
521         import au.notzed.nativez.*;
522
523         public class {Name} implements Pointer,Array<{Name}> {
524                 {header}
525                 {array}
526
527                 {create-all}
528
529                 {get}
530                 {set}
531                 {getorset}
532
533                 {getat}
534                 {setat}
535                 {getorsetat}
536
537                 {handle}
538                 {handleat}
539         }
540   }}
541 }
542
543 # ###################################################################### #
544
545 # Basic value-based accessor
546 type value accessor=value {
547         native-value    {{ {name} }}
548
549         native-get              {{ ({type}){name}$VH.get(this.segment) }}
550         handle                  {{ final static VarHandle {name}$VH = LAYOUT.varHandle(MemoryLayout.PathElement.groupElement("{name}")); }}
551
552         java-get                {{ {native-get} }}
553         java-set                {{ {name}$VH.set(this.segment, {native-value}) }}
554
555         native-getat    {{ ({type}){name}$AH.get(this.segment, i$) }}
556         native-setat    {{ {name}$AH.set(this.segment, i$, {native-value}) }}
557         handleat                {{ final static VarHandle {name}$AH = MemoryLayout.sequenceLayout(LAYOUT).varHandle(MemoryLayout.PathElement.sequenceElement(), MemoryLayout.PathElement.groupElement("{name}")); }}
558
559         java-getat              {{ {native-getat} }}
560         java-setat              {{ {native-setat} }}
561 }
562
563 type value-array accessor=value-array {
564         native-get      {{ (MemorySegment){name}$SH.invokeExact(this.segment) }}
565         java-get        {{ {type}.create({native-get}) }}
566         java-geti       {{ ({typei}){name}$EH.get(this.segment, i$) }}
567         java-seti       {{ {name}$EH.set(this.segment, i$, {name}) }}
568         handle          {{
569                 final static MethodHandle {name}$SH = LAYOUT.sliceHandle(MemoryLayout.PathElement.groupElement("{name}"));
570                 final static VarHandle {name}$EH = LAYOUT.varHandle(MemoryLayout.PathElement.groupElement("{name}"), MemoryLayout.PathElement.sequenceElement());
571         }}
572 }
573
574 type value-array2d accessor=value-array2d {
575         native-get      {{ (MemorySegment){name}$SH.invokeExact(this.segment) }}
576         java-get        {{ {type}.create({native-get}) }}
577         java-geti       {{ ({typei}){name}$EH.get(this.segment, i$, j$) }}
578         java-seti       {{ {name}$EH.set(this.segment, i$, j$, {name}) }}
579         handle          {{
580                 final static MethodHandle {name}$SH = LAYOUT.sliceHandle(MemoryLayout.PathElement.groupElement("{name}"));
581                 final static VarHandle {name}$EH = LAYOUT.varHandle(MemoryLayout.PathElement.groupElement("{name}"), MemoryLayout.PathElement.sequenceElement(), MemoryLayout.PathElement.sequenceElement());
582         }}
583 }
584
585 type inline accessor=inline {
586         native-get      {{ (MemorySegment){name}$SH.invokeExact(this.segment) }}
587         java-get        {{ {type}.create({native-get}) }}
588         handle          {{ final static MethodHandle {name}$SH = LAYOUT.sliceHandle(MemoryLayout.PathElement.groupElement("{name}")); }}
589 }
590
591 type inline-array accessor=inline {
592 #       type            {{ MemorySegment }}
593         native-get      {{ (MemorySegment){name}$SH.invokeExact(this.segment) }}
594 #       java-get        {{ {native-get} }}
595         java-get        {{ {type}.create({native-get}) }}
596         handle          {{
597                 final static MethodHandle {name}$SH = LAYOUT.sliceHandle(MemoryLayout.PathElement.groupElement("{name}"));
598         }}
599 }
600
601 type uint8_t,char value {
602         type    {{ byte }}
603         layout  {{ Memory.BYTE }}
604 }
605
606 type uint16_t value {
607         type    {{ short }}
608         layout  {{ Memory.SHORT }}
609 }
610
611 type uint32_t,int,int32_t value {
612         type    {{ int }}
613         layout  {{ Memory.INT }}
614 }
615
616 type uint64_t,int64_t,size_t value {
617         type    {{ long }}
618         layout  {{ Memory.LONG }}
619 }
620
621 type float value {
622         type    {{ float }}
623         layout  {{ Memory.FLOAT }}
624 }
625
626 type double value {
627         type    {{ double }}
628         layout  {{ Memory.DOUBLE }}
629 }
630
631 # ###################################################################### #
632 # implied length types
633 type uint64_t-implied,size_t-implied uint64_t accessor=value-implied {
634 }
635
636 type uint32_t-implied uint32_t accessor=value-implied {
637 }
638
639 # ###################################################################### #
640
641 type uint8_t[],char[] value-array {
642         type    {{ ByteArray }}
643         layout  {{ MemoryLayout.sequenceLayout({len1}, Memory.BYTE) }}
644         typei   {{ byte }}
645 }
646
647 type uint32_t[],int32_t[] value-array {
648         type    {{ IntArray }}
649         layout  {{ MemoryLayout.sequenceLayout({len1}, Memory.INT) }}
650         typei   {{ int }}
651 }
652
653 type uint64_t[] value-array {
654         type    {{ LongArray }}
655         layout  {{ MemoryLayout.sequenceLayout({len1}, Memory.LONG) }}
656         typei   {{ long }}
657 }
658
659 type float[] value-array {
660         type    {{ FloatArray }}
661         layout  {{ MemoryLayout.sequenceLayout({len1}, Memory.FLOAT) }}
662         typei   {{ float }}
663 }
664
665 type struct[] inline-array {
666         type    {{ {baseType} }}
667         layout  {{ MemoryLayout.sequenceLayout({len1}, {baseType}.LAYOUT) }}
668 }
669
670 type float[][] value-array2d {
671         type    {{ FloatArray }}
672         typei   {{ float }}
673         layout  {{ MemoryLayout.sequenceLayout({len1}, MemoryLayout.sequenceLayout({len2}, Memory.FLOAT)) }}
674 }
675
676 # select=len?  or what?
677
678 type pointer value {
679         layout  {{ Memory.POINTER }}
680         type    {{ MemoryAddress }}
681
682         native-value    {{ Memory.address({name}) }}
683         native-get              {{ (MemoryAddress){name}$VH.get(this.segment) }}
684
685 #       java-get        {{ {native-get} }}
686 #       java-set        {{ {name}$VH.set(this.segment, Memory.address({name})) }}
687 }
688
689 type void* pointer;
690
691 type value-pointer pointer {
692         java-get        {{ {type}.create((MemoryAddress){name}$VH.get(this.segment), segment.scope()) }}
693 }
694
695 type uint8_t* value-pointer {
696         type    ByteArray;
697 }
698
699 type uint32_t*,int32_t*,int* value-pointer {
700         type    IntArray;
701 }
702
703 type uint64_t* value-pointer {
704         type    LongArray;
705 }
706
707 type float* value-pointer {
708         type    FloatArray;
709 }
710
711 type size_t* value-pointer {
712         type    LongArray;
713 }
714
715 type pointer-length pointer {
716         java-get        {{ {type}.createArray({native-get}, {length}, this.segment.scope()) }}
717 }
718
719 type void*-length pointer-length {
720         type            MemorySegment;
721         java-get        {{ MemorySegment.ofAddress({native-get}, {length}, this.segment.scope()) }}
722 }
723
724 type uint8_t*-length pointer-length {
725         type    ByteArray;
726 }
727
728 type uint32_t*-length,int32_t*-length pointer-length {
729         type    IntArray;
730 }
731
732 type uint64_t*-length pointer-length {
733         type    LongArray;
734 }
735
736 type float*-length pointer-length {
737         type    FloatArray;
738 }
739
740 # special handling for strings, will fail if it isn't
741 type char* pointer accessor=value-alloc {
742         type            {{ String }}
743
744         java-get        {{ ({native-get}).getUtf8String(0) }}
745         native-value {{ alloc$.allocateUtf8String({name}).address() }}
746
747         # this just verifies it's a string type
748         length eval     {{
749                 if ($v->{len} =~ m/null-terminated/) {
750                         1;
751                 } else {
752                         die Dumper($v, $s);
753                 }
754         }}
755
756 }
757
758 type char**-length pointer-length accessor=value-alloc {
759         type    {{ String[] }}
760
761         java-set        {{ {name}$VH.set(this.segment, Memory.copyStringArray({name}, alloc$).address()); {set-length} }}
762         java-get        {{ Memory.copyStringArray((MemoryAddress){name}$VH.get(this.segment), {length}) }}
763
764 #       set-length eval {{
765 #               if ($v->{len} =~ m/(.*),null-terminated/) {
766 #                       'set'.ucfirst($1).'({name}.length)';
767 #               } else {
768 #                       die Dumper($v, $s);
769 #               }
770 #       }}
771 }
772
773 # FIXME: wrong
774 type uint32_t** pointer {
775         type    {{ HandleArray<IntArray> }}
776 }
777
778 type funcpointer pointer {
779         type            {{ FunctionPointer<{baseType}> }}
780         typei           {{ {baseType} }}
781         java-get        {{ {baseType}.downcall({native-get}, this.segment.scope()) }}
782 }
783
784 type void** pointer {
785 }
786
787 type void**-length pointer-length {
788         type    PointerArray;
789 }
790
791 type handle pointer {
792         type            {{ {baseType} }}
793         java-get        {{ {type}.create({native-get}, this.segment.scope()) }}
794 }
795
796 # FIXME: wrong
797 type handle[] {
798         type    {{ HandleArray<{typei}> }}
799         layout  {{ MemoryLayout.sequenceLayout({len1}, Memory.POINTER) }}
800         #java-get       {{ HandleArray.create({get}, {typei}::create) }}
801         java-get        {{ error }}
802         typei   {{ {baseType} }}
803 }
804
805 type handle* pointer {
806         type            {{ HandleArray<{typei}> }}
807         typei           {{ {baseType} }}
808         java-get        {{ HandleArray.create({native-get}, {typei}::create) }}
809 }
810
811 type handle*-length pointer-length {
812         type            {{ HandleArray<{baseType}> }}
813         typei           {{ {baseType} }}
814         java-get        {{ HandleArray.createArray({native-get}, {length}, {typei}::create, this.segment.scope()) }}
815         java-set        {{ {name}$VH.set(this.segment, Memory.address({name})); {set-length} }}
816 }
817
818 type struct inline {
819         type    {{ {baseType} }}
820         layout  {{ {baseType}.LAYOUT }}
821 }
822
823 # how?  length?
824 type struct* pointer {
825         type            {{ {baseType} }}
826         java-get        {{ {baseType}.create({native-get}, this.segment.scope()) }}
827 }
828
829 type struct*-length pointer-length {
830         type    {{ {baseType} }}
831         typei   {{ {baseType} }}
832 }
833
834 type struct** pointer {
835 }
836
837 # xlib
838 type XID,Window,VisualID uint64_t;
839
840 type Display* handle {
841         type    xlib.XDisplay;
842 }
843
844 # xcb
845 type xcb_window_t uint32_t;
846 type xcb_visualid_t uint32_t;
847 type xcb_connection_t* handle {
848         type    xcb.Connection;
849 }
850
851 override structs {
852         VkInstance                      template=handle-instance;
853         VkPhysicalDevice        template=handle-dispatch;
854         VkDevice                        template=handle-dispatch;
855         VkCommandBuffer         template=handle-dispatch;
856         VkQueue                         template=handle-dispatch;
857
858         VkAllocationCallbacks   ignore;
859
860         #VkQueueFamilyProperties        template=struct-readwrite;
861
862         # Override default read/write
863         VkDebugUtilsMessengerCallbackDataEXT template=struct-readonly;
864         VkDebugUtilsLabelEXT template=struct-readonly-array;
865         VkDebugUtilsObjectNameInfoEXT template=struct-readonly-array;
866
867         # override default array-length behaviours, some of these are independent of the array pointer
868         VkAccelerationStructureBuildGeometryInfoKHR geometryCount=type:uint32_t;
869         VkDescriptorSetLayoutBinding pImmutableSamplers=type:handle* descriptorCount=type:uint32_t;
870         VkPipelineViewportStateCreateInfo scissorCount=type:uint32_t viewportCount=type:uint32_t;
871
872 # can't really work out what this is it's a void ** but it stays it's a pointer to uint8_t * in the spec
873         VkCuLaunchInfoNVX       pParams=type:pointer pExtras=type:pointer;
874 }