import java.util.regex.Pattern;\r
\r
public final class SourceFileReplacer {\r
- SourceFileReplacer(String path, String outpath, ModuleInfo moduleinfo) {\r
- modulepath = path;\r
- outputpath = outpath;\r
- mi = moduleinfo;\r
- }\r
- private String modulepath;\r
- private String outputpath;\r
- private ModuleInfo mi;\r
- private boolean showdetails = false;\r
+ private static ModuleInfo mi;\r
+ private static boolean showdetails = false;\r
\r
- private class r8tor9 {\r
+ private static class r8tor9 {\r
r8tor9(String r8, String r9) {\r
r8thing = r8;\r
r9thing = r9;\r
}\r
\r
// these sets are used only for printing log of the changes in current file\r
- private Set<r8tor9> filefunc = new HashSet<r8tor9>();\r
- private Set<r8tor9> filemacro = new HashSet<r8tor9>();\r
- private Set<r8tor9> fileguid = new HashSet<r8tor9>();\r
- private Set<r8tor9> fileppi = new HashSet<r8tor9>();\r
- private Set<r8tor9> fileprotocol = new HashSet<r8tor9>();\r
- private Set<String> filer8only = new HashSet<String>();\r
- \r
- private static final String r8only = "EfiLibInstallDriverBinding " +\r
- "EfiLibInstallAllDriverProtocols " +\r
- "EfiLibCompareLanguage " +\r
- "BufToHexString " +\r
- "EfiStrTrim " + //is the r8only lib going to be enlarged???? Caution !!!!\r
- "EfiValueToHexStr " +\r
- "HexStringToBuf " +\r
- "IsHexDigit " +\r
- "NibbleToHexChar " +\r
- "GetHob " +\r
- "GetHobListSize " +\r
- "GetHobVersion " +\r
- "GetHobBootMode " +\r
- "GetCpuHobInfo " +\r
- "GetDxeCoreHobInfo " +\r
- "GetNextFirmwareVolumeHob " +\r
- "GetNextGuidHob " +\r
- "GetPalEntryHobInfo " +\r
- "GetIoPortSpaceAddressHobInfo ";\r
+ private static final Set<r8tor9> filefunc = new HashSet<r8tor9>();\r
+ private static final Set<r8tor9> filemacro = new HashSet<r8tor9>();\r
+ private static final Set<r8tor9> fileguid = new HashSet<r8tor9>();\r
+ private static final Set<r8tor9> fileppi = new HashSet<r8tor9>();\r
+ private static final Set<r8tor9> fileprotocol = new HashSet<r8tor9>();\r
+ private static final Set<String> filer8only = new HashSet<String>();\r
\r
- public void flush() throws Exception {\r
+ public static final void flush(ModuleInfo moduleinfo) throws Exception {\r
+ \r
+ mi = moduleinfo;\r
+ \r
String outname = null;\r
String inname = null;\r
if (MigrationTool.ui.yesOrNo("Changes will be made to the Source Code. View details?")) {\r
outname = inname;\r
}\r
MigrationTool.ui.println("\nModifying file: " + inname);\r
- Common.string2file(sourcefilereplace(modulepath + File.separator + "temp" + File.separator + inname), outputpath + File.separator + "Migration_" + mi.modulename + File.separator + outname);\r
+ Common.string2file(sourcefilereplace(mi.modulepath + File.separator + "temp" + File.separator + inname), mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + outname);\r
} else if (inname.contains(".h") || inname.contains(".H") || inname.contains(".dxs") || inname.contains(".uni")) {\r
if (inname.contains(".H")) {\r
outname = inname.replaceFirst(".H", ".h");\r
outname = inname;\r
}\r
MigrationTool.ui.println("\nCopying file: " + inname);\r
- Common.string2file(Common.file2string(modulepath + File.separator + "temp" + File.separator + inname), outputpath + File.separator + "Migration_" + mi.modulename + File.separator + outname);\r
+ Common.string2file(Common.file2string(mi.modulepath + File.separator + "temp" + File.separator + inname), mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + outname);\r
}\r
}\r
\r
}\r
}\r
\r
- private void addr8only() throws Exception {\r
+ private static final void addr8only() throws Exception {\r
String paragraph = null;\r
- String line = Common.file2string(Database.defaultpath + File.separator + "R8Lib.c");\r
- Common.ensureDir(modulepath + File.separator + "result" + File.separator + "R8Lib.c");\r
- PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(outputpath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c")));\r
- PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(outputpath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.h")));\r
+ String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");\r
+ Common.ensureDir(mi.modulepath + File.separator + "result" + File.separator + "R8Lib.c");\r
+ PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c")));\r
+ PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.h")));\r
Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL);\r
Matcher mtrr8only = ptnr8only.matcher(line);\r
Matcher mtrr8onlyhead;\r
}\r
\r
// Caution : if there is @ in file , it will be replaced with \n , so is you use Doxygen ... God Bless you!\r
- private String sourcefilereplace(String filename) throws Exception {\r
+ private static final String sourcefilereplace(String filename) throws Exception {\r
BufferedReader rd = new BufferedReader(new FileReader(filename));\r
StringBuffer wholefile = new StringBuffer();\r
String line;\r
Iterator<r8tor9> rt = filefunc.iterator();\r
while (rt.hasNext()) {\r
temp = rt.next();\r
- if (r8only.contains(temp.r8thing)) {\r
+ if (MigrationTool.db.r8only.contains(temp.r8thing)) {\r
filer8only.add(r8thing);\r
mi.hashr8only.add(r8thing);\r
addr8 = true;\r
return line;\r
}\r
\r
- private void show(Set<r8tor9> hash, String sh) {\r
+ private static final void show(Set<r8tor9> hash, String sh) {\r
Iterator<r8tor9> it = hash.iterator();\r
r8tor9 temp;\r
if (showdetails) {\r
}\r
}\r
\r
- private void replaceGuid(String line, Set<String> hash, String kind, Set<r8tor9> filehash) {\r
+ private static final void replaceGuid(String line, Set<String> hash, String kind, Set<r8tor9> filehash) {\r
Iterator<String> it;\r
String r8thing;\r
String r9thing;\r