[Kotlin] Control the generation of reflection with --reflect-names (#7775)

* [Kotlin] Control the generation of reflection with --reflect-names.
Tested:
```
$ cmake -G "Unix Makefiles" && make && ./tests/flatc/main.py
...
KotlinTests.EnumValAttributes
 [PASSED]
KotlinTests.EnumValAttributes_ReflectNames
 [PASSED]
KotlinTests: 2 of 2 passsed
...

35 of 35 tests passed
```

* [Kotlin] Fix SampleBinary by converting Byte to UByte for ubyte fields.

* [Kotlin] Annotate all generated classes with kotlin.ExperimentalUnsignedTypes.
This commit is contained in:
Anton Bobukh
2023-01-10 10:03:39 -08:00
committed by GitHub
parent 7bf83f5ea0
commit b50b6be60a
35 changed files with 74 additions and 6 deletions

View File

@@ -24,6 +24,7 @@ import MyGame.Sample.Weapon
import com.google.flatbuffers.FlatBufferBuilder
@kotlin.ExperimentalUnsignedTypes
class SampleBinary {
companion object {
@@ -45,7 +46,7 @@ class SampleBinary {
// Serialize the FlatBuffer data.
val name = builder.createString("Orc")
val treasure = byteArrayOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
val treasure = byteArrayOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9).asUByteArray()
val inv = Monster.createInventoryVector(builder, treasure)
val weapons = Monster.createWeaponsVector(builder, weaps)
val pos = Vec3.createVec3(builder, 1.0f, 2.0f, 3.0f)
@@ -85,7 +86,7 @@ class SampleBinary {
// Get and test the `inventory` FlatBuffer `vector`.
for (i in 0 until monster.inventoryLength) {
assert(monster.inventory(i) == i.toByte().toInt())
assert(monster.inventory(i) == i.toUByte())
}
// Get and test the `weapons` FlatBuffer `vector` of `table`s.