You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-11 13:10:58 +00:00
Fix C# bindings after recent breaking changes
Implementation for new Variant types Callable, Signal, StringName. Added support for PackedInt64Array and PackedFloat64Array. Add generation of signal members as events, as well as support for user created signals as events. NOTE: As of now, raising such events will not emit the signal. As such, one must use `EmitSignal` instead of raising the event directly. Removed old ThreadLocal fallback class. It's safe to use thread_local now since it's supported on all minimum versions of compilers we support.
This commit is contained in:
@@ -101,50 +101,41 @@ IMonoClassMember::Visibility GDMonoMethod::get_visibility() {
|
||||
}
|
||||
}
|
||||
|
||||
MonoObject *GDMonoMethod::invoke(MonoObject *p_object, const Variant **p_params, MonoException **r_exc) {
|
||||
if (get_return_type().type_encoding != MONO_TYPE_VOID || get_parameters_count() > 0) {
|
||||
MonoArray *params = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(MonoObject), get_parameters_count());
|
||||
MonoObject *GDMonoMethod::invoke(MonoObject *p_object, const Variant **p_params, MonoException **r_exc) const {
|
||||
MonoException *exc = NULL;
|
||||
MonoObject *ret;
|
||||
|
||||
if (params_count > 0) {
|
||||
MonoArray *params = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(MonoObject), params_count);
|
||||
|
||||
for (int i = 0; i < params_count; i++) {
|
||||
MonoObject *boxed_param = GDMonoMarshal::variant_to_mono_object(p_params[i], param_types[i]);
|
||||
mono_array_setref(params, i, boxed_param);
|
||||
}
|
||||
|
||||
MonoException *exc = NULL;
|
||||
MonoObject *ret = GDMonoUtils::runtime_invoke_array(mono_method, p_object, params, &exc);
|
||||
|
||||
if (exc) {
|
||||
ret = NULL;
|
||||
if (r_exc) {
|
||||
*r_exc = exc;
|
||||
} else {
|
||||
GDMonoUtils::set_pending_exception(exc);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
ret = GDMonoUtils::runtime_invoke_array(mono_method, p_object, params, &exc);
|
||||
} else {
|
||||
MonoException *exc = NULL;
|
||||
GDMonoUtils::runtime_invoke(mono_method, p_object, NULL, &exc);
|
||||
|
||||
if (exc) {
|
||||
if (r_exc) {
|
||||
*r_exc = exc;
|
||||
} else {
|
||||
GDMonoUtils::set_pending_exception(exc);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
ret = GDMonoUtils::runtime_invoke(mono_method, p_object, NULL, &exc);
|
||||
}
|
||||
|
||||
if (exc) {
|
||||
ret = NULL;
|
||||
if (r_exc) {
|
||||
*r_exc = exc;
|
||||
} else {
|
||||
GDMonoUtils::set_pending_exception(exc);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
MonoObject *GDMonoMethod::invoke(MonoObject *p_object, MonoException **r_exc) {
|
||||
MonoObject *GDMonoMethod::invoke(MonoObject *p_object, MonoException **r_exc) const {
|
||||
ERR_FAIL_COND_V(get_parameters_count() > 0, NULL);
|
||||
return invoke_raw(p_object, NULL, r_exc);
|
||||
}
|
||||
|
||||
MonoObject *GDMonoMethod::invoke_raw(MonoObject *p_object, void **p_params, MonoException **r_exc) {
|
||||
MonoObject *GDMonoMethod::invoke_raw(MonoObject *p_object, void **p_params, MonoException **r_exc) const {
|
||||
MonoException *exc = NULL;
|
||||
MonoObject *ret = GDMonoUtils::runtime_invoke(mono_method, p_object, p_params, &exc);
|
||||
|
||||
@@ -247,7 +238,7 @@ void GDMonoMethod::get_parameter_names(Vector<StringName> &names) const {
|
||||
}
|
||||
|
||||
void GDMonoMethod::get_parameter_types(Vector<ManagedType> &types) const {
|
||||
for (int i = 0; i < param_types.size(); ++i) {
|
||||
for (int i = 0; i < params_count; ++i) {
|
||||
types.push_back(param_types[i]);
|
||||
}
|
||||
}
|
||||
@@ -256,13 +247,22 @@ const MethodInfo &GDMonoMethod::get_method_info() {
|
||||
|
||||
if (!method_info_fetched) {
|
||||
method_info.name = name;
|
||||
method_info.return_val = PropertyInfo(GDMonoMarshal::managed_to_variant_type(return_type), "");
|
||||
|
||||
bool nil_is_variant = false;
|
||||
method_info.return_val = PropertyInfo(GDMonoMarshal::managed_to_variant_type(return_type, &nil_is_variant), "");
|
||||
if (method_info.return_val.type == Variant::NIL && nil_is_variant)
|
||||
method_info.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
|
||||
|
||||
Vector<StringName> names;
|
||||
get_parameter_names(names);
|
||||
|
||||
for (int i = 0; i < params_count; ++i) {
|
||||
method_info.arguments.push_back(PropertyInfo(GDMonoMarshal::managed_to_variant_type(param_types[i]), names[i]));
|
||||
nil_is_variant = false;
|
||||
PropertyInfo arg_info = PropertyInfo(GDMonoMarshal::managed_to_variant_type(param_types[i], &nil_is_variant), names[i]);
|
||||
if (arg_info.type == Variant::NIL && nil_is_variant)
|
||||
arg_info.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
|
||||
|
||||
method_info.arguments.push_back(arg_info);
|
||||
}
|
||||
|
||||
// TODO: default arguments
|
||||
|
||||
Reference in New Issue
Block a user