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.NativeGetter; 30 import java.foreign.annotations.NativeHeader; 31 import java.foreign.annotations.NativeSetter; 32 import java.foreign.annotations.NativeStruct; 33 import java.foreign.memory.Pointer; 34 import java.foreign.memory.Struct; 35 36 @NativeHeader(path="bitfields.h") 37 public interface bitfields_h { 38 39 @NativeStruct("[" + 40 "u64=[" + 41 "i2(x)" + 42 "x6" + 43 "i15(y)" + 44 "x9" + 45 "i20(z)" + 46 "x12]" + 47 "u64=[" + 48 "i13(w)" + 49 "x51]" + 50 "](bitfields1)") 51 interface bitfields1 extends Struct<bitfields1> { 52 @NativeGetter("x") 53 long x$get(); 54 @NativeSetter("x") 55 void x$set(long value); 56 @NativeGetter("y") 57 long y$get(); 58 @NativeSetter("y") 59 void y$set(long value); 60 @NativeGetter("z") 61 int z$get(); 62 @NativeSetter("z") 63 void z$set(int value); 64 @NativeGetter("w") 65 int w$get(); 66 @NativeSetter("w") 67 void w$set(int value); 68 } 69 70 @NativeStruct("[" + 71 "u64=[" + 72 "u3(c)" + 73 "u3(c2)" + 74 "x2" + 75 "u7(c3)" + 76 "i4(i)" + 77 "i21(l)" + 78 "x24]" + 79 "u64=[" + 80 "i42(ll)" + 81 "x22]" + 82 "](bitfields2)") 83 interface bitfields2 extends Struct<bitfields2> { 84 @NativeGetter("c") 85 byte c$get(); 86 @NativeSetter("c") 87 void c$set(byte value); 88 @NativeGetter("c2") 89 byte c2$get(); 90 @NativeSetter("c2") 91 void c2$set(byte value); 92 @NativeGetter("c3") 93 byte c3$get(); 94 @NativeSetter("c3") 95 void c3$set(byte value); 96 @NativeGetter("i") 97 int i$get(); 98 @NativeSetter("i") 99 void i$set(int value); 100 @NativeGetter("l") 101 long l$get(); 102 @NativeSetter("l") 103 void l$set(long value); 104 @NativeGetter("ll") 105 long ll$get(); 106 @NativeSetter("ll") 107 void ll$set(long value); 108 } 109 110 @NativeStruct("[" + 111 "u32=[" + 112 "u4(c1)" + 113 "i20(i)" + 114 "u8(c2)]" + 115 "u32=[" + 116 "i32(l1)]" + 117 "u32=[" + 118 "i32(l2)]" + 119 "](bitfields3)") 120 interface bitfields3 extends Struct<bitfields3> { 121 @NativeGetter("c1") 122 byte c1$get(); 123 @NativeSetter("c1") 124 void c1$set(byte value); 125 @NativeGetter("i") 126 int i$get(); 127 @NativeSetter("i") 128 void i$set(int value); 129 @NativeGetter("c2") 130 byte c2$get(); 131 @NativeSetter("c2") 132 void c2$set(byte value); 133 @NativeGetter("l1") 134 int l1$get(); 135 @NativeSetter("l1") 136 void l1$set(int value); 137 @NativeGetter("l2") 138 int l2$get(); 139 @NativeSetter("l2") 140 void l2$set(int value); 141 } 142 143 @NativeStruct("[" + 144 "i64(l)" + 145 "u64=[" + 146 "u4(c)" + 147 "x60]" + 148 "](bitfields4)") 149 interface bitfields4 extends Struct<bitfields4> { 150 @NativeGetter("l") 151 long l$get(); 152 @NativeSetter("l") 153 void l$set(long value); 154 @NativeAddressof("l") 155 Pointer<Long> l$ptr(); 156 @NativeGetter("c") 157 byte c$get(); 158 @NativeSetter("c") 159 void c$set(byte value); 160 } 161 162 @NativeStruct("[" + 163 "u64=[" + 164 "u7(c)" + 165 "x57]" + 166 "u64=[" + 167 "i63(l)" + 168 "x1]" + 169 "](bitfields5)") 170 interface bitfields5 extends Struct<bitfields5> { 171 @NativeGetter("c") 172 byte c$get(); 173 @NativeSetter("c") 174 void c$set(byte value); 175 @NativeGetter("l") 176 long l$get(); 177 @NativeSetter("l") 178 void l$set(long value); 179 } 180 181 @NativeStruct("[" + 182 "u8=[" + 183 "u4(c1)]|" + 184 "i32=[" + 185 "i20(i)]" + 186 "](bitfields6)") 187 interface bitfields6 extends Struct<bitfields6> { 188 @NativeGetter("c1") 189 byte c1$get(); 190 @NativeSetter("c1") 191 void c1$set(byte value); 192 @NativeGetter("i") 193 int i$get(); 194 @NativeSetter("i") 195 void i$set(int value); 196 } 197 198 @NativeStruct("[" + 199 "u32(x)" + 200 "u32=[u15(a)u17(pad)]" + 201 "](bitfields7)") 202 public interface bitfields7 extends Struct<bitfields7> { 203 @NativeGetter("x") 204 int x$get(); 205 @NativeSetter("x") 206 void x$set(int value); 207 @NativeAddressof("x") 208 Pointer<Integer> x$ptr(); 209 @NativeGetter("a") 210 int a$get(); 211 @NativeSetter("a") 212 void a$set(int value); 213 @NativeGetter("pad") 214 int pad$get(); 215 @NativeSetter("pad") 216 void pad$set(int value); 217 } 218 219 @NativeStruct("[" + 220 "i32(i)" + 221 "i32(j)" + 222 "](Point)") 223 public interface Point extends Struct<Point> { 224 @NativeGetter("i") 225 int i$get(); 226 @NativeSetter("i") 227 void i$set(int value); 228 @NativeAddressof("i") 229 Pointer<Integer> i$ptr(); 230 @NativeGetter("j") 231 int j$get(); 232 @NativeSetter("j") 233 void j$set(int value); 234 @NativeAddressof("j") 235 Pointer<Integer> j$ptr(); 236 } 237 238 @NativeStruct("[" + 239 "${Point}(p)" + 240 "u32=[i12(x)i2(y)x18]" + 241 "](bitfields8)") 242 public interface bitfields8 extends Struct<bitfields8> { 243 @NativeGetter("p") 244 Point p$get(); 245 @NativeSetter("p") 246 void p$set(Point value); 247 Pointer<Point> p$ptr(); 248 @NativeGetter("x") 249 int x$get(); 250 @NativeSetter("x") 251 void x$set(int value); 252 @NativeGetter("y") 253 int y$get(); 254 @NativeSetter("y") 255 void y$set(int value); 256 } 257 258 @NativeStruct("[" + 259 "u32=[u1(x)x7u8(y)x16]" + 260 "i32(z)" + 261 "](bitfields9)") 262 public interface bitfields9 extends Struct<bitfields9> { 263 @NativeGetter("x") 264 int x$get(); 265 @NativeSetter("x") 266 void x$set(int var1); 267 268 @NativeGetter("y") 269 int y$get(); 270 @NativeSetter("y") 271 void y$set(int var1); 272 273 @NativeGetter("z") 274 int z$get(); 275 @NativeSetter("z") 276 void z$set(int var1); 277 @NativeAddressof("z") 278 Pointer<Integer> z$ptr(); 279 } 280 281 @NativeStruct("[u32=[u1(x)]|x64](bitfields10)") 282 public interface bitfields10 extends Struct<bitfields10> { 283 @NativeGetter("x") 284 int x$get(); 285 286 @NativeSetter("x") 287 void x$set(int var1); 288 } 289 290 }