summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/debugger/engine_profiler.h4
-rw-r--r--core/io/packet_peer.h1
-rw-r--r--core/io/resource_format_binary.cpp1
-rw-r--r--core/io/resource_loader.cpp1
-rw-r--r--core/io/resource_loader.h1
-rw-r--r--core/io/resource_saver.h1
-rw-r--r--core/io/stream_peer.h1
-rw-r--r--core/math/a_star.h1
-rw-r--r--core/math/a_star_grid_2d.h1
-rw-r--r--core/object/make_virtuals.py2
-rw-r--r--core/object/script_instance.cpp71
-rw-r--r--core/object/script_instance.h98
-rw-r--r--core/object/script_language.cpp34
-rw-r--r--core/object/script_language.h61
-rw-r--r--core/os/main_loop.h1
-rw-r--r--core/string/translation.h1
-rw-r--r--core/variant/variant_parser.cpp1
17 files changed, 176 insertions, 105 deletions
diff --git a/core/debugger/engine_profiler.h b/core/debugger/engine_profiler.h
index f74481c84b..d3d0021e67 100644
--- a/core/debugger/engine_profiler.h
+++ b/core/debugger/engine_profiler.h
@@ -31,10 +31,8 @@
#ifndef ENGINE_PROFILER_H
#define ENGINE_PROFILER_H
-#include "core/object/ref_counted.h"
-
#include "core/object/gdvirtual.gen.inc"
-#include "core/object/script_language.h"
+#include "core/object/ref_counted.h"
class EngineProfiler : public RefCounted {
GDCLASS(EngineProfiler, RefCounted);
diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h
index 7383ab84df..86ebe32cb6 100644
--- a/core/io/packet_peer.h
+++ b/core/io/packet_peer.h
@@ -37,7 +37,6 @@
#include "core/extension/ext_wrappers.gen.inc"
#include "core/object/gdvirtual.gen.inc"
-#include "core/object/script_language.h"
#include "core/variant/native_ptr.h"
class PacketPeer : public RefCounted {
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 551d3268b8..ea97e5ecce 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -36,6 +36,7 @@
#include "core/io/image.h"
#include "core/io/marshalls.h"
#include "core/io/missing_resource.h"
+#include "core/object/script_language.h"
#include "core/version.h"
//#define print_bl(m_what) print_line(m_what)
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index df0253349c..c1a38f0af8 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -33,6 +33,7 @@
#include "core/config/project_settings.h"
#include "core/io/file_access.h"
#include "core/io/resource_importer.h"
+#include "core/object/script_language.h"
#include "core/os/condition_variable.h"
#include "core/os/os.h"
#include "core/string/print_string.h"
diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h
index 2701caa3f4..0c7d6c0feb 100644
--- a/core/io/resource_loader.h
+++ b/core/io/resource_loader.h
@@ -33,7 +33,6 @@
#include "core/io/resource.h"
#include "core/object/gdvirtual.gen.inc"
-#include "core/object/script_language.h"
#include "core/object/worker_thread_pool.h"
#include "core/os/semaphore.h"
#include "core/os/thread.h"
diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h
index 572742d129..4828df297a 100644
--- a/core/io/resource_saver.h
+++ b/core/io/resource_saver.h
@@ -33,7 +33,6 @@
#include "core/io/resource.h"
#include "core/object/gdvirtual.gen.inc"
-#include "core/object/script_language.h"
class ResourceFormatSaver : public RefCounted {
GDCLASS(ResourceFormatSaver, RefCounted);
diff --git a/core/io/stream_peer.h b/core/io/stream_peer.h
index ba11144e33..29cdb82615 100644
--- a/core/io/stream_peer.h
+++ b/core/io/stream_peer.h
@@ -35,7 +35,6 @@
#include "core/extension/ext_wrappers.gen.inc"
#include "core/object/gdvirtual.gen.inc"
-#include "core/object/script_language.h"
#include "core/variant/native_ptr.h"
class StreamPeer : public RefCounted {
diff --git a/core/math/a_star.h b/core/math/a_star.h
index fc4bb09f03..0758500c8a 100644
--- a/core/math/a_star.h
+++ b/core/math/a_star.h
@@ -33,7 +33,6 @@
#include "core/object/gdvirtual.gen.inc"
#include "core/object/ref_counted.h"
-#include "core/object/script_language.h"
#include "core/templates/oa_hash_map.h"
/**
diff --git a/core/math/a_star_grid_2d.h b/core/math/a_star_grid_2d.h
index dd5f9d0575..ecc9bb01f9 100644
--- a/core/math/a_star_grid_2d.h
+++ b/core/math/a_star_grid_2d.h
@@ -33,7 +33,6 @@
#include "core/object/gdvirtual.gen.inc"
#include "core/object/ref_counted.h"
-#include "core/object/script_language.h"
#include "core/templates/list.h"
#include "core/templates/local_vector.h"
diff --git a/core/object/make_virtuals.py b/core/object/make_virtuals.py
index 5be9650b32..38682d6d92 100644
--- a/core/object/make_virtuals.py
+++ b/core/object/make_virtuals.py
@@ -160,6 +160,8 @@ def run(target, source, env):
#ifndef GDVIRTUAL_GEN_H
#define GDVIRTUAL_GEN_H
+#include "core/object/script_instance.h"
+
"""
diff --git a/core/object/script_instance.cpp b/core/object/script_instance.cpp
new file mode 100644
index 0000000000..303b127db1
--- /dev/null
+++ b/core/object/script_instance.cpp
@@ -0,0 +1,71 @@
+/**************************************************************************/
+/* script_instance.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#include "script_instance.h"
+
+#include "core/object/script_language.h"
+
+Variant ScriptInstance::call_const(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
+ return callp(p_method, p_args, p_argcount, r_error);
+}
+
+void ScriptInstance::get_property_state(List<Pair<StringName, Variant>> &state) {
+ List<PropertyInfo> pinfo;
+ get_property_list(&pinfo);
+ for (const PropertyInfo &E : pinfo) {
+ if (E.usage & PROPERTY_USAGE_STORAGE) {
+ Pair<StringName, Variant> p;
+ p.first = E.name;
+ if (get(p.first, p.second)) {
+ state.push_back(p);
+ }
+ }
+ }
+}
+
+void ScriptInstance::property_set_fallback(const StringName &, const Variant &, bool *r_valid) {
+ if (r_valid) {
+ *r_valid = false;
+ }
+}
+
+Variant ScriptInstance::property_get_fallback(const StringName &, bool *r_valid) {
+ if (r_valid) {
+ *r_valid = false;
+ }
+ return Variant();
+}
+
+const Variant ScriptInstance::get_rpc_config() const {
+ return get_script()->get_rpc_config();
+}
+
+ScriptInstance::~ScriptInstance() {
+}
diff --git a/core/object/script_instance.h b/core/object/script_instance.h
new file mode 100644
index 0000000000..df978a25ea
--- /dev/null
+++ b/core/object/script_instance.h
@@ -0,0 +1,98 @@
+/**************************************************************************/
+/* script_instance.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#ifndef SCRIPT_INSTANCE_H
+#define SCRIPT_INSTANCE_H
+
+#include "core/object/ref_counted.h"
+
+class Script;
+class ScriptLanguage;
+
+class ScriptInstance {
+public:
+ virtual bool set(const StringName &p_name, const Variant &p_value) = 0;
+ virtual bool get(const StringName &p_name, Variant &r_ret) const = 0;
+ virtual void get_property_list(List<PropertyInfo> *p_properties) const = 0;
+ virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const = 0;
+ virtual void validate_property(PropertyInfo &p_property) const = 0;
+
+ virtual bool property_can_revert(const StringName &p_name) const = 0;
+ virtual bool property_get_revert(const StringName &p_name, Variant &r_ret) const = 0;
+
+ virtual Object *get_owner() { return nullptr; }
+ virtual void get_property_state(List<Pair<StringName, Variant>> &state);
+
+ virtual void get_method_list(List<MethodInfo> *p_list) const = 0;
+ virtual bool has_method(const StringName &p_method) const = 0;
+
+ virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) = 0;
+
+ template <typename... VarArgs>
+ Variant call(const StringName &p_method, VarArgs... p_args) {
+ Variant args[sizeof...(p_args) + 1] = { p_args..., Variant() }; // +1 makes sure zero sized arrays are also supported.
+ const Variant *argptrs[sizeof...(p_args) + 1];
+ for (uint32_t i = 0; i < sizeof...(p_args); i++) {
+ argptrs[i] = &args[i];
+ }
+ Callable::CallError cerr;
+ return callp(p_method, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args), cerr);
+ }
+
+ virtual Variant call_const(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error); // implement if language supports const functions
+ virtual void notification(int p_notification, bool p_reversed = false) = 0;
+ virtual String to_string(bool *r_valid) {
+ if (r_valid) {
+ *r_valid = false;
+ }
+ return String();
+ }
+
+ //this is used by script languages that keep a reference counter of their own
+ //you can make make Ref<> not die when it reaches zero, so deleting the reference
+ //depends entirely from the script
+
+ virtual void refcount_incremented() {}
+ virtual bool refcount_decremented() { return true; } //return true if it can die
+
+ virtual Ref<Script> get_script() const = 0;
+
+ virtual bool is_placeholder() const { return false; }
+
+ virtual void property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid);
+ virtual Variant property_get_fallback(const StringName &p_name, bool *r_valid);
+
+ virtual const Variant get_rpc_config() const;
+
+ virtual ScriptLanguage *get_language() = 0;
+ virtual ~ScriptInstance();
+};
+
+#endif // SCRIPT_INSTANCE_H
diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp
index a8b0e426ae..e1d21c875c 100644
--- a/core/object/script_language.cpp
+++ b/core/object/script_language.cpp
@@ -388,40 +388,6 @@ String ScriptServer::get_global_class_cache_file_path() {
////////////////////
-Variant ScriptInstance::call_const(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
- return callp(p_method, p_args, p_argcount, r_error);
-}
-
-void ScriptInstance::get_property_state(List<Pair<StringName, Variant>> &state) {
- List<PropertyInfo> pinfo;
- get_property_list(&pinfo);
- for (const PropertyInfo &E : pinfo) {
- if (E.usage & PROPERTY_USAGE_STORAGE) {
- Pair<StringName, Variant> p;
- p.first = E.name;
- if (get(p.first, p.second)) {
- state.push_back(p);
- }
- }
- }
-}
-
-void ScriptInstance::property_set_fallback(const StringName &, const Variant &, bool *r_valid) {
- if (r_valid) {
- *r_valid = false;
- }
-}
-
-Variant ScriptInstance::property_get_fallback(const StringName &, bool *r_valid) {
- if (r_valid) {
- *r_valid = false;
- }
- return Variant();
-}
-
-ScriptInstance::~ScriptInstance() {
-}
-
ScriptCodeCompletionCache *ScriptCodeCompletionCache::singleton = nullptr;
ScriptCodeCompletionCache::ScriptCodeCompletionCache() {
singleton = this;
diff --git a/core/object/script_language.h b/core/object/script_language.h
index 3cac360b1a..e0c4d650dd 100644
--- a/core/object/script_language.h
+++ b/core/object/script_language.h
@@ -33,6 +33,7 @@
#include "core/doc_data.h"
#include "core/io/resource.h"
+#include "core/object/script_instance.h"
#include "core/templates/pair.h"
#include "core/templates/rb_map.h"
#include "core/templates/safe_refcount.h"
@@ -101,7 +102,6 @@ public:
static bool are_languages_finished() { return languages_finished.is_set(); }
};
-class ScriptInstance;
class PlaceHolderScriptInstance;
class Script : public Resource {
@@ -174,65 +174,6 @@ public:
Script() {}
};
-class ScriptInstance {
-public:
- virtual bool set(const StringName &p_name, const Variant &p_value) = 0;
- virtual bool get(const StringName &p_name, Variant &r_ret) const = 0;
- virtual void get_property_list(List<PropertyInfo> *p_properties) const = 0;
- virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const = 0;
- virtual void validate_property(PropertyInfo &p_property) const = 0;
-
- virtual bool property_can_revert(const StringName &p_name) const = 0;
- virtual bool property_get_revert(const StringName &p_name, Variant &r_ret) const = 0;
-
- virtual Object *get_owner() { return nullptr; }
- virtual void get_property_state(List<Pair<StringName, Variant>> &state);
-
- virtual void get_method_list(List<MethodInfo> *p_list) const = 0;
- virtual bool has_method(const StringName &p_method) const = 0;
-
- virtual Variant callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) = 0;
-
- template <typename... VarArgs>
- Variant call(const StringName &p_method, VarArgs... p_args) {
- Variant args[sizeof...(p_args) + 1] = { p_args..., Variant() }; // +1 makes sure zero sized arrays are also supported.
- const Variant *argptrs[sizeof...(p_args) + 1];
- for (uint32_t i = 0; i < sizeof...(p_args); i++) {
- argptrs[i] = &args[i];
- }
- Callable::CallError cerr;
- return callp(p_method, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args), cerr);
- }
-
- virtual Variant call_const(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error); // implement if language supports const functions
- virtual void notification(int p_notification, bool p_reversed = false) = 0;
- virtual String to_string(bool *r_valid) {
- if (r_valid) {
- *r_valid = false;
- }
- return String();
- }
-
- //this is used by script languages that keep a reference counter of their own
- //you can make make Ref<> not die when it reaches zero, so deleting the reference
- //depends entirely from the script
-
- virtual void refcount_incremented() {}
- virtual bool refcount_decremented() { return true; } //return true if it can die
-
- virtual Ref<Script> get_script() const = 0;
-
- virtual bool is_placeholder() const { return false; }
-
- virtual void property_set_fallback(const StringName &p_name, const Variant &p_value, bool *r_valid);
- virtual Variant property_get_fallback(const StringName &p_name, bool *r_valid);
-
- virtual const Variant get_rpc_config() const { return get_script()->get_rpc_config(); }
-
- virtual ScriptLanguage *get_language() = 0;
- virtual ~ScriptInstance();
-};
-
class ScriptCodeCompletionCache {
static ScriptCodeCompletionCache *singleton;
diff --git a/core/os/main_loop.h b/core/os/main_loop.h
index 90cad009b1..b45eb38aeb 100644
--- a/core/os/main_loop.h
+++ b/core/os/main_loop.h
@@ -34,7 +34,6 @@
#include "core/input/input_event.h"
#include "core/object/gdvirtual.gen.inc"
#include "core/object/ref_counted.h"
-#include "core/object/script_language.h"
class MainLoop : public Object {
GDCLASS(MainLoop, Object);
diff --git a/core/string/translation.h b/core/string/translation.h
index ca8b460312..3f9dbcc476 100644
--- a/core/string/translation.h
+++ b/core/string/translation.h
@@ -33,7 +33,6 @@
#include "core/io/resource.h"
#include "core/object/gdvirtual.gen.inc"
-#include "core/object/script_language.h"
class Translation : public Resource {
GDCLASS(Translation, Resource);
diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp
index b7bdf1d97a..fea1622222 100644
--- a/core/variant/variant_parser.cpp
+++ b/core/variant/variant_parser.cpp
@@ -32,6 +32,7 @@
#include "core/input/input_event.h"
#include "core/io/resource_loader.h"
+#include "core/object/script_language.h"
#include "core/os/keyboard.h"
#include "core/string/string_buffer.h"