diff options
author | reduz <reduzio@gmail.com> | 2022-03-10 08:17:38 +0100 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2022-03-10 12:28:11 +0100 |
commit | 6f51eca1e3045571ccc68414a922e8b0229111f0 (patch) | |
tree | 8aee693d8f1972009c5788f34fcebfd6c681e9e1 /core/io | |
parent | 741bbb9d7c95dfd810c113ca935a8f16238b5334 (diff) |
Discern between virtual and abstract class bindings
* Previous "virtual" classes (which can't be instantiated) are not corretly named "abstract".
* Added a new "virtual" category for classes, they can't be instantiated from the editor, but can be inherited from script and extensions.
* Converted a large amount of classes from "abstract" to "virtual" where it makes sense.
Most classes that make sense have been converted. Missing:
* Physics servers
* VideoStream
* Script* classes.
which will go in a separate PR due to the complexity involved.
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/resource.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/io/resource.cpp b/core/io/resource.cpp index 66d5c54b53..f90a6e9304 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -290,6 +290,21 @@ void Resource::_take_over_path(const String &p_path) { } RID Resource::get_rid() const { + if (get_script_instance()) { + Callable::CallError ce; + RID ret = get_script_instance()->callp(SNAME("_get_rid"), nullptr, 0, ce); + if (ce.error == Callable::CallError::CALL_OK && ret.is_valid()) { + return ret; + } + } + if (_get_extension() && _get_extension()->get_rid) { + RID ret; + ret.from_uint64(_get_extension()->get_rid(_get_extension_instance())); + if (ret.is_valid()) { + return ret; + } + } + return RID(); } @@ -428,6 +443,11 @@ void Resource::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resource_local_to_scene"), "set_local_to_scene", "is_local_to_scene"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "resource_path", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_path", "get_path"); ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "resource_name"), "set_name", "get_name"); + + MethodInfo get_rid_bind("_get_rid"); + get_rid_bind.return_val.type = Variant::RID; + + ::ClassDB::add_virtual_method(get_class_static(), get_rid_bind, true, Vector<String>(), true); } Resource::Resource() : |