diff options
Diffstat (limited to 'modules/nativescript/nativescript.cpp')
-rw-r--r-- | modules/nativescript/nativescript.cpp | 51 |
1 files changed, 13 insertions, 38 deletions
diff --git a/modules/nativescript/nativescript.cpp b/modules/nativescript/nativescript.cpp index 661ae5371d..fd83b74727 100644 --- a/modules/nativescript/nativescript.cpp +++ b/modules/nativescript/nativescript.cpp @@ -59,6 +59,8 @@ void NativeScript::_bind_methods() { ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "class_name"), "set_class_name", "get_class_name"); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library"); + + ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &NativeScript::_new, MethodInfo(Variant::OBJECT, "new")); } #define NSL NativeScriptLanguage::get_singleton() @@ -500,7 +502,7 @@ bool NativeScriptInstance::get(const StringName &p_name, Variant &r_ret) const { if (P) { godot_variant value; value = P->get().getter.get_func((godot_object *)owner, - P->get().setter.method_data, + P->get().getter.method_data, userdata); r_ret = *(Variant *)&value; godot_variant_destroy(&value); @@ -532,6 +534,7 @@ bool NativeScriptInstance::get(const StringName &p_name, Variant &r_ret) const { } void NativeScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const { + script->get_script_property_list(p_properties); NativeScriptDesc *script_data = GET_SCRIPT_DESC(); @@ -799,7 +802,7 @@ NativeScriptLanguage::NativeScriptLanguage() { // TODO(karroffel): implement this NativeScriptLanguage::~NativeScriptLanguage() { - _unload_stuff(); + // _unload_stuff(); // NOTE(karroffel): This gets called in ::finish() for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { @@ -955,7 +958,8 @@ void NativeReloadNode::_notification(int p_what) { switch (p_what) { case MainLoop::NOTIFICATION_WM_FOCUS_OUT: { - print_line("unload"); + if (unloaded) + break; NSL->_unload_stuff(); for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { @@ -964,11 +968,14 @@ void NativeReloadNode::_notification(int p_what) { NSL->library_classes.erase(L->key()); } + unloaded = true; + } break; case MainLoop::NOTIFICATION_WM_FOCUS_IN: { - print_line("load"); + if (!unloaded) + break; Set<StringName> libs_to_remove; @@ -1007,44 +1014,12 @@ void NativeReloadNode::_notification(int p_what) { } } + unloaded = false; + for (Set<StringName>::Element *R = libs_to_remove.front(); R; R = R->next()) { NSL->library_gdnatives.erase(R->get()); } - /* - for (Set<NativeLibrary *>::Element *L = libs_to_reload.front(); L; L = L->next()) { - - GDNativeLibrary *lib = L->get()->dllib; - - lib->_terminate(); - lib->_initialize(); - - // update placeholders (if any) - - Set<GDNativeScript *> scripts; - - for (Set<GDNativeScript *>::Element *S = GDNativeScriptLanguage::get_singleton()->script_list.front(); S; S = S->next()) { - - if (lib->native_library->scripts.has(S->get()->get_script_name())) { - GDNativeScript *script = S->get(); - script->script_data = lib->get_script_data(script->get_script_name()); - scripts.insert(script); - } - } - - for (Set<GDNativeScript *>::Element *S = scripts.front(); S; S = S->next()) { - GDNativeScript *script = S->get(); - if (script->placeholders.size() == 0) - continue; - - for (Set<PlaceHolderScriptInstance *>::Element *P = script->placeholders.front(); P; P = P->next()) { - PlaceHolderScriptInstance *p = P->get(); - script->_update_placeholder(p); - } - } - } - */ - } break; default: { }; |