From 96f8254b24109884bdc3f6a7e224a8045b27ee15 Mon Sep 17 00:00:00 2001 From: reduz Date: Tue, 24 Aug 2021 15:16:25 -0300 Subject: Implement error return documetation Adds ability to add error return documetation to the binder and class reference. Usage example: ```C++ void MyClass::_bind_method() { [..] BIND_METHOD_ERR_RETURN_DOC("load", ERR_FILE_CANT_OPEN, ERR_FILE_UNRECOGNIZED); } ``` One function of ConfigFile was changed as example. --- core/object/class_db.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'core/object/class_db.cpp') diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index b29b2bd421..e268a8d292 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -892,6 +892,32 @@ void ClassDB::get_enum_constants(const StringName &p_class, const StringName &p_ } } +void ClassDB::set_method_error_return_values(const StringName &p_class, const StringName &p_method, const Vector &p_values) { + OBJTYPE_RLOCK; +#ifdef DEBUG_METHODS_ENABLED + ClassInfo *type = classes.getptr(p_class); + + ERR_FAIL_COND(!type); + + type->method_error_values[p_method] = p_values; +#endif +} + +Vector ClassDB::get_method_error_return_values(const StringName &p_class, const StringName &p_method) { +#ifdef DEBUG_METHODS_ENABLED + ClassInfo *type = classes.getptr(p_class); + + ERR_FAIL_COND_V(!type, Vector()); + + if (!type->method_error_values.has(p_method)) { + return Vector(); + } + return type->method_error_values[p_method]; +#else + return Vector(); +#endif +} + bool ClassDB::has_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance) { OBJTYPE_RLOCK; -- cgit v1.2.3