diff options
| author | Thomas Herzog | 2017-07-26 21:29:26 +0200 |
|---|---|---|
| committer | GitHub | 2017-07-26 21:29:26 +0200 |
| commit | 18e23ad4dcec0713fb24211be964ade35bff951d (patch) | |
| tree | 28cbacd973338e3eee4db57b3aa188215f5a2c5e /modules/nativescript/nativescript.cpp | |
| parent | 88bd18244bda74843ed6e0b99db106dffa4979bc (diff) | |
| parent | db9dcbddbc9231d520a14eaa4e256c276273eeb7 (diff) | |
| download | godot-18e23ad4dcec0713fb24211be964ade35bff951d.tar.gz godot-18e23ad4dcec0713fb24211be964ade35bff951d.tar.zst godot-18e23ad4dcec0713fb24211be964ade35bff951d.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 f3db33cce..271f5bde1 100644 --- a/modules/nativescript/nativescript.cpp +++ b/modules/nativescript/nativescript.cpp @@ -628,6 +628,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; } |
