Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup out #4

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
}
finally
{
// Cleanup - Perform required cleanup.
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
{
System.ReadOnlySpan<nint> __param_native__nativeSpan = __param_native__marshaller.GetUnmanagedValuesDestination();
for (int __i0 = 0; __i0 < __param_native__lastIndexMarshalled; ++__i0)
Expand Down Expand Up @@ -102,7 +102,7 @@
}
finally
{
// Cleanup - Perform required cleanup.
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
{
System.ReadOnlySpan<nint> __param_native__nativeSpan = __param_native__marshaller.GetUnmanagedValuesDestination();
for (int __i0 = 0; __i0 < __param_native__lastIndexMarshalled; ++__i0)
Expand All @@ -120,6 +120,7 @@
void global::SharedTypes.ComInterfaces.IArrayOfStatelessElements.MethodOut(out global::SharedTypes.ComInterfaces.StatelessType[] param, int size)
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.IArrayOfStatelessElements));
bool __invokeSucceeded = default;
System.Runtime.CompilerServices.Unsafe.SkipInit(out param);
nint* __param_native = default;
int __invokeRetVal = default;
Expand All @@ -132,6 +133,7 @@
__invokeRetVal = ((delegate* unmanaged[MemberFunction]<void*, nint**, int, int> )__vtable_native[5])(__this, &__param_native, size);
}

__invokeSucceeded = true;
System.GC.KeepAlive(this);
// Unmarshal - Convert native data to managed data.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
Expand All @@ -148,17 +150,20 @@
}
finally
{
// Cleanup - Perform required cleanup.
if (__invokeSucceeded)
{
System.ReadOnlySpan<nint> __param_native__nativeSpan = global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<global::SharedTypes.ComInterfaces.StatelessType, nint>.GetUnmanagedValuesDestination(__param_native, __param_native__numElements);
for (int __i0 = 0; __i0 < __param_native__nativeSpan.Length; ++__i0)
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
{
global::SharedTypes.ComInterfaces.StatelessTypeMarshaller.Free(__param_native__nativeSpan[__i0]);
System.ReadOnlySpan<nint> __param_native__nativeSpan = global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<global::SharedTypes.ComInterfaces.StatelessType, nint>.GetUnmanagedValuesDestination(__param_native, __param_native__numElements);
for (int __i0 = 0; __i0 < __param_native__nativeSpan.Length; ++__i0)
{
global::SharedTypes.ComInterfaces.StatelessTypeMarshaller.Free(__param_native__nativeSpan[__i0]);
}
}
}

__param_native__numElements = size;
global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<global::SharedTypes.ComInterfaces.StatelessType, nint>.Free(__param_native);
__param_native__numElements = size;
global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<global::SharedTypes.ComInterfaces.StatelessType, nint>.Free(__param_native);
}
}
}

Expand Down Expand Up @@ -206,7 +211,7 @@
}
finally
{
// Cleanup - Perform required cleanup.
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
{
System.ReadOnlySpan<nint> __param_native__nativeSpan = global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<global::SharedTypes.ComInterfaces.StatelessType, nint>.GetUnmanagedValuesDestination(__param_native, __param_native__numElements);
for (int __i0 = 0; __i0 < __param_native__lastIndexMarshalled; ++__i0)
Expand Down Expand Up @@ -259,7 +264,7 @@
}
finally
{
// Cleanup - Perform required cleanup.
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
{
System.ReadOnlySpan<nint> __param_native__nativeSpan = __param_native__marshaller.GetUnmanagedValuesDestination();
for (int __i0 = 0; __i0 < __param_native__lastIndexMarshalled; ++__i0)
Expand Down Expand Up @@ -311,7 +316,7 @@
}
finally
{
// Cleanup - Perform required cleanup.
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
{
System.ReadOnlySpan<nint> __param_native__nativeSpan = __param_native__marshaller.GetUnmanagedValuesDestination();
for (int __i0 = 0; __i0 < __param_native__nativeSpan.Length; ++__i0)
Expand Down Expand Up @@ -372,7 +377,7 @@
}
finally
{
// Cleanup - Perform required cleanup.
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
{
System.ReadOnlySpan<nint> __param_native__nativeSpan = __param_native__marshaller.GetUnmanagedValuesDestination();
for (int __i0 = 0; __i0 < __param_native__lastIndexMarshalled; ++__i0)
Expand Down Expand Up @@ -543,7 +548,7 @@ internal static int ABI_MethodRef(System.Runtime.InteropServices.ComWrappers.Com
}
finally
{
// Cleanup - Perform required cleanup.
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
if (__param_native__ownOriginal)
{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
string global::SharedTypes.ComInterfaces.ICustomStringMarshallingUtf16.GetString()
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.ICustomStringMarshallingUtf16));
bool __invokeSucceeded = default;
string __retVal = default;
ushort* __retVal_native = default;
int __invokeRetVal = default;
Expand All @@ -25,15 +26,19 @@
__invokeRetVal = ((delegate* unmanaged[MemberFunction]<void*, ushort**, int> )__vtable_native[3])(__this, &__retVal_native);
}

__invokeSucceeded = true;
System.GC.KeepAlive(this);
// Unmarshal - Convert native data to managed data.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
__retVal = global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.ConvertToManaged(__retVal_native);
}
finally
{
// Cleanup - Perform required cleanup.
global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.Free(__retVal_native);
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.Free(__retVal_native);
}
}

return __retVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
string global::SharedTypes.ComInterfaces.IDerived.GetName()
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.IDerived));
bool __invokeSucceeded = default;
string __retVal = default;
ushort* __retVal_native = default;
int __invokeRetVal = default;
Expand All @@ -42,15 +43,19 @@
__invokeRetVal = ((delegate* unmanaged[MemberFunction]<void*, ushort**, int> )__vtable_native[6])(__this, &__retVal_native);
}

