summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Quaadgras <email@quentinquaadgras.com>2022-10-12 21:23:34 +1300
committerQuentin Quaadgras <email@quentinquaadgras.com>2022-10-12 21:23:34 +1300
commit6bc16660cc14d16193d758e906e355a24d4d8353 (patch)
treef156fb6bc0a8491fa5ffdb3d33bc1998ac202d78
parentd5ae80c8bdeaa8761a359728cefe652340dd5f9b (diff)
Fix _unnamed_arg so that arguments defined by GDExtension show up in docs.
The Godot API (gdnative_interface.h) allows methods to be registered on extension classes with `classdb_register_extension_class_method` a `GDNativeExtensionClassMethodInfo` can be provided to this function along with a `get_argument_info_func` which according to the comment indicates that argument names should be definable here. Unfortunately, setting the name field in the `GDNativePropertyInfo` struct has no effect on the editor documentation, which continues to display "_unnamed_arg" for each argument. I discovered that `get_argument_info` is responsible for this as it always overrides the `info.name`. I've added an if condition that will only override the name when it is empty. I've tested this with my GDExtension module and I can confirm that with this commit, the argument name shows up in the builtin docs. eg. in Lookup Symbol.
-rw-r--r--core/object/method_bind.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/object/method_bind.cpp b/core/object/method_bind.cpp
index 0edc7a90c2..5381c596ce 100644
--- a/core/object/method_bind.cpp
+++ b/core/object/method_bind.cpp
@@ -63,7 +63,9 @@ PropertyInfo MethodBind::get_argument_info(int p_argument) const {
PropertyInfo info = _gen_argument_type_info(p_argument);
#ifdef DEBUG_METHODS_ENABLED
- info.name = p_argument < arg_names.size() ? String(arg_names[p_argument]) : String("_unnamed_arg" + itos(p_argument));
+ if (info.name.is_empty()) {
+ info.name = p_argument < arg_names.size() ? String(arg_names[p_argument]) : String("_unnamed_arg" + itos(p_argument));
+ }
#endif
return info;
}