From e86d5b8e97c09d4eac46dbbb8541f180d05f1da2 Mon Sep 17 00:00:00 2001 From: Yoon Kyong Sik Date: Wed, 19 Aug 2020 01:44:43 +0900 Subject: [Kotlin] Attach JvmStatic annotation to each method in companion object (#6052) * Attach JvmStatic annotation to each method of companion object Kotlin does not have static accessor so companion object used instead of static. It's so natural. But when use kotlin companion object methods on java it is very inconvenient. ```java GeneratedClassByFlatBuffer.Companion.someMethod() ``` If use @JvmStatic annotation it can be shorten like below. ```java GeneratedClassByFlatBuffer.someMethod() ``` * Formatting by Idea Google C++ style * Add comments - Commit for missing cla Signed-off-by: Yoon KyongSik * Add comments - Commit for missing cla Signed-off-by: Yoon KyongSik * Reset code formatting except modified lines Signed-off-by: Yoon KyongSik * Pass missing flag to validateVersion method Signed-off-by: Yoon KyongSik * Add annotations to missing method in companion object * addVector * createVector * endVector * tableCreator And also I tried add compiler option for generate annotation who don't like this operation. Signed-off-by: Yoon KyongSik * Modify unmatched option name in compiler usage Signed-off-by: Yoon KyongSik * Add missing operation for finishSizePrefixed and finishStructBuffer method. Signed-off-by: Yoon KyongSik * Add compiled example with --kotlin-gen-jvmstatic option. Signed-off-by: Yoon KyongSik * Fix Compiler.md Change option name from --gen-jvm-static-annotation to --kotlin-gen-jvmstatic Signed-off-by: Yoon KyongSik * Use IDLOptions reference instead of bool parameter. Signed-off-by: Yoon KyongSik * Change option name - kotlin_gen_jvmstatic to gen_jvmstatic Signed-off-by: Yoon KyongSik * Use IDLOptions reference instead of bool parameter and missing process @JvmStatic as suffix. Signed-off-by: Yoon KyongSik * Add code generation for --gen-jvmstatic option Signed-off-by: Yoon KyongSik * Miss typo directory for including. Signed-off-by: Yoon KyongSik * Miss typo variable suffix for including. Signed-off-by: Yoon KyongSik * Fix camel case to snake case. Signed-off-by: Yoon KyongSik * Rollback generate code for gen_jvmstatic option. Signed-off-by: Yoon KyongSik * Delete generated test files. Signed-off-by: Yoon KyongSik * add missing new line at end of file. Signed-off-by: Yoon KyongSik * Remove generated test file by command line. Signed-off-by: Yoon KyongSik Co-authored-by: sam --- include/flatbuffers/idl.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/flatbuffers/idl.h b/include/flatbuffers/idl.h index 70a2b787..847c976a 100644 --- a/include/flatbuffers/idl.h +++ b/include/flatbuffers/idl.h @@ -509,6 +509,7 @@ struct ServiceDef : public Definition { // Container of options that may apply to any of the source/text generators. struct IDLOptions { + bool gen_jvmstatic; // Use flexbuffers instead for binary and text generation bool use_flexbuffers; bool strict_json; @@ -604,7 +605,8 @@ struct IDLOptions { bool set_empty_vectors_to_null; IDLOptions() - : use_flexbuffers(false), + : gen_jvmstatic(false), + use_flexbuffers(false), strict_json(false), skip_js_exports(false), use_goog_js_export_format(false), -- cgit v1.2.3