You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Extract ScriptInstance to simplify includes
This allows to include script_instance.h directly in the generated gdvirtual.gen.inc, and remove excessive includes from the codebase. This should also allow Resource to use GDVIRTUAL macros, which wasn't possible previously due to a circular dependency.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user