X Tutup
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 12 additions & 0 deletions src/runtime/Native/PyStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Runtime.InteropServices;

namespace Python.Runtime.Native;

[StructLayout(LayoutKind.Sequential)]
struct PyStatus
{
int exitcode;
IntPtr err_msg;
IntPtr func;
}
17 changes: 16 additions & 1 deletion src/runtime/Runtime.Delegates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ static Delegates()
}
catch (MissingMethodException)
{

PyThreadState_GetUnchecked = (delegate* unmanaged[Cdecl]<PyThreadState*>)GetFunctionByName(nameof(PyThreadState_GetUnchecked), GetUnmanagedDll(_PythonDll));
}
try
Expand Down Expand Up @@ -277,6 +276,15 @@ static Delegates()
PyType_GetSlot = (delegate* unmanaged[Cdecl]<BorrowedReference, TypeSlotID, IntPtr>)GetFunctionByName(nameof(PyType_GetSlot), GetUnmanagedDll(_PythonDll));
PyType_FromSpecWithBases = (delegate* unmanaged[Cdecl]<in NativeTypeSpec, BorrowedReference, NewReference>)GetFunctionByName(nameof(PyType_FromSpecWithBases), GetUnmanagedDll(PythonDLL));

PyConfig_InitPythonConfig = (delegate* unmanaged[Cdecl]<IntPtr, void>)GetFunctionByName(nameof(PyConfig_InitPythonConfig), GetUnmanagedDll(_PythonDll));
PyConfig_InitIsolatedConfig = (delegate* unmanaged[Cdecl]<IntPtr, void>)GetFunctionByName(nameof(PyConfig_InitIsolatedConfig), GetUnmanagedDll(_PythonDll));
PyConfig_SetString = (delegate* unmanaged[Cdecl]<IntPtr, IntPtr, PyStatus>)GetFunctionByName(nameof(PyConfig_SetString), GetUnmanagedDll(_PythonDll));

Py_InitializeFromConfig = (delegate* unmanaged[Cdecl]<IntPtr, PyStatus>)GetFunctionByName(nameof(Py_InitializeFromConfig), GetUnmanagedDll(_PythonDll));
PyConfig_Clear = (delegate* unmanaged[Cdecl]<IntPtr, void>)GetFunctionByName(nameof(PyConfig_Clear), GetUnmanagedDll(_PythonDll));
PyStatus_Exception = (delegate* unmanaged[Cdecl]<PyStatus, int>)GetFunctionByName(nameof(PyStatus_Exception), GetUnmanagedDll(_PythonDll));
Py_ExitStatusException = (delegate* unmanaged[Cdecl]<PyStatus, void>)GetFunctionByName(nameof(Py_ExitStatusException), GetUnmanagedDll(_PythonDll));

try
{
_Py_NewReference = (delegate* unmanaged[Cdecl]<BorrowedReference, void>)GetFunctionByName(nameof(_Py_NewReference), GetUnmanagedDll(_PythonDll));
Expand Down Expand Up @@ -548,5 +556,12 @@ static Delegates()
internal static delegate* unmanaged[Cdecl]<int> _Py_IsFinalizing { get; }
internal static IntPtr PyType_Type { get; }
internal static int* Py_NoSiteFlag { get; }
internal static delegate* unmanaged[Cdecl]<IntPtr, void> PyConfig_InitPythonConfig { get; }
internal static delegate* unmanaged[Cdecl]<IntPtr, void> PyConfig_InitIsolatedConfig { get; }
internal static delegate* unmanaged[Cdecl]<IntPtr, IntPtr, PyStatus> PyConfig_SetString { get; }
internal static delegate* unmanaged[Cdecl]<IntPtr, PyStatus> Py_InitializeFromConfig { get; }
internal static delegate* unmanaged[Cdecl]<IntPtr, void> PyConfig_Clear { get; }
internal static delegate* unmanaged[Cdecl]<PyStatus, int> PyStatus_Exception { get; }
internal static delegate* unmanaged[Cdecl]<PyStatus, void> Py_ExitStatusException { get; }
}
}
Loading
X Tutup