public override void ParseText() { StreamReader sr = new StreamReader(filename); string input = sr.ReadLine(); while (null != input) { while (input.Trim().StartsWith("'")) { input = sr.ReadLine(); } APIUtility.GetRidExtraSpaces(ref input); if (input.StartsWith("Declare ")) { string[] pieces = input.Split(' '); string returnType = GetFunctionReturnType(pieces); string funcName = pieces[2]; string dllName = GetDllName(pieces[4]); string paramStr = ParseParameters(input); string cSharpCode = CompleteDllImportCoding(dllName, returnType, funcName, paramStr); AddCSharpCode(funcName, cSharpCode); } input = sr.ReadLine(); } sr.Close(); }
public override void ParseText() { bool structStart = false; bool structEnd = false; string cSharpCode = ""; string structKey = ""; StreamReader sr = new StreamReader(filename); string input = sr.ReadLine(); while (null != input) { while (input.Trim().StartsWith("'")) { input = sr.ReadLine(); } APIUtility.GetRidExtraSpaces(ref input); if (IsStruct(input)) { structStart = true; structEnd = false; cSharpCode += DefineCShpStruct(input, ref structKey); input = sr.ReadLine(); continue; } if (structStart) { if (input.Trim().StartsWith(APIUtility.VB_END_TYPE)) { structStart = false; structEnd = true; cSharpCode += "}\n"; AddCSharpCode(structKey, cSharpCode); structKey = ""; cSharpCode = ""; input = sr.ReadLine(); continue; } else if (!structEnd) { cSharpCode += DefineCShpStructBody(input); input = sr.ReadLine(); continue; } } input = sr.ReadLine(); } sr.Close(); }
public override void ParseText() { StreamReader sr = new StreamReader(filename); string input = sr.ReadLine(); while (null != input) { // Ignore comments while (input.Trim().StartsWith("'")) { input = sr.ReadLine(); } APIUtility.GetRidExtraSpaces(ref input); if (input.StartsWith("Const ")) { string cKey = input.Split(' ')[1]; string cshpType = "int"; if (input.IndexOf(" As ") > 0) { input = input.Replace(" As ", " : "); cshpType = input.Split(':')[1].Trim(); cshpType = cshpType.Substring(0, cshpType.IndexOf(" ")); input = input.Replace(": " + cshpType, ""); APIUtility.GetCSharpStyle(ref cshpType); } string cSharpCode = APIUtility.CSHP_SCOPE + " " + input + ";\n"; cSharpCode = cSharpCode.Replace(APIUtility.VB_CONST_LEADING, APIUtility.CSHP_CONST_LEADING + cshpType); cSharpCode = cSharpCode.Replace(APIUtility.VB_HEX_EXP, APIUtility.CSHP_HEX_EXP); cSharpCode = cSharpCode.Replace(APIUtility.VB_OR, APIUtility.CSHP_OR); cSharpCode = cSharpCode.Replace("&'", "; //"); cSharpCode = cSharpCode.Replace("'", "; //"); cSharpCode = cSharpCode.Replace("&;", ";"); AddCSharpCode(cKey, cSharpCode); cSharpCode = ""; } input = sr.ReadLine(); } sr.Close(); }