Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

Commit 5f79ca4

Browse files
Merge pull request #826 from xamarin/bad-exceptions
fixed issues with closures that throw and have args
2 parents d4cbb42 + 3453ed2 commit 5f79ca4

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

SwiftRuntimeLibrary/SwiftClosureRepresentation.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static void FuncCallbackVoidMaybeThrows (IntPtr retValPtr, IntPtr refPtr)
8080
[UnmanagedCallersOnly]
8181
public static void FuncCallbackMaybeThrows (IntPtr retValPtr, IntPtr args, IntPtr refPtr)
8282
{
83-
FuncCallbackMaybeThrowsImpl (retValPtr, IntPtr.Zero, refPtr);
83+
FuncCallbackMaybeThrowsImpl (retValPtr, args, refPtr);
8484
}
8585

8686
static void FuncCallbackMaybeThrowsImpl (IntPtr retValPtr, IntPtr args, IntPtr refPtr)
@@ -114,8 +114,12 @@ static void FuncCallbackMaybeThrowsImpl (IntPtr retValPtr, IntPtr args, IntPtr r
114114
#endif
115115
var argumentValues = args != IntPtr.Zero ? StructMarshal.Marshaler.MarshalSwiftTupleMemoryToNet (args, delInfo.Item2) : null;
116116
#if DEBUG
117-
//foreach (var arg in argumentValues) {
118-
// Console.WriteLine ($"arg: {arg} type: {arg.GetType ().Name}");
117+
//if (argumentValues is not null) {
118+
// foreach (var arg in argumentValues) {
119+
// Console.WriteLine ($"arg: {arg} type: {arg.GetType ().Name}");
120+
// }
121+
//} else {
122+
// Console.WriteLine ("argumentValues is null");
119123
//}
120124
#endif
121125

SwiftRuntimeLibrary/SwiftMarshal/StructMarshal.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,14 +1362,14 @@ public bool ExceptionReturnContainsSwiftError (IntPtr swiftMedusaTuple, Type t)
13621362
bool ExceptionReturnContainsSwiftError (IntPtr swiftMeduaTuple, SwiftTupleMap tMap)
13631363
{
13641364
//#if DEBUG
1365-
// Console.WriteLine("Given pointer " + p.ToString("X8"));
1365+
// Console.WriteLine("Given pointer " + swiftMeduaTuple.ToString("X8"));
13661366
// Console.WriteLine($"And a tuple map with ${tMap.Offsets.Length} offsets");
13671367
// foreach (int i in tMap.Offsets)
13681368
// {
13691369
// Console.Write($"{i}, ");
13701370
// }
13711371
// Console.WriteLine();
1372-
// Memory.Dump(p, 40);
1372+
// Memory.Dump(swiftMeduaTuple, 40);
13731373
//#endif
13741374
var boolPtr = swiftMeduaTuple + tMap.Offsets [tMap.Offsets.Length - 1];
13751375
//#if DEBUG

0 commit comments

Comments
 (0)