xref: /aosp_15_r20/external/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.kt (revision 890232f25432b36107d06881e0a25aaa6b473652)
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 class TestSimpleTableWithEnum : Table() {
11 
__initnull12     fun __init(_i: Int, _bb: ByteBuffer)  {
13         __reset(_i, _bb)
14     }
__assignnull15     fun __assign(_i: Int, _bb: ByteBuffer) : TestSimpleTableWithEnum {
16         __init(_i, _bb)
17         return this
18     }
19     val color : UByte
20         get() {
21             val o = __offset(4)
22             return if(o != 0) bb.get(o + bb_pos).toUByte() else 2u
23         }
mutateColornull24     fun mutateColor(color: UByte) : Boolean {
25         val o = __offset(4)
26         return if (o != 0) {
27             bb.put(o + bb_pos, color.toByte())
28             true
29         } else {
30             false
31         }
32     }
33     companion object {
validateVersionnull34         fun validateVersion() = Constants.FLATBUFFERS_2_0_0()
35         fun getRootAsTestSimpleTableWithEnum(_bb: ByteBuffer): TestSimpleTableWithEnum = getRootAsTestSimpleTableWithEnum(_bb, TestSimpleTableWithEnum())
36         fun getRootAsTestSimpleTableWithEnum(_bb: ByteBuffer, obj: TestSimpleTableWithEnum): TestSimpleTableWithEnum {
37             _bb.order(ByteOrder.LITTLE_ENDIAN)
38             return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
39         }
createTestSimpleTableWithEnumnull40         fun createTestSimpleTableWithEnum(builder: FlatBufferBuilder, color: UByte) : Int {
41             builder.startTable(1)
42             addColor(builder, color)
43             return endTestSimpleTableWithEnum(builder)
44         }
startTestSimpleTableWithEnumnull45         fun startTestSimpleTableWithEnum(builder: FlatBufferBuilder) = builder.startTable(1)
46         fun addColor(builder: FlatBufferBuilder, color: UByte) = builder.addByte(0, color.toByte(), 2)
47         fun endTestSimpleTableWithEnum(builder: FlatBufferBuilder) : Int {
48             val o = builder.endTable()
49             return o
50         }
51     }
52 }
53