[registrar] Fix/implement returning SEL/Class in a ref/out parameter in the registrars.

This commit is contained in:
Rolf Bjarne Kvinge 2019-04-23 08:03:28 +02:00 коммит произвёл monojenkins
Родитель 84b99d85e5
Коммит b750056271
2 изменённых файлов: 12 добавлений и 3 удалений

Просмотреть файл

@ -245,6 +245,8 @@ xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_
switch (type [0]) {
case _C_PTR: {
switch (type [1]) {
case _C_CLASS:
case _C_SEL:
case _C_ID: {
MonoClass *p_klass = mono_class_from_mono_type (p);
if (!mono_type_is_byref (p)) {
@ -277,6 +279,11 @@ xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_
goto exception_handling;
}
LOGZ (" argument %i is a ref NSObject parameter: %p = %p\n", i + 1, arg, arg_frame [ofs]);
} else if (xamarin_is_class_inativeobject (p_klass)) {
arg_frame [ofs] = xamarin_get_inative_object_dynamic (*(NSObject **) arg, false, mono_type_get_object (domain, p), &exception_gchandle);
if (exception_gchandle != 0)
goto exception_handling;
LOGZ (" argument %i is a ref ptr/INativeObject %p: %p\n", i + 1, arg, arg_frame [ofs]);
} else {
exception_gchandle = xamarin_get_exception_for_parameter (8029, 0, "Unable to marshal the byref parameter", sel, method, p, i, true);
goto exception_handling;
@ -550,7 +557,7 @@ xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_
continue;
}
if (type [0] == _C_PTR && type [1] == _C_ID) {
if (type [0] == _C_PTR && (type [1] == _C_ID || type [1] == _C_SEL || type [1] == _C_CLASS)) {
MonoClass *p_klass = mono_class_from_mono_type (p);
MonoObject *value = *(MonoObject **) arg_ptrs [i + mofs];
MonoObject *pvalue = (MonoObject *) arg_copy [i + mofs];

Просмотреть файл

@ -3498,7 +3498,8 @@ namespace Registrar {
setup_call_stack.AppendLine ("if (exception_gchandle != 0) goto exception_handling;");
}
setup_call_stack.AppendLine ("arg_ptrs [{0}] = &a{0};", i);
copyback.AppendLine ("*p{0} = a{0};", i);
copyback.AppendLine ("*p{0} = a{0} ? (SEL) xamarin_get_handle_for_inativeobject (a{0}, &exception_gchandle) : NULL;", i);
copyback.AppendLine ("if (exception_gchandle != 0) goto exception_handling;");
} else {
setup_call_stack.AppendLine ("arg_ptrs [{0}] = p{0} ? xamarin_get_selector (p{0}, &exception_gchandle) : NULL;", i);
setup_call_stack.AppendLine ("if (exception_gchandle != 0) goto exception_handling;");
@ -3513,7 +3514,8 @@ namespace Registrar {
setup_call_stack.AppendLine ("if (exception_gchandle != 0) goto exception_handling;");
}
setup_call_stack.AppendLine ("arg_ptrs [{0}] = &a{0};", i);
copyback.AppendLine ("*p{0} = a{0};", i);
copyback.AppendLine ("*p{0} = a{0} ? (Class) xamarin_get_handle_for_inativeobject (a{0}, &exception_gchandle) : NULL;", i);
copyback.AppendLine ("if (exception_gchandle != 0) goto exception_handling;");
} else {
setup_call_stack.AppendLine ("arg_ptrs [{0}] = p{0} ? xamarin_get_class (p{0}, &exception_gchandle) : NULL;", i);
setup_call_stack.AppendLine ("if (exception_gchandle != 0) goto exception_handling;");