1 /*
2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.acme;
27
28 import java.foreign.annotations.NativeAddressof;
29 import java.foreign.annotations.NativeFunction;
30 import java.foreign.annotations.NativeGetter;
31 import java.foreign.annotations.NativeHeader;
32 import java.foreign.annotations.NativeLocation;
33 import java.foreign.annotations.NativeSetter;
34 import java.foreign.annotations.NativeStruct;
35 import java.foreign.memory.Pointer;
36 import java.foreign.memory.Struct;
37
38 /**
39 * This test is platform dependent, as the C type size may vary on platform.
40 * Current value is based on x64 with __LP64__.
41 */
42 @NativeHeader(path="simple.h", globals =
43 {"i32(global)", "${anonymous}(basics)", "u64(unsigned_int):${_unsigned}"}
44 )
45 public interface simple {
46 @NativeLocation(file="simple.h", line=26, column=5)
47 @NativeGetter("global")
48 public int global$get();
49 @NativeSetter("global")
50 public void global$set(int arg);
51 @NativeAddressof("global")
52 public Pointer<Integer> global$ptr();
53
54 @NativeLocation(file="simple.h", line=32, column=8)
55 @NativeStruct("[" +
56 "u8(ch)" +
57 "i8(sch)" +
58 "i16(s)" +
59 "i32(n)" +
60 "i32(l)" + // platform dependent
61 "x32" +
62 "i64(ll)" +
63 "f32(f)" +
64 "x32" +
65 "f64(d)" +
66 "f64(ld)" + // platform dependent
67 "](anonymous)")
68 public static interface anonymous extends Struct<anonymous> {
69 @NativeLocation(file="simple.h", line=33, column=10)
70 @NativeGetter("ch")
71 public byte ch$get();
72 @NativeSetter("ch")
73 public void ch$set(byte arg);
74 @NativeAddressof("ch")
75 public Pointer<Byte> ch$ptr();
76
77 @NativeLocation(file="simple.h", line=34, column=17)
78 @NativeGetter("sch")
79 public byte sch$get();
80 @NativeSetter("sch")
81 public void sch$set(byte arg);
82 @NativeAddressof("sch")
83 public Pointer<Byte> sch$ptr();
84
85 @NativeLocation(file="simple.h", line=35, column=11)
86 @NativeGetter("s")
87 public short s$get();
88 @NativeSetter("s")
89 public void s$set(short arg);
90 @NativeAddressof("s")
91 public Pointer<Short> s$ptr();
92
93 @NativeLocation(file="simple.h", line=36, column=9)
94 @NativeGetter("n")
95 public int n$get();
96 @NativeSetter("n")
97 public void n$set(int arg);
98 @NativeAddressof("n")
99 public Pointer<Integer> n$ptr();
100
101 @NativeLocation(file="simple.h", line=37, column=10)
102 @NativeGetter("l")
103 public int l$get();
104 @NativeSetter("l")
105 public void l$set(int arg);
106 @NativeAddressof("l")
107 public Pointer<Integer> l$ptr();
108
109 @NativeLocation(file="simple.h", line=38, column=15)
110 @NativeGetter("ll")
111 public long ll$get();
112 @NativeSetter("ll")
113 public void ll$set(long arg);
114 @NativeAddressof("ll")
115 public Pointer<Long> ll$ptr();
116
117 @NativeLocation(file="simple.h", line=39, column=11)
118 @NativeGetter("f")
119 public float f$get();
120 @NativeSetter("f")
121 public void f$set(float arg);
122 @NativeAddressof("f")
123 public Pointer<Float> f$ptr();
124
125 @NativeLocation(file="simple.h", line=40, column=12)
126 @NativeGetter("d")
127 public double d$get();
128 @NativeSetter("d")
129 public void d$set(double arg);
130 @NativeAddressof("d")
131 public Pointer<Double> d$ptr();
132
133 @NativeLocation(file="simple.h", line=41, column=17)
134 @NativeGetter("ld")
135 public double ld$get();
136 @NativeSetter("ld")
137 public void ld$set(double arg);
138 @NativeAddressof("ld")
139 public Pointer<Double> ld$ptr();
140 }
141
142 @NativeLocation(file="simple.h", line=42, column=3)
143 @NativeGetter("basics")
144 public anonymous basics$get();
145 @NativeSetter("basics")
146 public void basics$set(anonymous arg);
147 @NativeAddressof("basics")
148 public Pointer<anonymous> basics$ptr();
149
150 @NativeLocation(file = "simple.h", line = 45, column = 8)
151 @NativeStruct("[" +
152 "u8(b)" +
153 "u8(ch)" +
154 "u16(s)" +
155 "u32(n)" +
156 "u32(l)" + // platform dependent
157 "x32" +
158 "u64(ll)" +
159 "](_unsigned)")
160 public static interface _unsigned extends Struct<_unsigned> {
161 @NativeLocation(file="simple.h", line=46, column=11)
162 @NativeGetter("b")
163 public boolean b$get();
164 @NativeSetter("b")
165 public void b$set(boolean arg);
166 @NativeAddressof("b")
167 public Pointer<Boolean> b$ptr();
168
169 @NativeLocation(file="simple.h", line=47, column=19)
170 @NativeGetter("ch")
171 public byte ch$get();
172 @NativeSetter("ch")
173 public void ch$set(byte c);
174 @NativeAddressof("ch")
175 public Pointer<Byte> ch$ptr();
176
177 @NativeLocation(file="simple.h", line=48, column=20)
178 @NativeGetter("s")
179 public short s$get();
180 @NativeSetter("s")
181 public void s$set(short s);
182 @NativeAddressof("s")
183 public Pointer<Short> s$ptr();
184
185 @NativeLocation(file="simple.h", line=49, column=18)
186 @NativeGetter("n")
187 public int n$get();
188 @NativeSetter("n")
189 public void n$set(int i);
190 @NativeAddressof("n")
191 public Pointer<Integer> n$ptr();
192
193 @NativeLocation(file="simple.h", line=50, column=19)
194 @NativeGetter("l")
195 public int l$get();
196 @NativeSetter("l")
197 public void l$set(int l);
198 @NativeAddressof("l")
199 public Pointer<Integer> l$ptr();
200
201 @NativeLocation(file="simple.h", line=51, column=24)
202 @NativeGetter("ll")
203 public long ll$get();
204 @NativeSetter("ll")
205 public void ll$set(long l);
206 @NativeAddressof("ll")
207 public Pointer<Long> ll$ptr();
208 }
209
210 @NativeLocation(file="simple.h", line=52, column=4)
211 @NativeGetter("unsigned_int")
212 public Pointer<_unsigned> unsigned_int$get();
213 @NativeSetter("unsigned_int")
214 public void unsigned_int$set(Pointer<_unsigned> arg);
215 @NativeAddressof("unsigned_int")
216 public Pointer<Pointer<_unsigned>> unsigned_int$ptr();
217
218 @NativeLocation(file = "simple.h", line = 54, column = 6)
219 @NativeFunction("(${anonymous}u64:u8)v")
220 public void func(anonymous s, Pointer<Byte> str);
221 }
--- EOF ---