Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
Next Next commit
Remove non-existent PInvoke functions
  • Loading branch information
amos402 committed Aug 19, 2020
commit 7cb00ee34c72d0c835c365ae56cb3502ec5521ba
11 changes: 1 addition & 10 deletions src/runtime/runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -846,12 +846,6 @@ internal static IntPtr Py_CompileStringFlags(string str, string file, int start,
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyCFunction_Call(IntPtr func, IntPtr args, IntPtr kw);

[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyInstance_New(IntPtr cls, IntPtr args, IntPtr kw);

[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyInstance_NewRaw(IntPtr cls, IntPtr dict);

[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr PyMethod_New(IntPtr func, IntPtr self, IntPtr cls);

Expand Down Expand Up @@ -1018,9 +1012,6 @@ internal static long PyObject_Size(IntPtr pointer)
// Python buffer API
//====================================================================

[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_CheckBuffer(IntPtr obj);

[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyObject_GetBuffer(IntPtr exporter, ref Py_buffer view, int flags);

Expand Down Expand Up @@ -1793,7 +1784,7 @@ internal static IntPtr PyType_GenericAlloc(IntPtr type, long n)
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _PyObject_GetDictPtr(IntPtr obj);

[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "_PyObject_GC_New")]
internal static extern IntPtr PyObject_GC_New(IntPtr tp);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this one used anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None.
Its implemetantion is

#define PyObject_GC_New(type, typeobj) \
                ( (type *) _PyObject_GC_New(typeobj) )

Just compare to the PyObject_CheckBuffer, it's easy to make it be a PInvoke function by specific the entry point.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not used, just remove it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's a not big deal though, but what's bad for declaring a valid api?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't use it, it should not be included. The fewer functions we refer to, the easier it will be to keep compatible with different Python versions from the same DLL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a point, although I don't think this API will be deleted in the future.
Removed it.


[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
Expand Down