diff --git a/src/runtime/assemblymanager.cs b/src/runtime/AssemblyManager.cs
similarity index 100%
rename from src/runtime/assemblymanager.cs
rename to src/runtime/AssemblyManager.cs
diff --git a/src/runtime/classmanager.cs b/src/runtime/ClassManager.cs
similarity index 100%
rename from src/runtime/classmanager.cs
rename to src/runtime/ClassManager.cs
diff --git a/src/runtime/Codecs/IPyObjectDecoder.cs b/src/runtime/Codecs/IPyObjectDecoder.cs
new file mode 100644
index 000000000..a8cd8ff03
--- /dev/null
+++ b/src/runtime/Codecs/IPyObjectDecoder.cs
@@ -0,0 +1,22 @@
+namespace Python.Runtime;
+
+using System;
+
+///
+/// Defines conversion to CLR types (unmarshalling)
+///
+public interface IPyObjectDecoder
+{
+ ///
+ /// Checks if this decoder can decode from to
+ ///
+ bool CanDecode(PyType objectType, Type targetType);
+ ///
+ /// Attempts do decode into a variable of specified type
+ ///
+ /// CLR type to decode into
+ /// Object to decode
+ /// The variable, that will receive decoding result
+ ///
+ bool TryDecode(PyObject pyObj, out T? value);
+}
diff --git a/src/runtime/Codecs/IPyObjectEncoder.cs b/src/runtime/Codecs/IPyObjectEncoder.cs
new file mode 100644
index 000000000..94d19da90
--- /dev/null
+++ b/src/runtime/Codecs/IPyObjectEncoder.cs
@@ -0,0 +1,18 @@
+namespace Python.Runtime;
+
+using System;
+
+///
+/// Defines conversion from CLR objects into Python objects (e.g. ) (marshalling)
+///
+public interface IPyObjectEncoder
+{
+ ///
+ /// Checks if encoder can encode CLR objects of specified type
+ ///
+ bool CanEncode(Type type);
+ ///
+ /// Attempts to encode CLR object into Python object
+ ///
+ PyObject? TryEncode(object value);
+}
diff --git a/src/runtime/converterextensions.cs b/src/runtime/Codecs/PyObjectConversions.cs
similarity index 80%
rename from src/runtime/converterextensions.cs
rename to src/runtime/Codecs/PyObjectConversions.cs
index 9a7ae5403..94ed4cdc3 100644
--- a/src/runtime/converterextensions.cs
+++ b/src/runtime/Codecs/PyObjectConversions.cs
@@ -6,41 +6,8 @@ namespace Python.Runtime
using System.Diagnostics;
using System.Linq;
using System.Reflection;
- using Python.Runtime.Codecs;
-
- ///
- /// Defines conversion to CLR types (unmarshalling)
- ///
- public interface IPyObjectDecoder
- {
- ///
- /// Checks if this decoder can decode from to
- ///
- bool CanDecode(PyType objectType, Type targetType);
- ///
- /// Attempts do decode into a variable of specified type
- ///
- /// CLR type to decode into
- /// Object to decode
- /// The variable, that will receive decoding result
- ///
- bool TryDecode(PyObject pyObj, out T? value);
- }
- ///
- /// Defines conversion from CLR objects into Python objects (e.g. ) (marshalling)
- ///
- public interface IPyObjectEncoder
- {
- ///
- /// Checks if encoder can encode CLR objects of specified type
- ///
- bool CanEncode(Type type);
- ///
- /// Attempts to encode CLR object into Python object
- ///
- PyObject? TryEncode(object value);
- }
+ using Python.Runtime.Codecs;
///
/// This class allows to register additional marshalling codecs.
diff --git a/src/runtime/converter.cs b/src/runtime/Converter.cs
similarity index 100%
rename from src/runtime/converter.cs
rename to src/runtime/Converter.cs
diff --git a/src/runtime/delegatemanager.cs b/src/runtime/DelegateManager.cs
similarity index 100%
rename from src/runtime/delegatemanager.cs
rename to src/runtime/DelegateManager.cs
diff --git a/src/runtime/exceptions.cs b/src/runtime/Exceptions.cs
similarity index 84%
rename from src/runtime/exceptions.cs
rename to src/runtime/Exceptions.cs
index 5cf845155..c3ac889ed 100644
--- a/src/runtime/exceptions.cs
+++ b/src/runtime/Exceptions.cs
@@ -5,87 +5,6 @@
namespace Python.Runtime
{
- ///
- /// Base class for Python types that reflect managed exceptions based on
- /// System.Exception
- ///
- ///
- /// The Python wrapper for managed exceptions LIES about its inheritance
- /// tree. Although the real System.Exception is a subclass of
- /// System.Object the Python type for System.Exception does NOT claim that
- /// it subclasses System.Object. Instead TypeManager.CreateType() uses
- /// Python's exception.Exception class as base class for System.Exception.
- ///
- [Serializable]
- internal class ExceptionClassObject : ClassObject
- {
- internal ExceptionClassObject(Type tp) : base(tp)
- {
- }
-
- internal static Exception? ToException(BorrowedReference ob)
- {
- var co = GetManagedObject(ob) as CLRObject;
- return co?.inst as Exception;
- }
-
- ///
- /// Exception __repr__ implementation
- ///
- public new static NewReference tp_repr(BorrowedReference ob)
- {
- Exception? e = ToException(ob);
- if (e == null)
- {
- return Exceptions.RaiseTypeError("invalid object");
- }
- string name = e.GetType().Name;
- string message;
- if (e.Message != String.Empty)
- {
- message = String.Format("{0}('{1}')", name, e.Message);
- }
- else
- {
- message = String.Format("{0}()", name);
- }
- return Runtime.PyString_FromString(message);
- }
-
- ///
- /// Exception __str__ implementation
- ///
- public new static NewReference tp_str(BorrowedReference ob)
- {
- Exception? e = ToException(ob);
- if (e == null)
- {
- return Exceptions.RaiseTypeError("invalid object");
- }
-
- string message = e.ToString();
- string fullTypeName = e.GetType().FullName;
- string prefix = fullTypeName + ": ";
- if (message.StartsWith(prefix))
- {
- message = message.Substring(prefix.Length);
- }
- else if (message.StartsWith(fullTypeName))
- {
- message = message.Substring(fullTypeName.Length);
- }
- return Runtime.PyString_FromString(message);
- }
-
- public override bool Init(BorrowedReference obj, BorrowedReference args, BorrowedReference kw)
- {
- if (!base.Init(obj, args, kw)) return false;
-
- var e = (CLRObject)GetManagedObject(obj)!;
-
- return Exceptions.SetArgsAndCause(obj, (Exception)e.inst);
- }
- }
///
/// Encapsulates the Python exception APIs.
diff --git a/src/runtime/finalizer.cs b/src/runtime/Finalizer.cs
similarity index 100%
rename from src/runtime/finalizer.cs
rename to src/runtime/Finalizer.cs
diff --git a/src/runtime/importhook.cs b/src/runtime/ImportHook.cs
similarity index 100%
rename from src/runtime/importhook.cs
rename to src/runtime/ImportHook.cs
diff --git a/src/runtime/interfaces.cs b/src/runtime/Interfaces.cs
similarity index 100%
rename from src/runtime/interfaces.cs
rename to src/runtime/Interfaces.cs
diff --git a/src/runtime/intern.cs b/src/runtime/InternString.cs
similarity index 100%
rename from src/runtime/intern.cs
rename to src/runtime/InternString.cs
diff --git a/src/runtime/interop.cs b/src/runtime/Interop.cs
similarity index 100%
rename from src/runtime/interop.cs
rename to src/runtime/Interop.cs
diff --git a/src/runtime/loader.cs b/src/runtime/Loader.cs
similarity index 100%
rename from src/runtime/loader.cs
rename to src/runtime/Loader.cs
diff --git a/src/runtime/methodbinder.cs b/src/runtime/MethodBinder.cs
similarity index 100%
rename from src/runtime/methodbinder.cs
rename to src/runtime/MethodBinder.cs
diff --git a/src/runtime/native/ABI.cs b/src/runtime/Native/ABI.cs
similarity index 100%
rename from src/runtime/native/ABI.cs
rename to src/runtime/Native/ABI.cs
diff --git a/src/runtime/BorrowedReference.cs b/src/runtime/Native/BorrowedReference.cs
similarity index 100%
rename from src/runtime/BorrowedReference.cs
rename to src/runtime/Native/BorrowedReference.cs
diff --git a/src/runtime/CustomMarshaler.cs b/src/runtime/Native/CustomMarshaler.cs
similarity index 100%
rename from src/runtime/CustomMarshaler.cs
rename to src/runtime/Native/CustomMarshaler.cs
diff --git a/src/runtime/native/GeneratedTypeOffsets.cs b/src/runtime/Native/GeneratedTypeOffsets.cs
similarity index 100%
rename from src/runtime/native/GeneratedTypeOffsets.cs
rename to src/runtime/Native/GeneratedTypeOffsets.cs
diff --git a/src/runtime/native/ITypeOffsets.cs b/src/runtime/Native/ITypeOffsets.cs
similarity index 100%
rename from src/runtime/native/ITypeOffsets.cs
rename to src/runtime/Native/ITypeOffsets.cs
diff --git a/src/runtime/platform/LibDL.cs b/src/runtime/Native/LibDL.cs
similarity index 100%
rename from src/runtime/platform/LibDL.cs
rename to src/runtime/Native/LibDL.cs
diff --git a/src/runtime/platform/LibraryLoader.cs b/src/runtime/Native/LibraryLoader.cs
similarity index 100%
rename from src/runtime/platform/LibraryLoader.cs
rename to src/runtime/Native/LibraryLoader.cs
diff --git a/src/runtime/nativecall.cs b/src/runtime/Native/NativeCall.cs
similarity index 100%
rename from src/runtime/nativecall.cs
rename to src/runtime/Native/NativeCall.cs
diff --git a/src/runtime/native/NativeFunc.cs b/src/runtime/Native/NativeFunc.cs
similarity index 100%
rename from src/runtime/native/NativeFunc.cs
rename to src/runtime/Native/NativeFunc.cs
diff --git a/src/runtime/native/NativeTypeSpec.cs b/src/runtime/Native/NativeTypeSpec.cs
similarity index 100%
rename from src/runtime/native/NativeTypeSpec.cs
rename to src/runtime/Native/NativeTypeSpec.cs
diff --git a/src/runtime/NewReference.cs b/src/runtime/Native/NewReference.cs
similarity index 100%
rename from src/runtime/NewReference.cs
rename to src/runtime/Native/NewReference.cs
diff --git a/src/runtime/bufferinterface.cs b/src/runtime/Native/PyBufferInterface.cs
similarity index 100%
rename from src/runtime/bufferinterface.cs
rename to src/runtime/Native/PyBufferInterface.cs
diff --git a/src/runtime/native/PyCompilerFlags.cs b/src/runtime/Native/PyCompilerFlags.cs
similarity index 100%
rename from src/runtime/native/PyCompilerFlags.cs
rename to src/runtime/Native/PyCompilerFlags.cs
diff --git a/src/runtime/native/PyGILState.cs b/src/runtime/Native/PyGILState.cs
similarity index 100%
rename from src/runtime/native/PyGILState.cs
rename to src/runtime/Native/PyGILState.cs
diff --git a/src/runtime/intern_.cs b/src/runtime/Native/PyIdentifier_.cs
similarity index 100%
rename from src/runtime/intern_.cs
rename to src/runtime/Native/PyIdentifier_.cs
diff --git a/src/runtime/intern_.tt b/src/runtime/Native/PyIdentifier_.tt
similarity index 100%
rename from src/runtime/intern_.tt
rename to src/runtime/Native/PyIdentifier_.tt
diff --git a/src/runtime/native/PyInterpreterState.cs b/src/runtime/Native/PyInterpreterState.cs
similarity index 100%
rename from src/runtime/native/PyInterpreterState.cs
rename to src/runtime/Native/PyInterpreterState.cs
diff --git a/src/runtime/native/PyMemberFlags.cs b/src/runtime/Native/PyMemberFlags.cs
similarity index 100%
rename from src/runtime/native/PyMemberFlags.cs
rename to src/runtime/Native/PyMemberFlags.cs
diff --git a/src/runtime/native/PyMemberType.cs b/src/runtime/Native/PyMemberType.cs
similarity index 100%
rename from src/runtime/native/PyMemberType.cs
rename to src/runtime/Native/PyMemberType.cs
diff --git a/src/runtime/native/PyMethodFlags.cs b/src/runtime/Native/PyMethodFlags.cs
similarity index 100%
rename from src/runtime/native/PyMethodFlags.cs
rename to src/runtime/Native/PyMethodFlags.cs
diff --git a/src/runtime/native/PyThreadState.cs b/src/runtime/Native/PyThreadState.cs
similarity index 100%
rename from src/runtime/native/PyThreadState.cs
rename to src/runtime/Native/PyThreadState.cs
diff --git a/src/runtime/ReferenceExtensions.cs b/src/runtime/Native/ReferenceExtensions.cs
similarity index 100%
rename from src/runtime/ReferenceExtensions.cs
rename to src/runtime/Native/ReferenceExtensions.cs
diff --git a/src/runtime/StolenReference.cs b/src/runtime/Native/StolenReference.cs
similarity index 100%
rename from src/runtime/StolenReference.cs
rename to src/runtime/Native/StolenReference.cs
diff --git a/src/runtime/native/StrPtr.cs b/src/runtime/Native/StrPtr.cs
similarity index 100%
rename from src/runtime/native/StrPtr.cs
rename to src/runtime/Native/StrPtr.cs
diff --git a/src/runtime/native/TypeOffset.cs b/src/runtime/Native/TypeOffset.cs
similarity index 100%
rename from src/runtime/native/TypeOffset.cs
rename to src/runtime/Native/TypeOffset.cs
diff --git a/src/runtime/interop310.cs b/src/runtime/Native/TypeOffset310.cs
similarity index 100%
rename from src/runtime/interop310.cs
rename to src/runtime/Native/TypeOffset310.cs
diff --git a/src/runtime/interop36.cs b/src/runtime/Native/TypeOffset36.cs
similarity index 100%
rename from src/runtime/interop36.cs
rename to src/runtime/Native/TypeOffset36.cs
diff --git a/src/runtime/interop37.cs b/src/runtime/Native/TypeOffset37.cs
similarity index 100%
rename from src/runtime/interop37.cs
rename to src/runtime/Native/TypeOffset37.cs
diff --git a/src/runtime/interop38.cs b/src/runtime/Native/TypeOffset38.cs
similarity index 100%
rename from src/runtime/interop38.cs
rename to src/runtime/Native/TypeOffset38.cs
diff --git a/src/runtime/interop39.cs b/src/runtime/Native/TypeOffset39.cs
similarity index 100%
rename from src/runtime/interop39.cs
rename to src/runtime/Native/TypeOffset39.cs
diff --git a/src/runtime/Python.Runtime.csproj b/src/runtime/Python.Runtime.csproj
index a90aa3aaa..fad5b9da8 100644
--- a/src/runtime/Python.Runtime.csproj
+++ b/src/runtime/Python.Runtime.csproj
@@ -50,10 +50,10 @@
-
+
clr.py
-
+
interop.py
diff --git a/src/runtime/pythonengine.cs b/src/runtime/PythonEngine.cs
similarity index 100%
rename from src/runtime/pythonengine.cs
rename to src/runtime/PythonEngine.cs
diff --git a/src/runtime/pythonexception.cs b/src/runtime/PythonException.cs
similarity index 100%
rename from src/runtime/pythonexception.cs
rename to src/runtime/PythonException.cs
diff --git a/src/runtime/pybuffer.cs b/src/runtime/PythonTypes/PyBuffer.cs
similarity index 100%
rename from src/runtime/pybuffer.cs
rename to src/runtime/PythonTypes/PyBuffer.cs
diff --git a/src/runtime/pydict.cs b/src/runtime/PythonTypes/PyDict.cs
similarity index 100%
rename from src/runtime/pydict.cs
rename to src/runtime/PythonTypes/PyDict.cs
diff --git a/src/runtime/pyfloat.cs b/src/runtime/PythonTypes/PyFloat.cs
similarity index 100%
rename from src/runtime/pyfloat.cs
rename to src/runtime/PythonTypes/PyFloat.cs
diff --git a/src/runtime/pyint.cs b/src/runtime/PythonTypes/PyInt.cs
similarity index 100%
rename from src/runtime/pyint.cs
rename to src/runtime/PythonTypes/PyInt.cs
diff --git a/src/runtime/pyiter.cs b/src/runtime/PythonTypes/PyIter.cs
similarity index 100%
rename from src/runtime/pyiter.cs
rename to src/runtime/PythonTypes/PyIter.cs
diff --git a/src/runtime/pyiterable.cs b/src/runtime/PythonTypes/PyIterable.cs
similarity index 100%
rename from src/runtime/pyiterable.cs
rename to src/runtime/PythonTypes/PyIterable.cs
diff --git a/src/runtime/pylist.cs b/src/runtime/PythonTypes/PyList.cs
similarity index 100%
rename from src/runtime/pylist.cs
rename to src/runtime/PythonTypes/PyList.cs
diff --git a/src/runtime/module.cs b/src/runtime/PythonTypes/PyModule.cs
similarity index 100%
rename from src/runtime/module.cs
rename to src/runtime/PythonTypes/PyModule.cs
diff --git a/src/runtime/pynumber.cs b/src/runtime/PythonTypes/PyNumber.cs
similarity index 100%
rename from src/runtime/pynumber.cs
rename to src/runtime/PythonTypes/PyNumber.cs
diff --git a/src/runtime/pyobject.cs b/src/runtime/PythonTypes/PyObject.cs
similarity index 100%
rename from src/runtime/pyobject.cs
rename to src/runtime/PythonTypes/PyObject.cs
diff --git a/src/runtime/pysequence.cs b/src/runtime/PythonTypes/PySequence.cs
similarity index 100%
rename from src/runtime/pysequence.cs
rename to src/runtime/PythonTypes/PySequence.cs
diff --git a/src/runtime/pystring.cs b/src/runtime/PythonTypes/PyString.cs
similarity index 100%
rename from src/runtime/pystring.cs
rename to src/runtime/PythonTypes/PyString.cs
diff --git a/src/runtime/pytuple.cs b/src/runtime/PythonTypes/PyTuple.cs
similarity index 100%
rename from src/runtime/pytuple.cs
rename to src/runtime/PythonTypes/PyTuple.cs
diff --git a/src/runtime/pytype.cs b/src/runtime/PythonTypes/PyType.cs
similarity index 100%
rename from src/runtime/pytype.cs
rename to src/runtime/PythonTypes/PyType.cs
diff --git a/src/runtime/TypeSpec.cs b/src/runtime/PythonTypes/TypeSpec.cs
similarity index 100%
rename from src/runtime/TypeSpec.cs
rename to src/runtime/PythonTypes/TypeSpec.cs
diff --git a/src/runtime/resources/clr.py b/src/runtime/Resources/clr.py
similarity index 100%
rename from src/runtime/resources/clr.py
rename to src/runtime/Resources/clr.py
diff --git a/src/runtime/resources/interop.py b/src/runtime/Resources/interop.py
similarity index 100%
rename from src/runtime/resources/interop.py
rename to src/runtime/Resources/interop.py
diff --git a/src/runtime/Runtime.Delegates.cs b/src/runtime/Runtime.Delegates.cs
new file mode 100644
index 000000000..6388bde9f
--- /dev/null
+++ b/src/runtime/Runtime.Delegates.cs
@@ -0,0 +1,542 @@
+using System;
+
+using Python.Runtime.Native;
+using Python.Runtime.Platform;
+
+namespace Python.Runtime;
+
+public unsafe partial class Runtime
+{
+ internal static class Delegates
+ {
+ static readonly ILibraryLoader libraryLoader = LibraryLoader.Instance;
+
+ static Delegates()
+ {
+ Py_IncRef = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_IncRef), GetUnmanagedDll(_PythonDll));
+ Py_DecRef = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_DecRef), GetUnmanagedDll(_PythonDll));
+ Py_Initialize = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_Initialize), GetUnmanagedDll(_PythonDll));
+ Py_InitializeEx = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_InitializeEx), GetUnmanagedDll(_PythonDll));
+ Py_IsInitialized = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_IsInitialized), GetUnmanagedDll(_PythonDll));
+ Py_Finalize = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_Finalize), GetUnmanagedDll(_PythonDll));
+ Py_NewInterpreter = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_NewInterpreter), GetUnmanagedDll(_PythonDll));
+ Py_EndInterpreter = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_EndInterpreter), GetUnmanagedDll(_PythonDll));
+ PyThreadState_New = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyThreadState_New), GetUnmanagedDll(_PythonDll));
+ PyThreadState_Get = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyThreadState_Get), GetUnmanagedDll(_PythonDll));
+ _PyThreadState_UncheckedGet = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(_PyThreadState_UncheckedGet), GetUnmanagedDll(_PythonDll));
+ try
+ {
+ PyGILState_Check = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyGILState_Check), GetUnmanagedDll(_PythonDll));
+ }
+ catch (MissingMethodException e)
+ {
+ throw new NotSupportedException(Util.MinimalPythonVersionRequired, innerException: e);
+ }
+ PyGILState_Ensure = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyGILState_Ensure), GetUnmanagedDll(_PythonDll));
+ PyGILState_Release = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyGILState_Release), GetUnmanagedDll(_PythonDll));
+ PyGILState_GetThisThreadState = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyGILState_GetThisThreadState), GetUnmanagedDll(_PythonDll));
+ Py_Main = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_Main), GetUnmanagedDll(_PythonDll));
+ PyEval_InitThreads = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyEval_InitThreads), GetUnmanagedDll(_PythonDll));
+ PyEval_ThreadsInitialized = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyEval_ThreadsInitialized), GetUnmanagedDll(_PythonDll));
+ PyEval_AcquireLock = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyEval_AcquireLock), GetUnmanagedDll(_PythonDll));
+ PyEval_ReleaseLock = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyEval_ReleaseLock), GetUnmanagedDll(_PythonDll));
+ PyEval_AcquireThread = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyEval_AcquireThread), GetUnmanagedDll(_PythonDll));
+ PyEval_ReleaseThread = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyEval_ReleaseThread), GetUnmanagedDll(_PythonDll));
+ PyEval_SaveThread = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyEval_SaveThread), GetUnmanagedDll(_PythonDll));
+ PyEval_RestoreThread = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyEval_RestoreThread), GetUnmanagedDll(_PythonDll));
+ PyEval_GetBuiltins = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyEval_GetBuiltins), GetUnmanagedDll(_PythonDll));
+ PyEval_GetGlobals = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyEval_GetGlobals), GetUnmanagedDll(_PythonDll));
+ PyEval_GetLocals = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyEval_GetLocals), GetUnmanagedDll(_PythonDll));
+ Py_GetProgramName = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_GetProgramName), GetUnmanagedDll(_PythonDll));
+ Py_SetProgramName = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_SetProgramName), GetUnmanagedDll(_PythonDll));
+ Py_GetPythonHome = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_GetPythonHome), GetUnmanagedDll(_PythonDll));
+ Py_SetPythonHome = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_SetPythonHome), GetUnmanagedDll(_PythonDll));
+ Py_GetPath = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_GetPath), GetUnmanagedDll(_PythonDll));
+ Py_SetPath = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_SetPath), GetUnmanagedDll(_PythonDll));
+ Py_GetVersion = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_GetVersion), GetUnmanagedDll(_PythonDll));
+ Py_GetPlatform = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_GetPlatform), GetUnmanagedDll(_PythonDll));
+ Py_GetCopyright = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_GetCopyright), GetUnmanagedDll(_PythonDll));
+ Py_GetCompiler = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_GetCompiler), GetUnmanagedDll(_PythonDll));
+ Py_GetBuildInfo = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_GetBuildInfo), GetUnmanagedDll(_PythonDll));
+ PyRun_SimpleStringFlags = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyRun_SimpleStringFlags), GetUnmanagedDll(_PythonDll));
+ PyRun_StringFlags = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyRun_StringFlags), GetUnmanagedDll(_PythonDll));
+ PyEval_EvalCode = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyEval_EvalCode), GetUnmanagedDll(_PythonDll));
+ Py_CompileStringObject = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(Py_CompileStringObject), GetUnmanagedDll(_PythonDll));
+ PyImport_ExecCodeModule = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyImport_ExecCodeModule), GetUnmanagedDll(_PythonDll));
+ PyObject_HasAttrString = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_HasAttrString), GetUnmanagedDll(_PythonDll));
+ PyObject_GetAttrString = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_GetAttrString), GetUnmanagedDll(_PythonDll));
+ PyObject_SetAttrString = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_SetAttrString), GetUnmanagedDll(_PythonDll));
+ PyObject_HasAttr = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_HasAttr), GetUnmanagedDll(_PythonDll));
+ PyObject_GetAttr = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_GetAttr), GetUnmanagedDll(_PythonDll));
+ PyObject_SetAttr = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_SetAttr), GetUnmanagedDll(_PythonDll));
+ PyObject_GetItem = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_GetItem), GetUnmanagedDll(_PythonDll));
+ PyObject_SetItem = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_SetItem), GetUnmanagedDll(_PythonDll));
+ PyObject_DelItem = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_DelItem), GetUnmanagedDll(_PythonDll));
+ PyObject_GetIter = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_GetIter), GetUnmanagedDll(_PythonDll));
+ PyObject_Call = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_Call), GetUnmanagedDll(_PythonDll));
+ PyObject_CallObject = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_CallObject), GetUnmanagedDll(_PythonDll));
+ PyObject_RichCompareBool = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_RichCompareBool), GetUnmanagedDll(_PythonDll));
+ PyObject_IsInstance = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_IsInstance), GetUnmanagedDll(_PythonDll));
+ PyObject_IsSubclass = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_IsSubclass), GetUnmanagedDll(_PythonDll));
+ PyCallable_Check = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyCallable_Check), GetUnmanagedDll(_PythonDll));
+ PyObject_IsTrue = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_IsTrue), GetUnmanagedDll(_PythonDll));
+ PyObject_Not = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_Not), GetUnmanagedDll(_PythonDll));
+ PyObject_Size = (delegate* unmanaged[Cdecl])GetFunctionByName("PyObject_Size", GetUnmanagedDll(_PythonDll));
+ PyObject_Hash = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_Hash), GetUnmanagedDll(_PythonDll));
+ PyObject_Repr = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_Repr), GetUnmanagedDll(_PythonDll));
+ PyObject_Str = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_Str), GetUnmanagedDll(_PythonDll));
+ PyObject_Type = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_Type), GetUnmanagedDll(_PythonDll));
+ PyObject_Dir = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_Dir), GetUnmanagedDll(_PythonDll));
+ PyObject_GetBuffer = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_GetBuffer), GetUnmanagedDll(_PythonDll));
+ PyBuffer_Release = (delegate* unmanaged[Cdecl][)GetFunctionByName(nameof(PyBuffer_Release), GetUnmanagedDll(_PythonDll));
+ try
+ {
+ PyBuffer_SizeFromFormat = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyBuffer_SizeFromFormat), GetUnmanagedDll(_PythonDll));
+ }
+ catch (MissingMethodException)
+ {
+ // only in 3.9+
+ }
+ PyBuffer_IsContiguous = (delegate* unmanaged[Cdecl]][)GetFunctionByName(nameof(PyBuffer_IsContiguous), GetUnmanagedDll(_PythonDll));
+ PyBuffer_GetPointer = (delegate* unmanaged[Cdecl]][)GetFunctionByName(nameof(PyBuffer_GetPointer), GetUnmanagedDll(_PythonDll));
+ PyBuffer_FromContiguous = (delegate* unmanaged[Cdecl]][)GetFunctionByName(nameof(PyBuffer_FromContiguous), GetUnmanagedDll(_PythonDll));
+ PyBuffer_ToContiguous = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyBuffer_ToContiguous), GetUnmanagedDll(_PythonDll));
+ PyBuffer_FillContiguousStrides = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyBuffer_FillContiguousStrides), GetUnmanagedDll(_PythonDll));
+ PyBuffer_FillInfo = (delegate* unmanaged[Cdecl]][)GetFunctionByName(nameof(PyBuffer_FillInfo), GetUnmanagedDll(_PythonDll));
+ PyNumber_Long = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_Long), GetUnmanagedDll(_PythonDll));
+ PyNumber_Float = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_Float), GetUnmanagedDll(_PythonDll));
+ PyNumber_Check = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_Check), GetUnmanagedDll(_PythonDll));
+ PyLong_FromLongLong = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyLong_FromLongLong), GetUnmanagedDll(_PythonDll));
+ PyLong_FromUnsignedLongLong = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyLong_FromUnsignedLongLong), GetUnmanagedDll(_PythonDll));
+ PyLong_FromString = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyLong_FromString), GetUnmanagedDll(_PythonDll));
+ PyLong_AsLongLong = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyLong_AsLongLong), GetUnmanagedDll(_PythonDll));
+ PyLong_AsUnsignedLongLong = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyLong_AsUnsignedLongLong), GetUnmanagedDll(_PythonDll));
+ PyLong_FromVoidPtr = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyLong_FromVoidPtr), GetUnmanagedDll(_PythonDll));
+ PyLong_AsVoidPtr = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyLong_AsVoidPtr), GetUnmanagedDll(_PythonDll));
+ PyFloat_FromDouble = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyFloat_FromDouble), GetUnmanagedDll(_PythonDll));
+ PyFloat_FromString = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyFloat_FromString), GetUnmanagedDll(_PythonDll));
+ PyFloat_AsDouble = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyFloat_AsDouble), GetUnmanagedDll(_PythonDll));
+ PyNumber_Add = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_Add), GetUnmanagedDll(_PythonDll));
+ PyNumber_Subtract = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_Subtract), GetUnmanagedDll(_PythonDll));
+ PyNumber_Multiply = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_Multiply), GetUnmanagedDll(_PythonDll));
+ PyNumber_TrueDivide = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_TrueDivide), GetUnmanagedDll(_PythonDll));
+ PyNumber_And = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_And), GetUnmanagedDll(_PythonDll));
+ PyNumber_Xor = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_Xor), GetUnmanagedDll(_PythonDll));
+ PyNumber_Or = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_Or), GetUnmanagedDll(_PythonDll));
+ PyNumber_Lshift = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_Lshift), GetUnmanagedDll(_PythonDll));
+ PyNumber_Rshift = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_Rshift), GetUnmanagedDll(_PythonDll));
+ PyNumber_Power = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_Power), GetUnmanagedDll(_PythonDll));
+ PyNumber_Remainder = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_Remainder), GetUnmanagedDll(_PythonDll));
+ PyNumber_InPlaceAdd = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_InPlaceAdd), GetUnmanagedDll(_PythonDll));
+ PyNumber_InPlaceSubtract = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_InPlaceSubtract), GetUnmanagedDll(_PythonDll));
+ PyNumber_InPlaceMultiply = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_InPlaceMultiply), GetUnmanagedDll(_PythonDll));
+ PyNumber_InPlaceTrueDivide = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_InPlaceTrueDivide), GetUnmanagedDll(_PythonDll));
+ PyNumber_InPlaceAnd = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_InPlaceAnd), GetUnmanagedDll(_PythonDll));
+ PyNumber_InPlaceXor = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_InPlaceXor), GetUnmanagedDll(_PythonDll));
+ PyNumber_InPlaceOr = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_InPlaceOr), GetUnmanagedDll(_PythonDll));
+ PyNumber_InPlaceLshift = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_InPlaceLshift), GetUnmanagedDll(_PythonDll));
+ PyNumber_InPlaceRshift = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_InPlaceRshift), GetUnmanagedDll(_PythonDll));
+ PyNumber_InPlacePower = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_InPlacePower), GetUnmanagedDll(_PythonDll));
+ PyNumber_InPlaceRemainder = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_InPlaceRemainder), GetUnmanagedDll(_PythonDll));
+ PyNumber_Negative = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_Negative), GetUnmanagedDll(_PythonDll));
+ PyNumber_Positive = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_Positive), GetUnmanagedDll(_PythonDll));
+ PyNumber_Invert = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyNumber_Invert), GetUnmanagedDll(_PythonDll));
+ PySequence_Check = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySequence_Check), GetUnmanagedDll(_PythonDll));
+ PySequence_GetItem = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySequence_GetItem), GetUnmanagedDll(_PythonDll));
+ PySequence_SetItem = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySequence_SetItem), GetUnmanagedDll(_PythonDll));
+ PySequence_DelItem = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySequence_DelItem), GetUnmanagedDll(_PythonDll));
+ PySequence_GetSlice = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySequence_GetSlice), GetUnmanagedDll(_PythonDll));
+ PySequence_SetSlice = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySequence_SetSlice), GetUnmanagedDll(_PythonDll));
+ PySequence_DelSlice = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySequence_DelSlice), GetUnmanagedDll(_PythonDll));
+ PySequence_Size = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySequence_Size), GetUnmanagedDll(_PythonDll));
+ PySequence_Contains = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySequence_Contains), GetUnmanagedDll(_PythonDll));
+ PySequence_Concat = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySequence_Concat), GetUnmanagedDll(_PythonDll));
+ PySequence_Repeat = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySequence_Repeat), GetUnmanagedDll(_PythonDll));
+ PySequence_Index = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySequence_Index), GetUnmanagedDll(_PythonDll));
+ PySequence_Count = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySequence_Count), GetUnmanagedDll(_PythonDll));
+ PySequence_Tuple = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySequence_Tuple), GetUnmanagedDll(_PythonDll));
+ PySequence_List = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySequence_List), GetUnmanagedDll(_PythonDll));
+ PyBytes_AsString = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyBytes_AsString), GetUnmanagedDll(_PythonDll));
+ PyBytes_FromString = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyBytes_FromString), GetUnmanagedDll(_PythonDll));
+ PyByteArray_FromStringAndSize = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyByteArray_FromStringAndSize), GetUnmanagedDll(_PythonDll));
+ PyBytes_Size = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyBytes_Size), GetUnmanagedDll(_PythonDll));
+ PyUnicode_AsUTF8 = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyUnicode_AsUTF8), GetUnmanagedDll(_PythonDll));
+ PyUnicode_DecodeUTF16 = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyUnicode_DecodeUTF16), GetUnmanagedDll(_PythonDll));
+ PyUnicode_GetLength = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyUnicode_GetLength), GetUnmanagedDll(_PythonDll));
+ PyUnicode_AsUnicode = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyUnicode_AsUnicode), GetUnmanagedDll(_PythonDll));
+ PyUnicode_AsUTF16String = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyUnicode_AsUTF16String), GetUnmanagedDll(_PythonDll));
+ PyUnicode_FromOrdinal = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyUnicode_FromOrdinal), GetUnmanagedDll(_PythonDll));
+ PyUnicode_InternFromString = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyUnicode_InternFromString), GetUnmanagedDll(_PythonDll));
+ PyUnicode_Compare = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyUnicode_Compare), GetUnmanagedDll(_PythonDll));
+ PyDict_New = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyDict_New), GetUnmanagedDll(_PythonDll));
+ PyDict_GetItem = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyDict_GetItem), GetUnmanagedDll(_PythonDll));
+ PyDict_GetItemString = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyDict_GetItemString), GetUnmanagedDll(_PythonDll));
+ PyDict_SetItem = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyDict_SetItem), GetUnmanagedDll(_PythonDll));
+ PyDict_SetItemString = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyDict_SetItemString), GetUnmanagedDll(_PythonDll));
+ PyDict_DelItem = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyDict_DelItem), GetUnmanagedDll(_PythonDll));
+ PyDict_DelItemString = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyDict_DelItemString), GetUnmanagedDll(_PythonDll));
+ PyMapping_HasKey = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyMapping_HasKey), GetUnmanagedDll(_PythonDll));
+ PyDict_Keys = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyDict_Keys), GetUnmanagedDll(_PythonDll));
+ PyDict_Values = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyDict_Values), GetUnmanagedDll(_PythonDll));
+ PyDict_Items = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyDict_Items), GetUnmanagedDll(_PythonDll));
+ PyDict_Copy = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyDict_Copy), GetUnmanagedDll(_PythonDll));
+ PyDict_Update = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyDict_Update), GetUnmanagedDll(_PythonDll));
+ PyDict_Clear = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyDict_Clear), GetUnmanagedDll(_PythonDll));
+ PyDict_Size = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyDict_Size), GetUnmanagedDll(_PythonDll));
+ PySet_New = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySet_New), GetUnmanagedDll(_PythonDll));
+ PySet_Add = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySet_Add), GetUnmanagedDll(_PythonDll));
+ PySet_Contains = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySet_Contains), GetUnmanagedDll(_PythonDll));
+ PyList_New = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyList_New), GetUnmanagedDll(_PythonDll));
+ PyList_GetItem = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyList_GetItem), GetUnmanagedDll(_PythonDll));
+ PyList_SetItem = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyList_SetItem), GetUnmanagedDll(_PythonDll));
+ PyList_Insert = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyList_Insert), GetUnmanagedDll(_PythonDll));
+ PyList_Append = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyList_Append), GetUnmanagedDll(_PythonDll));
+ PyList_Reverse = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyList_Reverse), GetUnmanagedDll(_PythonDll));
+ PyList_Sort = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyList_Sort), GetUnmanagedDll(_PythonDll));
+ PyList_GetSlice = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyList_GetSlice), GetUnmanagedDll(_PythonDll));
+ PyList_SetSlice = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyList_SetSlice), GetUnmanagedDll(_PythonDll));
+ PyList_Size = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyList_Size), GetUnmanagedDll(_PythonDll));
+ PyTuple_New = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyTuple_New), GetUnmanagedDll(_PythonDll));
+ PyTuple_GetItem = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyTuple_GetItem), GetUnmanagedDll(_PythonDll));
+ PyTuple_SetItem = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyTuple_SetItem), GetUnmanagedDll(_PythonDll));
+ PyTuple_GetSlice = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyTuple_GetSlice), GetUnmanagedDll(_PythonDll));
+ PyTuple_Size = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyTuple_Size), GetUnmanagedDll(_PythonDll));
+ try
+ {
+ PyIter_Check = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyIter_Check), GetUnmanagedDll(_PythonDll));
+ }
+ catch (MissingMethodException) { }
+ PyIter_Next = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyIter_Next), GetUnmanagedDll(_PythonDll));
+ PyModule_New = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyModule_New), GetUnmanagedDll(_PythonDll));
+ PyModule_GetDict = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyModule_GetDict), GetUnmanagedDll(_PythonDll));
+ PyModule_AddObject = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyModule_AddObject), GetUnmanagedDll(_PythonDll));
+ PyImport_Import = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyImport_Import), GetUnmanagedDll(_PythonDll));
+ PyImport_ImportModule = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyImport_ImportModule), GetUnmanagedDll(_PythonDll));
+ PyImport_ReloadModule = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyImport_ReloadModule), GetUnmanagedDll(_PythonDll));
+ PyImport_AddModule = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyImport_AddModule), GetUnmanagedDll(_PythonDll));
+ PyImport_GetModuleDict = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyImport_GetModuleDict), GetUnmanagedDll(_PythonDll));
+ PySys_SetArgvEx = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySys_SetArgvEx), GetUnmanagedDll(_PythonDll));
+ PySys_GetObject = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySys_GetObject), GetUnmanagedDll(_PythonDll));
+ PySys_SetObject = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PySys_SetObject), GetUnmanagedDll(_PythonDll));
+ PyType_Modified = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyType_Modified), GetUnmanagedDll(_PythonDll));
+ PyType_IsSubtype = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyType_IsSubtype), GetUnmanagedDll(_PythonDll));
+ PyType_GenericNew = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyType_GenericNew), GetUnmanagedDll(_PythonDll));
+ PyType_GenericAlloc = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyType_GenericAlloc), GetUnmanagedDll(_PythonDll));
+ PyType_Ready = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyType_Ready), GetUnmanagedDll(_PythonDll));
+ _PyType_Lookup = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(_PyType_Lookup), GetUnmanagedDll(_PythonDll));
+ PyObject_GenericGetAttr = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_GenericGetAttr), GetUnmanagedDll(_PythonDll));
+ PyObject_GenericGetDict = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_GenericGetDict), GetUnmanagedDll(PythonDLL));
+ PyObject_GenericSetAttr = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_GenericSetAttr), GetUnmanagedDll(_PythonDll));
+ PyObject_GC_Del = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_GC_Del), GetUnmanagedDll(_PythonDll));
+ try
+ {
+ PyObject_GC_IsTracked = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_GC_IsTracked), GetUnmanagedDll(_PythonDll));
+ }
+ catch (MissingMethodException) { }
+ PyObject_GC_Track = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_GC_Track), GetUnmanagedDll(_PythonDll));
+ PyObject_GC_UnTrack = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyObject_GC_UnTrack), GetUnmanagedDll(_PythonDll));
+ _PyObject_Dump = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(_PyObject_Dump), GetUnmanagedDll(_PythonDll));
+ PyMem_Malloc = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyMem_Malloc), GetUnmanagedDll(_PythonDll));
+ PyMem_Realloc = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyMem_Realloc), GetUnmanagedDll(_PythonDll));
+ PyMem_Free = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyMem_Free), GetUnmanagedDll(_PythonDll));
+ PyErr_SetString = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyErr_SetString), GetUnmanagedDll(_PythonDll));
+ PyErr_SetObject = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyErr_SetObject), GetUnmanagedDll(_PythonDll));
+ PyErr_ExceptionMatches = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyErr_ExceptionMatches), GetUnmanagedDll(_PythonDll));
+ PyErr_GivenExceptionMatches = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyErr_GivenExceptionMatches), GetUnmanagedDll(_PythonDll));
+ PyErr_NormalizeException = (delegate* unmanaged[Cdecl]][)GetFunctionByName(nameof(PyErr_NormalizeException), GetUnmanagedDll(_PythonDll));
+ PyErr_Occurred = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyErr_Occurred), GetUnmanagedDll(_PythonDll));
+ PyErr_Fetch = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyErr_Fetch), GetUnmanagedDll(_PythonDll));
+ PyErr_Restore = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyErr_Restore), GetUnmanagedDll(_PythonDll));
+ PyErr_Clear = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyErr_Clear), GetUnmanagedDll(_PythonDll));
+ PyErr_Print = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyErr_Print), GetUnmanagedDll(_PythonDll));
+ PyCell_Get = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyCell_Get), GetUnmanagedDll(_PythonDll));
+ PyCell_Set = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyCell_Set), GetUnmanagedDll(_PythonDll));
+ PyGC_Collect = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyGC_Collect), GetUnmanagedDll(_PythonDll));
+ PyCapsule_New = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyCapsule_New), GetUnmanagedDll(_PythonDll));
+ PyCapsule_GetPointer = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyCapsule_GetPointer), GetUnmanagedDll(_PythonDll));
+ PyCapsule_SetPointer = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyCapsule_SetPointer), GetUnmanagedDll(_PythonDll));
+ PyLong_AsUnsignedSize_t = (delegate* unmanaged[Cdecl])GetFunctionByName("PyLong_AsSize_t", GetUnmanagedDll(_PythonDll));
+ PyLong_AsSignedSize_t = (delegate* unmanaged[Cdecl])GetFunctionByName("PyLong_AsSsize_t", GetUnmanagedDll(_PythonDll));
+ PyDict_GetItemWithError = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyDict_GetItemWithError), GetUnmanagedDll(_PythonDll));
+ PyException_GetCause = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyException_GetCause), GetUnmanagedDll(_PythonDll));
+ PyException_GetTraceback = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyException_GetTraceback), GetUnmanagedDll(_PythonDll));
+ PyException_SetCause = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyException_SetCause), GetUnmanagedDll(_PythonDll));
+ PyException_SetTraceback = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyException_SetTraceback), GetUnmanagedDll(_PythonDll));
+ PyThreadState_SetAsyncExcLLP64 = (delegate* unmanaged[Cdecl])GetFunctionByName("PyThreadState_SetAsyncExc", GetUnmanagedDll(_PythonDll));
+ PyThreadState_SetAsyncExcLP64 = (delegate* unmanaged[Cdecl])GetFunctionByName("PyThreadState_SetAsyncExc", GetUnmanagedDll(_PythonDll));
+ PyType_GetSlot = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyType_GetSlot), GetUnmanagedDll(_PythonDll));
+ PyType_FromSpecWithBases = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(PyType_FromSpecWithBases), GetUnmanagedDll(PythonDLL));
+
+ try
+ {
+ _Py_NewReference = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(_Py_NewReference), GetUnmanagedDll(_PythonDll));
+ }
+ catch (MissingMethodException) { }
+ try
+ {
+ _Py_IsFinalizing = (delegate* unmanaged[Cdecl])GetFunctionByName(nameof(_Py_IsFinalizing), GetUnmanagedDll(_PythonDll));
+ }
+ catch (MissingMethodException) { }
+
+ PyType_Type = GetFunctionByName(nameof(PyType_Type), GetUnmanagedDll(_PythonDll));
+ Py_NoSiteFlag = (int*)GetFunctionByName(nameof(Py_NoSiteFlag), GetUnmanagedDll(_PythonDll));
+ }
+
+ static global::System.IntPtr GetUnmanagedDll(string? libraryName)
+ {
+ if (libraryName is null) return IntPtr.Zero;
+ return libraryLoader.Load(libraryName);
+ }
+
+ static global::System.IntPtr GetFunctionByName(string functionName, global::System.IntPtr libraryHandle)
+ {
+ try
+ {
+ return libraryLoader.GetFunction(libraryHandle, functionName);
+ }
+ catch (MissingMethodException e) when (libraryHandle == IntPtr.Zero)
+ {
+ throw new BadPythonDllException(
+ "Runtime.PythonDLL was not set or does not point to a supported Python runtime DLL." +
+ " See https://github.com/pythonnet/pythonnet#embedding-python-in-net",
+ e);
+ }
+ }
+
+ internal static delegate* unmanaged[Cdecl] Py_IncRef { get; }
+ internal static delegate* unmanaged[Cdecl] Py_DecRef { get; }
+ internal static delegate* unmanaged[Cdecl] Py_Initialize { get; }
+ internal static delegate* unmanaged[Cdecl] Py_InitializeEx { get; }
+ internal static delegate* unmanaged[Cdecl] Py_IsInitialized { get; }
+ internal static delegate* unmanaged[Cdecl] Py_Finalize { get; }
+ internal static delegate* unmanaged[Cdecl] Py_NewInterpreter { get; }
+ internal static delegate* unmanaged[Cdecl] Py_EndInterpreter { get; }
+ internal static delegate* unmanaged[Cdecl] PyThreadState_New { get; }
+ internal static delegate* unmanaged[Cdecl] PyThreadState_Get { get; }
+ internal static delegate* unmanaged[Cdecl] _PyThreadState_UncheckedGet { get; }
+ internal static delegate* unmanaged[Cdecl] PyGILState_Check { get; }
+ internal static delegate* unmanaged[Cdecl] PyGILState_Ensure { get; }
+ internal static delegate* unmanaged[Cdecl] PyGILState_Release { get; }
+ internal static delegate* unmanaged[Cdecl]]