Ver Fonte

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.
Quentin Quaadgras há 2 anos atrás
pai
commit
6bc16660cc
1 ficheiros alterados com 3 adições e 1 exclusões
  1. 3 1
      core/object/method_bind.cpp

+ 3 - 1
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;
 }