public static UnsafeMutablePointer <T> Allocate(nint capacity)
        {
            unsafe {
                var self = new UnsafeMutablePointer <T> ();
                fixed(byte *ptr = self.SwiftData)
                {
                    var actualPtr = new IntPtr(ptr);

                    NativeMethodsForUnsafeMutablePointer.Allocate(actualPtr, capacity, StructMarshal.Marshaler.Metatypeof(typeof(T)));
                }

                return(self);
            }
        }
        public UnsafeMutablePointer <T> Advance(nint by)
        {
            var retval = new UnsafeMutablePointer <T> ();

            unsafe
            {
                fixed(byte *ptr = SwiftData)
                {
                    var actualPtr = Marshal.ReadIntPtr(new IntPtr(ptr));

                    fixed(byte *retvalPtr = StructMarshal.Marshaler.PrepareNominal(retval))
                    {
                        NativeMethodsForUnsafeMutablePointer.Advance(new IntPtr(retvalPtr), actualPtr, by, StructMarshal.Marshaler.Metatypeof(typeof(T)));
                    }
                }
            }
            return(retval);
        }
Exemplo n.º 3
0
 public UnsafePointer(UnsafeMutablePointer <T> ptr)
     : this(ptr.ToIntPtr())
 {
 }
 public static OpaquePointer FromUnsafeMutablePointer <T> (UnsafeMutablePointer <T> ptr)
 {
     return(new OpaquePointer(ptr.ToIntPtr()));
 }