🌐 AI搜索 & 代理 主页
Skip to content

Commit d53baf6

Browse files
committed
Add PyConfig-related functions
1 parent 117c66a commit d53baf6

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/runtime/Native/PyStatus.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
4+
namespace Python.Runtime.Native;
5+
6+
[StructLayout(LayoutKind.Sequential)]
7+
struct PyStatus
8+
{
9+
int exitcode;
10+
IntPtr err_msg;
11+
IntPtr func;
12+
}

src/runtime/Runtime.Delegates.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ static Delegates()
3131
}
3232
catch (MissingMethodException)
3333
{
34-
3534
PyThreadState_GetUnchecked = (delegate* unmanaged[Cdecl]<PyThreadState*>)GetFunctionByName(nameof(PyThreadState_GetUnchecked), GetUnmanagedDll(_PythonDll));
3635
}
3736
try
@@ -277,6 +276,15 @@ static Delegates()
277276
PyType_GetSlot = (delegate* unmanaged[Cdecl]<BorrowedReference, TypeSlotID, IntPtr>)GetFunctionByName(nameof(PyType_GetSlot), GetUnmanagedDll(_PythonDll));
278277
PyType_FromSpecWithBases = (delegate* unmanaged[Cdecl]<in NativeTypeSpec, BorrowedReference, NewReference>)GetFunctionByName(nameof(PyType_FromSpecWithBases), GetUnmanagedDll(PythonDLL));
279278

279+
PyConfig_InitPythonConfig = (delegate* unmanaged[Cdecl]<IntPtr, void>)GetFunctionByName(nameof(PyConfig_InitPythonConfig), GetUnmanagedDll(_PythonDll));
280+
PyConfig_InitIsolatedConfig = (delegate* unmanaged[Cdecl]<IntPtr, void>)GetFunctionByName(nameof(PyConfig_InitIsolatedConfig), GetUnmanagedDll(_PythonDll));
281+
PyConfig_SetString = (delegate* unmanaged[Cdecl]<IntPtr, IntPtr, PyStatus>)GetFunctionByName(nameof(PyConfig_SetString), GetUnmanagedDll(_PythonDll));
282+
283+
Py_InitializeFromConfig = (delegate* unmanaged[Cdecl]<IntPtr, PyStatus>)GetFunctionByName(nameof(Py_InitializeFromConfig), GetUnmanagedDll(_PythonDll));
284+
PyConfig_Clear = (delegate* unmanaged[Cdecl]<IntPtr, void>)GetFunctionByName(nameof(PyConfig_Clear), GetUnmanagedDll(_PythonDll));
285+
PyStatus_Exception = (delegate* unmanaged[Cdecl]<PyStatus, int>)GetFunctionByName(nameof(PyStatus_Exception), GetUnmanagedDll(_PythonDll));
286+
Py_ExitStatusException = (delegate* unmanaged[Cdecl]<PyStatus, void>)GetFunctionByName(nameof(Py_ExitStatusException), GetUnmanagedDll(_PythonDll));
287+
280288
try
281289
{
282290
_Py_NewReference = (delegate* unmanaged[Cdecl]<BorrowedReference, void>)GetFunctionByName(nameof(_Py_NewReference), GetUnmanagedDll(_PythonDll));
@@ -548,5 +556,12 @@ static Delegates()
548556
internal static delegate* unmanaged[Cdecl]<int> _Py_IsFinalizing { get; }
549557
internal static IntPtr PyType_Type { get; }
550558
internal static int* Py_NoSiteFlag { get; }
559+
internal static delegate* unmanaged[Cdecl]<IntPtr, void> PyConfig_InitPythonConfig { get; }
560+
internal static delegate* unmanaged[Cdecl]<IntPtr, void> PyConfig_InitIsolatedConfig { get; }
561+
internal static delegate* unmanaged[Cdecl]<IntPtr, IntPtr, PyStatus> PyConfig_SetString { get; }
562+
internal static delegate* unmanaged[Cdecl]<IntPtr, PyStatus> Py_InitializeFromConfig { get; }
563+
internal static delegate* unmanaged[Cdecl]<IntPtr, void> PyConfig_Clear { get; }
564+
internal static delegate* unmanaged[Cdecl]<PyStatus, int> PyStatus_Exception { get; }
565+
internal static delegate* unmanaged[Cdecl]<PyStatus, void> Py_ExitStatusException { get; }
551566
}
552567
}

0 commit comments

Comments
 (0)