summaryrefslogtreecommitdiff
path: root/modules/gdnative/pluginscript/pluginscript_script.cpp
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2021-08-02 14:34:43 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2021-08-02 17:50:50 +0200
commit2dcd064056cd7905ef1559e9f35aa223a583d225 (patch)
treee176885e5265a89d800cc9624e88349bc06a7981 /modules/gdnative/pluginscript/pluginscript_script.cpp
parentf2efa6f4f38895a4adf8efc1e4f358a8dc5779cb (diff)
Implement inherits_script() for NativeScript and PluginScript
Diffstat (limited to 'modules/gdnative/pluginscript/pluginscript_script.cpp')
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp
index 7fc8178e34..5380858582 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_script.cpp
@@ -139,9 +139,20 @@ bool PluginScript::can_instantiate() const {
}
bool PluginScript::inherits_script(const Ref<Script> &p_script) const {
-#ifndef _MSC_VER
-#warning inheritance needs to be implemented in PluginScript
-#endif
+ Ref<PluginScript> ps = p_script;
+ if (ps.is_null()) {
+ return false;
+ }
+
+ const PluginScript *s = this;
+
+ while (s) {
+ if (s == p_script.ptr()) {
+ return true;
+ }
+ s = Object::cast_to<PluginScript>(s->_ref_base_parent.ptr());
+ }
+
return false;
}