public string DefineCShpStructBody(string input) { if (input == "") { return(""); } input = input.Replace(" as ", ApiUtility.VB_AS); input = input.Replace(ApiUtility.VB_AS, " ^ "); string[] pieces = input.Split('^'); string cSharpStruct = ""; if (input.IndexOf("*") > 0) { cSharpStruct = ApiUtility.CSHP_MARSHAL_EXP_1.Replace(ApiUtility.REPLACEABlE, input.Split('*')[1].Trim()); pieces[1] = pieces[1].Replace("* " + input.Split('*')[1].Trim(), ""); } if (pieces[0].IndexOf("(") > 0) { string[] arrSeps = pieces[0].Split('('); pieces[0] = arrSeps[0]; cSharpStruct = ApiUtility.CSHP_MARSHAL_EXP_2.Replace(ApiUtility.REPLACEABlE, arrSeps[1]); } cSharpStruct += ApiUtility.CSHP_SCOPE + " "; ApiUtility.GetCSharpStyle(ref pieces[1]); cSharpStruct += pieces[1] + " "; cSharpStruct += pieces[0].Trim() + ";\n"; cSharpStruct = cSharpStruct.Replace(" '", "; //"); cSharpStruct = cSharpStruct.Replace("'", "; //"); return(" " + cSharpStruct); }
public string GetFunctionReturnType(string[] pieces) { if (pieces[1].Trim() == "Sub") { return("void"); } else { ApiUtility.GetCSharpStyle(ref pieces[pieces.Length - 1]); return(pieces[pieces.Length - 1]); } }
public override void ParseText() { StreamReader sr = new StreamReader(FileName); string input = sr.ReadLine(); while (null != input) { // Ignore comments // ReSharper disable once PossibleNullReferenceException while (input.Trim().StartsWith("'")) { input = sr.ReadLine(); } ApiUtility.RemoveExtraSpace(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(); }
public string MakeAParameter(string paramA) { paramA = paramA.Trim().Replace(" As ", " "); string[] pPieces = paramA.Split(' '); int pLen = pPieces.Length; if (pPieces[0].Trim() == "ByRef") { ApiUtility.GetCSharpStyle(ref pPieces[pLen - 1], true); return("ref " + pPieces[pLen - 1] + " " + pPieces[pLen - 2]); } if (!ApiUtility.GetCSharpStyle(ref pPieces[pLen - 1])) { pPieces[pLen - 1] = ApiUtility.CSHP_MARSHAL_EXP_5 + pPieces[pLen - 1]; } ApiUtility.GetCSharpStyle(ref pPieces[pLen - 1], true); return(pPieces[pLen - 1] + " " + pPieces[pLen - 2]); }