public final class SourceFileReplacer implements Common.ForDoAll {\r
private static final SourceFileReplacer SFReplacer = new SourceFileReplacer();\r
private ModuleInfo mi;\r
- private static boolean showdetails = true; // set this as default now, may be changed in the future\r
+ //private static boolean showdetails = true; // set this as default now, may be changed in the future\r
\r
private static class r8tor9 {\r
r8tor9(String r8, String r9) {\r
private static final Set<r8tor9> fileprotocol = new HashSet<r8tor9>();\r
private static final Set<String> filer8only = new HashSet<String>();\r
\r
- private static final String addincludefile(String wholeline, String hfile) {\r
- return wholeline.replaceFirst("(\\*/\\s)", "$1\n#include " + hfile + "\n");\r
- }\r
- \r
- private final String convertdxs(String wholeline) {\r
- if (mi.getModuleType().equals("PEIM")) {\r
- return addincludefile(wholeline, "\\<PeimDepex.h\\>");\r
- } else {\r
- return addincludefile(wholeline, "\\<DxeDepex.h\\>");\r
- }\r
- }\r
- \r
- private final void addr8only() throws Exception {\r
- String paragraph = null;\r
- String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");\r
- PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c")));\r
- PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + 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
- while (mtrr8only.find()) {\r
- if (mi.hashr8only.contains(mtrr8only.group(2))) {\r
- paragraph = mtrr8only.group();\r
- outfile1.append(paragraph + "\n\n");\r
- if (mtrr8only.group(1).length() != 0) {\r
- mi.hashrequiredr9libs.add(mtrr8only.group(1));\r
- }\r
- //generate R8lib.h\r
- while ((mtrr8onlyhead = Func.ptnbrace.matcher(paragraph)).find()) {\r
- paragraph = mtrr8onlyhead.replaceAll(";");\r
- }\r
- outfile2.append(paragraph + "\n\n");\r
- }\r
- }\r
- outfile1.flush();\r
- outfile1.close();\r
- outfile2.flush();\r
- outfile2.close();\r
- \r
- mi.localmodulesources.add("R8Lib.h");\r
- mi.localmodulesources.add("R8Lib.c");\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 final String sourcefilereplace(String wholeline) throws Exception {\r
boolean addr8 = false;\r
\r
return wholeline;\r
}\r
+\r
+ private static final String addincludefile(String wholeline, String hfile) {\r
+ return wholeline.replaceFirst("(\\*/\\s)", "$1\n#include " + hfile + "\n");\r
+ }\r
\r
+ private final String convertdxs(String wholeline) {\r
+ if (mi.getModuleType().equals("PEIM")) {\r
+ return addincludefile(wholeline, "\\<PeimDepex.h\\>");\r
+ } else {\r
+ return addincludefile(wholeline, "\\<DxeDepex.h\\>");\r
+ }\r
+ }\r
+\r
private static final void show(Set<r8tor9> hash, String sh) {\r
Iterator<r8tor9> it = hash.iterator();\r
r8tor9 temp;\r
- if (showdetails) {\r
- if (!hash.isEmpty()) {\r
- MigrationTool.ui.print("Converting " + sh + " : ");\r
- while (it.hasNext()) {\r
- temp = it.next();\r
- MigrationTool.ui.print("[" + temp.r8thing + "->" + temp.r9thing + "] ");\r
- }\r
- MigrationTool.ui.println("");\r
+ if (!hash.isEmpty()) {\r
+ MigrationTool.ui.print("Converting " + sh + " : ");\r
+ while (it.hasNext()) {\r
+ temp = it.next();\r
+ MigrationTool.ui.print("[" + temp.r8thing + "->" + temp.r9thing + "] ");\r
}\r
+ MigrationTool.ui.println("");\r
}\r
}\r
- \r
+\r
private static final void replaceGuid(String line, Set<String> hash, String kind, Set<r8tor9> filehash) {\r
Iterator<String> it;\r
String r8thing;\r
}\r
}\r
}\r
+\r
+ private final void addr8only() throws Exception {\r
+ String paragraph = null;\r
+ String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");\r
+ PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c")));\r
+ PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(MigrationTool.ModuleInfoMap.get(mi) + 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
+ while (mtrr8only.find()) {\r
+ if (mi.hashr8only.contains(mtrr8only.group(2))) {\r
+ paragraph = mtrr8only.group();\r
+ outfile1.append(paragraph + "\n\n");\r
+ if (mtrr8only.group(1).length() != 0) {\r
+ mi.hashrequiredr9libs.add(mtrr8only.group(1));\r
+ }\r
+ //generate R8lib.h\r
+ while ((mtrr8onlyhead = Func.ptnbrace.matcher(paragraph)).find()) {\r
+ paragraph = mtrr8onlyhead.replaceAll(";");\r
+ }\r
+ outfile2.append(paragraph + "\n\n");\r
+ }\r
+ }\r
+ outfile1.flush();\r
+ outfile1.close();\r
+ outfile2.flush();\r
+ outfile2.close();\r
+ \r
+ mi.localmodulesources.add("R8Lib.h");\r
+ mi.localmodulesources.add("R8Lib.c");\r
+ }\r
\r
//-----------------------------------ForDoAll-----------------------------------//\r
public void run(String filepath) throws Exception {\r
}\r
}\r
\r
- public boolean dirFilter(String filepath) {\r
- return true;\r
- }\r
- \r
- public boolean fileFilter(String filepath) {\r
+ public boolean filter(File dir) {\r
return true;\r
}\r
//-----------------------------------ForDoAll-----------------------------------//\r