public IILLocal GenMain(IGenerationContext context) { var il = context.IL; var resultLocal = il.DeclareLocal(_resultType.MakeArrayType()); var itemLocal = il.DeclareLocal(_resultType); il .LdcI4(_list.Count) .Newarr(_resultType) .Stloc(resultLocal); var backupCtx = context.BuildContext; var idx = 0; foreach (var pair in _list) { context.BuildContext = pair.Key; var local = pair.Value.GenMain(context); if (local == null) { il.Stloc(itemLocal); local = itemLocal; } il.Ldloc(resultLocal).LdcI4(idx).Ldloc(local).StelemRef(); idx++; } context.BuildContext = backupCtx; il .Ldloc(resultLocal) .Castclass(_type); return null; }
public void Enact(IGenerationContext context, object target) { var fieldContext = new GenerationContext(context.Builders, new TypeFieldGenerationContextNode( (TypeGenerationContextNode) context.Node, _member)); _member.FieldInfo.SetValue(target, _datasource.Next(fieldContext)); }
private void ExportSection(TextWriter writer, IReportTemplateSection section, IGenerationContext context) { /* This searches for the first occurrence of a multiple rows producer. * CSV format is very limited and it makes no sense to export more tables or just a single value. */ IMultipleRowsProducer producer = section.RootElement.FindFirstMultipleRowsProducer(); if (producer != null) { DataRow[] rows = producer.GetValue(context).ToArray(); if (rows.Length > 0) { /* Write header row. */ writer.WriteLine(string.Join(";", rows.First().Table.Columns.Cast<DataColumn>().Select(_ => _.ColumnName))); /* Write data. */ foreach (DataRow row in rows) { writer.WriteLine(string.Join(";", row.ItemArray)); } } } }
public void Enact(IGenerationContext context, object target) { var propertyContext = new GenerationContext(context.Builders, new TypePropertyGenerationContextNode( (TypeGenerationContextNode) context.Node, mMember)); mMember.PropertyInfo.SetValue(target, mDatasource.Next(propertyContext), null); }
public IILLocal GenMain(IGenerationContext context) { context.IL .Call(typeof(Enumerable).GetMethod("Empty").MakeGenericMethod(_resultType)) .Castclass(_type); return null; }
/// <summary> /// Searches for a <see cref="IScriptingProvider"/> that can execute the script type as stated in <see cref="ScriptTypeKey"/> and invokes the script. /// </summary> /// <param name="context"></param> protected override void RetrieveData(IGenerationContext context) { IScriptingProvider[] matchingProviders = context.Engine.Extensions.Get<IScriptingProvider>().Where(_ => _.CanExecute(this.ScriptTypeKey)).ToArray(); /* We need at least one matching provider. If there is more than one matching provider, take the first one and maybe omit warning. */ if (matchingProviders.Length > 0) { IScriptingProvider prov = matchingProviders.First(); ScriptExecutionOptions options = new ScriptExecutionOptions(); options.AssociatedDataProvider = this; options.DesiredReturnValueType = typeof(DataSet); try { object ret = prov.Execute(this.ScriptText, options); DataSet ds = ret as DataSet; if (ds != null) { this.CurrentData = ds; } } catch (Exception) { throw; } } }
private void WriteTable(IMultipleRowsProducer rp, Table table, IGenerationContext context) { DataRow[] rows = rp.GetValue(context).ToArray(); if (rows.Length > 0) { DataTable ptab = rows.First().Table; for (int iCol = 0; iCol < ptab.Columns.Count; iCol++) { table.ColumnCollection.Add(new Column(table, string.Empty)); } for (int iRow = -1; iRow < rows.Length; iRow++) { Row row = new Row(table); table.RowCollection.Add(row); for (int iCol = 0; iCol < ptab.Columns.Count; iCol++) { Cell cell = new Cell(table); object value = (iRow == -1) ? ptab.Columns[iCol].ColumnName : rows[iRow][iCol]; CreateAddSimpleText(table.Document, cell.Content, value); row.CellCollection.Add(cell); } } } }
public void GenInitialization(IGenerationContext context) { var backupCtx = context.BuildContext; context.BuildContext = _buildCtx; _wrapping.GenInitialization(context); context.GetSpecific<SingletonsLocal>().Prepare(); context.BuildContext = backupCtx; }
public void GenInitialization(IGenerationContext context) { context.PushToCycleDetector(this, _implementationType.ToSimpleName()); foreach (var regILGen in GetNeeds(context).Select(context.ResolveNeed)) { regILGen.GenInitialization(context); } context.PopFromCycleDetector(); }
public void GenInitialization(IGenerationContext context) { var backupCtx = context.BuildContext; foreach (var pair in _list) { context.BuildContext = pair.Key; pair.Value.GenInitialization(context); } context.BuildContext = backupCtx; }
public IEnumerable<INeed> GetNeeds(IGenerationContext context) { if (_myNeed.Key==null) { var buildContext = context.BuildContext; var genCtx = new GenerationContext(context.Container, _nestedRegistration, buildContext, _type.GetMethod("Invoke").GetParameters()); _myNeed.Key = genCtx.GenerateFunc(_type); } yield return _myNeed; }
public void Apply(IGenerationContext generationContext) { var projectName = generationContext.GetArg(0, "<project name>"); var year = DateTime.Today.ToString("yyyy"); var copyrightHolder = generationContext.GetArg(1, "<copyright holder>"); generationContext.AddFolder(@"foo\bar\berry"); generationContext.AddFile("README", new ContentGenerator(String.Format(ReadmeTemplate, projectName))); generationContext.AddFile("LICENSE", new ContentGenerator(String.Format(LicenceTemplate, year, copyrightHolder))); generationContext.AddFile("TODO", new ContentGenerator(TodoTemplate)); }
/// <summary> /// Exports the specified report template in a CSV-format. /// </summary> /// <param name="context"></param> /// <returns></returns> protected override Stream Export(IGenerationContext context) { MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream, Encoding.UTF8); ExportSection(writer, context.Template.Sections.GetSection(SectionType.Detail), context); writer.Flush(); return stream; }
public bool IsCorruptingILStack(IGenerationContext context) { var backupCtx = context.BuildContext; var result = false; foreach (var pair in _list) { context.BuildContext = pair.Key; result|=pair.Value.IsCorruptingILStack(context); } context.BuildContext = backupCtx; return result; }
public void Enact(IGenerationContext context, object target) { List<Object> paramList = new List<object>(); var methodContext = new GenerationContext(context.Builders, new TypeMethodGenerationContextNode((TypeGenerationContextNode)context.Node, mMember)); foreach (var source in mSources) { paramList.Add(source.Next(methodContext)); } mMember.MethodInfo.Invoke(target, paramList.ToArray()); }
public IILLocal GenMain(IGenerationContext context) { var localInstances = context.GetSpecific<InstancesLocalGenCtxHelper>().MainLocal; var localInstance = context.IL.DeclareLocal(_type, "instance"); context.IL .Ldloc(localInstances) .LdcI4(_instanceIndex) .LdelemRef() .Castclass(typeof(Func<object>)) .Call(() => default(Func<object>).Invoke()) .Castclass(_type) .Stloc(localInstance); return localInstance; }
protected override void RetrieveData(IGenerationContext context) { DataTable table = new DataTable(); table.Columns.Add("Value"); Random rnd = new Random(); for (int i = 0; i < 100; i++) { table.LoadDataRow(new object[] { rnd.Next() }, true); } this.CurrentData = new DataSet(); this.CurrentData.Tables.Add(table); }
/// <summary> /// Exports the provided report template to an ODT document. /// </summary> /// <param name="context"></param> /// <returns></returns> protected override Stream Export(IGenerationContext context) { IReportTemplateSection sdet = context.Template.Sections.GetSection(SectionType.Detail); TextDocument doc = new TextDocument(); doc.New(); doc.DocumentConfigurations2 = null; doc.DocumentMetadata.Creator = context.Template.Description.Author; doc.DocumentMetadata.Title = context.Template.Description.Name; WriteElement(sdet.RootElement, context, doc); return CreateStream(doc); }
/// <summary> /// Exports the provided report template to an ODS document. /// </summary> /// <param name="context"></param> /// <returns></returns> protected override Stream Export(IGenerationContext context) { IReportTemplateSection sdet = context.Template.Sections.GetSection(SectionType.Detail); SpreadsheetDocument doc = new SpreadsheetDocument(); doc.New(); IMultipleRowsProducer producer = sdet.RootElement.FindFirstMultipleRowsProducer(); if (producer != null) { Table table = TableBuilder.CreateSpreadsheetTable(doc, "Table", string.Empty); doc.Content.Add(table); WriteTable(producer, table, context); } return CreateStream(doc); }
public IEnumerable<INeed> GetNeeds(IGenerationContext context) { Trace.Assert(_list.Count == 1); var backupCtx = context.BuildContext; var nextCtx = _list[0].Key; context.BuildContext = nextCtx; yield return new Need { Kind = NeedKind.CReg, Key = _list[0].Value }; nextCtx = nextCtx.IncrementEnumerable(); while (nextCtx != null) { context.BuildContext = nextCtx; var reg = nextCtx.ResolveNeedBy(_resultType, _key); if (reg != null) { _list.Add(new KeyValuePair<IBuildContext, ICRegILGen>(nextCtx, reg)); yield return new Need { Kind = NeedKind.CReg, Key = reg }; } nextCtx = nextCtx.IncrementEnumerable(); } context.BuildContext = backupCtx; }
public IILLocal GenMain(IGenerationContext context) { if (_instance == null) { context.IL.Ldnull(); return null; } var buildCRegLocals = context.GetSpecific<SingletonImpl.BuildCRegLocals>(); var localInstance = buildCRegLocals.Get(this); if (localInstance != null) { return localInstance; } var localInstances = context.GetSpecific<InstancesLocalGenCtxHelper>().MainLocal; localInstance = context.IL.DeclareLocal(_instance.GetType(), "instance"); context.IL .Ldloc(localInstances) .LdcI4(_instanceIndex) .LdelemRef() .UnboxAny(_instance.GetType()) .Stloc(localInstance); buildCRegLocals.Add(this, localInstance); return localInstance; }
public IEnumerable<INeed> GetNeeds(IGenerationContext context) { yield return Need.ContainerNeed; }
public void GenInitialization(IGenerationContext context) { }
public override IEnumerable <string> GetImplicitlyDefinedSymbols(IGenerationContext context) { yield return("_XBOX"); }
public override void SetupPlatformToolsetOptions(IGenerationContext context) { context.Options["PlatformToolset"] = FileGeneratorUtilities.RemoveLineTag; }
public object Next(IGenerationContext context) { throw new NotImplementedException(); }
public override void SelectCompilerOptions(IGenerationContext context) { var options = context.Options; var cmdLineOptions = context.CommandLineOptions; var conf = context.Configuration; // Although we add options to cmdLineOptions, FastBuild isn't supported yet for Android projects. context.SelectOption ( Options.Option(Options.Android.General.ShowAndroidPathsVerbosity.Default, () => { options["ShowAndroidPathsVerbosity"] = RemoveLineTag; }), Options.Option(Options.Android.General.ShowAndroidPathsVerbosity.High, () => { options["ShowAndroidPathsVerbosity"] = "High"; }), Options.Option(Options.Android.General.ShowAndroidPathsVerbosity.Normal, () => { options["ShowAndroidPathsVerbosity"] = "Normal"; }), Options.Option(Options.Android.General.ShowAndroidPathsVerbosity.Low, () => { options["ShowAndroidPathsVerbosity"] = "Low"; }) ); context.SelectOption ( Options.Option(Options.Android.General.AndroidAPILevel.Latest, () => { string lookupDirectory; if (context.Project is AndroidPackageProject) { // for the packaging projects, we look in the SDK lookupDirectory = options["androidHome"]; } else { // otherwise, look in the NDK lookupDirectory = options["ndkRoot"]; } string androidApiLevel = RemoveLineTag; if (lookupDirectory != RemoveLineTag) { string latestApiLevel = Util.FindLatestApiLevelInDirectory(Path.Combine(lookupDirectory, "platforms")); if (!string.IsNullOrEmpty(latestApiLevel)) { androidApiLevel = latestApiLevel; } } options["AndroidAPILevel"] = androidApiLevel; }), Options.Option(Options.Android.General.AndroidAPILevel.Default, () => { options["AndroidAPILevel"] = RemoveLineTag; }), Options.Option(Options.Android.General.AndroidAPILevel.Android16, () => { options["AndroidAPILevel"] = "android-16"; }), Options.Option(Options.Android.General.AndroidAPILevel.Android17, () => { options["AndroidAPILevel"] = "android-17"; }), Options.Option(Options.Android.General.AndroidAPILevel.Android18, () => { options["AndroidAPILevel"] = "android-18"; }), Options.Option(Options.Android.General.AndroidAPILevel.Android19, () => { options["AndroidAPILevel"] = "android-19"; }), Options.Option(Options.Android.General.AndroidAPILevel.Android20, () => { options["AndroidAPILevel"] = "android-20"; }), Options.Option(Options.Android.General.AndroidAPILevel.Android21, () => { options["AndroidAPILevel"] = "android-21"; }), Options.Option(Options.Android.General.AndroidAPILevel.Android22, () => { options["AndroidAPILevel"] = "android-22"; }), Options.Option(Options.Android.General.AndroidAPILevel.Android23, () => { options["AndroidAPILevel"] = "android-23"; }), Options.Option(Options.Android.General.AndroidAPILevel.Android24, () => { options["AndroidAPILevel"] = "android-24"; }), Options.Option(Options.Android.General.AndroidAPILevel.Android25, () => { options["AndroidAPILevel"] = "android-25"; }), Options.Option(Options.Android.General.AndroidAPILevel.Android26, () => { options["AndroidAPILevel"] = "android-26"; }), Options.Option(Options.Android.General.AndroidAPILevel.Android27, () => { options["AndroidAPILevel"] = "android-27"; }), Options.Option(Options.Android.General.AndroidAPILevel.Android28, () => { options["AndroidAPILevel"] = "android-28"; }), Options.Option(Options.Android.General.AndroidAPILevel.Android29, () => { options["AndroidAPILevel"] = "android-29"; }), Options.Option(Options.Android.General.AndroidAPILevel.Android30, () => { options["AndroidAPILevel"] = "android-30"; }) ); context.SelectOption ( Options.Option(Options.Android.General.PlatformToolset.Default, () => { options["PlatformToolset"] = RemoveLineTag; }), Options.Option(Options.Android.General.PlatformToolset.Clang_3_6, () => { options["PlatformToolset"] = "Clang_3_6"; }), Options.Option(Options.Android.General.PlatformToolset.Clang_3_8, () => { options["PlatformToolset"] = "Clang_3_8"; }), Options.Option(Options.Android.General.PlatformToolset.Clang_5_0, () => { options["PlatformToolset"] = "Clang_5_0"; }), Options.Option(Options.Android.General.PlatformToolset.Gcc_4_9, () => { options["PlatformToolset"] = "Gcc_4_9"; }) ); context.SelectOption ( Options.Option(Options.Android.General.UseOfStl.Default, () => { options["UseOfStl"] = RemoveLineTag; }), Options.Option(Options.Android.General.UseOfStl.System, () => { options["UseOfStl"] = "system"; }), Options.Option(Options.Android.General.UseOfStl.GAbiPP_Static, () => { options["UseOfStl"] = "gabi++_static"; }), Options.Option(Options.Android.General.UseOfStl.GAbiPP_Shared, () => { options["UseOfStl"] = "gabi++_shared"; }), Options.Option(Options.Android.General.UseOfStl.StlPort_Static, () => { options["UseOfStl"] = "stlport_static"; }), Options.Option(Options.Android.General.UseOfStl.StlPort_Shared, () => { options["UseOfStl"] = "stlport_shared"; }), Options.Option(Options.Android.General.UseOfStl.GnuStl_Static, () => { options["UseOfStl"] = "gnustl_static"; }), Options.Option(Options.Android.General.UseOfStl.GnuStl_Shared, () => { options["UseOfStl"] = "gnustl_shared"; }), Options.Option(Options.Android.General.UseOfStl.LibCpp_Static, () => { options["UseOfStl"] = "c++_static"; }), Options.Option(Options.Android.General.UseOfStl.LibCpp_Shared, () => { options["UseOfStl"] = "c++_shared"; }) ); context.SelectOption ( Options.Option(Options.Android.General.ThumbMode.Default, () => { options["ThumbMode"] = RemoveLineTag; }), Options.Option(Options.Android.General.ThumbMode.Thumb, () => { options["ThumbMode"] = "Thumb"; }), Options.Option(Options.Android.General.ThumbMode.ARM, () => { options["ThumbMode"] = "ARM"; }), Options.Option(Options.Android.General.ThumbMode.Disabled, () => { options["ThumbMode"] = "Disabled"; }) ); context.SelectOption ( Options.Option(Options.Android.General.WarningLevel.TurnOffAllWarnings, () => { options["WarningLevel"] = "TurnOffAllWarnings"; cmdLineOptions["WarningLevel"] = "-w"; }), Options.Option(Options.Android.General.WarningLevel.EnableAllWarnings, () => { options["WarningLevel"] = "EnableAllWarnings"; cmdLineOptions["WarningLevel"] = "-Wall"; }) ); context.SelectOption ( Options.Option(Options.Android.Compiler.CppLanguageStandard.Default, () => { options["CppLanguageStandard"] = "c++11"; cmdLineOptions["CppLanguageStandard"] = "-std=c++11"; }), Options.Option(Options.Android.Compiler.CppLanguageStandard.Cpp98, () => { options["CppLanguageStandard"] = "c++98"; cmdLineOptions["CppLanguageStandard"] = "-std=c++98"; }), Options.Option(Options.Android.Compiler.CppLanguageStandard.Cpp11, () => { options["CppLanguageStandard"] = "c++11"; cmdLineOptions["CppLanguageStandard"] = "-std=c++11"; }), Options.Option(Options.Android.Compiler.CppLanguageStandard.Cpp1y, () => { options["CppLanguageStandard"] = "c++1y"; cmdLineOptions["CppLanguageStandard"] = "-std=c++1y"; }), Options.Option(Options.Android.Compiler.CppLanguageStandard.Cpp14, () => { options["CppLanguageStandard"] = "c++14"; cmdLineOptions["CppLanguageStandard"] = "-std=c++14"; }), Options.Option(Options.Android.Compiler.CppLanguageStandard.Cpp17, () => { options["CppLanguageStandard"] = "c++17"; cmdLineOptions["CppLanguageStandard"] = "-std=c++17"; }), Options.Option(Options.Android.Compiler.CppLanguageStandard.Cpp1z, () => { options["CppLanguageStandard"] = "c++1z"; cmdLineOptions["CppLanguageStandard"] = "-std=c++1z"; }), Options.Option(Options.Android.Compiler.CppLanguageStandard.Cpp2a, () => { options["CppLanguageStandard"] = "c++2a"; cmdLineOptions["CppLanguageStandard"] = "-std=c++2a"; }), Options.Option(Options.Android.Compiler.CppLanguageStandard.GNU_Cpp98, () => { options["CppLanguageStandard"] = "gnu++98"; cmdLineOptions["CppLanguageStandard"] = "-std=gnu++98"; }), Options.Option(Options.Android.Compiler.CppLanguageStandard.GNU_Cpp11, () => { options["CppLanguageStandard"] = "gnu++11"; cmdLineOptions["CppLanguageStandard"] = "-std=gnu++11"; }), Options.Option(Options.Android.Compiler.CppLanguageStandard.GNU_Cpp1y, () => { options["CppLanguageStandard"] = "gnu++1y"; cmdLineOptions["CppLanguageStandard"] = "-std=gnu++1y"; }), Options.Option(Options.Android.Compiler.CppLanguageStandard.GNU_Cpp14, () => { options["CppLanguageStandard"] = "gnu++14"; cmdLineOptions["CppLanguageStandard"] = "-std=gnu++14"; }), Options.Option(Options.Android.Compiler.CppLanguageStandard.GNU_Cpp17, () => { options["CppLanguageStandard"] = "gnu++17"; cmdLineOptions["CppLanguageStandard"] = "-std=gnu++17"; }), Options.Option(Options.Android.Compiler.CppLanguageStandard.GNU_Cpp1z, () => { options["CppLanguageStandard"] = "gnu++1z"; cmdLineOptions["CppLanguageStandard"] = "-std=gnu++1z"; }), Options.Option(Options.Android.Compiler.CppLanguageStandard.GNU_Cpp2a, () => { options["CppLanguageStandard"] = "gnu++2a"; cmdLineOptions["CppLanguageStandard"] = "-std=gnu++2a"; }) ); context.SelectOption ( Options.Option(Options.Android.Compiler.DataLevelLinking.Disable, () => { options["EnableDataLevelLinking"] = "false"; cmdLineOptions["EnableDataLevelLinking"] = RemoveLineTag; }), Options.Option(Options.Android.Compiler.DataLevelLinking.Enable, () => { options["EnableDataLevelLinking"] = "true"; cmdLineOptions["EnableDataLevelLinking"] = "-fdata-sections"; }) ); context.SelectOption ( Options.Option(Options.Android.Compiler.DebugInformationFormat.None, () => { options["DebugInformationFormat"] = "None"; cmdLineOptions["DebugInformationFormat"] = "-g0"; }), Options.Option(Options.Android.Compiler.DebugInformationFormat.FullDebug, () => { options["DebugInformationFormat"] = "FullDebug"; cmdLineOptions["DebugInformationFormat"] = "-g2 -gdwarf-2"; }), Options.Option(Options.Android.Compiler.DebugInformationFormat.LineNumber, () => { options["DebugInformationFormat"] = "LineNumber"; cmdLineOptions["DebugInformationFormat"] = "-gline-tables-only"; }) ); context.SelectOption ( Options.Option(Options.Android.Compiler.Exceptions.Disable, () => { options["ExceptionHandling"] = "Disabled"; cmdLineOptions["ExceptionHandling"] = "-fno-exceptions"; }), Options.Option(Options.Android.Compiler.Exceptions.Enable, () => { options["ExceptionHandling"] = "Enabled"; cmdLineOptions["ExceptionHandling"] = "-fexceptions"; }), Options.Option(Options.Android.Compiler.Exceptions.UnwindTables, () => { options["ExceptionHandling"] = "UnwindTables"; cmdLineOptions["ExceptionHandling"] = "-funwind-tables"; }) ); context.SelectOption ( Options.Option(Options.Vc.General.TreatWarningsAsErrors.Disable, () => { options["TreatWarningAsError"] = "false"; cmdLineOptions["TreatWarningAsError"] = RemoveLineTag; }), Options.Option(Options.Vc.General.TreatWarningsAsErrors.Enable, () => { options["TreatWarningAsError"] = "true"; cmdLineOptions["TreatWarningAsError"] = "-Werror"; }) ); context.SelectOption ( Options.Option(Options.Vc.Compiler.BufferSecurityCheck.Enable, () => { options["BufferSecurityCheck"] = "true"; cmdLineOptions["BufferSecurityCheck"] = RemoveLineTag; }), Options.Option(Options.Vc.Compiler.BufferSecurityCheck.Disable, () => { options["BufferSecurityCheck"] = "false"; cmdLineOptions["BufferSecurityCheck"] = "-fstack-protector"; }) ); context.SelectOption ( Options.Option(Options.Vc.Compiler.FunctionLevelLinking.Disable, () => { options["EnableFunctionLevelLinking"] = "false"; cmdLineOptions["EnableFunctionLevelLinking"] = RemoveLineTag; }), Options.Option(Options.Vc.Compiler.FunctionLevelLinking.Enable, () => { options["EnableFunctionLevelLinking"] = "true"; cmdLineOptions["EnableFunctionLevelLinking"] = "-ffunction-sections"; }) ); context.SelectOption ( Options.Option(Options.Vc.Compiler.OmitFramePointers.Disable, () => { options["OmitFramePointers"] = "false"; cmdLineOptions["OmitFramePointers"] = "-fno-omit-frame-pointer"; }), Options.Option(Options.Vc.Compiler.OmitFramePointers.Enable, () => { options["OmitFramePointers"] = "true"; cmdLineOptions["OmitFramePointers"] = "-fomit-frame-pointer"; }) ); context.SelectOption ( Options.Option(Options.Vc.Compiler.Optimization.Disable, () => { options["Optimization"] = "Disabled"; cmdLineOptions["Optimization"] = "-O0"; }), Options.Option(Options.Vc.Compiler.Optimization.MinimizeSize, () => { options["Optimization"] = "MinSize"; cmdLineOptions["Optimization"] = "-Os"; }), Options.Option(Options.Vc.Compiler.Optimization.MaximizeSpeed, () => { options["Optimization"] = "MaxSpeed"; cmdLineOptions["Optimization"] = "-O2"; }), Options.Option(Options.Vc.Compiler.Optimization.FullOptimization, () => { options["Optimization"] = "Full"; cmdLineOptions["Optimization"] = "-O3"; }) ); context.SelectOption ( Options.Option(Options.Vc.Compiler.MultiProcessorCompilation.Enable, () => { options["UseMultiToolTask"] = "true"; }), Options.Option(Options.Vc.Compiler.MultiProcessorCompilation.Disable, () => { options["UseMultiToolTask"] = "false"; }) ); context.SelectOption ( Options.Option(Options.Vc.Compiler.RTTI.Disable, () => { options["RuntimeTypeInfo"] = "false"; cmdLineOptions["RuntimeTypeInfo"] = "-fno-rtti"; }), Options.Option(Options.Vc.Compiler.RTTI.Enable, () => { options["RuntimeTypeInfo"] = "true"; cmdLineOptions["RuntimeTypeInfo"] = "-frtti"; }) ); }
protected override IEnumerable <string> GetIncludePathsImpl(IGenerationContext context) { return(base.GetIncludePathsImpl(context)); }
public Object CreateObject(IGenerationContext context) { Object createdObject = null; if(mFactory != null) { createdObject = mFactory.Next(context); } else { createdObject = Activator.CreateInstance(this.InnerType); } // Don't set it up if we've reached recursion limit if (context.Depth < context.Builders.RecursionLimit) { EnactActionsOnObject(context, createdObject); } return createdObject; }
public IILLocal GenMain(IGenerationContext context) { var backupCtx = context.BuildContext; context.BuildContext = _buildCtx; var il = context.IL; var buildCRegLocals = context.GetSpecific <BuildCRegLocals>(); var localSingleton = buildCRegLocals.Get(this); if (localSingleton != null) { return(localSingleton); } var localSingletons = context.GetSpecific <SingletonsLocal>().MainLocal; var safeImplementationType = _implementationType.IsPublic ? _implementationType : typeof(object); localSingleton = il.DeclareLocal(safeImplementationType, "singleton"); var obj = context.Container.Singletons[_singletonIndex]; if (obj != null) { il .Ldloc(localSingletons) .LdcI4(_singletonIndex) .LdelemRef() .Castclass(_implementationType) .Stloc(localSingleton); return(localSingleton); } var localLockTaken = il.DeclareLocal(typeof(bool), "lockTaken"); var localLock = il.DeclareLocal(typeof(object), "lock"); var labelNull1 = il.DefineLabel(); var labelNotNull2 = il.DefineLabel(); var labelNotTaken = il.DefineLabel(); bool boolPlaceholder = false; il .Ldloc(localSingletons) .LdcI4(_singletonIndex) .LdelemRef() .Dup() .Castclass(safeImplementationType) .Stloc(localSingleton) .Brtrue(labelNull1) .LdcI4(0) .Stloc(localLockTaken); context.PushToILStack(Need.ContainerNeed); il .Castclass(typeof(ContainerImpl)) .Ldfld(() => default(ContainerImpl).SingletonLocks) .LdcI4(_singletonIndex) .LdelemRef() .Stloc(localLock) .Try() .Ldloc(localLock) .Ldloca(localLockTaken) .Call(() => Monitor.Enter(null, ref boolPlaceholder)) .Ldloc(localSingletons) .LdcI4(_singletonIndex) .LdelemRef() .Dup() .Castclass(safeImplementationType) .Stloc(localSingleton) .Brtrue(labelNotNull2); buildCRegLocals.Push(); var nestedLocal = _wrapping.GenMain(context); if (nestedLocal != null) { il.Ldloc(nestedLocal); } buildCRegLocals.Pop(); il .Stloc(localSingleton) .Ldloc(localSingletons) .LdcI4(_singletonIndex) .Ldloc(localSingleton) .StelemRef() .Mark(labelNotNull2) .Finally() .Ldloc(localLockTaken) .BrfalseS(labelNotTaken) .Ldloc(localLock) .Call(() => Monitor.Exit(null)) .Mark(labelNotTaken) .EndTry() .Mark(labelNull1); buildCRegLocals.Add(this, localSingleton); context.BuildContext = backupCtx; return(localSingleton); }
public IEnumerable <INeed> GetNeeds(IGenerationContext context) { yield return(Need.ContainerNeed); }
public bool IsCorruptingILStack(IGenerationContext context) { return(false); }
public void GenInitialization(IGenerationContext context) { context.GetSpecific <InstancesLocalGenCtxHelper>().Prepare(); }
string ICRegILGen.GenFuncName(IGenerationContext context) { return("Factory_" + _type.ToSimpleName()); }
public override int Next(IGenerationContext context) { return(0); }
public object Next(IGenerationContext context) { return mValue; }
public void Set(IGenerationContext context) { _context = context; }
public override string Next(IGenerationContext context) { return(Generate(_length)); }
public override void SelectPrecompiledHeaderOptions(IGenerationContext context) { base.SelectPrecompiledHeaderOptions(context); FixupPrecompiledHeaderOptions(context); }
public override string Next(IGenerationContext context) { return(string.Format("http://www.{0}", Urls[_random.Next(0, Urls.Length)])); }
public override int Next(IGenerationContext context) { return(_random.Next(_min, _max)); }
public override T Next(IGenerationContext context) { return(context.Single <T>().Get()); }
/// <summary> /// The next. /// </summary> /// <param name="context"> /// The context. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> public override string Next(IGenerationContext context) { // TODO: See if first name/last name has been used in this context return(string.Format("{0}@example.com", this.index++)); }
protected override IEnumerable <IncludeWithPrefix> GetPlatformIncludePathsWithPrefixImpl(IGenerationContext context) { if (!context.Configuration.IsFastBuild || GlobalSettings.SystemPathProvider == null) { yield break; } foreach (string systemIncludePath in GlobalSettings.SystemPathProvider.GetSystemIncludePaths(context.Configuration)) { yield return(new IncludeWithPrefix("-isystem", systemIncludePath)); } }
public override IEnumerable <string> GetLibraryPaths(IGenerationContext context) { yield return(@"$(Xbox360InstallDir)lib\xbox"); }
public override void SelectCompilerOptions(IGenerationContext context) { var options = context.Options; var cmdLineOptions = context.CommandLineOptions; var conf = context.Configuration; context.SelectOption ( Sharpmake.Options.Option(Options.Compiler.GenerateDebugInformation.Enable, () => { options["GenerateDebugInformation"] = "true"; cmdLineOptions["CLangGenerateDebugInformation"] = "-g"; }), Sharpmake.Options.Option(Options.Compiler.GenerateDebugInformation.Disable, () => { options["GenerateDebugInformation"] = "false"; cmdLineOptions["CLangGenerateDebugInformation"] = ""; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Compiler.Warnings.NormalWarnings, () => { options["Warnings"] = "NormalWarnings"; cmdLineOptions["Warnings"] = FileGeneratorUtilities.RemoveLineTag; }), Sharpmake.Options.Option(Options.Compiler.Warnings.MoreWarnings, () => { options["Warnings"] = "MoreWarnings"; cmdLineOptions["Warnings"] = "-Wall"; }), Sharpmake.Options.Option(Options.Compiler.Warnings.Disable, () => { options["Warnings"] = "WarningsOff"; cmdLineOptions["Warnings"] = "-w"; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Compiler.ExtraWarnings.Enable, () => { options["ExtraWarnings"] = "true"; cmdLineOptions["ExtraWarnings"] = "-Wextra"; }), Sharpmake.Options.Option(Options.Compiler.ExtraWarnings.Disable, () => { options["ExtraWarnings"] = "false"; cmdLineOptions["ExtraWarnings"] = FileGeneratorUtilities.RemoveLineTag; }) ); context.SelectOption ( Sharpmake.Options.Option(Sharpmake.Options.Vc.General.TreatWarningsAsErrors.Enable, () => { options["WarningsAsErrors"] = "true"; cmdLineOptions["WarningsAsErrors"] = "-Werror"; }), Sharpmake.Options.Option(Sharpmake.Options.Vc.General.TreatWarningsAsErrors.Disable, () => { options["WarningsAsErrors"] = "false"; cmdLineOptions["WarningsAsErrors"] = FileGeneratorUtilities.RemoveLineTag; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Compiler.InlineFunctionDebugInformation.Enable, () => { options["InlineFunctionDebugInformation"] = "true"; if (conf.IsFastBuild) { throw new NotImplementedException("FIXME!"); } }), Sharpmake.Options.Option(Options.Compiler.InlineFunctionDebugInformation.Disable, () => { options["InlineFunctionDebugInformation"] = FileGeneratorUtilities.RemoveLineTag; }) ); Options.Compiler.ProcessorNumber processorNumber = Sharpmake.Options.GetObject <Options.Compiler.ProcessorNumber>(conf); if (processorNumber == null) { options["ProcessorNumber"] = FileGeneratorUtilities.RemoveLineTag; } else { options["ProcessorNumber"] = processorNumber.Value.ToString(); } context.SelectOption ( Sharpmake.Options.Option(Options.Compiler.Distributable.Enable, () => { options["Distributable"] = "true"; }), Sharpmake.Options.Option(Options.Compiler.Distributable.Disable, () => { options["Distributable"] = "false"; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Compiler.OptimizationLevel.Disable, () => { options["OptimizationLevel"] = "Level0"; cmdLineOptions["OptimizationLevel"] = "-O0"; }), Sharpmake.Options.Option(Options.Compiler.OptimizationLevel.Standard, () => { options["OptimizationLevel"] = "Level1"; cmdLineOptions["OptimizationLevel"] = "-O1"; }), Sharpmake.Options.Option(Options.Compiler.OptimizationLevel.Full, () => { options["OptimizationLevel"] = "Level2"; cmdLineOptions["OptimizationLevel"] = "-O2"; }), Sharpmake.Options.Option(Options.Compiler.OptimizationLevel.FullWithInlining, () => { options["OptimizationLevel"] = "Level3"; cmdLineOptions["OptimizationLevel"] = "-O3"; }), Sharpmake.Options.Option(Options.Compiler.OptimizationLevel.ForSize, () => { options["OptimizationLevel"] = "Levels"; cmdLineOptions["OptimizationLevel"] = "-Os"; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Compiler.PositionIndependentCode.Disable, () => { options["PositionIndependentCode"] = "false"; cmdLineOptions["PositionIndependentCode"] = FileGeneratorUtilities.RemoveLineTag; }), Sharpmake.Options.Option(Options.Compiler.PositionIndependentCode.Enable, () => { options["PositionIndependentCode"] = "true"; cmdLineOptions["PositionIndependentCode"] = "-fPIC"; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Compiler.FastMath.Enable, () => { options["FastMath"] = "true"; cmdLineOptions["FastMath"] = "-ffast-math"; }), Sharpmake.Options.Option(Options.Compiler.FastMath.Disable, () => { options["FastMath"] = "false"; cmdLineOptions["FastMath"] = FileGeneratorUtilities.RemoveLineTag; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Compiler.NoStrictAliasing.Enable, () => { options["NoStrictAliasing"] = "true"; cmdLineOptions["NoStrictAliasing"] = "-fno-strict-aliasing"; }), Sharpmake.Options.Option(Options.Compiler.NoStrictAliasing.Disable, () => { options["NoStrictAliasing"] = "false"; cmdLineOptions["NoStrictAliasing"] = FileGeneratorUtilities.RemoveLineTag; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Compiler.UnrollLoops.Enable, () => { options["UnrollLoops"] = "true"; cmdLineOptions["UnrollLoops"] = "-funroll-loops"; }), Sharpmake.Options.Option(Options.Compiler.UnrollLoops.Disable, () => { options["UnrollLoops"] = "false"; cmdLineOptions["UnrollLoops"] = FileGeneratorUtilities.RemoveLineTag; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Compiler.LinkTimeOptimization.Enable, () => { options["LinkTimeOptimization"] = "true"; cmdLineOptions["LinkTimeOptimization"] = "-flto"; }), Sharpmake.Options.Option(Options.Compiler.LinkTimeOptimization.Disable, () => { options["LinkTimeOptimization"] = "false"; cmdLineOptions["LinkTimeOptimization"] = FileGeneratorUtilities.RemoveLineTag; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Compiler.CheckAnsiCompliance.Enable, () => { options["AnsiCompliance"] = "true"; cmdLineOptions["AnsiCompliance"] = "-ansi"; }), Sharpmake.Options.Option(Options.Compiler.CheckAnsiCompliance.Disable, () => { options["AnsiCompliance"] = "false"; cmdLineOptions["AnsiCompliance"] = FileGeneratorUtilities.RemoveLineTag; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Compiler.DefaultCharUnsigned.Enable, () => { options["CharUnsigned"] = "true"; cmdLineOptions["CharUnsigned"] = "-funsigned-char"; }), Sharpmake.Options.Option(Options.Compiler.DefaultCharUnsigned.Disable, () => { options["CharUnsigned"] = "false"; cmdLineOptions["CharUnsigned"] = FileGeneratorUtilities.RemoveLineTag; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Compiler.MsExtensions.Enable, () => { options["MsExtensions"] = "true"; cmdLineOptions["MsExtensions"] = "-fms-extensions"; }), Sharpmake.Options.Option(Options.Compiler.MsExtensions.Disable, () => { options["MsExtensions"] = "false"; cmdLineOptions["MsExtensions"] = FileGeneratorUtilities.RemoveLineTag; }) ); context.SelectOption ( Sharpmake.Options.Option(Sharpmake.Options.Vc.Compiler.RTTI.Enable, () => { options["RuntimeTypeInfo"] = "true"; cmdLineOptions["RuntimeTypeInfo"] = "-frtti"; }), Sharpmake.Options.Option(Sharpmake.Options.Vc.Compiler.RTTI.Disable, () => { options["RuntimeTypeInfo"] = FileGeneratorUtilities.RemoveLineTag; cmdLineOptions["RuntimeTypeInfo"] = "-fno-rtti"; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Linker.EditAndContinue.Enable, () => { options["EditAndContinue"] = "true"; cmdLineOptions["EditAndContinue"] = "-Wl,--enc"; }), Sharpmake.Options.Option(Options.Linker.EditAndContinue.Disable, () => { options["EditAndContinue"] = "false"; cmdLineOptions["EditAndContinue"] = FileGeneratorUtilities.RemoveLineTag; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Linker.InfoStripping.None, () => { options["InfoStripping"] = "None"; cmdLineOptions["InfoStripping"] = FileGeneratorUtilities.RemoveLineTag; }), Sharpmake.Options.Option(Options.Linker.InfoStripping.StripDebug, () => { options["InfoStripping"] = "StripDebug"; cmdLineOptions["InfoStripping"] = "-Wl,-S"; }), Sharpmake.Options.Option(Options.Linker.InfoStripping.StripSymsAndDebug, () => { options["InfoStripping"] = "StripSymsAndDebug"; cmdLineOptions["InfoStripping"] = "-Wl,-s"; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Linker.DataStripping.None, () => { options["DataStripping"] = "None"; cmdLineOptions["DataStripping"] = FileGeneratorUtilities.RemoveLineTag; }), Sharpmake.Options.Option(Options.Linker.DataStripping.StripFuncs, () => { options["DataStripping"] = "StripFuncs"; cmdLineOptions["DataStripping"] = FileGeneratorUtilities.RemoveLineTag; }), Sharpmake.Options.Option(Options.Linker.DataStripping.StripFuncsAndData, () => { options["DataStripping"] = "StripFuncsAndData"; cmdLineOptions["DataStripping"] = FileGeneratorUtilities.RemoveLineTag; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Linker.DuplicateStripping.Enable, () => { options["DuplicateStripping"] = "true"; cmdLineOptions["DuplicateStripping"] = "-strip-duplicates"; }), Sharpmake.Options.Option(Options.Linker.DuplicateStripping.Disable, () => { options["DuplicateStripping"] = "false"; cmdLineOptions["DuplicateStripping"] = FileGeneratorUtilities.RemoveLineTag; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Linker.Addressing.ASLR, () => { options["Addressing"] = "ASLR"; cmdLineOptions["Addressing"] = FileGeneratorUtilities.RemoveLineTag; }), Sharpmake.Options.Option(Options.Linker.Addressing.NonASLR, () => { options["Addressing"] = "NonASLR"; cmdLineOptions["Addressing"] = FileGeneratorUtilities.RemoveLineTag; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Linker.UseThinArchives.Enable, () => { options["UseThinArchives"] = "true"; cmdLineOptions["UseThinArchives"] = "T"; }), Sharpmake.Options.Option(Options.Linker.UseThinArchives.Disable, () => { options["UseThinArchives"] = "false"; cmdLineOptions["UseThinArchives"] = ""; }) ); context.SelectOption ( Sharpmake.Options.Option(Options.Linker.WholeArchive.Enable, () => { options["WholeArchive"] = "true"; cmdLineOptions["WholeArchiveBegin"] = "--whole-archive"; cmdLineOptions["WholeArchiveEnd"] = "--no-whole-archive"; }), Sharpmake.Options.Option(Options.Linker.WholeArchive.Disable, () => { options["WholeArchive"] = "false"; cmdLineOptions["WholeArchiveBegin"] = FileGeneratorUtilities.RemoveLineTag; cmdLineOptions["WholeArchiveEnd"] = FileGeneratorUtilities.RemoveLineTag; }) ); }
public string GenFuncName(IGenerationContext context) { return "IContainer"; }
// Ideally the object files should be suffixed .o when compiling with FastBuild, using the CompilerOutputExtension property in ObjectLists public override void SetupPlatformToolsetOptions(IGenerationContext context) { context.Options["PlatformToolset"] = "Remote_GCC_1_0"; }
public IILLocal GenMain(IGenerationContext context) { context.PushToILStack(Need.ContainerNeed); return null; }
public override string Next(IGenerationContext context) { return(string.Empty); }
public bool IsCorruptingILStack(IGenerationContext context) { return false; }
public override bool HasPrecomp(IGenerationContext context) { return(!string.IsNullOrEmpty(context.Configuration.PrecompHeader)); }
private void EnactActionsOnObject(IGenerationContext context, object createdObject) { var typeContext = new GenerationContext(context.Builders, new TypeGenerationContextNode(context.Node, createdObject)); foreach (var action in this.mActions) { action.Enact(typeContext, createdObject); } }
string ICRegILGen.GenFuncName(IGenerationContext context) { return("Singleton_" + _implementationType.ToSimpleName()); }
public string GenFuncName(IGenerationContext context) { return "Enumerable_" + _type.ToSimpleName(); }
public override string Next(IGenerationContext context) { return(FirstNames[mRandom.Next(0, FirstNames.Length)]); }
public override string Next(IGenerationContext context) { return(GetE164PhoneNumber(base.Next(context))); }
public override string Next(IGenerationContext context) { throw new NotImplementedException(); }
public override string Next(IGenerationContext context) { int num = mRandom.Next(0, STATES.Count); return(mUseAbbreviations ? STATES.Keys.ToList()[num] : STATES.Values.ToList()[num]); }
public override string Next(IGenerationContext context) { return(Guid.NewGuid().ToString().Replace("-", string.Empty)); }