diff options
author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2021-08-02 14:34:43 +0200 |
---|---|---|
committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2021-08-02 17:50:50 +0200 |
commit | 2dcd064056cd7905ef1559e9f35aa223a583d225 (patch) | |
tree | e176885e5265a89d800cc9624e88349bc06a7981 /modules/gdnative/nativescript/nativescript.cpp | |
parent | f2efa6f4f38895a4adf8efc1e4f358a8dc5779cb (diff) |
Implement inherits_script() for NativeScript and PluginScript
Diffstat (limited to 'modules/gdnative/nativescript/nativescript.cpp')
-rw-r--r-- | modules/gdnative/nativescript/nativescript.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index f3a0e9603f..26d3aed702 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -114,9 +114,25 @@ void NativeScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) #endif bool NativeScript::inherits_script(const Ref<Script> &p_script) const { -#ifndef _MSC_VER -#warning inheritance needs to be implemented in NativeScript -#endif + Ref<NativeScript> ns = p_script; + if (ns.is_null()) { + return false; + } + + const NativeScriptDesc *other_s = ns->get_script_desc(); + if (!other_s) { + return false; + } + + const NativeScriptDesc *s = get_script_desc(); + + while (s) { + if (s == other_s) { + return true; + } + s = s->base_data; + } + return false; } |