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

Commit c3462f1

Browse files
Merge pull request #435 from xamarin/name-change
Rename of many Nominal names (name)
2 parents 2597563 + 0be8dab commit c3462f1

28 files changed

+162
-175
lines changed

SwiftReflector/MarshalEngine.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public IEnumerable<ICodeElement> MarshalConstructor (TypeDeclaration classDecl,
7070
var thisDataPtr = new CSIdentifier (Uniqueify ("thisDataPtr", identifiersUsed));
7171
identifiersUsed.Add (thisDataPtr.Name);
7272
var returnFixed = new CSFixedCodeBlock (CSSimpleType.ByteStar, thisDataPtr,
73-
new CSFunctionCall ("StructMarshal.Marshaler.PrepareNominal", false, thisID), null);
73+
new CSFunctionCall ("StructMarshal.Marshaler.PrepareValueType", false, thisID), null);
7474
fixedChain.Add (returnFixed);
7575
var thisPtr = new CSIdentifier (Uniqueify ("thisPtr", identifiersUsed));
7676
identifiersUsed.Add (thisPtr.Name);
@@ -155,7 +155,7 @@ CSLine CreateNominalCall (CSType returnType, CSIdentifier id, CSType objectType,
155155
return CSVariableDeclaration.VarLine (returnType, id, objectType.Ctor ());
156156
} else {
157157
use.AddIfNotPresent (typeof (StructMarshal));
158-
var marshalCreate = CSFunctionCall.Function ($"StructMarshal.DefaultNominal<{objectType}>");
158+
var marshalCreate = CSFunctionCall.Function ($"StructMarshal.DefaultValueType<{objectType}>");
159159

160160
return CSVariableDeclaration.VarLine (returnType, id, marshalCreate);
161161
}
@@ -288,7 +288,7 @@ public IEnumerable<ICodeElement> MarshalFunctionCall (FunctionDeclaration wrappe
288288

289289
if (returnEntity != null && returnEntity.EntityType == EntityType.Enum) {
290290
// SomeEnumType someEnum = new SomeEnum();
291-
// fixed (byte *retvalPtr = StructMarshal.Marshaler.PrepareNominal(someEnum)) {
291+
// fixed (byte *retvalPtr = StructMarshal.Marshaler.PrepareValueType(someEnum)) {
292292
// ...
293293
// IntPtr retvalIntPtr = new IntPtr(retvalPtr);
294294
// SomePInvokeCall(retValIntPtr);
@@ -843,7 +843,7 @@ CSBaseExpression MarshalClassAsPointer (CSParameter p, FunctionDeclaration funcD
843843

844844
CSBaseExpression MarshalNominalAsPointer (CSParameter p, bool isReturnValue)
845845
{
846-
// fixed (byte * pSwiftDataPtr = StructMarshal.Marshaler.PrepareNominal(p)) {
846+
// fixed (byte * pSwiftDataPtr = StructMarshal.Marshaler.PrepareValueType(p)) {
847847
// SomePiCall(... newIntPtr(pSwiftDataPtr));
848848
// }
849849
string enumDataPtrName = Uniqueify (String.Format ("{0}SwiftDataPtr", p.Name.Name), identifiersUsed);
@@ -853,7 +853,7 @@ CSBaseExpression MarshalNominalAsPointer (CSParameter p, bool isReturnValue)
853853
RequiredUnsafeCode = true;
854854
use.AddIfNotPresent (typeof (StructMarshal));
855855
CSFixedCodeBlock fixedBlock = new CSFixedCodeBlock (CSSimpleType.ByteStar, enumDataPtr,
856-
new CSFunctionCall ("StructMarshal.Marshaler.PrepareNominal", false, p.Name), null);
856+
new CSFunctionCall ("StructMarshal.Marshaler.PrepareValueType", false, p.Name), null);
857857
fixedChain.Add (fixedBlock);
858858
return new CSCastExpression ("IntPtr", enumDataPtr);
859859
}
@@ -1595,7 +1595,7 @@ CSBaseExpression MarshalStruct (CSParameter p, NamedTypeSpec st)
15951595

15961596
CSBaseExpression MarshalNominal (CSParameter p)
15971597
{
1598-
// fixed (byte *nameSwiftDataPtr = StructMarshal.Marshaler.PrepareNominal(name)) {
1598+
// fixed (byte *nameSwiftDataPtr = StructMarshal.Marshaler.PrepareValueType(name)) {
15991599
// ...
16001600
// someCallToAPinvoke(new IntPtr(nameSwiftDataPtr))
16011601
// ...
@@ -1610,7 +1610,7 @@ CSBaseExpression MarshalNominal (CSParameter p)
16101610
RequiredUnsafeCode = true;
16111611
use.AddIfNotPresent (typeof (StructMarshal));
16121612
var fixedBlock = new CSFixedCodeBlock (CSSimpleType.ByteStar, enumDataPtr,
1613-
new CSFunctionCall ("StructMarshal.Marshaler.PrepareNominal", false, p.Name), null);
1613+
new CSFunctionCall ("StructMarshal.Marshaler.PrepareValueType", false, p.Name), null);
16141614
fixedChain.Add (fixedBlock);
16151615
return new CSCastExpression ("IntPtr", enumDataPtr);
16161616
}

SwiftReflector/NewClassCompiler.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ CSMethod CompileEnumFactory (EnumDeclaration enumDecl, EnumElement element, stri
961961
// {
962962
// EnumType retval = new Parameter();
963963
// unsafe {
964-
// fixed (byte *retvalSwiftDataPtr = StructMarshal.Marshaler.PrepareNominal(this)) {
964+
// fixed (byte *retvalSwiftDataPtr = StructMarshal.Marshaler.PrepareValueType(this)) {
965965
// Pinvoke.ToSwift(new IntPtr(retvalSwiftDataPtr));
966966
// }
967967
// }
@@ -972,7 +972,7 @@ CSMethod CompileEnumFactory (EnumDeclaration enumDecl, EnumElement element, stri
972972
// {
973973
// EnumType retval = new Parameter()
974974
// unsafe {
975-
// fixed (byte *retvalSwiftDataPtr = StructMarshal.Marshaler.PrepareNominal(this)) {
975+
// fixed (byte *retvalSwiftDataPtr = StructMarshal.Marshaler.PrepareValueType(this)) {
976976
// // marshal code for value
977977
// Pinvoke.ToSwift(new IntPtr(retvalSwiftDataPtr), whateverMarshaledValueIs);
978978
// }
@@ -1034,7 +1034,7 @@ void CompileEnumPayload(CSClass cl, EnumDeclaration enumDecl, EnumElement elemen
10341034
// throw new ArgumentOutOfRangeException("Expected Case to be Optional.");
10351035
// // marshaling for return type
10361036
// unsafe {
1037-
// fixed (byte *thisSwiftDataPtr = StructMarshal.Marshaler.PrepareNominal(this)) {
1037+
// fixed (byte *thisSwiftDataPtr = StructMarshal.Marshaler.PrepareValueType(this)) {
10381038
// Pinvoke.ToSwift(..., new IntPtr(thisSwiftDataPtr));
10391039
// // more marshaling
10401040
// return value;
@@ -1905,7 +1905,7 @@ CSClass CompileVirtualClass (ClassDeclaration classDecl, ModuleInventory modInve
19051905

19061906
string className = StubbedClassName (swiftClassName);
19071907
use.AddIfNotPresent ("SwiftRuntimeLibrary");
1908-
use.AddIfNotPresent (typeof (SwiftNominalTypeAttribute));
1908+
use.AddIfNotPresent (typeof (SwiftValueTypeAttribute));
19091909

19101910
var cl = new CSClass (CSVisibility.Public, className, null);
19111911
CSAttribute.FromAttr (typeof (SwiftNativeObjectAttribute), new CSArgumentList (), true).AttachBefore (cl);
@@ -3050,7 +3050,7 @@ CSClass CompileFinalClass (ClassDeclaration classDecl, ModuleInventory modInvent
30503050

30513051
string className = StubbedClassName (swiftClassName);
30523052
use.AddIfNotPresent ("SwiftRuntimeLibrary");
3053-
use.AddIfNotPresent (typeof (SwiftNominalTypeAttribute));
3053+
use.AddIfNotPresent (typeof (SwiftValueTypeAttribute));
30543054

30553055

30563056
var cl = new CSClass (CSVisibility.Public, className, null);
@@ -3521,7 +3521,7 @@ void ImplementObjCClassField (CSClass cl)
35213521

35223522
void ImplementMTFields (CSClass cl, CSUsingPackages use)
35233523
{
3524-
use.AddIfNotPresent (typeof (SwiftNominalTypeAttribute));
3524+
use.AddIfNotPresent (typeof (SwiftValueTypeAttribute));
35253525
cl.Fields.Add (CSFieldDeclaration.FieldLine (CSSimpleType.IntPtr, kHandleField, null,
35263526
CSVisibility.Protected));
35273527
use.AddIfNotPresent (typeof (SwiftMetatype));
@@ -4002,14 +4002,14 @@ IEnumerable<CSMethod> MakeStructConstructors (CSClass st, CSClass picl, List<str
40024002
CSMethod NominalDefaultConstructor (CSType structType, ClassContents classContents, CSUsingPackages use)
40034003
{
40044004
var parms = new CSParameterList ();
4005-
use.AddIfNotPresent (typeof (SwiftNominalCtorArgument));
4006-
parms.Add (new CSParameter (new CSSimpleType (typeof (SwiftNominalCtorArgument)), "unused"));
4005+
use.AddIfNotPresent (typeof (SwiftValueTypeCtorArgument));
4006+
parms.Add (new CSParameter (new CSSimpleType (typeof (SwiftValueTypeCtorArgument)), "unused"));
40074007
var body = new CSCodeBlock ();
40084008

40094009
string consName = StubbedClassName (classContents.Name);
40104010

40114011
var ctor = new CSMethod (CSVisibility.Internal, CSMethodKind.None, null, new CSIdentifier (consName), parms, body);
4012-
body.Add (CSFunctionCall.FunctionCallLine ("StructMarshal.Marshaler.PrepareNominal", false, CSIdentifier.This));
4012+
body.Add (CSFunctionCall.FunctionCallLine ("StructMarshal.Marshaler.PrepareValueType", false, CSIdentifier.This));
40134013

40144014
return ctor;
40154015
}
@@ -6230,7 +6230,7 @@ static CSAttribute MakeNominalTypeAttribute (string library, string nominalSym,
62306230
al.Add (new CSArgument (CSConstant.Val (library)));
62316231
al.Add (new CSArgument (CSConstant.Val (nominalSym)));
62326232
al.Add (new CSArgument (CSConstant.Val (metaSym)));
6233-
return CSAttribute.FromAttr (typeof (SwiftNominalTypeAttribute), al, true);
6233+
return CSAttribute.FromAttr (typeof (SwiftValueTypeAttribute), al, true);
62346234
}
62356235

62366236
static CSAttribute MakeSwiftStructTypeAttribute (string library, string nominalSym, string metaSym, string witnessSym)

SwiftRuntimeLibrary.Mac/SwiftRuntimeLibrary.Mac.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@
6161
<Compile Include="..\SwiftRuntimeLibrary\ISwiftHashable.cs">
6262
<Link>ISwiftHashable.cs</Link>
6363
</Compile>
64-
<Compile Include="..\SwiftRuntimeLibrary\ISwiftNominalType.cs">
65-
<Link>ISwiftNominalType.cs</Link>
66-
</Compile>
6764
<Compile Include="..\SwiftRuntimeLibrary\ISwiftObject.cs">
6865
<Link>ISwiftObject.cs</Link>
6966
</Compile>
@@ -286,6 +283,9 @@
286283
<Compile Include="..\SwiftRuntimeLibrary\SwiftNativeValueType.cs">
287284
<Link>SwiftNativeValueType.cs</Link>
288285
</Compile>
286+
<Compile Include="..\SwiftRuntimeLibrary\ISwiftValueType.cs">
287+
<Link>ISwiftValueType.cs</Link>
288+
</Compile>
289289
</ItemGroup>
290290
<ItemGroup>
291291
<Folder Include="SwiftMarshal\" />

SwiftRuntimeLibrary.iOS/SwiftRuntimeLibrary.iOS.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@
6666
<Compile Include="..\SwiftRuntimeLibrary\ISwiftHashable.cs">
6767
<Link>ISwiftHashable.cs</Link>
6868
</Compile>
69-
<Compile Include="..\SwiftRuntimeLibrary\ISwiftNominalType.cs">
70-
<Link>ISwiftNominalType.cs</Link>
71-
</Compile>
7269
<Compile Include="..\SwiftRuntimeLibrary\ISwiftObject.cs">
7370
<Link>ISwiftObject.cs</Link>
7471
</Compile>
@@ -291,6 +288,9 @@
291288
<Compile Include="..\SwiftRuntimeLibrary\SwiftNativeValueType.cs">
292289
<Link>SwiftNativeValueType.cs</Link>
293290
</Compile>
291+
<Compile Include="..\SwiftRuntimeLibrary\ISwiftValueType.cs">
292+
<Link>ISwiftValueType.cs</Link>
293+
</Compile>
294294
</ItemGroup>
295295
<Target Name="GeneratedCSCode" BeforeTargets="CoreCompile" Inputs="$(MSBuildProjectFullPath)" Outputs="GeneratedCode\BindingMetadata.iOS.cs">
296296
<Exec Command="make --directory=../SwiftRuntimeLibrary create-pinvokes-ios configuration=$(Configuration)" />

SwiftRuntimeLibrary/ICustomStringConvertible.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public SwiftString Description {
7070
if (actualImpl != null)
7171
return actualImpl.Description;
7272
unsafe {
73-
SwiftString retval = new SwiftString (SwiftNominalCtorArgument.None);
74-
fixed (byte* retvalSwiftDataPtr = StructMarshal.Marshaler.PrepareNominal (retval)) {
73+
SwiftString retval = new SwiftString (SwiftValueTypeCtorArgument.None);
74+
fixed (byte* retvalSwiftDataPtr = StructMarshal.Marshaler.PrepareValueType (retval)) {
7575
NativeMethodsForICustomStringConvertible.PIpropg_IConvertiblexamarin_NoneDConvertibleGdescription (new IntPtr (retvalSwiftDataPtr),
7676
ref container);
7777
return retval;

SwiftRuntimeLibrary/ISwiftNominalType.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
namespace SwiftRuntimeLibrary {
6+
public interface ISwiftValueType : IDisposable {
7+
byte [] SwiftData { get; set; }
8+
}
9+
10+
public interface ISwiftEnum : ISwiftValueType {
11+
}
12+
13+
public interface ISwiftStruct : ISwiftValueType {
14+
}
15+
16+
public enum SwiftValueTypeCtorArgument {
17+
None = 0
18+
}
19+
}

SwiftRuntimeLibrary/SwiftAnyObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public T CastAs<T> () where T : class, ISwiftObject
4040
var metaType = StructMarshal.Marshaler.Metatypeof (typeof (T));
4141
using (var optional = SwiftOptional<T>.None ()) {
4242
unsafe {
43-
fixed (byte* dataPtr = StructMarshal.Marshaler.PrepareNominal (optional)) {
43+
fixed (byte* dataPtr = StructMarshal.Marshaler.PrepareValueType (optional)) {
4444
NativeMethodsForSwiftAnyObject.CastAs (new IntPtr (dataPtr), SwiftObject, metaType);
4545
return optional.HasValue ? optional.Value : default (T);
4646
}

SwiftRuntimeLibrary/SwiftArray.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ static nint ValidateCapacity (nint capacity)
3535
}
3636

3737
internal SwiftArray (IntPtr p)
38-
: this (SwiftNominalCtorArgument.None)
38+
: this (SwiftValueTypeCtorArgument.None)
3939
{
4040
CheckedSwiftData.WriteIntPtr (p, offset: 0);
4141
}
4242

4343
public SwiftArray ()
44-
: this ((nint) 0)
44+
: this ((nint)0)
4545
{
4646

4747
}
@@ -53,12 +53,12 @@ public SwiftArray (IList<T> list)
5353
}
5454

5555
public SwiftArray (IEnumerable<T> collection)
56-
: this ((nint) 0)
56+
: this ((nint)0)
5757
{
5858
AddRange (collection);
5959
}
6060

61-
public SwiftArray (params T[] items)
61+
public SwiftArray (params T [] items)
6262
: this (Exceptions.ThrowOnNull (items, nameof (items)).Length)
6363
{
6464
AddRange (items);
@@ -67,7 +67,7 @@ public SwiftArray (params T[] items)
6767
static SwiftMetatype ElementMetatype {
6868
get {
6969
return StructMarshal.Marshaler.Metatypeof (typeof (T));
70-
}
70+
}
7171
}
7272

7373
static int ElementStride {
@@ -87,7 +87,7 @@ static int ElementSizeOf {
8787
Dispose (false);
8888
}
8989

90-
internal SwiftArray (SwiftNominalCtorArgument unused)
90+
internal SwiftArray (SwiftValueTypeCtorArgument unused)
9191
: base ()
9292
{
9393

SwiftRuntimeLibrary/SwiftCharacter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace SwiftRuntimeLibrary {
1212
[SwiftTypeName ("Swift.Character")]
1313
[SwiftStruct (SwiftCoreConstants.LibSwiftCore, SwiftCoreConstants.SwiftCharacter_NominalTypeDescriptor, SwiftCoreConstants.SwiftCharacter_Metadata, "")]
1414
public sealed class SwiftCharacter : SwiftNativeValueType, ISwiftStruct {
15-
public unsafe SwiftCharacter (string character) : this (SwiftNominalCtorArgument.None)
15+
public unsafe SwiftCharacter (string character) : this (SwiftValueTypeCtorArgument.None)
1616
{
1717
SwiftString swiftString = SwiftString.FromString (character);
1818
fixed (byte* src = swiftString.SwiftData)
@@ -24,7 +24,7 @@ public SwiftCharacter (char character) : this (character.ToString ())
2424
{
2525
}
2626

27-
internal SwiftCharacter (SwiftNominalCtorArgument unused)
27+
internal SwiftCharacter (SwiftValueTypeCtorArgument unused)
2828
: base ()
2929
{
3030
}
@@ -48,7 +48,7 @@ internal SwiftCharacter (SwiftNominalCtorArgument unused)
4848

4949
public unsafe override string ToString ()
5050
{
51-
SwiftString swiftString = new SwiftString (SwiftNominalCtorArgument.None);
51+
SwiftString swiftString = new SwiftString (SwiftValueTypeCtorArgument.None);
5252
fixed (byte* source = SwiftData) {
5353
fixed (byte* dest = swiftString.SwiftData) {
5454
GetCharacterValue (source, dest);

0 commit comments

Comments
 (0)