summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/register_types.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/register_types.cpp')
-rw-r--r--modules/gdscript/register_types.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp
index 605e82be6e..e835c93b7c 100644
--- a/modules/gdscript/register_types.cpp
+++ b/modules/gdscript/register_types.cpp
@@ -34,6 +34,7 @@
#include "gdscript_analyzer.h"
#include "gdscript_cache.h"
#include "gdscript_tokenizer.h"
+#include "gdscript_tokenizer_buffer.h"
#include "gdscript_utility_functions.h"
#ifdef TOOLS_ENABLED
@@ -83,18 +84,32 @@ class EditorExportGDScript : public EditorExportPlugin {
public:
virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) override {
- String script_key;
+ int script_mode = EditorExportPreset::MODE_SCRIPT_BINARY_TOKENS;
const Ref<EditorExportPreset> &preset = get_export_preset();
if (preset.is_valid()) {
- script_key = preset->get_script_encryption_key().to_lower();
+ script_mode = preset->get_script_export_mode();
}
- if (!p_path.ends_with(".gd")) {
+ if (!p_path.ends_with(".gd") || script_mode == EditorExportPreset::MODE_SCRIPT_TEXT) {
return;
}
+ Vector<uint8_t> file = FileAccess::get_file_as_bytes(p_path);
+ if (file.is_empty()) {
+ return;
+ }
+
+ String source;
+ source.parse_utf8(reinterpret_cast<const char *>(file.ptr()), file.size());
+ file = GDScriptTokenizerBuffer::parse_code_string(source);
+ if (file.is_empty()) {
+ return;
+ }
+
+ add_file(p_path.get_basename() + ".gdc", file, true);
+
return;
}
@@ -185,6 +200,10 @@ void test_tokenizer() {
GDScriptTests::test(GDScriptTests::TestType::TEST_TOKENIZER);
}
+void test_tokenizer_buffer() {
+ GDScriptTests::test(GDScriptTests::TestType::TEST_TOKENIZER_BUFFER);
+}
+
void test_parser() {
GDScriptTests::test(GDScriptTests::TestType::TEST_PARSER);
}
@@ -198,6 +217,7 @@ void test_bytecode() {
}
REGISTER_TEST_COMMAND("gdscript-tokenizer", &test_tokenizer);
+REGISTER_TEST_COMMAND("gdscript-tokenizer-buffer", &test_tokenizer_buffer);
REGISTER_TEST_COMMAND("gdscript-parser", &test_parser);
REGISTER_TEST_COMMAND("gdscript-compiler", &test_compiler);
REGISTER_TEST_COMMAND("gdscript-bytecode", &test_bytecode);