__invokeSucceeded = true;
System.GC.KeepAlive(this);
// Unmarshal - Convert native data to managed data.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
__retVal = global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.ConvertToManaged(__retVal_native);
}
finally
{
// Cleanup - Perform required cleanup.
global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.Free(__retVal_native);
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.Free(__retVal_native);
}
}

return __retVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
}
finally
{
// Cleanup - Perform required cleanup.
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
{
System.ReadOnlySpan<System.IntPtr> __rgelt_native__nativeSpan = __rgelt_native__marshaller.GetUnmanagedValuesDestination();
for (int __i0 = 0; __i0 < __rgelt_native__nativeSpan.Length; ++__i0)
Expand Down Expand Up @@ -100,6 +100,7 @@
void global::SharedTypes.ComInterfaces.IEnumUnknown.Clone(out global::SharedTypes.ComInterfaces.IEnumUnknown ppenum)
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.IEnumUnknown));
bool __invokeSucceeded = default;
System.Runtime.CompilerServices.Unsafe.SkipInit(out ppenum);
void* __ppenum_native = default;
int __invokeRetVal = default;
Expand All @@ -109,15 +110,19 @@
__invokeRetVal = ((delegate* unmanaged[MemberFunction]<void*, void**, int> )__vtable_native[6])(__this, &__ppenum_native);
}

__invokeSucceeded = true;
System.GC.KeepAlive(this);
// Unmarshal - Convert native data to managed data.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
ppenum = global::System.Runtime.InteropServices.Marshalling.ComInterfaceMarshaller<global::SharedTypes.ComInterfaces.IEnumUnknown>.ConvertToManaged(__ppenum_native);
}
finally
{
// Cleanup - Perform required cleanup.
global::System.Runtime.InteropServices.Marshalling.ComInterfaceMarshaller<global::SharedTypes.ComInterfaces.IEnumUnknown>.Free(__ppenum_native);
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
global::System.Runtime.InteropServices.Marshalling.ComInterfaceMarshaller<global::SharedTypes.ComInterfaces.IEnumUnknown>.Free(__ppenum_native);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
int[] global::SharedTypes.ComInterfaces.IGetIntArray.GetInts()
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.IGetIntArray));
bool __invokeSucceeded = default;
int[] __retVal = default;
int* __retVal_native = default;
int __invokeRetVal = default;
Expand All @@ -28,6 +29,7 @@
__invokeRetVal = ((delegate* unmanaged[MemberFunction]<void*, int**, int> )__vtable_native[3])(__this, &__retVal_native);
}

__invokeSucceeded = true;
System.GC.KeepAlive(this);
// Unmarshal - Convert native data to managed data.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
Expand All @@ -37,9 +39,12 @@
}
finally
{
// Cleanup - Perform required cleanup.
__retVal_native__numElements = 10;
global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<int, int>.Free(__retVal_native);
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__retVal_native__numElements = 10;
global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<int, int>.Free(__retVal_native);
}
}

return __retVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
int[] global::SharedTypes.ComInterfaces.IIntArray.GetReturn(out int size)
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.IIntArray));
bool __invokeSucceeded = default;
System.Runtime.CompilerServices.Unsafe.SkipInit(out size);
int[] __retVal = default;
int* __retVal_native = default;
Expand All @@ -31,6 +32,7 @@
__invokeRetVal = ((delegate* unmanaged[MemberFunction]<void*, int*, int**, int> )__vtable_native[3])(__this, __size_native, &__retVal_native);
}

__invokeSucceeded = true;
System.GC.KeepAlive(this);
// Unmarshal - Convert native data to managed data.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
Expand All @@ -40,9 +42,12 @@
}
finally
{
// Cleanup - Perform required cleanup.
__retVal_native__numElements = size;
global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<int, int>.Free(__retVal_native);
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__retVal_native__numElements = size;
global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<int, int>.Free(__retVal_native);
}
}

return __retVal;
Expand All @@ -53,6 +58,7 @@
int global::SharedTypes.ComInterfaces.IIntArray.GetOut(out int[] array)
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.IIntArray));
bool __invokeSucceeded = default;
System.Runtime.CompilerServices.Unsafe.SkipInit(out array);
int* __array_native = default;
int __retVal = default;
Expand All @@ -66,6 +72,7 @@
__invokeRetVal = ((delegate* unmanaged[MemberFunction]<void*, int**, int*, int> )__vtable_native[4])(__this, &__array_native, &__retVal);
}

__invokeSucceeded = true;
System.GC.KeepAlive(this);
// Unmarshal - Convert native data to managed data.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
Expand All @@ -75,9 +82,12 @@
}
finally
{
// Cleanup - Perform required cleanup.
__array_native__numElements = __retVal;
global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<int, int>.Free(__array_native);
if (__invokeSucceeded)
{
// CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
__array_native__numElements = __retVal;
global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<int, int>.Free(__array_native);
}
}

return __retVal;
Expand Down Expand Up @@ -164,7 +174,7 @@
}
finally
{
// Cleanup - Perform required cleanup.
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__array_native__marshaller.Free();
}
}
Expand Down Expand Up @@ -197,7 +207,7 @@
}
finally
{
// Cleanup - Perform required cleanup.
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__array_native__numElements = size;
global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller<int, int>.Free(__array_native);
}
Expand Down Expand Up @@ -409,7 +419,7 @@ internal static int ABI_SwapArray(System.Runtime.InteropServices.ComWrappers.Com
}
finally
{
// Cleanup - Perform required cleanup.
// CleanupCallerAllocated - Perform cleanup of caller allocated resources.
if (__array_native__ownOriginal)
{
__array_native__numElements = size;
Expand Down
Loading