Skip to content

DLR-based overload resolution #1278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added BorrowedReference.Null and DangerousGetAddressOrNull
  • Loading branch information
lostmsu committed Nov 12, 2020
commit ebb579dfcac0e531b71889f37dd7b5a1594d9072
6 changes: 5 additions & 1 deletion src/runtime/BorrowedReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ readonly ref struct BorrowedReference
public bool IsNull => this.pointer == IntPtr.Zero;


/// <summary>Gets a raw pointer to the Python object</summary>
/// <summary>Gets a raw pointer to the Python object. Performs null check</summary>
public IntPtr DangerousGetAddress()
=> this.IsNull ? throw new NullReferenceException() : this.pointer;
/// <summary>Gets a raw pointer to the Python object</summary>
public IntPtr DangerousGetAddressOrNull() => this.pointer;

/// <summary>
/// Creates new instance of <see cref="BorrowedReference"/> from raw pointer. Unsafe.
Expand All @@ -22,5 +24,7 @@ public BorrowedReference(IntPtr pointer)
{
this.pointer = pointer;
}

public static BorrowedReference Null => default;
}
}