static void Main(string[] args) { var assembly = ParseArgs(args); if (assembly == null) { return; } var cd = Path.GetDirectoryName(GluonData.InputDll); if (!string.IsNullOrEmpty(cd)) { Directory.SetCurrentDirectory(cd); } foreach (var target in GluonData.AllTargets.Values) { if (!target.CleanAndValidate(assembly.GetName().Name)) { return; } } var types = assembly.GetTypes(); foreach (var target in GluonData.SelectedTargets) { GeneratorSettings settings; if (!GluonData.AllTargets.TryGetValue(target, out settings)) { Errors.Generic("Target not found: " + target); return; } var astBuilder = new AST.Builder(); astBuilder.BuildFromAssembly(assembly); astBuilder.Product.Analyze(); astBuilder.Product.Validate(); if (Errors.ErrorCount > 0) { return; } var generator = GluonData.AllGenerators[settings.GeneratorType](astBuilder.Product, settings); generator.GenerateAll(); } Environment.ExitCode = 0; }
private void PreprocessDefinition() { Definition.ApplyTypeSubstitutions(Settings.TargetId); Definition.ApplyNamespaceSubsitutions(Settings.TargetId); foreach (var type in Definition.AllTypes) { if (type.Origin != TypeOrigin.Mapped) { if (type.IsObject && type.Origin != TypeOrigin.Managed && type.Assembly == Definition.Assembly) { AllGeneratedClasses.Add((AST.Object)type); } else if (type.IsStruct) { AllGeneratedStructs.Add((AST.Struct)type); } else if (type.IsEnum && type.Origin != TypeOrigin.Managed && type.Assembly == Definition.Assembly) { AllGeneratedEnums.Add((AST.Enum)type); } else if (type.IsDelegate && !((AST.Delegate)type).IsGeneric) { AllGeneratedDelegates.Add((AST.Delegate)type); } } } foreach (var type in Definition.AllTypes) { if (type.IsDelegate) { AllTranslatedDelegates.Add((AST.Delegate)type); } else if (type.IsStruct && CppRender.RequiresABITranslation(type.ToVariable())) { AllTranslatedStructs.Add((AST.Struct)type); } } Definition.StripAllGluonAttributes(); Definition.PutDefaultConstructorsFirst(); Definition.InsertDefaultConstructorsWhereNoneAreDefined(); var builder = new AST.Builder(Definition); _assemblyNS = builder.Resolve(Definition.Assembly.Name); _gluonNS = builder.Resolve("Gluon"); builder.Resolve(typeof(DllImportAttribute)); builder.Resolve(typeof(MarshalAsAttribute)); builder.Resolve(typeof(GluonObject)); builder.Resolve(typeof(DelegateBlob)); }