From 5798c6048b30156be8295426563a4457ed85f291 Mon Sep 17 00:00:00 2001 From: CedNaru Date: Mon, 22 Sep 2025 05:43:10 +0200 Subject: [PATCH 01/21] Bump version --- .github/workflows/trigger_dev.yml | 6 +++--- .github/workflows/trigger_on_pull_request.yml | 6 +++--- .github/workflows/trigger_on_push_master.yml | 6 +++--- .github/workflows/trigger_on_tag.yml | 6 +++--- config.py | 2 +- docs/src/doc/index.md | 6 +++--- kt/common/src/main/kotlin/godot/common/Version.kt | 2 +- kt/gradle/libs.versions.toml | 4 ++-- src/version.h | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/trigger_dev.yml b/.github/workflows/trigger_dev.yml index 9e9ab7daf6..e1213b3516 100644 --- a/.github/workflows/trigger_dev.yml +++ b/.github/workflows/trigger_dev.yml @@ -66,9 +66,9 @@ jobs: - run: | echo "Setup done" outputs: # defined here explicitly, so it only needs to be defined here. All other workflows can just reference it - godot-kotlin-jvm-version: "0.13.1-4.4.1" - godot-version: "4.4.1-stable" - build-version: "0.13.1" + godot-kotlin-jvm-version: "0.14.0-4.5" + godot-version: "4.5-stable" + build-version: "0.14.0" jvm-version: "17" build-jvm: diff --git a/.github/workflows/trigger_on_pull_request.yml b/.github/workflows/trigger_on_pull_request.yml index 78f5ae6dae..9ab43c0e9b 100644 --- a/.github/workflows/trigger_on_pull_request.yml +++ b/.github/workflows/trigger_on_pull_request.yml @@ -14,9 +14,9 @@ jobs: - run: | echo "Setup done" outputs: # defined here explicitly, so it only needs to be defined here. All other workflows can just reference it - godot-kotlin-jvm-version: "0.13.1-4.4.1" - godot-version: "4.4.1-stable" - build-version: "0.13.1" + godot-kotlin-jvm-version: "0.14.0-4.5" + godot-version: "4.5-stable" + build-version: "0.14.0" jvm-version: "17" build-jvm: diff --git a/.github/workflows/trigger_on_push_master.yml b/.github/workflows/trigger_on_push_master.yml index a7facdb2bf..d0d89cabee 100644 --- a/.github/workflows/trigger_on_push_master.yml +++ b/.github/workflows/trigger_on_push_master.yml @@ -19,9 +19,9 @@ jobs: - run: | echo "Setup done" outputs: # defined here explicitly, so it only needs to be defined here. All other workflows can just reference it - godot-kotlin-jvm-version: "0.13.1-4.4.1" - godot-version: "4.4.1-stable" - build-version: "0.13.1" + godot-kotlin-jvm-version: "0.14.0-4.5" + godot-version: "4.5-stable" + build-version: "0.14.0" jvm-version: "17" build-jvm: diff --git a/.github/workflows/trigger_on_tag.yml b/.github/workflows/trigger_on_tag.yml index 813d2627b0..8d170392dc 100644 --- a/.github/workflows/trigger_on_tag.yml +++ b/.github/workflows/trigger_on_tag.yml @@ -26,9 +26,9 @@ jobs: - run: | echo "Setup done" outputs: # defined here explicitly, so it only needs to be defined here. All other workflows can just reference it - godot-kotlin-jvm-version: "0.13.1-4.4.1" - godot-version: "4.4.1-stable" - build-version: "0.13.1" + godot-kotlin-jvm-version: "0.14.0-4.5" + godot-version: "4.5-stable" + build-version: "0.14.0" jvm-version: "17" build-jvm: diff --git a/config.py b/config.py index ff0f0dd917..294a9b8207 100644 --- a/config.py +++ b/config.py @@ -2,4 +2,4 @@ def can_build(env, platform): return True def configure(env): - env.add_module_version_string("jvm.0.13.1") \ No newline at end of file + env.add_module_version_string("jvm.0.14.0") \ No newline at end of file diff --git a/docs/src/doc/index.md b/docs/src/doc/index.md index fc145124bc..976fc23dad 100644 --- a/docs/src/doc/index.md +++ b/docs/src/doc/index.md @@ -64,11 +64,11 @@ While Kotlin and Godot supports a wide range of platforms, this module for the m The module uses semantic versioning for its own versions but adds a suffix for the supported Godot version: -Full version: `0.13.1-4.4.1` +Full version: `0.14.0-4.5` -Module Version: `0.13.1` +Module Version: `0.14.0` -Supported Godot Version: `4.4.1` +Supported Godot Version: `4.5` This module relies on a Kotlin *compiler plugin* for registering your classes and members to Godot. As the compiler API from Kotlin is not stable yet, at the moment we can only support specific Kotlin version per release. diff --git a/kt/common/src/main/kotlin/godot/common/Version.kt b/kt/common/src/main/kotlin/godot/common/Version.kt index e670fb2738..92247411ba 100644 --- a/kt/common/src/main/kotlin/godot/common/Version.kt +++ b/kt/common/src/main/kotlin/godot/common/Version.kt @@ -1,3 +1,3 @@ package godot.common -const val GODOT_KOTLIN_VERSION = "0.13.1-4.4.1" +const val GODOT_KOTLIN_VERSION = "0.14.0-4.5" diff --git a/kt/gradle/libs.versions.toml b/kt/gradle/libs.versions.toml index c9ac1a6931..f8adbe0011 100644 --- a/kt/gradle/libs.versions.toml +++ b/kt/gradle/libs.versions.toml @@ -1,9 +1,9 @@ [versions] -godotKotlinJvm = "0.13.1" +godotKotlinJvm = "0.14.0" kotlin = "2.1.10" # https://kotlinlang.org/docs/releases.html#release-details kotlinCoroutine = "1.10.1" # https://github.com/Kotlin/kotlinx.coroutines/releases -godot = "4.4.1" +godot = "4.5" ideaPluginDefaultIntellijVersion = "2025.1" toolchain-jvm="11" diff --git a/src/version.h b/src/version.h index b1bacce68e..972b5cf27d 100644 --- a/src/version.h +++ b/src/version.h @@ -1,6 +1,6 @@ #ifndef GODOT_JVM_VERSION_H #define GODOT_JVM_VERSION_H -constexpr const char* GODOT_KOTLIN_VERSION = "0.13.1-4.4.1"; +constexpr const char* GODOT_KOTLIN_VERSION = "0.14.0-4.5"; #endif// GODOT_JVM_VERSION_H From bba2ab2cd66fa92cf987d109d6aa53e86b8b9317 Mon Sep 17 00:00:00 2001 From: CedNaru Date: Mon, 22 Sep 2025 07:23:20 +0200 Subject: [PATCH 02/21] Adapt code to new godot internals --- src/editor/dialog/about_dialog.cpp | 5 +- src/editor/dialog/about_dialog.h | 2 - src/editor/godot_kotlin_jvm_editor.cpp | 5 +- src/editor/project/project_generator.cpp | 2 +- src/jni/env.cpp | 2 +- src/jvm_wrapper/registration/kt_function.cpp | 2 +- src/kotlin_editor_export_plugin.cpp | 6 +- src/kt_variant.h | 5 +- src/language/gdj_language.cpp | 34 ++-- src/language/gdj_language.h | 8 +- src/language/java_language.cpp | 124 ++++++----- src/language/java_language.h | 8 +- src/language/jvm_language.cpp | 3 +- src/language/kotlin_language.cpp | 192 ++++++++---------- src/language/kotlin_language.h | 8 +- .../jvm_resource_format_loader.cpp | 11 +- src/script/jvm_script.cpp | 2 +- src/script/jvm_script.h | 4 +- 18 files changed, 194 insertions(+), 229 deletions(-) diff --git a/src/editor/dialog/about_dialog.cpp b/src/editor/dialog/about_dialog.cpp index eee109e259..93ee28290d 100644 --- a/src/editor/dialog/about_dialog.cpp +++ b/src/editor/dialog/about_dialog.cpp @@ -7,7 +7,9 @@ #include "editor/strings.h" #include +#include #include +#include #include #include @@ -30,7 +32,6 @@ void AboutDialog::_notification(int notification) { VBoxContainer* about_vbox {memnew(VBoxContainer)}; add_child(about_vbox); - RichTextLabel* about_label {memnew(RichTextLabel)}; about_label->set_custom_minimum_size(Size2 {600, 150} * EDSCALE); about_label->set_v_size_flags(Control::SizeFlags::SIZE_EXPAND_FILL); @@ -58,4 +59,4 @@ void AboutDialog::_notification(int notification) { } } -#endif// TOOLS_ENABLED \ No newline at end of file +#endif // TOOLS_ENABLED \ No newline at end of file diff --git a/src/editor/dialog/about_dialog.h b/src/editor/dialog/about_dialog.h index 9b43e7f617..854aa0540a 100644 --- a/src/editor/dialog/about_dialog.h +++ b/src/editor/dialog/about_dialog.h @@ -4,8 +4,6 @@ #ifndef GODOT_JVM_ABOUT_DIALOG_H #define GODOT_JVM_ABOUT_DIALOG_H -#include -#include #include class AboutDialog : public AcceptDialog { diff --git a/src/editor/godot_kotlin_jvm_editor.cpp b/src/editor/godot_kotlin_jvm_editor.cpp index e618b8ca5d..f057df25a7 100644 --- a/src/editor/godot_kotlin_jvm_editor.cpp +++ b/src/editor/godot_kotlin_jvm_editor.cpp @@ -8,8 +8,9 @@ #include "strings.h" #include +#include #include -#include +#include #include void GodotKotlinJvmEditor::on_menu_option_pressed(int option_id) { @@ -20,6 +21,7 @@ void GodotKotlinJvmEditor::on_menu_option_pressed(int option_id) { case ABOUT: about_dialog->popup_centered(); break; + default:; } } @@ -155,6 +157,7 @@ void GodotKotlinJvmEditor::_notification(int notification) { remove_control_from_container(CustomControlContainer::CONTAINER_TOOLBAR, tool_bar_gradle_task_choice); remove_control_from_container(CustomControlContainer::CONTAINER_TOOLBAR, tool_bar_gradle_task_button); break; + default:; } } diff --git a/src/editor/project/project_generator.cpp b/src/editor/project/project_generator.cpp index 75397327e8..7be79806c9 100644 --- a/src/editor/project/project_generator.cpp +++ b/src/editor/project/project_generator.cpp @@ -18,7 +18,7 @@ void ProjectGenerator::generate_jvm_files(bool erase_existing) { String root = String("res://"); Ref root_directory = DirAccess::open(root); - core_bind::Marshalls* marshall = memnew(core_bind::Marshalls); + CoreBind::Marshalls* marshall = memnew(CoreBind::Marshalls); for (int i = 0; i < number_of_files; ++i) { String file_location = String(file_names[i]); diff --git a/src/jni/env.cpp b/src/jni/env.cpp index cba398a045..8de1c421ba 100644 --- a/src/jni/env.cpp +++ b/src/jni/env.cpp @@ -28,7 +28,7 @@ namespace jni { //Support fully qualified class names with "a/b/c" and "a.b.c" format JClass Env::find_class(const char* name) { - jclass cls = env->FindClass(String(name).replace(".", "/").utf8()); + jclass cls = env->FindClass(String(name).replace(".", "/").utf8().get_data()); JVM_DEV_ASSERT(cls, "Class not found: %s", name); handle_exception(); return JClass(cls); diff --git a/src/jvm_wrapper/registration/kt_function.cpp b/src/jvm_wrapper/registration/kt_function.cpp index 0bbbd4edec..b73bbd44fe 100644 --- a/src/jvm_wrapper/registration/kt_function.cpp +++ b/src/jvm_wrapper/registration/kt_function.cpp @@ -80,7 +80,7 @@ KtFunctionInfo::~KtFunctionInfo() { MethodInfo KtFunctionInfo::to_method_info() const { MethodInfo methodInfo; methodInfo.name = name; - List pInfoList; + Vector pInfoList; for (auto argument : arguments) { pInfoList.push_back(argument->toPropertyInfo()); } diff --git a/src/kotlin_editor_export_plugin.cpp b/src/kotlin_editor_export_plugin.cpp index 489d4d6876..4a8bd47eaa 100644 --- a/src/kotlin_editor_export_plugin.cpp +++ b/src/kotlin_editor_export_plugin.cpp @@ -137,13 +137,13 @@ void KotlinEditorExportPlugin::_export_begin(const HashSet& p_features, _generate_export_configuration_file(jni::JvmType::GRAAL_NATIVE_IMAGE); - add_ios_project_static_lib( + add_apple_embedded_platform_project_static_lib( ProjectSettings::get_singleton()->globalize_path(base_ios_jdk_dir.path_join("libjava-release.a")) ); - add_ios_project_static_lib( + add_apple_embedded_platform_project_static_lib( ProjectSettings::get_singleton()->globalize_path(base_ios_jdk_dir.path_join("libjvm-release.a")) ); - add_ios_project_static_lib(ProjectSettings::get_singleton()->globalize_path(base_ios_build_dir.path_join(IOS_GRAAL_NATIVE_IMAGE_FILE))); + add_apple_embedded_platform_project_static_lib(ProjectSettings::get_singleton()->globalize_path(base_ios_build_dir.path_join(IOS_GRAAL_NATIVE_IMAGE_FILE))); } else { JVM_ERR_FAIL_MSG("Godot Kotlin/JVM doesn't handle this platform"); } diff --git a/src/kt_variant.h b/src/kt_variant.h index ca4ead8fc6..4cf9a46b7b 100644 --- a/src/kt_variant.h +++ b/src/kt_variant.h @@ -56,15 +56,14 @@ class VariantToBuffer { String str {src}; const CharString& char_string {str.utf8()}; set_variant_type(des, Variant::Type::STRING); - int size = char_string.size(); - if (unlikely(size > LongStringQueue::max_string_size)) { + if (int size = char_string.size(); unlikely(size > LongStringQueue::max_string_size)) { des->increment_position(encode_uint32(true, des->get_cursor())); jni::Env env = jni::Jvm::current_env(); LongStringQueue::get_instance().send_string_to_jvm(env, str); } else { des->increment_position(encode_uint32(false, des->get_cursor())); des->increment_position(encode_uint32(char_string.size(), des->get_cursor())); - if (likely(size > 0)) { des->increment_position(encode_cstring(char_string, des->get_cursor())); } + if (likely(size > 0)) { des->increment_position(encode_cstring(char_string.get_data(), des->get_cursor())); } } } diff --git a/src/language/gdj_language.cpp b/src/language/gdj_language.cpp index 051b9c4c3d..ca056a437b 100644 --- a/src/language/gdj_language.cpp +++ b/src/language/gdj_language.cpp @@ -112,36 +112,30 @@ String GdjLanguage::get_global_class_name(const String& p_path, String* r_base_t return {}; } -void GdjLanguage::get_reserved_words(List* p_words) const { - static const char* _reserved_words[] = {// RESERVED KEYWORDS - "registeredName", - "fqName", - "relativeSourcePath ", - "baseType ", - "supertypes", - "signals", - "properties", - "functions", - nullptr +Vector GdjLanguage::get_reserved_words() const { + return { + "registeredName", + "fqName", + "relativeSourcePath ", + "baseType ", + "supertypes", + "signals", + "properties", + "functions" }; - const char** w = _reserved_words; - while (*w) { - p_words->push_back(*w); - w++; - } } bool GdjLanguage::is_control_flow_keyword(const String& p_keyword) const { return false; } -void GdjLanguage::get_comment_delimiters(List* p_delimiters) const { - p_delimiters->push_back("//"); +Vector GdjLanguage::get_comment_delimiters() const { + return {"//"}; } -void GdjLanguage::get_doc_comment_delimiters(List* p_delimiters) const {} +Vector GdjLanguage::get_doc_comment_delimiters() const {return {};} -void GdjLanguage::get_string_delimiters(List* p_delimiters) const {} +Vector GdjLanguage::get_string_delimiters() const {return {};} Ref