-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Implement boilerplate code required to support Kotlin generator #1649
Conversation
This change extends parsing of command line arguments to honor three new flags: - 'kotlinpackage' - Kotlin package name - 'kotlinintpackage' - Kotlin package name to append to 'kotlinpackage' for internal types - 'kotlinnamerules' - Kotlin name rules property file Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
This commit introduces new generator type in CMake scripts as well as parameters, which are Kotlin-specific: - 'GLUECODIUM_KOTLIN_PACKAGE' - 'GLUECODIUM_KOTLIN_INTERNAL_PACKAGE' - 'GLUECODIUM_KOTLIN_NAMERULES' The scripts have been adjusted to ensure that the generated files are properly listed and included. Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
'spotless.gradle' was adjusted to avoid checking formatting in generated Kotlin files from smoke tests directory. Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
This change is intended to prepare LIME loader and runtime for processing of Kotlin. Therefore, the following changes are introduced: - LimeAttributeType.KOTLIN is added - LimeExternalDescriptor provides Kotlin specific descriptor - AntlrLimeConverter is able to correctly convert Kotlin annotation Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
This change brings the boilerplate code required to run generation of Kotlin code. This is still WIP and therefore, certain classes may not support all required functionalities. Note: this change does not implements comments processing. Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
This commit introduces smoke tests for basic input files including generation of simple classes, structures, enumerations, errors, properties etc. Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
This change brings basic functional tests of generated Kotlin code including creating and calling methods of classes, structures and interfaces. Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
This change adds a new workflow, which runs Kotlin functional tests on CI. Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
@@ -74,6 +74,11 @@ function(gluecodium_get_target_include_directories _target) | |||
"$<BUILD_INTERFACE:${_output_${_source_set_lower}_dir}/android/jni>") | |||
endif() | |||
|
|||
if(android-kotlin IN_LIST _generators) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and other similar places we should consider the case when we generate both Java and Kotlin. In such cases when packages (com.here.sdk.etc) are the same we can't include both generated JNI sources. Even when packages are not the same and generated functions name in MAIN sources should be unique, the code in COMMON source set still might somehow clash. And the last problem which came to my mind: in case of different packages even if we don't have problems with name conflicts (i.e. functions name are unique, namespace in COMMON sources is also unique, etc.) there is still problem with passing types in weird scenarios like Java -> C++ -> Kotlin and vice versa. But may be last scenario is not possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per offline discussion: for now I will implement a check to prevent generation of both Java and Kotlin in one pass. I will also create a task to look for a viable solution.
@@ -59,6 +59,10 @@ function(gluecodium_list_generated_files _target) | |||
list(APPEND _android_generated_files "${_unity_dir}/${GLUECODIUM_GENERATED_jni_${_group}}") | |||
endif() | |||
|
|||
if(android-kotlin IN_LIST _generators) | |||
list(APPEND _android_kotlin_generated_files "${_unity_dir}/${GLUECODIUM_GENERATED_jni_kotlin_${_group}}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same...
if(android-kotlin IN_LIST GLUECODIUM_GENERATORS) | ||
# Include all conversion headers first, so all later generic conversions relying on | ||
# specialization have all these defined | ||
_include_all(jni_kotlin "android-kotlin/jni/*_Conversion.h" "android-kotlin/jni/*.cpp") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking into account our plans it would be nice to have mixed tests. I.e. existing tests on Java which run over Kotlin generated code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea 👍
As per offline discussion:
- currently the generated Kotlin code does not support many required features
- some small adjustments may be required in the case of Java functional tests -- some of them do not obey preconditions related to
nullability
of parameters. For instanceInterfacesTest.java -> setSelfInterfaceNull()
passes null to a function, which does not accept nullable types.
Therefore, I will write it down as a task and I will proceed with it in the near future.
Usage of both generators in one pass could cause symbols clash for JNI bindings. At the moment running both generators in one pass is disallowed. Signed-off-by: Patryk Wrobel <183546751+pwrobeldev@users.noreply.github.com>
This change is intended to bring the boilerplate code, which is required
to support generation of the new output language: Kotlin.
The CLI interface has been extended by the new Kotlin-specific parameters:
kotlinpackage
- Kotlin package namekotlinintpackage
- Kotlin package name to append tokotlinpackage
for internal typeskotlinnamerules
- Kotlin name rules property fileCMake scripts have been adjusted to allow the users to generate the code for Kotlin and properly
build it. Moreover, CMake parameters, which correspond to new CLI options have been added as well:
GLUECODIUM_KOTLIN_PACKAGE
GLUECODIUM_KOTLIN_INTERNAL_PACKAGE
GLUECODIUM_KOTLIN_NAMERULES
The required classes for Kotlin have been created in
gluecodium/generator/
directory.Furthermore, new mustache templates were added to generate Kotlin files.
To provide some basic level of validation new smoke and functional tests were created.
The CI workflow file for functional tests has been also adjusted to execute the tests on CI.