flatbuffers
flatbuffers copied to clipboard
[kotlin] flatc --kotlin monster.fbs does not produce code compatible with the kotlin/ directory of this repository
The kotlin/
directory of this repository contains the FlatBuffers core library written in a multi-platform way. The top-level package it uses is com.google.flatbuffers.kotlin
. When I compile flatc
locally and run it against monster.fbs
, I get, among other things, Monster.kt
. The top of this file looks like this:
// automatically generated by the FlatBuffers compiler, do not modify
package MyGame.Sample
import java.nio.*
import kotlin.math.sign
import com.google.flatbuffers.*
@Suppress("unused")
class Monster : Table() {
fun __init(_i: Int, _bb: ByteBuffer) {
__reset(_i, _bb)
}
Notice the import, which is com.google.flatbuffers.*
. This is different from com.google.flatbuffers.kotlin.*
, and means this kotlin code is not compatible with the kotlin/
directory. I see that I can probably use this generated Kotlin code with the java/
library code. But what I'm specifically interested is getting generated code to work with kotlin multiplatform, and the kotlin/
directory. How do I generate code that uses the com.google.flatbuffers.kotlin
imports?
Compiler Version: v2.0.6
Operating System: Ubuntu 20.04
FlatBuffers version: v2.0.6
I believe @paulovap is the most active java/kotlin maintainer
Hi @mikeholler. The kotlin code generated code still uses the java runtime, so you must declare the flatbuffers runtime for java as dependency. The code you see on /kotlin
folder is still in development and is not production code.
I am working on a pure kotlin runtime and hope to remove this dependency from java soon.
This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale
, or this will be closed in 14 days.
This issue was automatically closed due to no activity for 6 months plus the 14 day notice period.