Incparser upgrades.
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402088
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace incparser
|
||||
{
|
||||
@@ -9,6 +11,16 @@ namespace incparser
|
||||
private int level;
|
||||
private StringBuilder data;
|
||||
|
||||
public ArrayList enumList = new ArrayList();
|
||||
public ArrayList defineList = new ArrayList();
|
||||
public ArrayList enumTypeList = new ArrayList();
|
||||
public ArrayList forwardList = new ArrayList();
|
||||
public ArrayList nativeList = new ArrayList();
|
||||
public ArrayList stockList = new ArrayList();
|
||||
public ArrayList funcenumList = new ArrayList();
|
||||
public ArrayList functagList = new ArrayList();
|
||||
public ArrayList structList = new ArrayList();
|
||||
|
||||
public int Level
|
||||
{
|
||||
get
|
||||
@@ -25,6 +37,12 @@ namespace incparser
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
level = 0;
|
||||
data = new StringBuilder();
|
||||
}
|
||||
|
||||
public ParseWriter()
|
||||
{
|
||||
level = 0;
|
||||
@@ -52,6 +70,79 @@ namespace incparser
|
||||
WriteLine("}");
|
||||
}
|
||||
|
||||
public void WriteFiles(string template, string outputfile)
|
||||
{
|
||||
StreamReader sr = null;
|
||||
|
||||
try
|
||||
{
|
||||
sr = File.OpenText(template);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("Failed to open template file: " + e.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
string contents = sr.ReadToEnd();
|
||||
|
||||
string replace = ToOutputString(defineList);
|
||||
contents = contents.Replace("$defines", replace);
|
||||
|
||||
replace = ToOutputString(enumList);
|
||||
contents = contents.Replace("$enums", replace);
|
||||
|
||||
replace = ToOutputString(enumTypeList);
|
||||
contents = contents.Replace("$enumtypes", replace);
|
||||
|
||||
replace = ToOutputString(forwardList);
|
||||
contents = contents.Replace("$forwards", replace);
|
||||
|
||||
replace = ToOutputString(nativeList);
|
||||
contents = contents.Replace("$natives", replace);
|
||||
|
||||
replace = ToOutputString(stockList);
|
||||
contents = contents.Replace("$stocks", replace);
|
||||
|
||||
replace = ToOutputString(funcenumList);
|
||||
contents = contents.Replace("$funcenums", replace);
|
||||
|
||||
replace = ToOutputString(functagList);
|
||||
contents = contents.Replace("$functags", replace);
|
||||
|
||||
replace = ToOutputString(structList);
|
||||
contents = contents.Replace("$structs", replace);
|
||||
|
||||
StreamWriter sw;
|
||||
sw = File.CreateText(outputfile);
|
||||
|
||||
sw.Write(contents);
|
||||
|
||||
sr.Close();
|
||||
sw.Close();
|
||||
}
|
||||
|
||||
private string ToOutputString(ArrayList a)
|
||||
{
|
||||
string defines = "";
|
||||
int count = 0;
|
||||
|
||||
foreach (object o in a)
|
||||
{
|
||||
defines += o;
|
||||
defines += " ";
|
||||
count += o.ToString().Length;
|
||||
|
||||
if (count > 180)
|
||||
{
|
||||
defines += "\r\n";
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return defines;
|
||||
}
|
||||
|
||||
private void WriteLine(string line)
|
||||
{
|
||||
Tabinate();
|
||||
|
||||
Reference in New Issue
Block a user