forked from BigfootDev/flatbuffers
* [Kotlin] Add kotlin generate code for tests and add kotlin test to TestAll.sh * [Kotlin] Add Kotlin generator This change adds support for generating Kotlin classes. The approach of this generator is to keep it as close as possible to the java generator for now, in order to keep the change simple. It uses the already implemented java runtime, so we don't support cross-platform nor js Kotlin yet. Kotlin tests are just a copy of the java tests. * Add optional ident support for CodeWriter Identation is important for some languages and different projects have different ways of ident code, e.g. tabs vs spaces, so we are adding optional support on CodeWriter for identation. * [Kotlin] Add Documentation for Kotlin * [Kotlin] Modify generated code to use experimental Unsigned types.
34 lines
919 B
Kotlin
34 lines
919 B
Kotlin
// automatically generated by the FlatBuffers compiler, do not modify
|
|
|
|
package MyGame.Example
|
|
|
|
import java.nio.*
|
|
import kotlin.math.sign
|
|
import com.google.flatbuffers.*
|
|
|
|
@Suppress("unused")
|
|
@ExperimentalUnsignedTypes
|
|
class Test : Struct() {
|
|
|
|
fun __init(_i: Int, _bb: ByteBuffer) {
|
|
__reset(_i, _bb)
|
|
}
|
|
fun __assign(_i: Int, _bb: ByteBuffer) : Test {
|
|
__init(_i, _bb)
|
|
return this
|
|
}
|
|
val a : Short get() = bb.getShort(bb_pos + 0)
|
|
fun mutateA(a: Short) : ByteBuffer = bb.putShort(bb_pos + 0, a)
|
|
val b : Byte get() = bb.get(bb_pos + 2)
|
|
fun mutateB(b: Byte) : ByteBuffer = bb.put(bb_pos + 2, b)
|
|
companion object {
|
|
fun createTest(builder: FlatBufferBuilder, a: Short, b: Byte) : Int {
|
|
builder.prep(2, 4)
|
|
builder.pad(1)
|
|
builder.putByte(b)
|
|
builder.putShort(a)
|
|
return builder.offset()
|
|
}
|
|
}
|
|
}
|