Skip to content

Commit 5cc9c4c

Browse files
authored
Merge pull request #148 from why-try313/gd4
Godot 4.0.0-rc compilation fixes
2 parents 19b54c1 + 9b16953 commit 5cc9c4c

File tree

6 files changed

+31
-23
lines changed

6 files changed

+31
-23
lines changed

SCsub

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Import('env')
55
Import('env_modules')
66
env_module = env_modules.Clone()
77
JS_ENGINE = 'quickjs'
8+
TOOLS = env.get('TOOLS');
89

910
def open_file(path, mode):
1011
if platform.python_version() > '3':
@@ -41,7 +42,7 @@ if JS_ENGINE == 'quickjs':
4142
env_module.Append(CPPPATH=["quickjs/quickjs"])
4243
# env_module.Append(CXXFLAGS=["-std=c++20"])
4344
# env_module.Append(CCFLAGS=["-std=c++20"])
44-
if env['tools']:
45+
if TOOLS:
4546
env_module.add_source_files(env.modules_sources, 'tools/editor_tools.cpp')
4647
env_module.add_source_files(env.modules_sources, 'quickjs/quickjs_builtin_binder.gen.cpp')
4748
env_module.add_source_files(env.modules_sources, 'quickjs/*.cpp')
@@ -60,7 +61,7 @@ sources = [
6061
'misc/godot.binding_script.gen.cpp',
6162
]
6263

63-
if env['tools']:
64+
if TOOLS:
6465
base_text = '/* THIS FILE IS GENERATED DO NOT EDIT */\n#include "editor_tools.h"\nString JavaScriptPlugin::{} = \n{};'
6566
tool_fns = {"tools/godot.d.ts.gen.cpp": ("BUILTIN_DECLARATION_TEXT", dump_text_file_to_cpp("misc/godot.d.ts")),
6667
"tools/tsconfig.json.gen.cpp": ("TSCONFIG_CONTENT", dump_text_file_to_cpp("misc/tsconfig.json")),

javascript.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ bool JavaScript::can_instantiate() const {
2323
#endif
2424
}
2525

26+
StringName JavaScript::get_global_name() const {
27+
return StringName();
28+
}
29+
2630
StringName JavaScript::get_instance_base_type() const {
2731
static StringName empty;
2832
ERR_FAIL_NULL_V(javascript_class, empty);

javascript.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class JavaScript : public Script {
4343
virtual Ref<Script> get_base_script() const override { return nullptr; }
4444
virtual bool inherits_script(const Ref<Script> &p_script) const override { return false; }
4545

46+
StringName get_global_name() const override;
4647
virtual StringName get_instance_base_type() const override;
4748
virtual ScriptInstance *instance_create(Object *p_this) override;
4849
virtual PlaceHolderScriptInstance *placeholder_instance_create(Object *p_this) override;

javascript_language.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static void free_callback(void *p_token, void *p_instance, void *p_binding) {
1818
}
1919
}
2020

21-
static GDNativeBool reference_callback(void *p_token, void *p_binding, GDNativeBool p_reference) {
21+
static GDExtensionBool reference_callback(void *p_token, void *p_binding, GDExtensionBool p_reference) {
2222
if (JavaScriptBinder *binder = JavaScriptLanguage::get_singleton()->get_thread_binder(Thread::get_caller_id())) {
2323
if (p_reference) {
2424
binder->godot_refcount_incremented(static_cast<JavaScriptGCHandler *>(p_binding));
@@ -163,7 +163,7 @@ void JavaScriptLanguage::get_reserved_words(List<String> *p_words) const {
163163
"RegExp",
164164
"ArrayBuffer",
165165
"SharedArrayBuffer",
166-
"Uint8ClampedArray"
166+
"Uint8ClampedArray",
167167
"Int8Array",
168168
"Uint8Array",
169169
"Int16Array",

javascript_language.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class JavaScriptLanguage : public ScriptLanguage {
2121
static JavaScriptLanguage *singleton;
2222
JavaScriptBinder *main_binder;
2323
HashMap<Thread::ID, JavaScriptBinder *> thread_binder_map;
24-
GDNativeInstanceBindingCallbacks instance_binding_callbacks;
24+
GDExtensionInstanceBindingCallbacks instance_binding_callbacks;
2525

2626
CallableMiddleman *callable_middleman;
2727
#ifdef TOOLS_ENABLED
@@ -43,7 +43,7 @@ class JavaScriptLanguage : public ScriptLanguage {
4343
}
4444

4545
_FORCE_INLINE_ virtual String get_name() const override { return "JavaScript"; }
46-
const GDNativeInstanceBindingCallbacks *get_instance_binding_callbacks() const { return &instance_binding_callbacks; }
46+
const GDExtensionInstanceBindingCallbacks *get_instance_binding_callbacks() const { return &instance_binding_callbacks; }
4747
#ifdef TOOLS_ENABLED
4848
_FORCE_INLINE_ HashSet<Ref<JavaScript> > &get_scripts() { return scripts; }
4949
#endif

register_types.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,34 @@ class EditorExportJavaScript : public EditorExportPlugin {
4444

4545
public:
4646
virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) override {
47-
int script_mode = EditorExportPreset::MODE_SCRIPT_COMPILED;
47+
String script_key;
48+
// int script_mode = EditorExportPreset::MODE_SCRIPT_COMPILED;
4849
const Ref<EditorExportPreset> &preset = get_export_preset();
4950

50-
if (preset.is_valid()) {
51-
script_mode = preset->get_script_export_mode();
52-
}
51+
// if (preset.is_valid()) {
52+
// script_mode = preset->get_file_export_mode(p_path);
53+
// }
5354

54-
if (script_mode == EditorExportPreset::MODE_SCRIPT_TEXT)
55-
return;
55+
// if (script_mode == EditorExportPreset::MODE_SCRIPT_TEXT)
56+
// return;
5657

5758
String extension = p_path.get_extension();
5859
if (extension != EXT_JSCLASS && extension != EXT_JSMODULE)
5960
return;
6061

61-
if (script_mode == EditorExportPreset::ScriptExportMode::MODE_SCRIPT_COMPILED) {
62-
#if 0 // Disable compile to bytecode as it is not battle tested on all platform
63-
Error err;
64-
String code = FileAccess::get_file_as_string(p_path, &err);
65-
ERR_FAIL_COND(err != OK);
66-
67-
Vector<uint8_t> file;
68-
ERR_FAIL_COND(JavaScriptLanguage::get_singleton()->get_main_binder()->compile_to_bytecode(code, p_path, file) != OK);
69-
add_file(p_path.get_basename() + "." + extension + "b", file, true);
70-
#endif
71-
}
62+
// if (script_mode == EditorExportPreset::FileExportMode::MODE_SCRIPT_COMPILED) {
63+
// #if 0 // Disable compile to bytecode as it is not battle tested on all platform
64+
// Error err;
65+
// String code = FileAccess::get_file_as_string(p_path, &err);
66+
// ERR_FAIL_COND(err != OK);
67+
68+
// Vector<uint8_t> file;
69+
// ERR_FAIL_COND(JavaScriptLanguage::get_singleton()->get_main_binder()->compile_to_bytecode(code, p_path, file) != OK);
70+
// add_file(p_path.get_basename() + "." + extension + "b", file, true);
71+
// #endif
72+
// }
7273
}
74+
virtual String _get_name() const override { return "JavaScript"; }
7375
};
7476

7577
#endif

0 commit comments

Comments
 (0)