Fix godot-cpp types registration

A initialization bug was causing the registration to occur prior to a key required field being set (see https://github.com/GodotNativeTools/godot-cpp/issues/394#issuecomment-613636985 for more details).

Fixes #394
pull/395/head
Fredia Huya-Kouadio 2020-04-14 12:28:27 -07:00 committed by fhuya
parent c2f765e49c
commit 3747ffe871
1 changed files with 7 additions and 6 deletions

View File

@ -140,6 +140,13 @@ void Godot::gdnative_init(godot_gdnative_init_options *options) {
} }
} }
// Initialize the `language_index` here since `__register_types()` makes use of it.
godot_instance_binding_functions binding_funcs = {};
binding_funcs.alloc_instance_binding_data = wrapper_create;
binding_funcs.free_instance_binding_data = wrapper_destroy;
godot::_RegisterState::language_index = godot::nativescript_1_1_api->godot_nativescript_register_instance_binding_data_functions(binding_funcs);
// register these now // register these now
___register_types(); ___register_types();
___init_method_bindings(); ___init_method_bindings();
@ -155,12 +162,6 @@ void Godot::gdnative_profiling_add_data(const char *p_signature, uint64_t p_time
void Godot::nativescript_init(void *handle) { void Godot::nativescript_init(void *handle) {
godot::_RegisterState::nativescript_handle = handle; godot::_RegisterState::nativescript_handle = handle;
godot_instance_binding_functions binding_funcs = {};
binding_funcs.alloc_instance_binding_data = wrapper_create;
binding_funcs.free_instance_binding_data = wrapper_destroy;
godot::_RegisterState::language_index = godot::nativescript_1_1_api->godot_nativescript_register_instance_binding_data_functions(binding_funcs);
} }
void Godot::nativescript_terminate(void *handle) { void Godot::nativescript_terminate(void *handle) {