* Expose synthetic structs for method args and result
* Make ThriftException a Struct
and make kind required (there is an "unknown" type anyways)
* Move type holders to class level in order to allow for methods to write to them
* Add runtime classes for server support
* Add server support
* Update README
* Clear type outputs at the beginning of generate()
in case the generator gets re-used
* clean up imports
* remove @JvmOverloads
* import all the things
* Remove wildcard import
* Use hand-built ClassNames instead of direct type references
in order to try to be as compatible with Kotlin Multiplatform as
possible.
* Generate server-specific interface
in a server-specific namespace instead of reusing the client interface.
This is necessary because we always want to generate a coroutine based interface for the server and never a callback based one.
* Support compilation of multiple FileSpecs as a unit
because now we generate a separate FileSpec for the server that also need the types from the "normal" FileSpec.
* Move server integration test to "normal" task
as it no longer requires the coroutine client flag to be set.
* Add license headers
* Add license to thrift test code
* Fix README
* Check if specs compile in tests
* Show name clash between field name and kotlin error()
* Use fully-qualified reference to allow KotlinPoet to disambiguate
* Introducing flags to add a required builder constructor and omit empty builder constructor
* Making sure not to create constructor if it is empty
* Removingy omitBuilderEmptyConstructor
* Adding deprecated annotation when required constructor is present
* Adding extra documentation, simplifying test
* Convert thrifty-runtime to kotlin, require Java 8
* Remove erroneous nits in KotlinCodeGenerator
* New kt files should end with a newline
* Fix artifacts from Java->Kotlin conversion, use better idioms
When specified, `@file:JvmName(name)` annotations will be added to all
of the generated files. This improves the usability of importing these
Kotlin-based classes into Java code modules (e.g. as `foo.Constants`
instead of `foo.ConstantsKt`).
This would ideally be the default behavior, but it's introduced as an
opt-in compiler option to avoid breaking backwards compatibility.
When specified, no service clients will be generated. We only support
service clients in the Kotlin generator, so this is implicitly a
Kotlin-only option, but it's not prefixed with `kt` because it could
apply to Java in the future.
This is useful for projects that only need Thrift-generated structures,
etc. and won't use Thrift service calls.
This adds support in generated Kotlin code for unions that have default values.
Unions are currently represented as sealed types; the default value, if present, will be a static val on the base sealed type. For example, given the following thrift:
```
union Sample {
1: string Foo = "bar";
}
```
this will emit (partial code):
```
sealed class Sample : Struct {
companion object {
@JvmStatic
val DEFAULT: Sample = Foo("bar")
}
...
class Builder {
private var value: Sample? = DEFAULT
...
}
...
class Adapter {
override fun read(protocol: Protocol): Sample {
var result: Sample = DEFAULT
...
}
}
}
```
The only point about which I'm uncertain is the Adapter.read method; it's not clear to me whether we should assume a default value if no value (or no expected value) is received; the remote end may have a different idea about what the default value is. I expect we'll never revisit this point due to the obscurity of the feature, but have called out the question as a TODO.
Fixes#303.
Also, change the representation of an empty union from an empty sealed class (which can never be instantiated) to a plain-old empty class.
TODO: toString for empty union, toString for sealed class leaf-nodes.
Fixes#285