...

Text file src/github.com/google/flatbuffers/tests/MyGame/Example/NestedStruct.java

Documentation: github.com/google/flatbuffers/tests/MyGame/Example

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

View as plain text