|
1 | | -package io.github.dfa1.vortex.core.fbs; |
| 1 | +// Generated by vortex-fbs-gen. Do not edit. |
2 | 2 |
|
3 | | -import static io.github.dfa1.vortex.core.io.VortexFormat.LE_DOUBLE; |
4 | | -import static io.github.dfa1.vortex.core.io.VortexFormat.LE_FLOAT; |
5 | | -import static io.github.dfa1.vortex.core.io.VortexFormat.LE_INT; |
6 | | -import static io.github.dfa1.vortex.core.io.VortexFormat.LE_LONG; |
7 | | -import static io.github.dfa1.vortex.core.io.VortexFormat.LE_SHORT; |
| 3 | +package io.github.dfa1.vortex.core.fbs; |
8 | 4 |
|
9 | 5 | import java.lang.foreign.MemorySegment; |
10 | | -import java.lang.foreign.ValueLayout; |
| 6 | +import javax.annotation.processing.Generated; |
| 7 | + |
| 8 | +/// Reader and builder for the `Struct_` FlatBuffers table. |
| 9 | +@Generated("io.github.dfa1.vortex.fbsgen.CodeGen") |
| 10 | +public final class FbsStruct extends FbsTable { |
| 11 | + |
| 12 | + /// Positions a reader at the root table of a finished buffer. |
| 13 | + /// @param seg the buffer |
| 14 | + /// @return a reader positioned at the root |
| 15 | + public static FbsStruct getRootAsFbsStruct(MemorySegment seg) { |
| 16 | + return new FbsStruct().assign(seg, FbsTable.rootPosition(seg, 0)); |
| 17 | + } |
| 18 | + |
| 19 | + /// Positions this reader at a table. |
| 20 | + /// @param seg the buffer |
| 21 | + /// @param position the table position |
| 22 | + /// @return this |
| 23 | + public FbsStruct assign(MemorySegment seg, long position) { |
| 24 | + init(seg, position); |
| 25 | + return this; |
| 26 | + } |
| 27 | + |
| 28 | + /// @return the length of the `names` vector |
| 29 | + public int namesLength() { |
| 30 | + int o = fieldOffset(4); |
| 31 | + return o != 0 ? vectorLength(o) : 0; |
| 32 | + } |
| 33 | + |
| 34 | + /// @param j element index |
| 35 | + /// @return the j-th `names` string |
| 36 | + public String names(int j) { |
| 37 | + int o = fieldOffset(4); |
| 38 | + return readStringAt(vectorElements(o) + (long) j * 4); |
| 39 | + } |
| 40 | + |
| 41 | + /// @return the length of the `dtypes` vector |
| 42 | + public int dtypesLength() { |
| 43 | + int o = fieldOffset(6); |
| 44 | + return o != 0 ? vectorLength(o) : 0; |
| 45 | + } |
| 46 | + |
| 47 | + /// @param j element index |
| 48 | + /// @return the j-th `dtypes` element |
| 49 | + public FbsDType dtypes(int j) { |
| 50 | + int o = fieldOffset(6); |
| 51 | + return new FbsDType().assign(seg, indirect(vectorElements(o) + (long) j * 4)); |
| 52 | + } |
11 | 53 |
|
12 | | -/// MemorySegment-native base for generated FlatBuffers struct accessors. |
13 | | -/// |
14 | | -/// Unlike a table, a FlatBuffers struct is a fixed-size, inline record with no |
15 | | -/// vtable: every field lives at a compile-time-constant byte offset from the |
16 | | -/// struct position, and every field is always present. Generated accessors read |
17 | | -/// directly at `position + fieldOffset`. |
18 | | -/// |
19 | | -/// Package-private: only the generated struct accessors in this package extend it. |
20 | | -class FbsStruct { |
| 54 | + /// @return the `nullable` field |
| 55 | + public boolean nullable() { |
| 56 | + int o = fieldOffset(8); |
| 57 | + return o != 0 ? readByte(pos + o) != 0 : false; |
| 58 | + } |
21 | 59 |
|
22 | | - /// The backing buffer. |
23 | | - protected MemorySegment seg; |
| 60 | + /// Sets the `names` offset field. |
| 61 | + /// @param b the builder |
| 62 | + /// @param offset the referenced offset |
| 63 | + public static void addNames(FbsBuilder b, int offset) { |
| 64 | + b.addOffset(0, offset, 0); |
| 65 | + } |
24 | 66 |
|
25 | | - /// This struct's byte position within [#seg]. |
26 | | - protected long pos; |
| 67 | + /// Creates the `names` offset vector. |
| 68 | + /// @param b the builder |
| 69 | + /// @param data element offsets |
| 70 | + /// @return the vector offset |
| 71 | + public static int createNamesVector(FbsBuilder b, int[] data) { |
| 72 | + b.startVector(4, data.length, 4); |
| 73 | + for (int i = data.length - 1; i >= 0; i--) { |
| 74 | + b.addOffset(data[i]); |
| 75 | + } |
| 76 | + return b.endVector(); |
| 77 | + } |
| 78 | + |
| 79 | + /// Begins the `names` vector. |
| 80 | + /// @param b the builder |
| 81 | + /// @param numElems element count |
| 82 | + public static void startNamesVector(FbsBuilder b, int numElems) { |
| 83 | + b.startVector(4, numElems, 4); |
| 84 | + } |
27 | 85 |
|
28 | | - /// Creates an unpositioned cursor; call [#init(MemorySegment, long)] before use. |
29 | | - protected FbsStruct() { |
| 86 | + /// Sets the `dtypes` offset field. |
| 87 | + /// @param b the builder |
| 88 | + /// @param offset the referenced offset |
| 89 | + public static void addDtypes(FbsBuilder b, int offset) { |
| 90 | + b.addOffset(1, offset, 0); |
30 | 91 | } |
31 | 92 |
|
32 | | - /// Positions this cursor at a struct. |
33 | | - /// |
34 | | - /// @param segment backing buffer |
35 | | - /// @param position struct position within the buffer |
36 | | - protected final void init(MemorySegment segment, long position) { |
37 | | - this.seg = segment; |
38 | | - this.pos = position; |
| 93 | + /// Creates the `dtypes` offset vector. |
| 94 | + /// @param b the builder |
| 95 | + /// @param data element offsets |
| 96 | + /// @return the vector offset |
| 97 | + public static int createDtypesVector(FbsBuilder b, int[] data) { |
| 98 | + b.startVector(4, data.length, 4); |
| 99 | + for (int i = data.length - 1; i >= 0; i--) { |
| 100 | + b.addOffset(data[i]); |
| 101 | + } |
| 102 | + return b.endVector(); |
39 | 103 | } |
40 | 104 |
|
41 | | - /// @param fieldOffset constant byte offset of the field within the struct |
42 | | - /// @return the signed byte field |
43 | | - protected final byte readByte(int fieldOffset) { |
44 | | - return seg.get(ValueLayout.JAVA_BYTE, pos + fieldOffset); |
| 105 | + /// Begins the `dtypes` vector. |
| 106 | + /// @param b the builder |
| 107 | + /// @param numElems element count |
| 108 | + public static void startDtypesVector(FbsBuilder b, int numElems) { |
| 109 | + b.startVector(4, numElems, 4); |
45 | 110 | } |
46 | 111 |
|
47 | | - /// @param fieldOffset constant byte offset of the field within the struct |
48 | | - /// @return the little-endian 16-bit field |
49 | | - protected final short readShort(int fieldOffset) { |
50 | | - return seg.get(LE_SHORT, pos + fieldOffset); |
| 112 | + /// Sets the `nullable` field. |
| 113 | + /// @param b the builder |
| 114 | + /// @param nullable value |
| 115 | + public static void addNullable(FbsBuilder b, boolean nullable) { |
| 116 | + b.addBoolean(2, nullable, false); |
51 | 117 | } |
52 | 118 |
|
53 | | - /// @param fieldOffset constant byte offset of the field within the struct |
54 | | - /// @return the little-endian 32-bit field |
55 | | - protected final int readInt(int fieldOffset) { |
56 | | - return seg.get(LE_INT, pos + fieldOffset); |
| 119 | + /// Builds a `FbsStruct` table. |
| 120 | + /// @param b the builder |
| 121 | + /// @param namesOffset field value |
| 122 | + /// @param dtypesOffset field value |
| 123 | + /// @param nullable field value |
| 124 | + /// @return the table offset |
| 125 | + public static int createFbsStruct(FbsBuilder b, int namesOffset, int dtypesOffset, boolean nullable) { |
| 126 | + b.startTable(3); |
| 127 | + b.addOffset(1, dtypesOffset, 0); |
| 128 | + b.addOffset(0, namesOffset, 0); |
| 129 | + b.addBoolean(2, nullable, false); |
| 130 | + return b.endTable(); |
57 | 131 | } |
58 | 132 |
|
59 | | - /// @param fieldOffset constant byte offset of the field within the struct |
60 | | - /// @return the little-endian 64-bit field |
61 | | - protected final long readLong(int fieldOffset) { |
62 | | - return seg.get(LE_LONG, pos + fieldOffset); |
| 133 | + /// Begins a `FbsStruct` table. |
| 134 | + /// @param b the builder |
| 135 | + public static void startFbsStruct(FbsBuilder b) { |
| 136 | + b.startTable(3); |
63 | 137 | } |
64 | 138 |
|
65 | | - /// @param fieldOffset constant byte offset of the field within the struct |
66 | | - /// @return the little-endian 32-bit float field |
67 | | - protected final float readFloat(int fieldOffset) { |
68 | | - return seg.get(LE_FLOAT, pos + fieldOffset); |
| 139 | + /// Finishes a `FbsStruct` table. |
| 140 | + /// @param b the builder |
| 141 | + /// @return the table offset |
| 142 | + public static int endFbsStruct(FbsBuilder b) { |
| 143 | + return b.endTable(); |
69 | 144 | } |
70 | 145 |
|
71 | | - /// @param fieldOffset constant byte offset of the field within the struct |
72 | | - /// @return the little-endian 64-bit double field |
73 | | - protected final double readDouble(int fieldOffset) { |
74 | | - return seg.get(LE_DOUBLE, pos + fieldOffset); |
| 146 | + /// Finishes the buffer with a `FbsStruct` root. |
| 147 | + /// @param b the builder |
| 148 | + /// @param offset the root table offset |
| 149 | + public static void finishFbsStructBuffer(FbsBuilder b, int offset) { |
| 150 | + b.finish(offset); |
75 | 151 | } |
76 | 152 | } |
0 commit comments