Skip to content

Commit

Permalink
Use IntPtr in Bindgen.Runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
lithiumtoast committed May 7, 2024
1 parent d472b77 commit ddec994
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions src/cs/production/Bindgen.Runtime/CString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ namespace Bindgen.Runtime;
[StructLayout(LayoutKind.Sequential)]
public readonly unsafe struct CString : IEquatable<CString>, IDisposable
{
public readonly nint Pointer;
public readonly IntPtr Pointer;

/// <summary>
/// Gets a value indicating whether this <see cref="CString" /> is a null pointer.
/// </summary>
public bool IsNull => Pointer == 0;
public bool IsNull => Pointer == IntPtr.Zero;

/// <summary>
/// Initializes a new instance of the <see cref="CString" /> struct.
/// </summary>
/// <param name="value">The pointer value.</param>
public CString(byte* value)
{
Pointer = (nint)value;
Pointer = (IntPtr)value;
}

/// <summary>
/// Initializes a new instance of the <see cref="CString" /> struct.
/// </summary>
/// <param name="value">The pointer value.</param>
public CString(nint value)
public CString(IntPtr value)
{
Pointer = value;
}
Expand Down Expand Up @@ -61,7 +61,7 @@ public void Dispose()
/// <returns>
/// The resulting <see cref="CString" />.
/// </returns>
public static explicit operator CString(nint value)
public static explicit operator CString(IntPtr value)
{
return FromIntPtr(value);
}
Expand All @@ -73,7 +73,7 @@ public static explicit operator CString(nint value)
/// <returns>
/// The resulting <see cref="CString" />.
/// </returns>
public static CString FromIntPtr(nint value)
public static CString FromIntPtr(IntPtr value)
{
return new CString(value);
}
Expand All @@ -99,7 +99,7 @@ public static implicit operator CString(byte* value)
/// </returns>
public static CString From(byte* value)
{
return new CString((nint)value);
return new CString((IntPtr)value);
}

/// <summary>
Expand All @@ -109,7 +109,7 @@ public static CString From(byte* value)
/// <returns>
/// The resulting <see cref="IntPtr" />.
/// </returns>
public static implicit operator nint(CString value)
public static implicit operator IntPtr(CString value)
{
return value.Pointer;
}
Expand All @@ -121,7 +121,7 @@ public static implicit operator nint(CString value)
/// <returns>
/// The resulting <see cref="IntPtr" />.
/// </returns>
public static nint ToIntPtr(CString value)
public static IntPtr ToIntPtr(CString value)
{
return value.Pointer;
}
Expand Down
18 changes: 9 additions & 9 deletions src/cs/production/Bindgen.Runtime/CStringWide.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ namespace Bindgen.Runtime;
[StructLayout(LayoutKind.Sequential)]
public readonly unsafe struct CStringWide : IEquatable<CStringWide>
{
public readonly nint Pointer;
public readonly IntPtr Pointer;

/// <summary>
/// Gets a value indicating whether this <see cref="CStringWide" /> is a null pointer.
/// </summary>
public bool IsNull => Pointer == 0;
public bool IsNull => Pointer == IntPtr.Zero;

/// <summary>
/// Initializes a new instance of the <see cref="CStringWide" /> struct.
/// </summary>
/// <param name="value">The pointer value.</param>
public CStringWide(byte* value)
{
Pointer = (nint)value;
Pointer = (IntPtr)value;
}

/// <summary>
/// Initializes a new instance of the <see cref="CStringWide" /> struct.
/// </summary>
/// <param name="value">The pointer value.</param>
public CStringWide(nint value)
public CStringWide(IntPtr value)
{
Pointer = value;
}
Expand All @@ -53,7 +53,7 @@ public CStringWide(string s)
/// <returns>
/// The resulting <see cref="CStringWide" />.
/// </returns>
public static explicit operator CStringWide(nint value)
public static explicit operator CStringWide(IntPtr value)
{
return FromIntPtr(value);
}
Expand All @@ -65,7 +65,7 @@ public static explicit operator CStringWide(nint value)
/// <returns>
/// The resulting <see cref="CStringWide" />.
/// </returns>
public static CStringWide FromIntPtr(nint value)
public static CStringWide FromIntPtr(IntPtr value)
{
return new CStringWide(value);
}
Expand All @@ -91,7 +91,7 @@ public static implicit operator CStringWide(byte* value)
/// </returns>
public static CStringWide From(byte* value)
{
return new CStringWide((nint)value);
return new CStringWide((IntPtr)value);
}

/// <summary>
Expand All @@ -101,7 +101,7 @@ public static CStringWide From(byte* value)
/// <returns>
/// The resulting <see cref="IntPtr" />.
/// </returns>
public static implicit operator nint(CStringWide value)
public static implicit operator IntPtr(CStringWide value)
{
return value.Pointer;
}
Expand All @@ -113,7 +113,7 @@ public static implicit operator nint(CStringWide value)
/// <returns>
/// The resulting <see cref="IntPtr" />.
/// </returns>
public static nint ToIntPtr(CStringWide value)
public static IntPtr ToIntPtr(CStringWide value)
{
return value.Pointer;
}
Expand Down

0 comments on commit ddec994

Please sign in to comment.