...

Text file src/github.com/google/flatbuffers/tests/MyGame/Example/TestSimpleTableWithEnum.kt

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.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 TestSimpleTableWithEnum : Table() {
    23
    24    fun __init(_i: Int, _bb: ByteBuffer)  {
    25        __reset(_i, _bb)
    26    }
    27    fun __assign(_i: Int, _bb: ByteBuffer) : TestSimpleTableWithEnum {
    28        __init(_i, _bb)
    29        return this
    30    }
    31    val color : UByte
    32        get() {
    33            val o = __offset(4)
    34            return if(o != 0) bb.get(o + bb_pos).toUByte() else 2u
    35        }
    36    fun mutateColor(color: UByte) : Boolean {
    37        val o = __offset(4)
    38        return if (o != 0) {
    39            bb.put(o + bb_pos, color.toByte())
    40            true
    41        } else {
    42            false
    43        }
    44    }
    45    companion object {
    46        fun validateVersion() = Constants.FLATBUFFERS_23_5_26()
    47        fun getRootAsTestSimpleTableWithEnum(_bb: ByteBuffer): TestSimpleTableWithEnum = getRootAsTestSimpleTableWithEnum(_bb, TestSimpleTableWithEnum())
    48        fun getRootAsTestSimpleTableWithEnum(_bb: ByteBuffer, obj: TestSimpleTableWithEnum): TestSimpleTableWithEnum {
    49            _bb.order(ByteOrder.LITTLE_ENDIAN)
    50            return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
    51        }
    52        fun createTestSimpleTableWithEnum(builder: FlatBufferBuilder, color: UByte) : Int {
    53            builder.startTable(1)
    54            addColor(builder, color)
    55            return endTestSimpleTableWithEnum(builder)
    56        }
    57        fun startTestSimpleTableWithEnum(builder: FlatBufferBuilder) = builder.startTable(1)
    58        fun addColor(builder: FlatBufferBuilder, color: UByte) = builder.addByte(0, color.toByte(), 2)
    59        fun endTestSimpleTableWithEnum(builder: FlatBufferBuilder) : Int {
    60            val o = builder.endTable()
    61            return o
    62        }
    63    }
    64}

View as plain text