// copy from memory to a container0, used for boxing
        internal static void CopyTo(IntPtr memoryFrom, ref SwiftExistentialContainer0 to)
        {
            to.Data0          = Marshal.ReadIntPtr(memoryFrom);
            memoryFrom       += IntPtr.Size;
            to.Data1          = Marshal.ReadIntPtr(memoryFrom);
            memoryFrom       += IntPtr.Size;
            to.Data2          = Marshal.ReadIntPtr(memoryFrom);
            memoryFrom       += IntPtr.Size;
            to.ObjectMetadata = new SwiftMetatype(Marshal.ReadIntPtr(memoryFrom));
            memoryFrom       += IntPtr.Size;

            for (int i = 0; i < to.Count; i++)
            {
                to [i]      = Marshal.ReadIntPtr(memoryFrom);
                memoryFrom += IntPtr.Size;
            }
        }
        public static unsafe SwiftExistentialContainer0 Box(object o)
        {
            if (o == null)
            {
                throw new ArgumentNullException(nameof(o));
            }
            var mt = StructMarshal.Marshaler.Metatypeof(o.GetType());
            SwiftExistentialContainer0 result = new SwiftExistentialContainer0();
            byte *anyPtr    = stackalloc byte [result.SizeOf];
            var   anyIntPtr = new IntPtr(anyPtr);

            byte *argPtr    = stackalloc byte [StructMarshal.Marshaler.Strideof(o.GetType())];
            var   argIntPtr = new IntPtr(argPtr);

            StructMarshal.Marshaler.ToSwift(o, argIntPtr);

            AnyPinvokes.ToAny(anyIntPtr, argIntPtr, mt);
            CopyTo(anyIntPtr, ref result);

            return(result);
        }
Example #3
0
 public void CopyTo(ISwiftExistentialContainer to)
 {
     SwiftExistentialContainer0.Copy(this, to);
 }
Example #4
0
 public IntPtr CopyTo(IntPtr memory)
 {
     return(SwiftExistentialContainer0.CopyTo(this, memory));
 }
 public void CopyTo <T> (ref T to) where T : ISwiftExistentialContainer
 {
     SwiftExistentialContainer0.Copy(this, ref to);
 }