1 /* 2 * Copyright (c) 2018, 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)", 44 "${anonymous}(basics)", 45 "u64(unsigned_int)" } 46 ) 47 public interface simple { 48 @NativeLocation(file="simple.h", line=26, column=5) 49 @NativeGetter("global") 50 public int global$get(); 51 @NativeSetter("global") 52 public void global$set(int arg); 53 @NativeAddressof("global") 54 public Pointer<Integer> global$ptr(); 55 56 @NativeLocation(file="simple.h", line=32, column=8) 57 @NativeStruct("[" + 58 "u8(ch)" + 59 "i8(sch)" + 60 "i16(s)" + 61 "i32(n)" + 62 "i64(l)" + 63 "i64(ll)" + 64 "f32(f)" + 65 "x32" + 66 "f64(d)" + 67 "x64" + 68 "f128(ld)" + 69 "](anonymous)") 70 public static interface anonymous extends Struct<anonymous> { 71 @NativeLocation(file="simple.h", line=33, column=10) 72 @NativeGetter("ch") 73 public byte ch$get(); 74 @NativeSetter("ch") 75 public void ch$set(byte arg); 76 @NativeAddressof("ch") 77 public Pointer<Byte> ch$ptr(); 78 79 @NativeLocation(file="simple.h", line=34, column=17) 80 @NativeGetter("sch") 81 public byte sch$get(); 82 @NativeSetter("sch") 83 public void sch$set(byte arg); 84 @NativeAddressof("sch") 85 public Pointer<Byte> sch$ptr(); 86 87 @NativeLocation(file="simple.h", line=35, column=11) 88 @NativeGetter("s") 89 public short s$get(); 90 @NativeSetter("s") 91 public void s$set(short arg); 92 @NativeAddressof("s") 93 public Pointer<Short> s$ptr(); 94 95 @NativeLocation(file="simple.h", line=36, column=9) 96 @NativeGetter("n") 97 public int n$get(); 98 @NativeSetter("n") 99 public void n$set(int arg); 100 @NativeAddressof("n") 101 public Pointer<Integer> n$ptr(); 102 103 @NativeLocation(file="simple.h", line=37, column=10) 104 @NativeGetter("l") 105 public long l$get(); 106 @NativeSetter("l") 107 public void l$set(long arg); 108 @NativeAddressof("l") 109 public Pointer<Long> l$ptr(); 110 111 @NativeLocation(file="simple.h", line=38, column=15) 112 @NativeGetter("ll") 113 public long ll$get(); 114 @NativeSetter("ll") 115 public void ll$set(long arg); 116 @NativeAddressof("ll") 117 public Pointer<Long> ll$ptr(); 118 119 @NativeLocation(file="simple.h", line=39, column=11) 120 @NativeGetter("f") 121 public float f$get(); 122 @NativeSetter("f") 123 public void f$set(float arg); 124 @NativeAddressof("f") 125 public Pointer<Float> f$ptr(); 126 127 @NativeLocation(file="simple.h", line=40, column=12) 128 @NativeGetter("d") 129 public double d$get(); 130 @NativeSetter("d") 131 public void d$set(double arg); 132 @NativeAddressof("d") 133 public Pointer<Double> d$ptr(); 134 135 @NativeLocation(file="simple.h", line=41, column=17) 136 @NativeGetter("ld") 137 public double ld$get(); 138 @NativeSetter("ld") 139 public void ld$set(double arg); 140 @NativeAddressof("ld") 141 public Pointer<Double> ld$ptr(); 142 } 143 144 @NativeLocation(file="simple.h", line=42, column=3) 145 @NativeGetter("basics") 146 public anonymous basics$get(); 147 @NativeSetter("basics") 148 public void basics$set(anonymous arg); 149 @NativeAddressof("basics") 150 public Pointer<anonymous> basics$ptr(); 151 152 @NativeLocation(file = "simple.h", line = 45, column = 8) 153 @NativeStruct("[" + 154 "u8(b)" + 155 "u8(ch)" + 156 "u16(s)" + 157 "u32(n)" + 158 "u64(l)" + 159 "u64(ll)" + 160 "](_unsigned)") 161 public static interface _unsigned extends Struct<_unsigned> { 162 @NativeLocation(file="simple.h", line=46, column=11) 163 @NativeGetter("b") 164 public boolean b$get(); 165 @NativeSetter("b") 166 public void b$set(boolean arg); 167 @NativeAddressof("b") 168 public Pointer<Boolean> b$ptr(); 169 170 @NativeLocation(file="simple.h", line=47, column=19) 171 @NativeGetter("ch") 172 public byte ch$get(); 173 @NativeSetter("ch") 174 public void ch$set(byte c); 175 @NativeAddressof("ch") 176 public Pointer<Byte> ch$ptr(); 177 178 @NativeLocation(file="simple.h", line=48, column=20) 179 @NativeGetter("s") 180 public short s$get(); 181 @NativeSetter("s") 182 public void s$set(short s); 183 @NativeAddressof("s") 184 public Pointer<Short> s$ptr(); 185 186 @NativeLocation(file="simple.h", line=49, column=18) 187 @NativeGetter("n") 188 public int n$get(); 189 @NativeSetter("n") 190 public void n$set(int i); 191 @NativeAddressof("n") 192 public Pointer<Integer> n$ptr(); 193 194 @NativeLocation(file="simple.h", line=50, column=19) 195 @NativeGetter("l") 196 public long l$get(); 197 @NativeSetter("l") 198 public void l$set(long l); 199 @NativeAddressof("l") 200 public Pointer<Long> l$ptr(); 201 202 @NativeLocation(file="simple.h", line=51, column=24) 203 @NativeGetter("ll") 204 public long ll$get(); 205 @NativeSetter("ll") 206 public void ll$set(long l); 207 @NativeAddressof("ll") 208 public Pointer<Long> ll$ptr(); 209 } 210 211 @NativeLocation(file="simple.h", line=52, column=4) 212 @NativeGetter("unsigned_int") 213 public Pointer<_unsigned> unsigned_int$get(); 214 @NativeSetter("unsigned_int") 215 public void unsigned_int$set(Pointer<_unsigned> arg); 216 @NativeAddressof("unsigned_int") 217 public Pointer<Pointer<_unsigned>> unsigned_int$ptr(); 218 219 @NativeLocation(file = "simple.h", line = 54, column = 6) 220 @NativeFunction("(${anonymous}u64:u8)v") 221 public void func(anonymous s, Pointer<Byte> str); 222 }