d8551f24af6111454f2ac0442263cdaffb165a8d
[panamaz] / src / notzed.vkheader / gen / vkheader.api
1 # -*- Mode:text; tab-width:4; electric-indent-mode: nil; indent-line-function:insert-tab; -*-
2
3 include types.api
4 include code.api
5
6 struct <default> rename=s/_T$// {
7 }
8
9 struct VkInstance_T {
10         func:vkGetInstanceProcAddr raw:result$ instance:0;
11
12         # be nice if findMatches() took the name of the target then it could handle pattern matching struct // automatically
13         # todo: check this works for extension functions
14         func:<match-function> instance:0 {{
15                 # another way perhaps?   func:<match-function> match:0=u64:${VkInstance_T};
16                 sub {
17                         my $s = shift;
18                         return $s->{type} eq 'func' && defined($s->{items}->[0]) && $s->{items}->[0]->{deref} eq 'u64:${VkInstance_T}';
19                 }
20         }}
21
22         # another version for extension functions - uses a dynamic func resolution
23         #func:<match-function> instance:0 func:template=code:vulkan-method=invoke-dynamic {{
24         #}}
25 }
26
27 struct // {
28 }
29
30 code vulkan-method {
31
32         invoke-dynamic {{
33         MethodHandle {name}$FH;
34         public {java-result} {rename}({java-arguments}) {
35                 {native-output-define}
36                 {native-result-define}
37                 try {create-frame}{
38                         if ({name}$FH == null)
39                                 {name}$FH = Memory.downcall("{name}", vkGetInstanceProcAddr("{name}"), {function-descriptor}, scope());
40
41                         {native-output-init}
42                         {native-result-assign}{name}$FH.invokeExact({native-call});
43                         {native-output-copy}
44                         {result-test}{
45                                 {java-result-assign}
46                                 {on-success}
47                                 {java-result-return}
48                         }
49                 } catch (Throwable t) {
50                         throw new RuntimeException(t);
51                 }
52                 {result-throw}
53         }
54         }}
55 }