...
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.LongVector
13import com.google.flatbuffers.StringVector
14import com.google.flatbuffers.Struct
15import com.google.flatbuffers.Table
16import com.google.flatbuffers.UnionVector
17import java.nio.ByteBuffer
18import java.nio.ByteOrder
19import kotlin.math.sign
20
21@Suppress("unused")
22class Referrable : Table() {
23
24 fun __init(_i: Int, _bb: ByteBuffer) {
25 __reset(_i, _bb)
26 }
27 fun __assign(_i: Int, _bb: ByteBuffer) : Referrable {
28 __init(_i, _bb)
29 return this
30 }
31 val id : ULong
32 get() {
33 val o = __offset(4)
34 return if(o != 0) bb.getLong(o + bb_pos).toULong() else 0UL
35 }
36 fun mutateId(id: ULong) : Boolean {
37 val o = __offset(4)
38 return if (o != 0) {
39 bb.putLong(o + bb_pos, id.toLong())
40 true
41 } else {
42 false
43 }
44 }
45 override fun keysCompare(o1: Int, o2: Int, _bb: ByteBuffer) : Int {
46 val val_1 = _bb.getLong(__offset(4, o1, _bb))
47 val val_2 = _bb.getLong(__offset(4, o2, _bb))
48 return (val_1 - val_2).sign
49 }
50 companion object {
51 fun validateVersion() = Constants.FLATBUFFERS_23_5_26()
52 fun getRootAsReferrable(_bb: ByteBuffer): Referrable = getRootAsReferrable(_bb, Referrable())
53 fun getRootAsReferrable(_bb: ByteBuffer, obj: Referrable): Referrable {
54 _bb.order(ByteOrder.LITTLE_ENDIAN)
55 return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
56 }
57 fun createReferrable(builder: FlatBufferBuilder, id: ULong) : Int {
58 builder.startTable(1)
59 addId(builder, id)
60 return endReferrable(builder)
61 }
62 fun startReferrable(builder: FlatBufferBuilder) = builder.startTable(1)
63 fun addId(builder: FlatBufferBuilder, id: ULong) {
64 builder.addLong(id.toLong())
65 builder.slot(0)
66 }
67 fun endReferrable(builder: FlatBufferBuilder) : Int {
68 val o = builder.endTable()
69 return o
70 }
71 fun __lookup_by_key(obj: Referrable?, vectorLocation: Int, key: ULong, bb: ByteBuffer) : Referrable? {
72 var span = bb.getInt(vectorLocation - 4)
73 var start = 0
74 while (span != 0) {
75 var middle = span / 2
76 val tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb)
77 val value = bb.getLong(__offset(4, bb.capacity() - tableOffset, bb)).toULong()
78 val comp = value.compareTo(key)
79 when {
80 comp > 0 -> span = middle
81 comp < 0 -> {
82 middle++
83 start += middle
84 span -= middle
85 }
86 else -> {
87 return (obj ?: Referrable()).__assign(tableOffset, bb)
88 }
89 }
90 }
91 return null
92 }
93 }
94}
View as plain text