Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public static void IIteratorMethods(
{ Stloc_1 },
{ Ldloc_1 },
{ Ldloca_S, loc_2_currentNative },
{ Conv_U },
{ Ldloc_1 },
{ Ldind_I },
{ Ldfld, interopDefinitions.IEnumerator1Vftbl.GetField("get_Current"u8) },
Expand Down Expand Up @@ -445,15 +446,13 @@ public static void ImplType(
module: module);

// Define the 'get_HasCurrent' method
MethodDefinition hasCurrentMethod = InteropMethodDefinitionFactory.IEnumerator1Impl.HasCurrentOrMoveNext(
nameUtf8: "get_HasCurrent"u8,
MethodDefinition hasCurrentMethod = InteropMethodDefinitionFactory.IEnumerator1Impl.get_HasCurrent(
enumeratorType: enumeratorType,
interopReferences: interopReferences,
module: module);

// Define the 'MoveNext' method
MethodDefinition moveNextMethod = InteropMethodDefinitionFactory.IEnumerator1Impl.HasCurrentOrMoveNext(
nameUtf8: "MoveNext"u8,
MethodDefinition moveNextMethod = InteropMethodDefinitionFactory.IEnumerator1Impl.MoveNext(
enumeratorType: enumeratorType,
interopReferences: interopReferences,
module: module);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System.Runtime.InteropServices;
using AsmResolver.DotNet;
using AsmResolver.DotNet.Code.Cil;
using AsmResolver.DotNet.Signatures;
using AsmResolver.PE.DotNet.Metadata.Tables;
using WindowsRuntime.InteropGenerator.Factories;
Expand All @@ -27,12 +26,14 @@ public static class IMapChangedEventArgs1
/// <param name="argsType">The <see cref="GenericInstanceTypeSignature"/> for the args type.</param>
/// <param name="interopDefinitions">The <see cref="InteropDefinitions"/> instance to use.</param>
/// <param name="interopReferences">The <see cref="InteropReferences"/> instance to use.</param>
/// <param name="emitState">The emit state for this invocation.</param>
/// <param name="module">The interop module being built.</param>
/// <param name="argsMethodsType">The resulting methods type.</param>
public static void Methods(
GenericInstanceTypeSignature argsType,
InteropDefinitions interopDefinitions,
InteropReferences interopReferences,
InteropGeneratorEmitState emitState,
ModuleDefinition module,
out TypeDefinition argsMethodsType)
{
Expand Down Expand Up @@ -70,30 +71,18 @@ public static void Methods(

argsMethodsType.Methods.Add(collectionChangeMethod);

// Define the 'Key' method as follows:
//
// public static <KEY_TYPE> Key(WindowsRuntimeObjectReference thisReference)
MethodDefinition keyMethod = new(
name: "Key"u8,
attributes: MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Static,
signature: MethodSignature.CreateStatic(
returnType: elementType.Import(module),
parameterTypes: [interopReferences.WindowsRuntimeObjectReference.Import(module).ToReferenceTypeSignature()]));
// Define the 'Key' method
MethodDefinition keyMethod = InteropMethodDefinitionFactory.IMapChangedEventArgs1Methods.Key(
argsType: argsType,
interopDefinitions: interopDefinitions,
interopReferences: interopReferences,
emitState: emitState,
module: module);

// Add and implement the 'Key' method
argsMethodsType.AddMethodImplementation(
declaration: interopReferences.IMapChangedEventArgsImpl1Key(elementType).Import(module),
method: keyMethod);

// Create a method body for the 'Key' method
keyMethod.CilMethodBody = new CilMethodBody()
{
Instructions =
{
{ Ldnull },
{ Throw } // TODO
}
};
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public static MethodDefinition GetResults(
{ Ldloc_1 },
{ Ldind_I },
{ Ldfld, vftblField },
{ Calli, WellKnownTypeSignatureFactory.get_TypedRetVal(resultType.GetAbiType(interopReferences).MakePointerType(), interopReferences).Import(module).MakeStandAloneSignature() },
{ Calli, WellKnownTypeSignatureFactory.get_UntypedRetVal(interopReferences).Import(module).MakeStandAloneSignature() },
{ Call, interopReferences.RestrictedErrorInfoThrowExceptionForHR.Import(module) },
{ Leave_S, nop_finallyEnd.CreateLabel() },

Expand Down
Loading
Loading