1<# 2// 3// Copyright (c) 2010-2018 Antmicro 4// Copyright (c) 2011-2015 Realtime Embedded 5// 6// This file is licensed under the MIT License. 7// Full license text is available in 'licenses/MIT.txt'. 8// 9#> 10<#@ template language="C#" hostspecific="true" #> 11<#@ parameter type="System.String" name="BASE_PATH" #> 12<#@ assembly name="System.Core" #> 13<#@ import namespace="System.Linq" #> 14<#@ import namespace="System.Text" #> 15<#@ import namespace="System.Collections.Generic" #> 16<#@ import namespace="System.IO" #> 17/* This file is automatically generated. Do not modify it manually! All changes should be made in `RegisterEnumParserContent.tt` file. */ 18<# 19 // This is a hack to have both: 20 // * file easy usable in other T4 templates 21 // * C# code that can be tested by UnitTests 22 // 23 // Parser code is stored in `RegisterEnumParserContent.tt` template. It is included 24 // and used by `RegisterTemplate.tt` and by this file. 25 // 26 // This file simply reads content of `RegisterEnumParserContent.tt` and, with simple transformations, 27 // writes it to `RegisterEnumParser.cs`. 28 29 30 var usings = new List<string>(); 31 var content = new List<string>(); 32 var baseDirectoryPath = Path.GetDirectoryName(BASE_PATH); 33 34 var skipLineMode = false; 35 foreach(var line in File.ReadAllLines(baseDirectoryPath + "/RegisterEnumParserContent.tt")) 36 { 37 if(line.StartsWith("#" + ">") && skipLineMode) 38 { 39 skipLineMode = false; 40 continue; 41 } 42 else if(skipLineMode) 43 { 44 continue; 45 } 46 else if(line.StartsWith("<#@ import namespace=")) 47 { 48 usings.Add("using " + line.Split('"')[1] + ";"); 49 } 50 else if(line.StartsWith("<#@") || line.StartsWith("<#+") || line.StartsWith("#" + ">")) 51 { 52 continue; 53 } 54 else if(line.StartsWith("<" + "#") && !skipLineMode) 55 { 56 skipLineMode = true; 57 continue; 58 } 59 else 60 { 61 content.Add(line); 62 } 63 } 64 65 foreach(var @using in usings) 66 { 67#> 68<#=@using#> 69<# 70 } 71#> 72 73namespace Antmicro.Renode.CoresSourceParser 74{ 75<# 76 foreach(var line in content) 77 { 78#> 79<#=line#> 80<# 81 } 82#> 83} 84 85