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 { 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 }