Use RequiredParam and RequiredResult in a handful of places in order to test

This commit is contained in:
David Snopek
2025-10-08 16:37:43 -05:00
parent d95d49ee12
commit 090a4540b7
10 changed files with 68 additions and 68 deletions

View File

@@ -165,7 +165,7 @@ void ResourceLoader::_bind_methods() {
////// ResourceSaver //////
Error ResourceSaver::save(const Ref<Resource> &p_resource, const String &p_path, BitField<SaverFlags> p_flags) {
Error ResourceSaver::save(RequiredParam<Resource> p_resource, const String &p_path, BitField<SaverFlags> p_flags) {
return ::ResourceSaver::save(p_resource, p_path, p_flags);
}

View File

@@ -109,7 +109,7 @@ public:
static ResourceSaver *get_singleton() { return singleton; }
Error save(const Ref<Resource> &p_resource, const String &p_path, BitField<SaverFlags> p_flags);
Error save(RequiredParam<Resource> p_resource, const String &p_path, BitField<SaverFlags> p_flags);
Error set_uid(const String &p_path, ResourceUID::ID p_uid);
Vector<String> get_recognized_extensions(const Ref<Resource> &p_resource);
void add_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver, bool p_at_front);

View File

@@ -97,8 +97,8 @@ void ResourceFormatSaver::_bind_methods() {
GDVIRTUAL_BIND(_recognize_path, "resource", "path");
}
Error ResourceSaver::save(const Ref<Resource> &p_resource, const String &p_path, uint32_t p_flags) {
ERR_FAIL_COND_V_MSG(p_resource.is_null(), ERR_INVALID_PARAMETER, vformat("Can't save empty resource to path '%s'.", p_path));
Error ResourceSaver::save(RequiredParam<Resource> rp_resource, const String &p_path, uint32_t p_flags) {
EXTRACT_PARAM_OR_FAIL_V_MSG(p_resource, rp_resource, ERR_INVALID_PARAMETER, vformat("Can't save empty resource to path '%s'.", p_path));
String path = p_path;
if (path.is_empty()) {
path = p_resource->get_path();

View File

@@ -83,7 +83,7 @@ public:
FLAG_REPLACE_SUBRESOURCE_PATHS = 64,
};
static Error save(const Ref<Resource> &p_resource, const String &p_path = "", uint32_t p_flags = (uint32_t)FLAG_NONE);
static Error save(RequiredParam<Resource> p_resource, const String &p_path = "", uint32_t p_flags = (uint32_t)FLAG_NONE);
static void get_recognized_extensions(const Ref<Resource> &p_resource, List<String> *p_extensions);
static void add_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver, bool p_at_front = false);
static void remove_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver);