• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // automatically generated by the FlatBuffers compiler, do not modify
2 
3 package MyGame.Example
4 
5 import java.nio.*
6 import kotlin.math.sign
7 import com.google.flatbuffers.*
8 
9 @Suppress("unused")
10 @ExperimentalUnsignedTypes
11 class Referrable : Table() {
12 
__initnull13     fun __init(_i: Int, _bb: ByteBuffer)  {
14         __reset(_i, _bb)
15     }
__assignnull16     fun __assign(_i: Int, _bb: ByteBuffer) : Referrable {
17         __init(_i, _bb)
18         return this
19     }
20     val id : ULong
21         get() {
22             val o = __offset(4)
23             return if(o != 0) bb.getLong(o + bb_pos).toULong() else 0UL
24         }
mutateIdnull25     fun mutateId(id: ULong) : Boolean {
26         val o = __offset(4)
27         return if (o != 0) {
28             bb.putLong(o + bb_pos, id.toLong())
29             true
30         } else {
31             false
32         }
33     }
keysComparenull34     override fun keysCompare(o1: Int, o2: Int, _bb: ByteBuffer) : Int {
35         val val_1 = _bb.getLong(__offset(4, o1, _bb))
36         val val_2 = _bb.getLong(__offset(4, o2, _bb))
37         return (val_1 - val_2).sign
38     }
39     companion object {
validateVersionnull40         fun validateVersion() = Constants.FLATBUFFERS_1_12_0()
41         fun getRootAsReferrable(_bb: ByteBuffer): Referrable = getRootAsReferrable(_bb, Referrable())
42         fun getRootAsReferrable(_bb: ByteBuffer, obj: Referrable): Referrable {
43             _bb.order(ByteOrder.LITTLE_ENDIAN)
44             return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
45         }
createReferrablenull46         fun createReferrable(builder: FlatBufferBuilder, id: ULong) : Int {
47             builder.startTable(1)
48             addId(builder, id)
49             return endReferrable(builder)
50         }
startReferrablenull51         fun startReferrable(builder: FlatBufferBuilder) = builder.startTable(1)
52         fun addId(builder: FlatBufferBuilder, id: ULong) = builder.addLong(0, id.toLong(), 0)
53         fun endReferrable(builder: FlatBufferBuilder) : Int {
54             val o = builder.endTable()
55             return o
56         }
__lookup_by_keynull57         fun __lookup_by_key(obj: Referrable?, vectorLocation: Int, key: ULong, bb: ByteBuffer) : Referrable? {
58             var span = bb.getInt(vectorLocation - 4)
59             var start = 0
60             while (span != 0) {
61                 var middle = span / 2
62                 val tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb)
63                 val value = bb.getLong(__offset(4, bb.capacity() - tableOffset, bb)).toULong()
64                 val comp = value.compareTo(key)
65                 when {
66                     comp > 0 -> span = middle
67                     comp < 0 -> {
68                         middle++
69                         start += middle
70                         span -= middle
71                     }
72                     else -> {
73                         return (obj ?: Referrable()).__assign(tableOffset, bb)
74                     }
75                 }
76             }
77             return null
78         }
79     }
80 }
81