xref: /aosp_15_r20/external/flatbuffers/tests/MyGame/Example/ArrayStruct.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 ArrayStruct 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 ArrayStruct __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
14 
a()15   public float a() { return bb.getFloat(bb_pos + 0); }
mutateA(float a)16   public void mutateA(float a) { bb.putFloat(bb_pos + 0, a); }
b(int j)17   public int b(int j) { return bb.getInt(bb_pos + 4 + j * 4); }
mutateB(int j, int b)18   public void mutateB(int j, int b) { bb.putInt(bb_pos + 4 + j * 4, b); }
c()19   public byte c() { return bb.get(bb_pos + 64); }
mutateC(byte c)20   public void mutateC(byte c) { bb.put(bb_pos + 64, c); }
d(int j)21   public MyGame.Example.NestedStruct d(int j) { return d(new MyGame.Example.NestedStruct(), j); }
d(MyGame.Example.NestedStruct obj, int j)22   public MyGame.Example.NestedStruct d(MyGame.Example.NestedStruct obj, int j) { return obj.__assign(bb_pos + 72 + j * 32, bb); }
e()23   public int e() { return bb.getInt(bb_pos + 136); }
mutateE(int e)24   public void mutateE(int e) { bb.putInt(bb_pos + 136, e); }
f(int j)25   public long f(int j) { return bb.getLong(bb_pos + 144 + j * 8); }
mutateF(int j, long f)26   public void mutateF(int j, long f) { bb.putLong(bb_pos + 144 + j * 8, f); }
27 
createArrayStruct(FlatBufferBuilder builder, float a, int[] b, byte c, int[][] d_a, byte[] d_b, byte[][] d_c, long[][] d_d, int e, long[] f)28   public static int createArrayStruct(FlatBufferBuilder builder, float a, int[] b, byte c, int[][] d_a, byte[] d_b, byte[][] d_c, long[][] d_d, int e, long[] f) {
29     builder.prep(8, 160);
30     for (int _idx0 = 2; _idx0 > 0; _idx0--) {
31       builder.putLong(f[_idx0-1]);
32     }
33     builder.pad(4);
34     builder.putInt(e);
35     for (int _idx0 = 2; _idx0 > 0; _idx0--) {
36       builder.prep(8, 32);
37       for (int _idx1 = 2; _idx1 > 0; _idx1--) {
38         builder.putLong(d_d[_idx0-1][_idx1-1]);
39       }
40       builder.pad(5);
41       for (int _idx1 = 2; _idx1 > 0; _idx1--) {
42         builder.putByte(d_c[_idx0-1][_idx1-1]);
43       }
44       builder.putByte(d_b[_idx0-1]);
45       for (int _idx1 = 2; _idx1 > 0; _idx1--) {
46         builder.putInt(d_a[_idx0-1][_idx1-1]);
47       }
48     }
49     builder.pad(7);
50     builder.putByte(c);
51     for (int _idx0 = 15; _idx0 > 0; _idx0--) {
52       builder.putInt(b[_idx0-1]);
53     }
54     builder.putFloat(a);
55     return builder.offset();
56   }
57 
58   public static final class Vector extends BaseVector {
__assign(int _vector, int _element_size, ByteBuffer _bb)59     public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
60 
get(int j)61     public ArrayStruct get(int j) { return get(new ArrayStruct(), j); }
get(ArrayStruct obj, int j)62     public ArrayStruct get(ArrayStruct obj, int j) {  return obj.__assign(__element(j), bb); }
63   }
unpack()64   public ArrayStructT unpack() {
65     ArrayStructT _o = new ArrayStructT();
66     unpackTo(_o);
67     return _o;
68   }
unpackTo(ArrayStructT _o)69   public void unpackTo(ArrayStructT _o) {
70     float _oA = a();
71     _o.setA(_oA);
72     int[] _oB = _o.getB();
73     for (int _j = 0; _j < 15; ++_j) { _oB[_j] = b(_j); }
74     byte _oC = c();
75     _o.setC(_oC);
76     MyGame.Example.NestedStructT[] _oD = _o.getD();
77     for (int _j = 0; _j < 2; ++_j) { _oD[_j] = d(_j).unpack(); }
78     int _oE = e();
79     _o.setE(_oE);
80     long[] _oF = _o.getF();
81     for (int _j = 0; _j < 2; ++_j) { _oF[_j] = f(_j); }
82   }
pack(FlatBufferBuilder builder, ArrayStructT _o)83   public static int pack(FlatBufferBuilder builder, ArrayStructT _o) {
84     if (_o == null) return 0;
85     int[] _b = _o.getB();
86     int[][] _d_a = new int[2][2];
87     for (int idx0 = 0; idx0 < 2; ++idx0) {for (int idx1 = 0; idx1 < 2; ++idx1) {_d_a[idx0][idx1] = _o.getD()[idx0].getA()[idx1];}}
88     byte[] _d_b = new byte[2];
89     for (int idx0 = 0; idx0 < 2; ++idx0) {_d_b[idx0] = _o.getD()[idx0].getB();}
90     byte[][] _d_c = new byte[2][2];
91     for (int idx0 = 0; idx0 < 2; ++idx0) {for (int idx1 = 0; idx1 < 2; ++idx1) {_d_c[idx0][idx1] = _o.getD()[idx0].getC()[idx1];}}
92     long[][] _d_d = new long[2][2];
93     for (int idx0 = 0; idx0 < 2; ++idx0) {for (int idx1 = 0; idx1 < 2; ++idx1) {_d_d[idx0][idx1] = _o.getD()[idx0].getD()[idx1];}}
94     long[] _f = _o.getF();
95     return createArrayStruct(
96       builder,
97       _o.getA(),
98       _b,
99       _o.getC(),
100       _d_a,
101       _d_b,
102       _d_c,
103       _d_d,
104       _o.getE(),
105       _f);
106   }
107 }
108 
109