// <auto-generated>
// Code generated by COM Proxy Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
#nullable enable
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ComInterfaceDispatch = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch;
using Marshal = System.Runtime.InteropServices.Marshal;

namespace CPF.Windows.ComWrapper
{
    [System.Runtime.Versioning.SupportedOSPlatform("windows")]
    unsafe partial class IEnumFORMATETCProxy
    {
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int Next(System.IntPtr thisPtr, int celt, FORMATETC* rgelt, int* pceltFetched)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IEnumFORMATETC>((ComInterfaceDispatch*)thisPtr);
                var local_1 = new System.Span<FORMATETC>(rgelt, 1).ToArray();
                var local_2 = pceltFetched == null ? new int[1] : new System.Span<int>(pceltFetched, 1).ToArray();
                var r = (int)inst.Next((int)celt, local_1, local_2);
                if (pceltFetched != null)
                {
                    *pceltFetched = local_2[0];
                }
                for (int i = 0; i < celt; i++)
                {
                    rgelt[i] = local_1[i];
                }
                return r;
            }
            catch (System.Exception __e)
            {
                Console.WriteLine(__e);
                return __e.HResult;
            }
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int Skip(System.IntPtr thisPtr, int celt)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IEnumFORMATETC>((ComInterfaceDispatch*)thisPtr);
                return (int)inst.Skip(celt);
            }
            catch (System.Exception __e)
            {
                Console.WriteLine(__e);
                return __e.HResult;
            }
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int Reset(System.IntPtr thisPtr)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IEnumFORMATETC>((ComInterfaceDispatch*)thisPtr);
                return (int)inst.Reset();
            }
            catch (System.Exception __e)
            {
                Console.WriteLine(__e);
                return __e.HResult;
            }
        }
        [System.Runtime.InteropServices.UnmanagedCallersOnly]
        public static int Clone(System.IntPtr thisPtr, System.IntPtr* newEnum)
        {
            try
            {
                var inst = ComInterfaceDispatch.GetInstance<IEnumFORMATETC>((ComInterfaceDispatch*)thisPtr);
                IEnumFORMATETC local_0;
                inst.Clone(out local_0);
                *newEnum = local_0 == null ? System.IntPtr.Zero : Marshal.GetIUnknownForObject(local_0);
            }
            catch (System.Exception __e)
            {
                Console.WriteLine(__e);
                return __e.HResult;
            }

            return 0; // S_OK;
        }
    }
}