blob: ef6f31ffa0827e587f3da9153690e08f6f7087bb [file] [log] [blame]
Austin Schuhe89fa2d2019-08-14 20:24:23 -07001// automatically generated by the FlatBuffers compiler, do not modify
2
3package MyGame.Example
4
5import java.nio.*
6import kotlin.math.sign
7import com.google.flatbuffers.*
8
9@Suppress("unused")
Austin Schuhe89fa2d2019-08-14 20:24:23 -070010class Stat : Table() {
11
12 fun __init(_i: Int, _bb: ByteBuffer) {
13 __reset(_i, _bb)
14 }
15 fun __assign(_i: Int, _bb: ByteBuffer) : Stat {
16 __init(_i, _bb)
17 return this
18 }
19 val id : String?
20 get() {
21 val o = __offset(4)
22 return if (o != 0) __string(o + bb_pos) else null
23 }
24 val idAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(4, 1)
25 fun idInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1)
26 val val_ : Long
27 get() {
28 val o = __offset(6)
29 return if(o != 0) bb.getLong(o + bb_pos) else 0L
30 }
31 fun mutateVal_(val_: Long) : Boolean {
32 val o = __offset(6)
33 return if (o != 0) {
34 bb.putLong(o + bb_pos, val_)
35 true
36 } else {
37 false
38 }
39 }
40 val count : UShort
41 get() {
42 val o = __offset(8)
43 return if(o != 0) bb.getShort(o + bb_pos).toUShort() else 0u
44 }
45 fun mutateCount(count: UShort) : Boolean {
46 val o = __offset(8)
47 return if (o != 0) {
48 bb.putShort(o + bb_pos, count.toShort())
49 true
50 } else {
51 false
52 }
53 }
James Kuszmaul8e62b022022-03-22 09:33:25 -070054 override fun keysCompare(o1: Int, o2: Int, _bb: ByteBuffer) : Int {
55 val val_1 = _bb.getShort(__offset(8, o1, _bb))
56 val val_2 = _bb.getShort(__offset(8, o2, _bb))
57 return (val_1 - val_2).sign
58 }
Austin Schuhe89fa2d2019-08-14 20:24:23 -070059 companion object {
Austin Schuh2dd86a92022-09-14 21:19:23 -070060 fun validateVersion() = Constants.FLATBUFFERS_2_0_8()
Austin Schuhe89fa2d2019-08-14 20:24:23 -070061 fun getRootAsStat(_bb: ByteBuffer): Stat = getRootAsStat(_bb, Stat())
62 fun getRootAsStat(_bb: ByteBuffer, obj: Stat): Stat {
63 _bb.order(ByteOrder.LITTLE_ENDIAN)
64 return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
65 }
66 fun createStat(builder: FlatBufferBuilder, idOffset: Int, val_: Long, count: UShort) : Int {
67 builder.startTable(3)
68 addVal_(builder, val_)
69 addId(builder, idOffset)
70 addCount(builder, count)
71 return endStat(builder)
72 }
73 fun startStat(builder: FlatBufferBuilder) = builder.startTable(3)
74 fun addId(builder: FlatBufferBuilder, id: Int) = builder.addOffset(0, id, 0)
75 fun addVal_(builder: FlatBufferBuilder, val_: Long) = builder.addLong(1, val_, 0L)
Austin Schuh2dd86a92022-09-14 21:19:23 -070076 fun addCount(builder: FlatBufferBuilder, count: UShort) {
77 builder.addShort(count.toShort())
78 builder.slot(2)
79 }
Austin Schuhe89fa2d2019-08-14 20:24:23 -070080 fun endStat(builder: FlatBufferBuilder) : Int {
81 val o = builder.endTable()
82 return o
83 }
James Kuszmaul8e62b022022-03-22 09:33:25 -070084 fun __lookup_by_key(obj: Stat?, vectorLocation: Int, key: UShort, bb: ByteBuffer) : Stat? {
85 var span = bb.getInt(vectorLocation - 4)
86 var start = 0
87 while (span != 0) {
88 var middle = span / 2
89 val tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb)
90 val value = bb.getShort(__offset(8, bb.capacity() - tableOffset, bb)).toUShort()
91 val comp = value.compareTo(key)
92 when {
93 comp > 0 -> span = middle
94 comp < 0 -> {
95 middle++
96 start += middle
97 span -= middle
98 }
99 else -> {
100 return (obj ?: Stat()).__assign(tableOffset, bb)
101 }
102 }
103 }
104 return null
105 }
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700106 }
107}