public void Generate(IEnumerableCollectionProcessor processor, ModuleDefinition mainModule, ModuleDefinition systemModule, ModuleDefinition unityModule) { var array = processor.EnabledNameCollection.Intersect(Api.NameCollection).ToArray(); if (!Api.ShouldDefine(array)) { return; } TypeDefinition @static; mainModule.Types.Add(@static = mainModule.DefineStatic(Api.Name + (IsNullable ? Api.Description.Replace('<', '_').Replace('>', '_') : Api.Description) + "Helper")); foreach (var name in array) { if (!processor.IsSpecialType(name, out var isSpecial)) { throw new KeyNotFoundException(); } if (!Api.TryGetEnabled(name, out var apiEnabled) || !apiEnabled) { continue; } GenerateEach(name, isSpecial, @static, mainModule, systemModule); } }
public void Generate(IEnumerableCollectionProcessor processor, ModuleDefinition mainModule, ModuleDefinition systemModule, ModuleDefinition unityModule) { var returnTypeReference = CalculateReturnType(mainModule); var array = processor.EnabledNameCollection.Intersect(Api.NameCollection).ToArray(); if (!Api.ShouldDefine(array)) { return; } TypeDefinition @static; mainModule.Types.Add(@static = mainModule.DefineStatic(Api.Name + processType + "FuncHelper")); if (Api.TryGetEnabled("TEnumerable", out var genericEnabled) && genericEnabled) { GenerateGeneric(@static, mainModule, systemModule, returnTypeReference); } foreach (var name in array) { if (!processor.IsSpecialType(name, out var isSpecial)) { throw new KeyNotFoundException(); } if (!Api.TryGetEnabled(name, out var apiEnabled) || !apiEnabled) { continue; } GenerateEach(name, isSpecial, @static, mainModule, systemModule, returnTypeReference); } }
public void Generate(IEnumerableCollectionProcessor processor, ModuleDefinition mainModule, ModuleDefinition systemModule, ModuleDefinition unityModule) { if (!processor.TryGetEnabled(Api.Name, out var enabled) || !enabled) { return; } var names = Api.NameCollection; if (names.All(name => !Api.TryGetEnabled(name, out var e) || !e)) { return; } var @static = mainModule.GetType("UniNativeLinq", "Enumerable"); if (@static is null) { @static = mainModule.DefineStatic("Enumerable"); @static.CustomAttributes.Clear(); mainModule.Types.Add(@static); } foreach (var name in names.Where(name => Api.TryGetEnabled(name, out var e) && e)) { GenerateEach(name, @static, mainModule, systemModule, unityModule); } }
public void Generate(IEnumerableCollectionProcessor processor, ModuleDefinition mainModule, ModuleDefinition systemModule, ModuleDefinition unityModule) { if (!processor.TryGetEnabled(Api.Name, out var enabled) || !enabled) { return; } var array = processor.EnabledNameCollection.Intersect(Api.NameCollection).ToArray(); if (!Api.ShouldDefine(array)) { return; } TypeDefinition @static; mainModule.Types.Add(@static = mainModule.DefineStatic(Api.Name + Api.Description + "Helper")); TypeReference elementTypeReference; switch (elementTypeName) { case "Double": elementTypeReference = mainModule.TypeSystem.Double; break; case "Single": elementTypeReference = mainModule.TypeSystem.Single; break; case "Int32": elementTypeReference = mainModule.TypeSystem.Int32; break; case "UInt32": elementTypeReference = mainModule.TypeSystem.UInt32; break; case "Int64": elementTypeReference = mainModule.TypeSystem.Int64; break; case "UInt64": elementTypeReference = mainModule.TypeSystem.UInt64; break; default: throw new ArgumentException(); } foreach (var name in array) { if (!processor.IsSpecialType(name, out var isSpecial)) { throw new KeyNotFoundException(); } if (!Api.TryGetEnabled(name, out var apiEnabled) || !apiEnabled) { continue; } GenerateEach(name, isSpecial, @static, mainModule, systemModule, elementTypeReference); } }
public void Generate(IEnumerableCollectionProcessor processor, ModuleDefinition mainModule, ModuleDefinition systemModule, ModuleDefinition unityModule) { if (!Api.TryGetEnabled("TEnumerable", out var genericEnabled) || !genericEnabled) { return; } var @static = mainModule.DefineStatic(nameof(AggregateRefValue2Operators) + "Helper"); @static.CustomAttributes.Clear(); mainModule.Types.Add(@static); GenerateGeneric(@static, mainModule); }
public void Generate(IEnumerableCollectionProcessor processor, ModuleDefinition mainModule, ModuleDefinition systemModule, ModuleDefinition unityModule) { if (!processor.TryGetEnabled(Api.Name, out var enabled) || !enabled || !Api.TryGetEnabled("", out enabled) || !enabled) { return; } var @static = mainModule.GetType("UniNativeLinq", "Enumerable"); if (@static is null) { @static = mainModule.DefineStatic("Enumerable"); @static.CustomAttributes.Clear(); mainModule.Types.Add(@static); } var method = new MethodDefinition(Api.Description, Helper.StaticMethodAttributes, mainModule.TypeSystem.Boolean) { DeclaringType = @static, AggressiveInlining = true, }; @static.Methods.Add(method); var T = method.DefineUnmanagedGenericParameter(); method.GenericParameters.Add(T); var NoAction = new GenericInstanceType(mainModule.GetType("UniNativeLinq", "NoAction`1")) { GenericArguments = { T } }; method.ReturnType = new GenericInstanceType(mainModule.GetType("UniNativeLinq", "RangeRepeatEnumerable`2")) { GenericArguments = { T, NoAction } }; method.Parameters.Add(new ParameterDefinition("value", ParameterAttributes.In, new ByReferenceType(T)) { CustomAttributes = { Helper.GetSystemRuntimeCompilerServicesIsReadOnlyAttributeTypeReference() } }); method.Parameters.Add(new ParameterDefinition("count", ParameterAttributes.None, mainModule.TypeSystem.Int64)); method.Body.GetILProcessor() .LdArgs(0, 2) .NewObj(method.ReturnType.FindMethod(".ctor", 2)) .Ret(); }
public static void HelpWithGenerate(this IDoubleApi Api, IEnumerableCollectionProcessor processor, ModuleDefinition mainModule, ModuleDefinition systemModule, Action <string, bool, string, bool, TypeDefinition, ModuleDefinition, ModuleDefinition> GenerateEachPair) { if (!processor.TryGetEnabled(Api.Name, out var enabled) || !enabled) { return; } var array = processor.EnabledNameCollection.Intersect(Api.NameCollection).ToArray(); if (!Api.ShouldDefine(array)) { return; } TypeDefinition @static; mainModule.Types.Add(@static = mainModule.DefineStatic(Api.Name + Api.Description + "Helper")); var count = Api.Count; for (var row = 0; row < count; row++) { var rowName = Api.NameCollection[row]; if (!processor.IsSpecialType(rowName, out var isRowSpecial)) { throw new KeyNotFoundException(); } for (var column = 0; column < count; column++) { var columnName = Api.NameCollection[column]; if (!processor.IsSpecialType(columnName, out var isColumnSpecial)) { throw new KeyNotFoundException(); } if (!Api.TryGetEnabled(rowName, columnName, out var apiEnabled) || !apiEnabled) { continue; } GenerateEachPair(rowName, isRowSpecial, columnName, isColumnSpecial, @static, mainModule, systemModule); } } }
public void Generate(IEnumerableCollectionProcessor processor, ModuleDefinition mainModule, ModuleDefinition systemModule, ModuleDefinition unityModule) { if (!processor.TryGetEnabled(Name + keyName, out var enabled) || !enabled) return; var array = processor.EnabledNameCollection.Intersect(Api.NameCollection).ToArray(); if (!Api.ShouldDefine(array)) return; TypeDefinition @static; mainModule.Types.Add(@static = mainModule.DefineStatic(Name + "RefFunc" + keyName + "Helper")); TypeReference keyType; switch (keyName) { case "Double": keyType = mainModule.TypeSystem.Double; break; case "Single": keyType = mainModule.TypeSystem.Single; break; case "Int32": keyType = mainModule.TypeSystem.Int32; break; case "UInt32": keyType = mainModule.TypeSystem.UInt32; break; case "Int64": keyType = mainModule.TypeSystem.Int64; break; case "UInt64": keyType = mainModule.TypeSystem.UInt64; break; default: throw new ArgumentOutOfRangeException(); } foreach (var name in array) { if (!processor.IsSpecialType(name, out var isSpecial)) throw new KeyNotFoundException(); if (!Api.TryGetEnabled(name, out var apiEnabled) || !apiEnabled) continue; GenerateEach(name, isSpecial, @static, mainModule, systemModule, keyType); } }