xref: /aosp_15_r20/external/flatbuffers/tests/MyGame/Example/NestedStruct.java (revision 890232f25432b36107d06881e0a25aaa6b473652)
1 // automatically generated by the FlatBuffers compiler, do not modify
2 
3 package MyGame.Example;
4 
5 import java.nio.*;
6 import java.lang.*;
7 import java.util.*;
8 import com.google.flatbuffers.*;
9 
10 @SuppressWarnings("unused")
11 public final class NestedStruct extends Struct {
__init(int _i, ByteBuffer _bb)12   public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
__assign(int _i, ByteBuffer _bb)13   public NestedStruct __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
14 
a(int j)15   public int a(int j) { return bb.getInt(bb_pos + 0 + j * 4); }
mutateA(int j, int a)16   public void mutateA(int j, int a) { bb.putInt(bb_pos + 0 + j * 4, a); }
b()17   public byte b() { return bb.get(bb_pos + 8); }
mutateB(byte b)18   public void mutateB(byte b) { bb.put(bb_pos + 8, b); }
c(int j)19   public byte c(int j) { return bb.get(bb_pos + 9 + j * 1); }
mutateC(int j, byte c)20   public void mutateC(int j, byte c) { bb.put(bb_pos + 9 + j * 1, c); }
d(int j)21   public long d(int j) { return bb.getLong(bb_pos + 16 + j * 8); }
mutateD(int j, long d)22   public void mutateD(int j, long d) { bb.putLong(bb_pos + 16 + j * 8, d); }
23 
createNestedStruct(FlatBufferBuilder builder, int[] a, byte b, byte[] c, long[] d)24   public static int createNestedStruct(FlatBufferBuilder builder, int[] a, byte b, byte[] c, long[] d) {
25     builder.prep(8, 32);
26     for (int _idx0 = 2; _idx0 > 0; _idx0--) {
27       builder.putLong(d[_idx0-1]);
28     }
29     builder.pad(5);
30     for (int _idx0 = 2; _idx0 > 0; _idx0--) {
31       builder.putByte(c[_idx0-1]);
32     }
33     builder.putByte(b);
34     for (int _idx0 = 2; _idx0 > 0; _idx0--) {
35       builder.putInt(a[_idx0-1]);
36     }
37     return builder.offset();
38   }
39 
40   public static final class Vector extends BaseVector {
__assign(int _vector, int _element_size, ByteBuffer _bb)41     public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
42 
get(int j)43     public NestedStruct get(int j) { return get(new NestedStruct(), j); }
get(NestedStruct obj, int j)44     public NestedStruct get(NestedStruct obj, int j) {  return obj.__assign(__element(j), bb); }
45   }
unpack()46   public NestedStructT unpack() {
47     NestedStructT _o = new NestedStructT();
48     unpackTo(_o);
49     return _o;
50   }
unpackTo(NestedStructT _o)51   public void unpackTo(NestedStructT _o) {
52     int[] _oA = _o.getA();
53     for (int _j = 0; _j < 2; ++_j) { _oA[_j] = a(_j); }
54     byte _oB = b();
55     _o.setB(_oB);
56     byte[] _oC = _o.getC();
57     for (int _j = 0; _j < 2; ++_j) { _oC[_j] = c(_j); }
58     long[] _oD = _o.getD();
59     for (int _j = 0; _j < 2; ++_j) { _oD[_j] = d(_j); }
60   }
pack(FlatBufferBuilder builder, NestedStructT _o)61   public static int pack(FlatBufferBuilder builder, NestedStructT _o) {
62     if (_o == null) return 0;
63     int[] _a = _o.getA();
64     byte[] _c = _o.getC();
65     long[] _d = _o.getD();
66     return createNestedStruct(
67       builder,
68       _a,
69       _o.getB(),
70       _c,
71       _d);
72   }
73 }
74 
75