mirror of
https://github.com/google/flatbuffers.git
synced 2025-04-08 09:12:14 +08:00
Only generate @kotlin.ExperimentalUnsigned annotation on create*Vector methods having an unsigned array type parameter. (#7881)
Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
parent
c192ab423b
commit
417821fdd7
@ -289,7 +289,6 @@ class KotlinGenerator : public BaseGenerator {
|
||||
GenerateComment(enum_def.doc_comment, writer, &comment_config);
|
||||
|
||||
writer += "@Suppress(\"unused\")";
|
||||
writer += "@kotlin.ExperimentalUnsignedTypes";
|
||||
writer += "class " + namer_.Type(enum_def) + " private constructor() {";
|
||||
writer.IncrementIdentLevel();
|
||||
|
||||
@ -495,7 +494,6 @@ class KotlinGenerator : public BaseGenerator {
|
||||
writer.SetValue("superclass", fixed ? "Struct" : "Table");
|
||||
|
||||
writer += "@Suppress(\"unused\")";
|
||||
writer += "@kotlin.ExperimentalUnsignedTypes";
|
||||
writer += "class {{struct_name}} : {{superclass}}() {\n";
|
||||
|
||||
writer.IncrementIdentLevel();
|
||||
@ -703,6 +701,9 @@ class KotlinGenerator : public BaseGenerator {
|
||||
writer.SetValue("root", GenMethod(vector_type));
|
||||
writer.SetValue("cast", CastToSigned(vector_type));
|
||||
|
||||
if (IsUnsigned(vector_type.base_type)) {
|
||||
writer += "@kotlin.ExperimentalUnsignedTypes";
|
||||
}
|
||||
GenerateFun(
|
||||
writer, method_name, params, "Int",
|
||||
[&]() {
|
||||
|
@ -19,7 +19,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class LongFloatEntry : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -19,7 +19,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class LongFloatMap : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -19,7 +19,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Ability : Struct() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -3,7 +3,6 @@
|
||||
package MyGame.Example
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Any_ private constructor() {
|
||||
companion object {
|
||||
const val NONE: UByte = 0u
|
||||
|
@ -3,7 +3,6 @@
|
||||
package MyGame.Example
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class AnyAmbiguousAliases private constructor() {
|
||||
companion object {
|
||||
const val NONE: UByte = 0u
|
||||
|
@ -3,7 +3,6 @@
|
||||
package MyGame.Example
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class AnyUniqueAliases private constructor() {
|
||||
companion object {
|
||||
const val NONE: UByte = 0u
|
||||
|
@ -6,7 +6,6 @@ package MyGame.Example
|
||||
* Composite components of Monster color.
|
||||
*/
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Color private constructor() {
|
||||
companion object {
|
||||
const val Red: UByte = 1u
|
||||
|
@ -3,7 +3,6 @@
|
||||
package MyGame.Example
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class LongEnum private constructor() {
|
||||
companion object {
|
||||
const val LongOne: ULong = 2UL
|
||||
|
@ -22,7 +22,6 @@ import kotlin.math.sign
|
||||
* an example documentation comment: "monster object"
|
||||
*/
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Monster : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
@ -1019,6 +1018,7 @@ class Monster : Table() {
|
||||
builder.slot(3)
|
||||
}
|
||||
fun addInventory(builder: FlatBufferBuilder, inventory: Int) = builder.addOffset(5, inventory, 0)
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
fun createInventoryVector(builder: FlatBufferBuilder, data: UByteArray) : Int {
|
||||
builder.startVector(1, data.size, 1)
|
||||
for (i in data.size - 1 downTo 0) {
|
||||
@ -1052,6 +1052,7 @@ class Monster : Table() {
|
||||
fun startTestarrayoftablesVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(4, numElems, 4)
|
||||
fun addEnemy(builder: FlatBufferBuilder, enemy: Int) = builder.addOffset(12, enemy, 0)
|
||||
fun addTestnestedflatbuffer(builder: FlatBufferBuilder, testnestedflatbuffer: Int) = builder.addOffset(13, testnestedflatbuffer, 0)
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
fun createTestnestedflatbufferVector(builder: FlatBufferBuilder, data: UByteArray) : Int {
|
||||
builder.startVector(1, data.size, 1)
|
||||
for (i in data.size - 1 downTo 0) {
|
||||
@ -1094,6 +1095,7 @@ class Monster : Table() {
|
||||
fun addTestarrayofsortedstruct(builder: FlatBufferBuilder, testarrayofsortedstruct: Int) = builder.addOffset(29, testarrayofsortedstruct, 0)
|
||||
fun startTestarrayofsortedstructVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(8, numElems, 4)
|
||||
fun addFlex(builder: FlatBufferBuilder, flex: Int) = builder.addOffset(30, flex, 0)
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
fun createFlexVector(builder: FlatBufferBuilder, data: UByteArray) : Int {
|
||||
builder.startVector(1, data.size, 1)
|
||||
for (i in data.size - 1 downTo 0) {
|
||||
@ -1134,6 +1136,7 @@ class Monster : Table() {
|
||||
fun startVectorOfReferrablesVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(4, numElems, 4)
|
||||
fun addSingleWeakReference(builder: FlatBufferBuilder, singleWeakReference: ULong) = builder.addLong(36, singleWeakReference.toLong(), 0)
|
||||
fun addVectorOfWeakReferences(builder: FlatBufferBuilder, vectorOfWeakReferences: Int) = builder.addOffset(37, vectorOfWeakReferences, 0)
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
fun createVectorOfWeakReferencesVector(builder: FlatBufferBuilder, data: ULongArray) : Int {
|
||||
builder.startVector(8, data.size, 8)
|
||||
for (i in data.size - 1 downTo 0) {
|
||||
@ -1153,6 +1156,7 @@ class Monster : Table() {
|
||||
fun startVectorOfStrongReferrablesVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(4, numElems, 4)
|
||||
fun addCoOwningReference(builder: FlatBufferBuilder, coOwningReference: ULong) = builder.addLong(39, coOwningReference.toLong(), 0)
|
||||
fun addVectorOfCoOwningReferences(builder: FlatBufferBuilder, vectorOfCoOwningReferences: Int) = builder.addOffset(40, vectorOfCoOwningReferences, 0)
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
fun createVectorOfCoOwningReferencesVector(builder: FlatBufferBuilder, data: ULongArray) : Int {
|
||||
builder.startVector(8, data.size, 8)
|
||||
for (i in data.size - 1 downTo 0) {
|
||||
@ -1163,6 +1167,7 @@ class Monster : Table() {
|
||||
fun startVectorOfCoOwningReferencesVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(8, numElems, 8)
|
||||
fun addNonOwningReference(builder: FlatBufferBuilder, nonOwningReference: ULong) = builder.addLong(41, nonOwningReference.toLong(), 0)
|
||||
fun addVectorOfNonOwningReferences(builder: FlatBufferBuilder, vectorOfNonOwningReferences: Int) = builder.addOffset(42, vectorOfNonOwningReferences, 0)
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
fun createVectorOfNonOwningReferencesVector(builder: FlatBufferBuilder, data: ULongArray) : Int {
|
||||
builder.startVector(8, data.size, 8)
|
||||
for (i in data.size - 1 downTo 0) {
|
||||
@ -1176,6 +1181,7 @@ class Monster : Table() {
|
||||
fun addAnyAmbiguousType(builder: FlatBufferBuilder, anyAmbiguousType: UByte) = builder.addByte(45, anyAmbiguousType.toByte(), 0)
|
||||
fun addAnyAmbiguous(builder: FlatBufferBuilder, anyAmbiguous: Int) = builder.addOffset(46, anyAmbiguous, 0)
|
||||
fun addVectorOfEnums(builder: FlatBufferBuilder, vectorOfEnums: Int) = builder.addOffset(47, vectorOfEnums, 0)
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
fun createVectorOfEnumsVector(builder: FlatBufferBuilder, data: UByteArray) : Int {
|
||||
builder.startVector(1, data.size, 1)
|
||||
for (i in data.size - 1 downTo 0) {
|
||||
@ -1186,6 +1192,7 @@ class Monster : Table() {
|
||||
fun startVectorOfEnumsVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(1, numElems, 1)
|
||||
fun addSignedEnum(builder: FlatBufferBuilder, signedEnum: Byte) = builder.addByte(48, signedEnum, -1)
|
||||
fun addTestrequirednestedflatbuffer(builder: FlatBufferBuilder, testrequirednestedflatbuffer: Int) = builder.addOffset(49, testrequirednestedflatbuffer, 0)
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
fun createTestrequirednestedflatbufferVector(builder: FlatBufferBuilder, data: UByteArray) : Int {
|
||||
builder.startVector(1, data.size, 1)
|
||||
for (i in data.size - 1 downTo 0) {
|
||||
|
@ -3,7 +3,6 @@
|
||||
package MyGame.Example
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Race private constructor() {
|
||||
companion object {
|
||||
const val None: Byte = -1
|
||||
|
@ -19,7 +19,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Referrable : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -19,7 +19,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Stat : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -19,7 +19,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class StructOfStructs : Struct() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -19,7 +19,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class StructOfStructsOfStructs : Struct() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -19,7 +19,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Test : Struct() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -19,7 +19,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class TestSimpleTableWithEnum : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -19,7 +19,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class TypeAliases : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -19,7 +19,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Vec3 : Struct() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -19,7 +19,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Monster : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -19,7 +19,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class InParentNamespace : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -19,7 +19,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class MonsterExtra : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -3,7 +3,6 @@
|
||||
package optional_scalars
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class OptionalByte private constructor() {
|
||||
companion object {
|
||||
const val None: Byte = 0
|
||||
|
@ -19,7 +19,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class ScalarStuff : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -17,7 +17,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Attacker : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -17,7 +17,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class BookReader : Struct() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Character_ private constructor() {
|
||||
companion object {
|
||||
const val NONE: UByte = 0u
|
||||
|
@ -17,7 +17,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class FallingTub : Struct() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Gadget private constructor() {
|
||||
companion object {
|
||||
const val NONE: UByte = 0u
|
||||
|
@ -17,7 +17,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class HandFan : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
@ -17,7 +17,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Movie : Table() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
@ -99,6 +98,7 @@ class Movie : Table() {
|
||||
fun addMainCharacterType(builder: FlatBufferBuilder, mainCharacterType: UByte) = builder.addByte(0, mainCharacterType.toByte(), 0)
|
||||
fun addMainCharacter(builder: FlatBufferBuilder, mainCharacter: Int) = builder.addOffset(1, mainCharacter, 0)
|
||||
fun addCharactersType(builder: FlatBufferBuilder, charactersType: Int) = builder.addOffset(2, charactersType, 0)
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
fun createCharactersTypeVector(builder: FlatBufferBuilder, data: UByteArray) : Int {
|
||||
builder.startVector(1, data.size, 1)
|
||||
for (i in data.size - 1 downTo 0) {
|
||||
|
@ -17,7 +17,6 @@ import java.nio.ByteOrder
|
||||
import kotlin.math.sign
|
||||
|
||||
@Suppress("unused")
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class Rapunzel : Struct() {
|
||||
|
||||
fun __init(_i: Int, _bb: ByteBuffer) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user