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

Commit 8ded69a

Browse files
author
Stephen Hawley
committed
Now use if-null test
1 parent c4c1162 commit 8ded69a

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

SwiftReflector/MarshalEngine.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,8 +1617,14 @@ CSBaseExpression MarshalNominal (CSParameter p)
16171617

16181618
CSLine ThrowOnNull (CSIdentifier parameterName)
16191619
{
1620-
use.AddIfNotPresent (typeof (SwiftRuntimeLibrary.Exceptions));
1621-
return CSFunctionCall.FunctionCallLine ("Exceptions.ThrowOnNull", parameterName, CSFunctionCall.Nameof (parameterName));
1620+
// code to generate:
1621+
// if (p == null)
1622+
// throw new ArgumentNullException (nameof (p));
1623+
1624+
var ifTest = parameterName == CSConstant.Null;
1625+
var throwCall = CSThrow.ThrowLine (new ArgumentNullException (), CSFunctionCall.Nameof (parameterName));
1626+
var ifStatement = new CSIfElse (ifTest, CSCodeBlock.Create (throwCall), null);
1627+
return new CSLine (ifStatement, false);
16221628
}
16231629

16241630
CSBaseExpression MarshalClass (CSParameter p, NamedTypeSpec cl)

SwiftRuntimeLibrary.iOS/SwiftRuntimeLibrary.iOS.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@
135135
<Compile Include="..\SwiftRuntimeLibrary\SwiftMarshal\DynamicLib.cs">
136136
<Link>SwiftMarshal\DynamicLib.cs</Link>
137137
</Compile>
138-
<Compile Include="..\SwiftRuntimeLibrary\SwiftMarshal\Exceptions.cs">
139-
<Link>SwiftMarshal\Exceptions.cs</Link>
138+
<Compile Include="..\SwiftRuntimeLibrary\SwiftMarshal\Extensions.cs">
139+
<Link>SwiftMarshal\Extentions.cs</Link>
140140
</Compile>
141141
<Compile Include="..\SwiftRuntimeLibrary\SwiftMarshal\Memory.cs">
142142
<Link>SwiftMarshal\Memory.cs</Link>

SwiftRuntimeLibrary/Exceptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System;
55
namespace SwiftRuntimeLibrary {
6-
public static class Exceptions {
6+
internal static class Exceptions {
77
public static T ThrowOnNull<T> (T o, string name, string message = null) where T : class
88
{
99
name = name ?? "::no name supplied::";

0 commit comments

Comments
 (0)