static void Main(string[] args) { LoggerHelper.Initialize(); LoggerHelper.StartGenerate(); try { ProMetaHelper.Instance().InitMeta(); //generate protocol file if (ExportConfig.Instance().Export2C) { export_to_c.ProExportCImpl exp = new export_to_c.ProExportCImpl(); exp.GenerateProLib(); //deploy generate files exp.DeployProLib(); } if (ExportConfig.Instance().Export2Java) { export_to_java.ProExportJavaImpl exp = new export_to_java.ProExportJavaImpl(); exp.GenerateProLib(); exp.DeployProLib(); } } catch (Exception se) { LoggerHelper.GenError(se.Message); } LoggerHelper.EndGenerate(); }
protected void GenerateEnumStruct() { try { MakeOutputFile(path_root_, "pro_enum_def.h"); GenHFileHeaderB("pro_enum_def"); cur_stream_.WriteString(ExportCConst.IncludeFiles1, 0); cur_stream_.WriteString(String.Format("#include <prolib/gen/pro_macro_def.h>"), 0); if (!ProMetaHelper.Instance().HaveGlobalEnum) { return; } List <EnumStruct> mds = ProMetaHelper.Instance().GlobalEnum; foreach (EnumStruct md in mds) { //output one enum struct OutputOneEnumStruct(md); cur_stream_.WriteEmptyLine(); } } finally { GenHFileHeaderE("pro_enum_def"); cur_stream_.FinishGenerate(); } }
protected void GenProIncludesCPP() { try { MakeOutputFile(path_root_, "Pro_all.cpp"); cur_stream_.WriteString(ExportCConst.IncludeFiles1, 0); cur_stream_.WriteString(ExportCConst.IncludeFilesOfProtocol, 0); cur_stream_.WriteEmptyLine(); if (!ProMetaHelper.Instance().HaveProtocols) { return; } foreach (ProRegion pr in ProMetaHelper.Instance().ProRegions) { if (!pr.HaveProMeta) { continue; } string ffname = String.Format("#include <prolib/gen/Pro_{0}.cpp>", pr.RegionName); cur_stream_.WriteString(ffname, 0); } cur_stream_.WriteEmptyLine(); } finally { cur_stream_.FinishGenerate(); } }
protected void GenProFactory() { try { MakeOutputFile(path_root_, "ProtocolFactory.cpp"); cur_stream_.WriteString( @" #include <vector> #include <prolib/ProtocolFactory.h> #include <prolib/SerializeFactoryContainer.h> #include <prolib/gen/Pro_all.h> ", 0); cur_stream_.WriteString("USE_PROTOCOL_NAMESPACE", 0); cur_stream_.WriteEmptyLine(); cur_stream_.WriteString("BEGIN_PRO_FACTORY()", 0); cur_stream_.WriteEmptyLine(); if (!ProMetaHelper.Instance().HaveProtocols) { return; } foreach (ProRegion pr in ProMetaHelper.Instance().ProRegions) { if (!pr.HaveProMeta) { continue; } cur_stream_.WriteComment(String.Format("Pro_{0}.h", pr.RegionName), 1); foreach (ProMeta pm in pr.ProMetas) { cur_stream_.WriteString(String.Format("PRO_MAPPING( {0}, {1})", pm.ProID, pm.Name), 1); } } cur_stream_.WriteEmptyLine(); } finally { cur_stream_.WriteString("END_PRO_FACTORY()", 0); cur_stream_.FinishGenerate(); } }
protected void GenerateProtocols() { //generate a file include all protocol defined, that can be used by application GenProIncludesH(); GenProIncludesCPP(); //auto generate all pro region foreach (ProRegion pr in ProMetaHelper.Instance().ProRegions) { if (pr.HaveProMeta) { GenProRegionId(pr); GenProRegionH(pr); GenProRegionCPP(pr); } } GenProFactory(); }
protected void GenerateGlobalStruct() { try { MakeOutputFile(path_root_, "pro_struct_def.h"); GenHFileHeaderB("pro_struct_def"); cur_stream_.WriteString(ExportCConst.IncludeFiles1, 0); cur_stream_.WriteString(String.Format("#include <prolib/StaticString.h>"), 0); cur_stream_.WriteString(String.Format("#include <prolib/gen/pro_macro_def.h>"), 0); cur_stream_.WriteString(String.Format("#include <prolib/gen/pro_enum_def.h>"), 0); cur_stream_.WriteEmptyLine(); if (!ProMetaHelper.Instance().HaveGlobalStruct) { return; } //defined under one namespace cur_stream_.WriteString("PROTOCOL_NAMESPACE_BEGIN", 0); cur_stream_.WriteEmptyLine(); List <GlobalStruct> mds = ProMetaHelper.Instance().GlobalStruct; foreach (GlobalStruct md in mds) { //output one enum struct OutputOneGlobalStruct(md); cur_stream_.WriteEmptyLine(); } cur_stream_.WriteString("PROTOCOL_NAMESPACE_END", 0); } finally { GenHFileHeaderE("pro_struct_def"); cur_stream_.FinishGenerate(); } }
protected void GenerateMacroDefine() { try { MakeOutputFile(path_root_, "pro_macro_def.h"); GenHFileHeaderB("pro_macro_def"); cur_stream_.WriteString(ExportCConst.IncludeFiles1, 0); if (!ProMetaHelper.Instance().HaveMacroDefines) { return; } List <MacroDefine> mds = ProMetaHelper.Instance().MacroDefines; foreach (MacroDefine md in mds) { if (!AppUtil.IsEmptyString(md.Desc)) { cur_stream_.WriteComment(md.Desc, 0); } if (md.Type == ProMetaConst.DATATYPE_INT32) { cur_stream_.WriteString(String.Format("#define {0} {1}", md.Name, md.Value), 0); } cur_stream_.WriteEmptyLine(); } } finally { GenHFileHeaderE("pro_macro_def"); cur_stream_.FinishGenerate(); } }