11using System ;
2+ using System . Runtime . InteropServices ;
23
34using Python . Runtime . Native ;
45using Python . Runtime . Platform ;
@@ -9,6 +10,9 @@ public unsafe partial class Runtime
910{
1011 internal static class Delegates
1112 {
13+ [ UnmanagedFunctionPointer ( CallingConvention . Cdecl ) ]
14+ internal delegate IntPtr PyBufferGetPointer ( ref Py_buffer view , [ MarshalAs ( UnmanagedType . LPArray ) ] nint [ ] indices ) ;
15+
1216 static readonly ILibraryLoader libraryLoader = LibraryLoader . Instance ;
1317
1418 static Delegates ( )
@@ -117,7 +121,7 @@ static Delegates()
117121 // only in 3.9+
118122 }
119123 PyBuffer_IsContiguous = ( delegate * unmanaged[ Cdecl] < ref Py_buffer , char , int > ) GetFunctionByName ( nameof ( PyBuffer_IsContiguous ) , GetUnmanagedDll ( _PythonDll ) ) ;
120- PyBuffer_GetPointer = ( delegate * unmanaged [ Cdecl ] < ref Py_buffer , nint * , IntPtr > ) GetFunctionByName ( nameof ( PyBuffer_GetPointer ) , GetUnmanagedDll ( _PythonDll ) ) ;
124+ PyBuffer_GetPointer = Marshal . GetDelegateForFunctionPointer < PyBufferGetPointer > ( GetFunctionByName ( nameof ( PyBuffer_GetPointer ) , GetUnmanagedDll ( _PythonDll ) ) ) ;
121125 PyBuffer_FromContiguous = ( delegate * unmanaged[ Cdecl] < ref Py_buffer , IntPtr , IntPtr , char , int > ) GetFunctionByName ( nameof ( PyBuffer_FromContiguous ) , GetUnmanagedDll ( _PythonDll ) ) ;
122126 PyBuffer_ToContiguous = ( delegate * unmanaged[ Cdecl] < IntPtr , ref Py_buffer , IntPtr , char , int > ) GetFunctionByName ( nameof ( PyBuffer_ToContiguous ) , GetUnmanagedDll ( _PythonDll ) ) ;
123127 PyBuffer_FillContiguousStrides = ( delegate * unmanaged[ Cdecl] < int , IntPtr , IntPtr , int , char , void > ) GetFunctionByName ( nameof ( PyBuffer_FillContiguousStrides ) , GetUnmanagedDll ( _PythonDll ) ) ;
@@ -394,7 +398,7 @@ static Delegates()
394398 internal static delegate * unmanaged[ Cdecl] < ref Py_buffer , void > PyBuffer_Release { get ; }
395399 internal static delegate * unmanaged[ Cdecl] < StrPtr , nint > PyBuffer_SizeFromFormat { get ; }
396400 internal static delegate * unmanaged[ Cdecl] < ref Py_buffer , char , int > PyBuffer_IsContiguous { get ; }
397- internal static delegate * unmanaged [ Cdecl ] < ref Py_buffer , nint * , IntPtr > PyBuffer_GetPointer { get ; }
401+ internal static PyBufferGetPointer PyBuffer_GetPointer { get ; }
398402 internal static delegate * unmanaged[ Cdecl] < ref Py_buffer , IntPtr , IntPtr , char , int > PyBuffer_FromContiguous { get ; }
399403 internal static delegate * unmanaged[ Cdecl] < IntPtr , ref Py_buffer , IntPtr , char , int > PyBuffer_ToContiguous { get ; }
400404 internal static delegate * unmanaged[ Cdecl] < int , IntPtr , IntPtr , int , char , void > PyBuffer_FillContiguousStrides { get ; }
0 commit comments