public override void Go(ResourceModel resourceModel) { FileCodeSink csFile = null; string currentModuleName = null; foreach (KeyFrameTemplateInstance instance in Instances) { // // If we've hit a new module we need to close off the current file // and make a new one. // if (instance.ModuleName != currentModuleName) { currentModuleName = instance.ModuleName; CloseFile(ref csFile); ProcessNewModule(resourceModel, currentModuleName, ref csFile); } // // Write the typed class for the current instance // csFile.WriteBlock(
public override void Go(ResourceModel resourceModel) { FileCodeSink csFile = null; string currentModuleName = null; foreach (EasingKeyFrameTemplateInstance instance in Instances) { string extraInterpolateArgs = ""; // // If we've hit a new module we need to close off the current file // and make a new one. // if (instance.ModuleName != currentModuleName) { currentModuleName = instance.ModuleName; CloseFile(ref csFile); ProcessNewModule(resourceModel, currentModuleName, ref csFile); } // AnimatedTypeHelpers.Interpolate has an extra parameter // for the Quaternion type if (instance.TypeName == "Quaternion") { extraInterpolateArgs = ", UseShortestPath"; } // // Write the typed class for the current instance // csFile.WriteBlock(
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods public override void Go() { string generatedPath = Path.Combine( _resourceModel.OutputDirectory, "src\\Graphics\\Include\\Generated" ); FileCodeSink cppFile = new FileCodeSink(generatedPath, "wincodec_private_generated.h");; Helpers.Style.WriteFileHeader(cppFile); foreach (McgEnum e in _resourceModel.Enums) { if (_resourceModel.ShouldGenerate(CodeSections.NativeWincodecPrivate, e)) { cppFile.WriteBlock(EnumHelper.FormatNativeEnum(e)); } } foreach (McgResource r in _resourceModel.Resources) { if (_resourceModel.ShouldGenerate(CodeSections.NativeWincodecPrivate, r)) { cppFile.WriteBlock(StructHelper.FormatNativeStructure(r)); } } cppFile.Dispose(); }
//+----------------------------------------------------------------------------- // // Function: ProcessArgs // // Synopsis: Process the command-line arguments. // //------------------------------------------------------------------------------ private static void ProcessArgs( string [] args, out ResourceModel resourceModel ) { Arguments parsedArgs = new Arguments(); if (!Utilities.Utility.ParseCommandLineArguments(args, parsedArgs, ReportArgumentError)) { // Should never get here - ReportArgumentError should throw an exception throw new ApplicationException("Internal error"); } // // Handle "-h" option. // if (parsedArgs.help) { Usage(); resourceModel = null; return; } // // Check that files exist // if (!File.Exists(parsedArgs.xmlFile)) { throw new FileNotFoundException("XML file not found", parsedArgs.xmlFile); } if (!File.Exists(parsedArgs.xsdFile)) { throw new FileNotFoundException("Schema not found", parsedArgs.xsdFile); } // // Handle "-disableSd" option. // NOTE: Side-effect. // if (parsedArgs.disableSd) { FileCodeSink.DisableSd(); } // // Load the XML file and create the resource model from it // XmlDocument document = LoadDocument(parsedArgs.xmlFile, parsedArgs.xsdFile); resourceModel = new ResourceModel(document, parsedArgs.outputDirectory); }
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods public override void Go() { FileCodeSink marshalFile = new FileCodeSink(_resourceModel.OutputDirectory, "src\\Graphics\\core\\resources\\marshal_generated.cpp"); Helpers.Style.WriteFileHeader(marshalFile); Helpers.Style.WriteIncludePrecomp(marshalFile); // Write common routine to unmarshall an array of resources marshalFile.WriteBlock(
public override void Go(ResourceModel resourceModel) { foreach (AnimatableTemplateInstance instance in Instances) { string fullPath = Path.Combine(resourceModel.OutputDirectory, instance.ManagedDestinationDir); string filename = instance.ClassName + ".cs"; using (FileCodeSink csFile = new FileCodeSink(fullPath, filename, true /* Create dir if necessary */)) { csFile.WriteBlock(
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ public override void Go() { foreach (CGElement e in CG.Elements) { string path = Path.Combine(CG.OutputDirectory, e.ManagedDestinationDir); string filename = e.Name + ".cs"; using (FileCodeSink cs = new FileCodeSink(path, filename, true /* Create dir if necessary */)) { cs.WriteBlock(Helpers.ManagedStyle.WriteFileHeader(filename)); cs.WriteBlock(
public override void Go(ResourceModel resourceModel) { foreach (AnimationTemplateInstance instance in Instances) { string fileName = instance.TypeName + "Animation" + ".cs"; string path = "src\\" + instance.ModuleName + "\\System\\Windows\\Media\\Animation\\Generated"; string fullPath = Path.Combine(resourceModel.OutputDirectory, path); string moduleReference = ""; string extraInterpolateArgs = ""; string checkNotNull; string propertyTypeName; // the actual type for the animation (e.g. Double? for DoubleAnimation) string nullableAccessor; // .Value for accessing value types, nothing for reference types // AnimatedTypeHelpers.Interpolate has an extra parameter // for the Quaternion type if (instance.TypeName == "Quaternion") { extraInterpolateArgs = ", UseShortestPath"; } // Duplicate AnimatedTypeHelpers class across Core/Framework causes name conflicts, // requiring that they be split across two namespaces. switch (instance.ModuleName) { case @"Core\CSharp": moduleReference = "using MS.Internal.PresentationCore;"; break; case "Framework": moduleReference = "using MS.Internal.PresentationFramework;"; break; } if (instance.IsValueType) { checkNotNull = ".HasValue"; propertyTypeName = instance.TypeName + "?"; nullableAccessor = ".Value"; } else { checkNotNull = " != null"; propertyTypeName = instance.TypeName; nullableAccessor = ""; } using (FileCodeSink csFile = new FileCodeSink(fullPath, fileName, true /* Create dir if necessary */)) { csFile.WriteBlock(
public override void Go(ResourceModel resourceModel) { foreach (AnimationResourceTemplateInstance instance in Instances) { string fileName = instance.TypeName.Name + "IndependentAnimationStorage.cs"; string fullPath = Path.Combine(resourceModel.OutputDirectory, instance.ManagedDestinationDir); using (FileCodeSink csFile = new FileCodeSink(fullPath, fileName, true /* Create dir if necessary */)) { string milTypeName = instance.TypeName.ManagedName.ToUpper(); csFile.WriteBlock(
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods public override void Go() { // // Opened the generated files // string generatedPath = Path.Combine( _resourceModel.OutputDirectory, "src\\Graphics\\Include\\Generated" ); string extensionPath = Path.Combine( _resourceModel.OutputDirectory, "src\\Graphics\\exts" ); FileCodeSink enumFile = new FileCodeSink(generatedPath, "wgx_command_types.h"); FileCodeSink enumCsFile = new FileCodeSink(generatedPath, "wgx_command_types.cs"); FileCodeSink extsFile = new FileCodeSink(extensionPath, "cmdstruct.h"); m_redirectionEnum = new StringCodeSink(); m_redirectionTypes = new StringCodeSink(); m_dwmEnum = new StringCodeSink(); m_enum = new StringCodeSink(); m_milTypes = new StringCodeSink(); m_exts = new StringCodeSink(); // // Collect the commands from the resource model and start generation. // PaddedCommandCollection paddedCommands = new PaddedCommandCollection(_resourceModel); /* ------------------------------------------------------------- */ /* -- EMIT THE REDIRECTION COMMANDS ---------------------------- */ /* ------------------------------------------------------------- */ uint redirectionCommandIndex = 1; m_redirectionEnum.Write(
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods public override void Go() { // // Opened the generated files // string generatedPath = Path.Combine( _resourceModel.OutputDirectory, "src\\Graphics\\core\\uce" ); FileCodeSink chFile = new FileCodeSink(generatedPath, "generated_resource_factory.h"); FileCodeSink ccFile = new FileCodeSink(generatedPath, "generated_resource_factory.cpp"); m_factory = new StringCodeSink(); // // Collect the resource types... // foreach (McgResource resource in _resourceModel.Resources) { if (resource.IsValueType || resource.IsAbstract || !resource.HasUnmanagedResource) { // // Do not allow creation of value types (Int32 etc.) or abstract resources. // continue; } EmitResourceCreator(resource); } // // Serialize the C++ file containing the resource factory implementation // Helpers.Style.WriteFileHeader(ccFile); ccFile.WriteBlock(
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods public override void Go() { string generatedPath = Path.Combine( _resourceModel.OutputDirectory, "src\\Graphics\\core\\uce" ); FileCodeSink processMessageFile = new FileCodeSink(generatedPath, "generated_process_message.inl"); m_processMessage = new StringCodeSink(); // // Walk the padded commands and build the message processing routine: // PaddedCommandCollection commands = new PaddedCommandCollection(_resourceModel); foreach (PaddedCommand command in commands.PaddedCommands) { if (command.Origin == PaddedCommandOrigin.RenderDataInstruction || command.Domain == "DWM" || command.Domain == "Redirection" || command.Domain == "RenderData" || (command.Domain == "Transport" && command.Target == "Ts") || (command.Target == String.Empty && command.Name == "GlyphBitmap") || command.Name == "GradientStop") { continue; } WriteCommandHandler(command); } // // Serialize the resulting routine // Helpers.Style.WriteFileHeader(processMessageFile); processMessageFile.WriteBlock(
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods public override void Go() { // AnimationClockResources end up in src\Core\CSharp\system\windows\media\animation string generatedPath = Path.Combine(_resourceModel.OutputDirectory, "src\\Core\\CSharp\\system\\windows\\media\\animation\\generated"); foreach (McgResource resource in _resourceModel.Resources) { if (!_resourceModel.ShouldGenerate(CodeSections.AnimationResource, resource)) { continue; } string fileName = resource.Name + "AnimationClockResource.cs"; string fullPath = Path.Combine(_resourceModel.OutputDirectory, generatedPath); using (FileCodeSink fileCodeSink = new FileCodeSink(fullPath, fileName, true /* Create dir if necessary */)) { string nameAsUpper = resource.Name.ToUpper(System.Globalization.CultureInfo.InvariantCulture); fileCodeSink.WriteBlock(
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods public override void Go() { string generatedPath = Path.Combine( _resourceModel.OutputDirectory, "src\\Graphics\\Include\\Generated" ); FileCodeSink cppFile = new FileCodeSink(generatedPath, "wgx_misc.h");; FileCodeSink csFile = new FileCodeSink(generatedPath, "wgx_misc.cs"); m_cpp = new StringCodeSink(); m_cs = new StringCodeSink(); // // Write the definitions // WriteEnums(); WriteStructs(); // // Serialize the C++ header and the C# files for the Avalon commands: // Helpers.Style.WriteFileHeader(cppFile); cppFile.WriteBlock(m_cpp.ToString()); csFile.WriteBlock(Helpers.ManagedStyle.WriteFileHeader("wgx_misc.cs")); csFile.WriteBlock(m_cs.ToString()); cppFile.Dispose(); csFile.Dispose(); }
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods public override void Go() { // // The MIL and DWM SDK versions are automagically calculated from the // UCE and DWM/redirection protocol fingerprints and manually incremented // SDK revisions. // uint uiDwmSdkVersion = 0, uiMilSdkVersion = 0; string generatedPath = Path.Combine( _resourceModel.OutputDirectory, "src\\Graphics\\Include\\Generated" ); FileCodeSink cppFile = new FileCodeSink(generatedPath, "wgx_sdk_version.h"); FileCodeSink csFile = new FileCodeSink(generatedPath, "wgx_sdk_version.cs"); m_cpp = new StringCodeSink(); m_cs = new StringCodeSink(); // // Collect the commands from the resource model and start generation. // PaddedCommandCollection commands = new PaddedCommandCollection(_resourceModel); // Contains list of Commands which contain security critical resources List <String> commandList = new List <String>(); // // Calculate the fingerprints of UCE and DWM protocols. Do it in two // passes and re-initialize the not-so-random number generator so that // DWM protocol changes do not affect MIL (and vice versae). // unchecked { InitializeSeeds(); uint uiDwmFingerprint = Seed; foreach (PaddedCommand command in commands.PaddedCommands) { if (command.Domain == "Redirection" || command.Domain == "DWM") { uiDwmFingerprint = Ror(uiDwmFingerprint ^ GetCommandHash(command)); } } uiDwmSdkVersion = uiDwmFingerprint; } unchecked { InitializeSeeds(); uint uiMilFingerprint = Seed; foreach (PaddedCommand command in commands.PaddedCommands) { if (command.Domain != "Redirection" && command.Domain != "DWM") { uiMilFingerprint = Ror(uiMilFingerprint ^ GetCommandHash(command)); } } uiMilSdkVersion = uiMilFingerprint; } // // Take into account the manually incremented SDK revisions // unchecked { XmlDocument document = LoadDocument("xml\\Version.xml", "xml\\Version.xsd"); string milSdkVersion = document.SelectSingleNode("/MilVersion/MilSdkVersion").InnerText; string dwmSdkVersion = document.SelectSingleNode("/MilVersion/DwmSdkVersion").InnerText; uiMilSdkVersion = Ror(uiMilSdkVersion ^ (Convert.ToUInt32(milSdkVersion) * 0x13579BDF)); uiDwmSdkVersion = Ror(uiDwmSdkVersion ^ (Convert.ToUInt32(dwmSdkVersion) * 0xFDB97531)); } // // Serialize the C++ header and the C# files: // Helpers.Style.WriteFileHeader(cppFile); cppFile.WriteBlock(