More Windows build fix.
2 using System.Collections;
3 using System.Collections.Generic;
12 private StringBuilder data;
14 public ArrayList enumList = new ArrayList();
15 public ArrayList defineList = new ArrayList();
16 public ArrayList enumTypeList = new ArrayList();
17 public ArrayList forwardList = new ArrayList();
18 public ArrayList nativeList = new ArrayList();
19 public ArrayList stockList = new ArrayList();
20 public ArrayList funcenumList = new ArrayList();
21 public ArrayList functagList = new ArrayList();
22 public ArrayList structList = new ArrayList();
32 public string Contents
36 return data.ToString();
43 data = new StringBuilder();
49 data = new StringBuilder();
52 public void BeginSection(string name)
54 WriteLine("\"" + PrepString(name) + "\"");
59 public void WritePair(string key, string value)
61 WriteLine("\"" + PrepString(key) + "\"\t\t\"" + PrepString(value) + "\"");
64 public void EndSection()
68 throw new System.Exception("Writer nesting level went out of bounds");
73 public void WriteFiles(string template, string outputfile)
75 StreamReader sr = null;
79 sr = File.OpenText(template);
83 Console.WriteLine("Failed to open template file: " + e.Message);
87 string contents = sr.ReadToEnd();
89 string replace = ToOutputString(defineList);
90 contents = contents.Replace("$defines", replace);
92 replace = ToOutputString(enumList);
93 contents = contents.Replace("$enums", replace);
95 replace = ToOutputString(enumTypeList);
96 contents = contents.Replace("$enumtypes", replace);
98 replace = ToOutputString(forwardList);
99 contents = contents.Replace("$forwards", replace);
101 replace = ToOutputString(nativeList);
102 contents = contents.Replace("$natives", replace);
104 replace = ToOutputString(stockList);
105 contents = contents.Replace("$stocks", replace);
107 replace = ToOutputString(funcenumList);
108 contents = contents.Replace("$funcenums", replace);
110 replace = ToOutputString(functagList);
111 contents = contents.Replace("$functags", replace);
113 replace = ToOutputString(structList);
114 contents = contents.Replace("$structs", replace);
117 sw = File.CreateText(outputfile);
125 private string ToOutputString(ArrayList a)
130 foreach (object o in a)
134 count += o.ToString().Length;
146 private void WriteLine(string line)
149 data.Append(line + "\n");
152 private void Tabinate()
154 for (int i = 0; i < level; i++)
160 private string PrepString(string text)
162 /* Escape all escaped newlines (so they can be unescaped later) */
163 text = text.Replace("\\n", "\\\\n");
164 /* Escape all literal newlines */
165 text = text.Replace("\n", "\\n");
166 text = text.Replace("\r", "");
167 /* Remove escaped quotations */
168 text = text.Replace("\\\"", "\"");
169 /* Replace all quotations with escaped ones now */
170 text = text.Replace("\"", "\\\"");