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
a few more *Reference overloads
  • Loading branch information
lostmsu committed Nov 12, 2020
commit 5dd74f9b4df7ff2cfb2f9d5f37f68a2c238c8ce2
12 changes: 12 additions & 0 deletions src/runtime/runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,15 @@ internal static IntPtr PyObject_Type(IntPtr op)
return tp;
}

/// <summary>
/// Managed version of the standard Python C API PyObject_Type call.
/// This version avoids a managed &lt;-&gt; unmanaged transition.
/// </summary>
internal static BorrowedReference PyObject_Type(BorrowedReference op)
{
return new BorrowedReference(PyObject_TYPE(op.DangerousGetAddress()));
}

internal static string PyObject_GetTypeName(IntPtr op)
{
IntPtr pyType = Marshal.ReadIntPtr(op, ObjectOffset.ob_type);
Expand Down Expand Up @@ -1150,6 +1159,9 @@ internal static long PyObject_Size(IntPtr pointer)
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "PyObject_Str")]
internal static extern IntPtr PyObject_Unicode(IntPtr pointer);
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "PyObject_Str")]
internal static extern NewReference PyObject_Unicode(BorrowedReference pointer);

[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyObject_Dir(IntPtr pointer);
Expand Down