See More

using System; using System.Runtime.InteropServices; namespace Python.Runtime { /* buffer interface */ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] internal struct Py_buffer { public IntPtr buf; public IntPtr obj; /* owned reference */ [MarshalAs(UnmanagedType.SysInt)] public IntPtr len; [MarshalAs(UnmanagedType.SysInt)] public IntPtr itemsize; /* This is Py_ssize_t so it can be pointed to by strides in simple case.*/ [MarshalAs(UnmanagedType.Bool)] public bool _readonly; public int ndim; [MarshalAs(UnmanagedType.LPStr)] public string format; public IntPtr shape; public IntPtr strides; public IntPtr suboffsets; public IntPtr _internal; } public enum BufferOrderStyle { C, Fortran, EitherOne, } /* Flags for getting buffers */ public enum PyBUF { ///

/// Simple buffer without shape strides and suboffsets /// SIMPLE = 0, /// /// Controls the field. If set, the exporter MUST provide a writable buffer or else report failure. Otherwise, the exporter MAY provide either a read-only or writable buffer, but the choice MUST be consistent for all consumers. /// WRITABLE = 0x0001, /// /// Controls the field. If set, this field MUST be filled in correctly. Otherwise, this field MUST be NULL. /// FORMATS = 0x0004, /// /// N-Dimensional buffer with shape /// ND = 0x0008, /// /// Buffer with strides and shape /// STRIDES = (0x0010 | ND), /// /// C-Contigous buffer with strides and shape /// C_CONTIGUOUS = (0x0020 | STRIDES), /// /// F-Contigous buffer with strides and shape /// F_CONTIGUOUS = (0x0040 | STRIDES), /// /// C or Fortran contigous buffer with strides and shape /// ANY_CONTIGUOUS = (0x0080 | STRIDES), /// /// Buffer with suboffsets (if needed) /// INDIRECT = (0x0100 | STRIDES), /// /// Writable C-Contigous buffer with shape /// CONTIG = (ND | WRITABLE), /// /// Readonly C-Contigous buffer with shape /// CONTIG_RO = (ND), /// /// Writable buffer with shape and strides /// STRIDED = (STRIDES | WRITABLE), /// /// Readonly buffer with shape and strides /// STRIDED_RO = (STRIDES), /// /// Writable buffer with shape, strides and format /// RECORDS = (STRIDES | WRITABLE | FORMATS), /// /// Readonly buffer with shape, strides and format /// RECORDS_RO = (STRIDES | FORMATS), /// /// Writable indirect buffer with shape, strides, format and suboffsets (if needed) /// FULL = (INDIRECT | WRITABLE | FORMATS), /// /// Readonly indirect buffer with shape, strides, format and suboffsets (if needed) /// FULL_RO = (INDIRECT | FORMATS), } }