Merge pull request #51910 from neikeq/csharp-callable-defval
C#: Fix bindings generator for Callable argument default value
This commit is contained in:
commit
dc6ed31675
|
@ -3130,8 +3130,18 @@ bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, Ar
|
|||
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL;
|
||||
} break;
|
||||
case Variant::CALLABLE:
|
||||
ERR_FAIL_COND_V_MSG(r_iarg.type.cname != name_cache.type_Callable, false,
|
||||
"Parameter of type '" + String(r_iarg.type.cname) + "' cannot have a default value of type '" + String(name_cache.type_Callable) + "'.");
|
||||
ERR_FAIL_COND_V_MSG(!p_val.is_zero(), false,
|
||||
"Parameter of type '" + String(r_iarg.type.cname) + "' can only have null/zero as the default value.");
|
||||
r_iarg.default_argument = "default";
|
||||
break;
|
||||
case Variant::SIGNAL:
|
||||
CRASH_NOW_MSG("Parameter of type '" + String(r_iarg.type.cname) + "' cannot have a default value.");
|
||||
ERR_FAIL_COND_V_MSG(r_iarg.type.cname != name_cache.type_Signal, false,
|
||||
"Parameter of type '" + String(r_iarg.type.cname) + "' cannot have a default value of type '" + String(name_cache.type_Signal) + "'.");
|
||||
ERR_FAIL_COND_V_MSG(!p_val.is_zero(), false,
|
||||
"Parameter of type '" + String(r_iarg.type.cname) + "' can only have null/zero as the default value.");
|
||||
r_iarg.default_argument = "default";
|
||||
break;
|
||||
default:
|
||||
CRASH_NOW_MSG("Unexpected Variant type: " + itos(p_val.get_type()));
|
||||
|
|
|
@ -536,6 +536,8 @@ class BindingsGenerator {
|
|||
StringName type_Object = StaticCString::create("Object");
|
||||
StringName type_RefCounted = StaticCString::create("RefCounted");
|
||||
StringName type_RID = StaticCString::create("RID");
|
||||
StringName type_Callable = StaticCString::create("Callable");
|
||||
StringName type_Signal = StaticCString::create("Signal");
|
||||
StringName type_String = StaticCString::create("String");
|
||||
StringName type_StringName = StaticCString::create("StringName");
|
||||
StringName type_NodePath = StaticCString::create("NodePath");
|
||||
|
|
|
@ -1686,7 +1686,9 @@ Callable managed_to_callable(const M_Callable &p_managed_callable) {
|
|||
Object *target = p_managed_callable.target ?
|
||||
unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_callable.target)) :
|
||||
nullptr;
|
||||
StringName *method_ptr = unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(p_managed_callable.method_string_name));
|
||||
StringName *method_ptr = p_managed_callable.method_string_name ?
|
||||
unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(p_managed_callable.method_string_name)) :
|
||||
nullptr;
|
||||
StringName method = method_ptr ? *method_ptr : StringName();
|
||||
return Callable(target, method);
|
||||
}
|
||||
|
@ -1732,7 +1734,9 @@ Signal managed_to_signal_info(const M_SignalInfo &p_managed_signal) {
|
|||
Object *owner = p_managed_signal.owner ?
|
||||
unbox<Object *>(CACHED_FIELD(GodotObject, ptr)->get_value(p_managed_signal.owner)) :
|
||||
nullptr;
|
||||
StringName *name_ptr = unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(p_managed_signal.name_string_name));
|
||||
StringName *name_ptr = p_managed_signal.name_string_name ?
|
||||
unbox<StringName *>(CACHED_FIELD(StringName, ptr)->get_value(p_managed_signal.name_string_name)) :
|
||||
nullptr;
|
||||
StringName name = name_ptr ? *name_ptr : StringName();
|
||||
return Signal(owner, name);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue