Skip to content

Commit

Permalink
fix: Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Pd233 committed May 5, 2024
1 parent b43b09f commit 8e699e5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 50 deletions.
8 changes: 4 additions & 4 deletions src/Unmanaged/CppTypeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public static T As<T>(this ICppInstanceNonGeneric @this, bool releaseSrc = false
return T.ConstructInstance(@this.Pointer, false, true);
}

T temp = T.ConstructInstance(@this.Pointer, @this.IsOwner, @this.IsTempStackValue);
T temp = T.ConstructInstance(@this.Pointer, @this.OwnsInstance, @this.OwnsMemory);
@this.Pointer = 0;
@this.IsOwner = false;
@this.IsTempStackValue = false;
@this.OwnsInstance = false;
@this.OwnsMemory = false;
@this.Dispose();
return temp;
}
Expand Down Expand Up @@ -106,7 +106,7 @@ static INativeVirtualMethodOverrideProvider()
list.Add((overrideAttr.VirtualMethodIndex, method.MethodHandle.GetFunctionPointer()));
}

virtFptrs = list.ToArray();
virtFptrs = [.. list];
}

static VTableHandle? SetupVtable(ICppInstanceNonGeneric ins)
Expand Down
4 changes: 2 additions & 2 deletions src/Unmanaged/ICppInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ public interface ICppInstanceNonGeneric : IDisposable
/// <summary>
/// noexcept
/// </summary>
public bool IsOwner { get; set; }
public bool OwnsInstance { get; set; }

/// <summary>
/// noexcept
/// </summary>
public bool IsTempStackValue { get; set; }
public bool OwnsMemory { get; set; }

/// <summary>
/// noexcept
Expand Down
33 changes: 0 additions & 33 deletions src/Unmanaged/Result.cs

This file was deleted.

22 changes: 11 additions & 11 deletions src/Unmanaged/STL/StdVector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static StdVector()
public StdVector(nint ptr, bool isOwner = false, bool isTempStackValue = true)
{
_pointer = (StdVector*)ptr.ToPointer();
IsOwner = isOwner;
OwnsInstance = isOwner;
}

public StdVector(StdVector<T> vec)
Expand All @@ -68,8 +68,8 @@ public StdVector(StdVector<T> vec)
Unsafe.CopyBlock(First, vec.First, (uint)size * (uint)sizeof(T));
Last = First + size;
End = Last + vec.Capacity();
IsOwner = true;
IsTempStackValue = false;
OwnsInstance = true;
OwnsMemory = false;
}

// public StdVector(MoveHandle<StdVector<T>> vec)
Expand All @@ -93,21 +93,21 @@ public StdVector(StdVector<T> vec)
public StdVector(nint pointer)
{
_pointer = (StdVector*)pointer.ToPointer();
IsOwner = false;
IsTempStackValue = true;
OwnsInstance = false;
OwnsMemory = true;
}

public StdVector(void* pointer)
{
_pointer = (StdVector*)pointer;
IsOwner = false;
IsTempStackValue = true;
OwnsInstance = false;
OwnsMemory = true;
}

public StdVector()
{
_pointer = (StdVector*)Marshal.AllocHGlobal(sizeof(StdVector)).ToPointer();
IsOwner = true;
OwnsInstance = true;
Unsafe.InitBlock(_pointer, 0, (uint)sizeof(StdVector));
}

Expand Down Expand Up @@ -148,8 +148,8 @@ public static StdVector<T> ConstructInstanceByCopy(StdVector<T> right)
}

public static ulong ClassSize => 24ul;
public bool IsOwner { get; set; }
public bool IsTempStackValue { get; set; }
public bool OwnsInstance { get; set; }
public bool OwnsMemory { get; set; }

public nint Pointer
{
Expand Down Expand Up @@ -226,7 +226,7 @@ private void Dispose(bool disposing)
return;
}

if (IsOwner)
if (OwnsInstance)
{
Destruct();
LibNative.operator_delete(this);
Expand Down
6 changes: 6 additions & 0 deletions src/Unmanaged/UnexploredType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Hosihikari.NativeInterop.Unmanaged;

public struct UnexploredType<T> where T : class, ICppInstance<T>
{
static UnexploredType() => throw new InvalidOperationException();
}

0 comments on commit 8e699e5

Please sign in to comment.