diff options
| author | Ruslan Mustakov | 2017-07-26 20:24:15 +0700 |
|---|---|---|
| committer | Ruslan Mustakov | 2017-07-26 22:36:57 +0700 |
| commit | db9dcbddbc9231d520a14eaa4e256c276273eeb7 (patch) | |
| tree | 5f95a7c5c754b611399dd40747c19179c628f88b /modules/nativescript/nativescript.cpp | |
| parent | f55211ae0dc202cc015c247495af8e05af81b24b (diff) | |
| download | godot-db9dcbddbc9231d520a14eaa4e256c276273eeb7.tar.gz godot-db9dcbddbc9231d520a14eaa4e256c276273eeb7.tar.zst godot-db9dcbddbc9231d520a14eaa4e256c276273eeb7.zip | |
Diffstat (limited to 'modules/nativescript/nativescript.cpp')
| -rw-r--r-- | modules/nativescript/nativescript.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/modules/nativescript/nativescript.cpp b/modules/nativescript/nativescript.cpp index fd83b7472..ae8746f68 100644 --- a/modules/nativescript/nativescript.cpp +++ b/modules/nativescript/nativescript.cpp @@ -650,6 +650,28 @@ void NativeScriptInstance::notification(int p_notification) { call_multilevel("_notification", args, 1); } +void NativeScriptInstance::refcount_incremented() { + Variant::CallError err; + call("_refcount_incremented", NULL, 0, err); + if (err.error != Variant::CallError::CALL_OK && err.error != Variant::CallError::CALL_ERROR_INVALID_METHOD) { + ERR_PRINT("Failed to invoke _refcount_incremented - should not happen"); + } +} + +bool NativeScriptInstance::refcount_decremented() { + Variant::CallError err; + Variant ret = call("_refcount_decremented", NULL, 0, err); + if (err.error != Variant::CallError::CALL_OK && err.error != Variant::CallError::CALL_ERROR_INVALID_METHOD) { + ERR_PRINT("Failed to invoke _refcount_decremented - should not happen"); + return true; // assume we can destroy the object + } + if (err.error == Variant::CallError::CALL_ERROR_INVALID_METHOD) { + // the method does not exist, default is true + return true; + } + return ret; +} + Ref<Script> NativeScriptInstance::get_script() const { return script; } |
