From 43673a0d0ebfd40b50a7487c9879b43ad995b58b Mon Sep 17 00:00:00 2001 From: poohcom1 Date: Mon, 15 Aug 2022 15:29:23 +0700 Subject: [PATCH 1/2] Fixed declaration file errors - Added checks for multiline comment endings - Added exception for KEY_MASK_CMD due to missing value --- tools/editor_tools.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/editor_tools.cpp b/tools/editor_tools.cpp index d713232e..ecd8bbff 100644 --- a/tools/editor_tools.cpp +++ b/tools/editor_tools.cpp @@ -156,6 +156,7 @@ static String format_doc_text(const String &p_bbcode, const String &p_indent = " line = line.replace("[constant ", "`"); line = line.replace("[", "`"); line = line.replace("]", "`"); + line = line.replace("*/", "* /"); // To solve issues with accidental multiline comment ends } if (!in_code_block && i < lines.size() - 1) { @@ -606,6 +607,21 @@ void ECMAScriptPlugin::_export_typescript_declare_file(const String &p_path) { dict["description"] = format_doc_text(enums[i]->description, "\t\t\t "); dict["name"] = format_property_name(enums[i]->name); dict["value"] = enums[i]->value; + + // Exceptions + + /** + * KEY_MASK_CMD docs has value listed as "platform-dependent", + * so the actual values have to be manually changed depending on the platform. + */ + if (dict["name"] == "KEY_MASK_CMD") { +#ifdef APPLE_STYLE_KEYS + dict["value"] = (1 << 27); +#else + dict["value"] = (1 << 28); +#endif + } + enum_str += apply_pattern(const_str, dict); } enum_str += "\t}\n"; From 2a4af4fc2c46ce83f064dfbddbab930445f45759 Mon Sep 17 00:00:00 2001 From: poohcom1 Date: Mon, 15 Aug 2022 15:58:12 +0700 Subject: [PATCH 2/2] Replaced hardcoded KEY_MASK_CMD with enum value --- tools/editor_tools.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/editor_tools.cpp b/tools/editor_tools.cpp index ecd8bbff..dda98e1e 100644 --- a/tools/editor_tools.cpp +++ b/tools/editor_tools.cpp @@ -1,6 +1,7 @@ #include "editor_tools.h" #include "../ecmascript_language.h" #include "core/math/expression.h" +#include "core/os/keyboard.h" #include "editor/filesystem_dock.h" #define TS_IGNORE "//@ts-ignore\n" @@ -612,14 +613,10 @@ void ECMAScriptPlugin::_export_typescript_declare_file(const String &p_path) { /** * KEY_MASK_CMD docs has value listed as "platform-dependent", - * so the actual values have to be manually changed depending on the platform. + * so we have to retreive the actual value manually */ if (dict["name"] == "KEY_MASK_CMD") { -#ifdef APPLE_STYLE_KEYS - dict["value"] = (1 << 27); -#else - dict["value"] = (1 << 28); -#endif + dict["value"] = KEY_MASK_CMD; } enum_str += apply_pattern(const_str, dict);