Skip to content

Commit

Permalink
Expand wildcard imports in the generated Kotlin files. (#7757)
Browse files Browse the repository at this point in the history
Tested:

```
$ cmake -G "Unix Makefiles" && make && ./flattests
...
[ 99%] Linking CXX executable flatsamplebinary
[100%] Built target flatsamplebinary
ALL TESTS PASSED
```

Co-authored-by: Derek Bailey <derekbailey@google.com>
  • Loading branch information
anton-bobukh and dbaileychess authored Jan 5, 2023
1 parent 82da3da commit 07d9485
Show file tree
Hide file tree
Showing 29 changed files with 408 additions and 59 deletions.
16 changes: 14 additions & 2 deletions android/app/src/main/java/generated/com/fbs/app/Animal.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

package com.fbs.app

import java.nio.*
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
class Animal : Table() {
Expand Down
19 changes: 16 additions & 3 deletions src/idl_gen_kotlin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,22 @@ class KotlinGenerator : public BaseGenerator {
code += "\n\n";
}
if (needs_includes) {
code += "import java.nio.*\n";
code += "import kotlin.math.sign\n";
code += "import com.google.flatbuffers.*\n\n";
code +=
"import com.google.flatbuffers.BaseVector\n"
"import com.google.flatbuffers.BooleanVector\n"
"import com.google.flatbuffers.ByteVector\n"
"import com.google.flatbuffers.Constants\n"
"import com.google.flatbuffers.DoubleVector\n"
"import com.google.flatbuffers.FlatBufferBuilder\n"
"import com.google.flatbuffers.FloatVector\n"
"import com.google.flatbuffers.LongVector\n"
"import com.google.flatbuffers.StringVector\n"
"import com.google.flatbuffers.Struct\n"
"import com.google.flatbuffers.Table\n"
"import com.google.flatbuffers.UnionVector\n"
"import java.nio.ByteBuffer\n"
"import java.nio.ByteOrder\n"
"import kotlin.math.sign\n\n";
}
code += classcode;
const std::string dirs = namer_.Directories(ns);
Expand Down
16 changes: 14 additions & 2 deletions tests/DictionaryLookup/LongFloatEntry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

package DictionaryLookup

import java.nio.*
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
class LongFloatEntry : Table() {
Expand Down
16 changes: 14 additions & 2 deletions tests/DictionaryLookup/LongFloatMap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

package DictionaryLookup

import java.nio.*
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
class LongFloatMap : Table() {
Expand Down
16 changes: 14 additions & 2 deletions tests/MyGame/Example/Ability.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

package MyGame.Example

import java.nio.*
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
class Ability : Struct() {
Expand Down
16 changes: 14 additions & 2 deletions tests/MyGame/Example/Monster.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

package MyGame.Example

import java.nio.*
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
import com.google.flatbuffers.*

/**
* an example documentation comment: "monster object"
Expand Down
16 changes: 14 additions & 2 deletions tests/MyGame/Example/Referrable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

package MyGame.Example

import java.nio.*
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
class Referrable : Table() {
Expand Down
16 changes: 14 additions & 2 deletions tests/MyGame/Example/Stat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

package MyGame.Example

import java.nio.*
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
class Stat : Table() {
Expand Down
16 changes: 14 additions & 2 deletions tests/MyGame/Example/StructOfStructs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

package MyGame.Example

import java.nio.*
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
class StructOfStructs : Struct() {
Expand Down
16 changes: 14 additions & 2 deletions tests/MyGame/Example/StructOfStructsOfStructs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

package MyGame.Example

import java.nio.*
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
class StructOfStructsOfStructs : Struct() {
Expand Down
16 changes: 14 additions & 2 deletions tests/MyGame/Example/Test.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

package MyGame.Example

import java.nio.*
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
class Test : Struct() {
Expand Down
16 changes: 14 additions & 2 deletions tests/MyGame/Example/TestSimpleTableWithEnum.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

package MyGame.Example

import java.nio.*
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
class TestSimpleTableWithEnum : Table() {
Expand Down
16 changes: 14 additions & 2 deletions tests/MyGame/Example/TypeAliases.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

package MyGame.Example

import java.nio.*
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
class TypeAliases : Table() {
Expand Down
16 changes: 14 additions & 2 deletions tests/MyGame/Example/Vec3.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

package MyGame.Example

import java.nio.*
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
class Vec3 : Struct() {
Expand Down
16 changes: 14 additions & 2 deletions tests/MyGame/Example2/Monster.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

package MyGame.Example2

import java.nio.*
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
class Monster : Table() {
Expand Down
16 changes: 14 additions & 2 deletions tests/MyGame/InParentNamespace.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

package MyGame

import java.nio.*
import com.google.flatbuffers.BaseVector
import com.google.flatbuffers.BooleanVector
import com.google.flatbuffers.ByteVector
import com.google.flatbuffers.Constants
import com.google.flatbuffers.DoubleVector
import com.google.flatbuffers.FlatBufferBuilder
import com.google.flatbuffers.FloatVector
import com.google.flatbuffers.LongVector
import com.google.flatbuffers.StringVector
import com.google.flatbuffers.Struct
import com.google.flatbuffers.Table
import com.google.flatbuffers.UnionVector
import java.nio.ByteBuffer
import java.nio.ByteOrder
import kotlin.math.sign
import com.google.flatbuffers.*

@Suppress("unused")
class InParentNamespace : Table() {
Expand Down
Loading

0 comments on commit 07d9485

Please sign in to comment.