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

Commit 881af7f

Browse files
author
Stephen Hawley
committed
renamed RetainNominalData and ReleaseNominalData
1 parent f5d4032 commit 881af7f

16 files changed

+36
-36
lines changed

SwiftReflector/MarshalEngine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ CSBaseExpression MarshalTupleAsPointer (BaseDeclaration typeContext, FunctionDec
10921092
// StructMarshal.Marshaler.ToSwiftTuple(typeof(pType), pName, tupleIntPtr, map)
10931093
// ...
10941094
// SomePInvoke(... tupleIntPtr ...)
1095-
// StructMarshal.Marshaler.ReleaseNominalData (typeof (pType), tupleIntPtr);
1095+
// StructMarshal.Marshaler.NominalDestroy (typeof (pType), tupleIntPtr);
10961096
// only injected if the argument is by reference
10971097
// p.Name = StructMarshal.Marshaler.ToNetTuple<t1, t2, t3, t4>(tupleIntPtr, map);
10981098
// }
@@ -1127,7 +1127,7 @@ CSBaseExpression MarshalTupleAsPointer (BaseDeclaration typeContext, FunctionDec
11271127
preMarshalCode.Add (pPtrDecl);
11281128

11291129
if (!MarshalingConstructor) {
1130-
var releaseNominal = CSFunctionCall.FunctionCallLine ("StructMarshal.Marshaler.ReleaseNominalData", false, p.CSType.Typeof (), pPtr);
1130+
var releaseNominal = CSFunctionCall.FunctionCallLine ("StructMarshal.Marshaler.NominalDestroy", false, p.CSType.Typeof (), pPtr);
11311131
postMarshalCode.Add (releaseNominal);
11321132
}
11331133

SwiftReflector/NewClassCompiler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,7 +3566,7 @@ void ImplementNominalIDisposable (CSClass cl, CSUsingPackages use)
35663566
// {
35673567
// fixed (byte* p = SwiftData)
35683568
// {
3569-
// StructMarshal.Marshaler.ReleaseNominalData(typeof(this), p);
3569+
// StructMarshal.Marshaler.NominalDestroy(typeof(this), p);
35703570
// }
35713571
// SwiftData = null;
35723572
// }
@@ -3583,7 +3583,7 @@ void ImplementNominalIDisposable (CSClass cl, CSUsingPackages use)
35833583
var fixedBody = new CSCodeBlock ();
35843584
var fixedBlock = new CSFixedCodeBlock (CSSimpleType.ByteStar, bytestarID, swiftDataID, fixedBody);
35853585
use.AddIfNotPresent (typeof (StructMarshal));
3586-
fixedBlock.Add (CSFunctionCall.FunctionCallLine ("StructMarshal.Marshaler.ReleaseNominalData", false,
3586+
fixedBlock.Add (CSFunctionCall.FunctionCallLine ("StructMarshal.Marshaler.NominalDestroy", false,
35873587
new CSFunctionCall ("typeof", false, new CSIdentifier (cl.ToCSType ().ToString ())),
35883588
bytestarID));
35893589

SwiftRuntimeLibrary/BaseAssociatedTypeProxy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected BaseAssociatedTypeProxy (byte [] swiftTypeData, SwiftMetatype mt)
2727
if (swiftTypeData == null)
2828
throw new ArgumentNullException (nameof (swiftTypeData));
2929
var length = swiftTypeData.Length;
30-
StructMarshal.Marshaler.RetainNominalData (mt, swiftTypeData);
30+
StructMarshal.Marshaler.NominalInitializeWithCopy (mt, swiftTypeData);
3131
SwiftData = new byte [length];
3232
Array.Copy (swiftTypeData, SwiftData, length);
3333
ProxiedMetatype = mt;
@@ -61,7 +61,7 @@ protected virtual void DisposeUnmanagedResources ()
6161
if (IsCSObjectProxy) {
6262
SwiftCore.Release (SwiftObject);
6363
} else {
64-
StructMarshal.Marshaler.ReleaseNominalData (ProxiedMetatype, SwiftData);
64+
StructMarshal.Marshaler.NominalDestroy (ProxiedMetatype, SwiftData);
6565
}
6666
}
6767

SwiftRuntimeLibrary/SwiftArray.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public void Dispose ()
147147

148148
void Dispose (bool disposing)
149149
{
150-
StructMarshal.Marshaler.ReleaseNominalData (this);
150+
StructMarshal.Marshaler.NominalDestroy (this);
151151
}
152152

153153
public IEnumerator<T> GetEnumerator ()

SwiftRuntimeLibrary/SwiftCharacter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public unsafe override string ToString ()
7272

7373
void Dispose (bool disposing)
7474
{
75-
StructMarshal.Marshaler.ReleaseNominalData (this);
75+
StructMarshal.Marshaler.NominalDestroy (this);
7676
}
7777
}
7878
}

SwiftRuntimeLibrary/SwiftDate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void Dispose (bool disposing)
9999
if (SwiftData != null) {
100100
unsafe {
101101
fixed (byte* p = SwiftData) {
102-
StructMarshal.Marshaler.ReleaseNominalData (typeof (SwiftDate),
102+
StructMarshal.Marshaler.NominalDestroy (typeof (SwiftDate),
103103
p);
104104
}
105105
SwiftData = null;

SwiftRuntimeLibrary/SwiftDictionary.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public SwiftDictionary (int capacity)
2525
DictPI.NewDict (new IntPtr(retvalData), capacity, StructMarshal.Marshaler.Metatypeof (typeof (T)),
2626
StructMarshal.Marshaler.Metatypeof (typeof (U)),
2727
StructMarshal.Marshaler.ProtocolWitnessof (typeof (ISwiftHashable), typeof (T)));
28-
StructMarshal.Marshaler.RetainNominalData (typeof (SwiftDictionary<T, U>), retvalData, SwiftData.Length);
28+
StructMarshal.Marshaler.NominalInitializeWithCopy (typeof (SwiftDictionary<T, U>), retvalData, SwiftData.Length);
2929
}
3030
}
3131
}
@@ -132,7 +132,7 @@ public bool ContainsKey (T key)
132132
unsafe {
133133
fixed (byte* thisPtr = SwiftData) {
134134
var thisIntPtr = new IntPtr (thisPtr);
135-
StructMarshal.Marshaler.RetainNominalData (typeof (SwiftDictionary<T, U>), thisIntPtr, SwiftData.Length);
135+
StructMarshal.Marshaler.NominalInitializeWithCopy (typeof (SwiftDictionary<T, U>), thisIntPtr, SwiftData.Length);
136136
byte* keyBuffer = stackalloc byte [StructMarshal.Marshaler.Sizeof (typeof (T))];
137137
var keyBufferPtr = new IntPtr (keyBuffer);
138138
StructMarshal.Marshaler.ToSwift (typeof (T), key, keyBufferPtr);
@@ -167,7 +167,7 @@ public void Clear ()
167167
unsafe {
168168
fixed (byte* thisPtr = SwiftData) {
169169
IntPtr thisIntPtr = new IntPtr (thisPtr);
170-
StructMarshal.Marshaler.RetainNominalData (typeof (SwiftDictionary<T, U>), thisIntPtr, SwiftData.Length);
170+
StructMarshal.Marshaler.NominalInitializeWithCopy (typeof (SwiftDictionary<T, U>), thisIntPtr, SwiftData.Length);
171171
DictPI.DictClear (thisIntPtr, StructMarshal.Marshaler.Metatypeof (typeof (T)),
172172
StructMarshal.Marshaler.Metatypeof (typeof (U)),
173173
StructMarshal.Marshaler.ProtocolWitnessof (typeof (ISwiftHashable), typeof (T)));
@@ -188,7 +188,7 @@ public bool Remove (T key)
188188
unsafe {
189189
fixed (byte* thisPtr = SwiftData) {
190190
var thisIntPtr = new IntPtr (thisPtr);
191-
StructMarshal.Marshaler.RetainNominalData (typeof (SwiftDictionary<T, U>), thisIntPtr, SwiftData.Length);
191+
StructMarshal.Marshaler.NominalInitializeWithCopy (typeof (SwiftDictionary<T, U>), thisIntPtr, SwiftData.Length);
192192
byte* keyBuffer = stackalloc byte [StructMarshal.Marshaler.Sizeof (typeof (T))];
193193
var keyBufferPtr = new IntPtr (keyBuffer);
194194
StructMarshal.Marshaler.ToSwift (typeof (T), key, keyBufferPtr);
@@ -233,7 +233,7 @@ public void Dispose ()
233233

234234
void Dispose (bool disposing)
235235
{
236-
StructMarshal.Marshaler.ReleaseNominalData (this);
236+
StructMarshal.Marshaler.NominalDestroy (this);
237237
}
238238

239239

SwiftRuntimeLibrary/SwiftHasher.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ unsafe void Dispose (bool disposing)
3737
{
3838
if (SwiftData != null) {
3939
fixed (byte *p = SwiftData) {
40-
StructMarshal.Marshaler.ReleaseNominalData (typeof (SwiftHasher), p);
40+
StructMarshal.Marshaler.NominalDestroy (typeof (SwiftHasher), p);
4141
}
4242
SwiftData = null;
4343
}

SwiftRuntimeLibrary/SwiftMarshal/StructMarshal.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,29 +1461,29 @@ public unsafe IntPtr MarshalNominalToSwift (Type t, object o, IntPtr p)
14611461
return p;
14621462
}
14631463

1464-
public unsafe void ReleaseNominalData (Type t, byte* p)
1464+
public unsafe void NominalDestroy (Type t, byte* p)
14651465
{
1466-
ReleaseNominalData (t, new IntPtr (p));
1466+
NominalDestroy (t, new IntPtr (p));
14671467
}
14681468

1469-
public unsafe void ReleaseNominalData (ISwiftNominalType obj)
1469+
public unsafe void NominalDestroy (ISwiftNominalType obj)
14701470
{
14711471
var data = obj.SwiftData;
14721472
if (data != null) {
14731473
fixed (byte* p = data)
1474-
ReleaseNominalData (obj.GetType (), p);
1474+
NominalDestroy (obj.GetType (), p);
14751475
obj.SwiftData = null;
14761476
}
14771477
}
14781478

1479-
public void ReleaseNominalData (Type t, IntPtr p)
1479+
public void NominalDestroy (Type t, IntPtr p)
14801480
{
14811481
var mt = Metatypeof (t);
14821482
var destroy = GetNominalDestroy (t);
14831483
destroy (p, mt);
14841484
}
14851485

1486-
public unsafe void ReleaseNominalData (SwiftMetatype mt, byte [] p)
1486+
public unsafe void NominalDestroy (SwiftMetatype mt, byte [] p)
14871487
{
14881488
var destroy = GetNominalDestroy (mt);
14891489
fixed (byte* pptr = p) {
@@ -1514,7 +1514,7 @@ public void ReleaseSwiftPointer (Type type, IntPtr value)
15141514
return; // nothing to release
15151515

15161516
if (IsSwiftNominal (type) || type.IsTuple ()) {
1517-
ReleaseNominalData (type, value);
1517+
NominalDestroy (type, value);
15181518
return;
15191519
}
15201520

@@ -1556,7 +1556,7 @@ static DestroyDelegate GetNominalDestroy (SwiftValueWitnessTable vt)
15561556
return destroy;
15571557
}
15581558

1559-
public unsafe IntPtr RetainNominalData (ISwiftNominalType obj)
1559+
public unsafe IntPtr NominalInitializeWithCopy (ISwiftNominalType obj)
15601560
{
15611561
if (obj == null)
15621562
throw new ArgumentNullException (nameof (obj));
@@ -1565,15 +1565,15 @@ public unsafe IntPtr RetainNominalData (ISwiftNominalType obj)
15651565
throw new ObjectDisposedException (obj.GetType ().ToString ());
15661566

15671567
fixed (byte* ptr = obj.SwiftData)
1568-
return RetainNominalData (obj.GetType (), ptr, obj.SwiftData.Length);
1568+
return NominalInitializeWithCopy (obj.GetType (), ptr, obj.SwiftData.Length);
15691569
}
15701570

1571-
public unsafe IntPtr RetainNominalData (Type t, byte* p, int size)
1571+
public unsafe IntPtr NominalInitializeWithCopy (Type t, byte* p, int size)
15721572
{
1573-
return RetainNominalData (t, new IntPtr (p), size);
1573+
return NominalInitializeWithCopy (t, new IntPtr (p), size);
15741574
}
15751575

1576-
public IntPtr RetainNominalData (Type t, IntPtr p, int size)
1576+
public IntPtr NominalInitializeWithCopy (Type t, IntPtr p, int size)
15771577
{
15781578
unsafe {
15791579
byte* tbuf = stackalloc byte [size];
@@ -1586,7 +1586,7 @@ public IntPtr RetainNominalData (Type t, IntPtr p, int size)
15861586
return p;
15871587
}
15881588

1589-
public unsafe void RetainNominalData (SwiftMetatype metadata, byte [] p)
1589+
public unsafe void NominalInitializeWithCopy (SwiftMetatype metadata, byte [] p)
15901590
{
15911591
byte* tbuf = stackalloc byte [p.Length];
15921592
var tbufPtr = new IntPtr (tbuf);
@@ -1672,7 +1672,7 @@ public ISwiftNominalType MarshalNominalToNet (IntPtr p, Type t, bool owns)
16721672
Marshal.Copy (p, payload, 0, payload.Length);
16731673

16741674
if (!owns)
1675-
RetainNominalData (t, p, payload.Length);
1675+
NominalInitializeWithCopy (t, p, payload.Length);
16761676

16771677
return o;
16781678
}

SwiftRuntimeLibrary/SwiftOptional.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void Dispose ()
6969

7070
void Dispose (bool disposing)
7171
{
72-
StructMarshal.Marshaler.ReleaseNominalData (this);
72+
StructMarshal.Marshaler.NominalDestroy (this);
7373
}
7474

7575
public static SwiftOptional<T> None ()

0 commit comments

Comments
 (0)