|
| 1 | +// Generated by jextract |
| 2 | + |
| 3 | +package dev.hallock.zstd.bindings; |
| 4 | + |
| 5 | +import java.lang.invoke.*; |
| 6 | +import java.lang.foreign.*; |
| 7 | +import java.nio.ByteOrder; |
| 8 | +import java.util.*; |
| 9 | +import java.util.function.*; |
| 10 | +import java.util.stream.*; |
| 11 | + |
| 12 | +import static java.lang.foreign.ValueLayout.*; |
| 13 | +import static java.lang.foreign.MemoryLayout.PathElement.*; |
| 14 | + |
| 15 | +/** |
| 16 | + * {@snippet lang=c : |
| 17 | + * struct { |
| 18 | + * int compressionLevel; |
| 19 | + * unsigned int notificationLevel; |
| 20 | + * unsigned int dictID; |
| 21 | + * } |
| 22 | + * } |
| 23 | + */ |
| 24 | +public class ZDICT_params_t { |
| 25 | + |
| 26 | + ZDICT_params_t() { |
| 27 | + // Should not be called directly |
| 28 | + } |
| 29 | + |
| 30 | + private static final GroupLayout $LAYOUT = MemoryLayout.structLayout( |
| 31 | + ZSTD_h.C_INT.withName("compressionLevel"), |
| 32 | + ZSTD_h.C_INT.withName("notificationLevel"), |
| 33 | + ZSTD_h.C_INT.withName("dictID") |
| 34 | + ).withName("$anon$214:9"); |
| 35 | + |
| 36 | + /** |
| 37 | + * The layout of this struct |
| 38 | + */ |
| 39 | + public static final GroupLayout layout() { |
| 40 | + return $LAYOUT; |
| 41 | + } |
| 42 | + |
| 43 | + private static final OfInt compressionLevel$LAYOUT = (OfInt)$LAYOUT.select(groupElement("compressionLevel")); |
| 44 | + |
| 45 | + /** |
| 46 | + * Layout for field: |
| 47 | + * {@snippet lang=c : |
| 48 | + * int compressionLevel |
| 49 | + * } |
| 50 | + */ |
| 51 | + public static final OfInt compressionLevel$layout() { |
| 52 | + return compressionLevel$LAYOUT; |
| 53 | + } |
| 54 | + |
| 55 | + private static final long compressionLevel$OFFSET = $LAYOUT.byteOffset(groupElement("compressionLevel")); |
| 56 | + |
| 57 | + /** |
| 58 | + * Offset for field: |
| 59 | + * {@snippet lang=c : |
| 60 | + * int compressionLevel |
| 61 | + * } |
| 62 | + */ |
| 63 | + public static final long compressionLevel$offset() { |
| 64 | + return compressionLevel$OFFSET; |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * Getter for field: |
| 69 | + * {@snippet lang=c : |
| 70 | + * int compressionLevel |
| 71 | + * } |
| 72 | + */ |
| 73 | + public static int compressionLevel(MemorySegment struct) { |
| 74 | + return struct.get(compressionLevel$LAYOUT, compressionLevel$OFFSET); |
| 75 | + } |
| 76 | + |
| 77 | + /** |
| 78 | + * Setter for field: |
| 79 | + * {@snippet lang=c : |
| 80 | + * int compressionLevel |
| 81 | + * } |
| 82 | + */ |
| 83 | + public static void compressionLevel(MemorySegment struct, int fieldValue) { |
| 84 | + struct.set(compressionLevel$LAYOUT, compressionLevel$OFFSET, fieldValue); |
| 85 | + } |
| 86 | + |
| 87 | + private static final OfInt notificationLevel$LAYOUT = (OfInt)$LAYOUT.select(groupElement("notificationLevel")); |
| 88 | + |
| 89 | + /** |
| 90 | + * Layout for field: |
| 91 | + * {@snippet lang=c : |
| 92 | + * unsigned int notificationLevel |
| 93 | + * } |
| 94 | + */ |
| 95 | + public static final OfInt notificationLevel$layout() { |
| 96 | + return notificationLevel$LAYOUT; |
| 97 | + } |
| 98 | + |
| 99 | + private static final long notificationLevel$OFFSET = $LAYOUT.byteOffset(groupElement("notificationLevel")); |
| 100 | + |
| 101 | + /** |
| 102 | + * Offset for field: |
| 103 | + * {@snippet lang=c : |
| 104 | + * unsigned int notificationLevel |
| 105 | + * } |
| 106 | + */ |
| 107 | + public static final long notificationLevel$offset() { |
| 108 | + return notificationLevel$OFFSET; |
| 109 | + } |
| 110 | + |
| 111 | + /** |
| 112 | + * Getter for field: |
| 113 | + * {@snippet lang=c : |
| 114 | + * unsigned int notificationLevel |
| 115 | + * } |
| 116 | + */ |
| 117 | + public static int notificationLevel(MemorySegment struct) { |
| 118 | + return struct.get(notificationLevel$LAYOUT, notificationLevel$OFFSET); |
| 119 | + } |
| 120 | + |
| 121 | + /** |
| 122 | + * Setter for field: |
| 123 | + * {@snippet lang=c : |
| 124 | + * unsigned int notificationLevel |
| 125 | + * } |
| 126 | + */ |
| 127 | + public static void notificationLevel(MemorySegment struct, int fieldValue) { |
| 128 | + struct.set(notificationLevel$LAYOUT, notificationLevel$OFFSET, fieldValue); |
| 129 | + } |
| 130 | + |
| 131 | + private static final OfInt dictID$LAYOUT = (OfInt)$LAYOUT.select(groupElement("dictID")); |
| 132 | + |
| 133 | + /** |
| 134 | + * Layout for field: |
| 135 | + * {@snippet lang=c : |
| 136 | + * unsigned int dictID |
| 137 | + * } |
| 138 | + */ |
| 139 | + public static final OfInt dictID$layout() { |
| 140 | + return dictID$LAYOUT; |
| 141 | + } |
| 142 | + |
| 143 | + private static final long dictID$OFFSET = $LAYOUT.byteOffset(groupElement("dictID")); |
| 144 | + |
| 145 | + /** |
| 146 | + * Offset for field: |
| 147 | + * {@snippet lang=c : |
| 148 | + * unsigned int dictID |
| 149 | + * } |
| 150 | + */ |
| 151 | + public static final long dictID$offset() { |
| 152 | + return dictID$OFFSET; |
| 153 | + } |
| 154 | + |
| 155 | + /** |
| 156 | + * Getter for field: |
| 157 | + * {@snippet lang=c : |
| 158 | + * unsigned int dictID |
| 159 | + * } |
| 160 | + */ |
| 161 | + public static int dictID(MemorySegment struct) { |
| 162 | + return struct.get(dictID$LAYOUT, dictID$OFFSET); |
| 163 | + } |
| 164 | + |
| 165 | + /** |
| 166 | + * Setter for field: |
| 167 | + * {@snippet lang=c : |
| 168 | + * unsigned int dictID |
| 169 | + * } |
| 170 | + */ |
| 171 | + public static void dictID(MemorySegment struct, int fieldValue) { |
| 172 | + struct.set(dictID$LAYOUT, dictID$OFFSET, fieldValue); |
| 173 | + } |
| 174 | + |
| 175 | + /** |
| 176 | + * Obtains a slice of {@code arrayParam} which selects the array element at {@code index}. |
| 177 | + * The returned segment has address {@code arrayParam.address() + index * layout().byteSize()} |
| 178 | + */ |
| 179 | + public static MemorySegment asSlice(MemorySegment array, long index) { |
| 180 | + return array.asSlice(layout().byteSize() * index); |
| 181 | + } |
| 182 | + |
| 183 | + /** |
| 184 | + * The size (in bytes) of this struct |
| 185 | + */ |
| 186 | + public static long sizeof() { return layout().byteSize(); } |
| 187 | + |
| 188 | + /** |
| 189 | + * Allocate a segment of size {@code layout().byteSize()} using {@code allocator} |
| 190 | + */ |
| 191 | + public static MemorySegment allocate(SegmentAllocator allocator) { |
| 192 | + return allocator.allocate(layout()); |
| 193 | + } |
| 194 | + |
| 195 | + /** |
| 196 | + * Allocate an array of size {@code elementCount} using {@code allocator}. |
| 197 | + * The returned segment has size {@code elementCount * layout().byteSize()}. |
| 198 | + */ |
| 199 | + public static MemorySegment allocateArray(long elementCount, SegmentAllocator allocator) { |
| 200 | + return allocator.allocate(MemoryLayout.sequenceLayout(elementCount, layout())); |
| 201 | + } |
| 202 | + |
| 203 | + /** |
| 204 | + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). |
| 205 | + * The returned segment has size {@code layout().byteSize()} |
| 206 | + */ |
| 207 | + public static MemorySegment reinterpret(MemorySegment addr, Arena arena, Consumer<MemorySegment> cleanup) { |
| 208 | + return reinterpret(addr, 1, arena, cleanup); |
| 209 | + } |
| 210 | + |
| 211 | + /** |
| 212 | + * Reinterprets {@code addr} using target {@code arena} and {@code cleanupAction} (if any). |
| 213 | + * The returned segment has size {@code elementCount * layout().byteSize()} |
| 214 | + */ |
| 215 | + public static MemorySegment reinterpret(MemorySegment addr, long elementCount, Arena arena, Consumer<MemorySegment> cleanup) { |
| 216 | + return addr.reinterpret(layout().byteSize() * elementCount, arena, cleanup); |
| 217 | + } |
| 218 | +} |
| 219 | + |
0 commit comments