import java.io.*;\r
import java.util.regex.*;\r
import java.util.*;\r
+import java.lang.reflect.*;\r
\r
-public class Common {\r
- public static Pattern ptnseparate = Pattern.compile("(.*)\\\\([^\\\\]*)");\r
+public final class Common {\r
+ public static final int BOTH = 0;\r
+ public static final int FILE = 1;\r
+ public static final int DIR = 2;\r
\r
- public static String file2string(String filename) throws Exception {\r
+ public static final Pattern ptnseparate = Pattern.compile("(.*)\\\\([^\\\\]*)");\r
+\r
+ //-------------------------------------regex------------------------------------------//\r
+ \r
+ public static final String replaceAll(String line, Pattern ptn, String des) {\r
+ Matcher mtr = ptn.matcher(line);\r
+ if (mtr.find()) {\r
+ return mtr.replaceAll(des);\r
+ }\r
+ return line;\r
+ }\r
+\r
+ //-------------------------------------regex------------------------------------------//\r
+ \r
+ //-----------------------------------file&string---------------------------------------//\r
+ \r
+ public static final String file2string(String filename) throws Exception {\r
BufferedReader rd = new BufferedReader(new FileReader(filename));\r
StringBuffer wholefile = new StringBuffer();\r
String line;\r
return wholefile.toString();\r
}\r
\r
- public static void string2file(String content, String filename) throws Exception {\r
+ public static final void string2file(String content, String filename) throws Exception {\r
ensureDir(filename);\r
PrintWriter outfile = new PrintWriter(new BufferedWriter(new FileWriter(filename)));\r
outfile.append(content);\r
outfile.close();\r
}\r
\r
- public static void ensureDir(String objFileWhole) {\r
+ //-----------------------------------file&string---------------------------------------//\r
+\r
+ //--------------------------------------dir--------------------------------------------//\r
+ \r
+ public static final void ensureDir(String objFileWhole) {\r
File tempdir;\r
Matcher mtrseparate = ptnseparate.matcher(objFileWhole);\r
if (mtrseparate.find()) {\r
}\r
}\r
\r
- public static HashSet<String> dirScan(String path) { // use HashSet, persue speed rather than space\r
- HashSet<String> filelist = new HashSet<String>();\r
- String[] list = new File(path).list();\r
- File test;\r
-\r
+ public static final void deleteDir(String objFileWhole) {\r
+ String[] list = new File(objFileWhole).list();\r
+ File temp;\r
for (int i = 0 ; i < list.length ; i++) {\r
- test = new File(path + File.separator + list[i]);\r
- if (test.isDirectory()) {\r
- dirScan(path + File.separator + list[i]);\r
+ temp = new File(objFileWhole + File.separator + list[i]);\r
+ if (temp.isDirectory()) {\r
+ deleteDir(objFileWhole + File.separator + list[i]);\r
} else {\r
- filelist.add(path + File.separator + list[i]);\r
+ temp.delete();\r
}\r
}\r
- \r
- return filelist;\r
- }\r
-\r
- public static String replaceAll(String line, Pattern ptn, String des) {\r
- Matcher mtr = ptn.matcher(line);\r
- if (mtr.find()) {\r
- return mtr.replaceAll(des);\r
- }\r
- return line;\r
+ new File(objFileWhole).delete();\r
}\r
\r
- public static String dirCopy_(String src) throws Exception {\r
+ public static final String dirCopy_(String src) throws Exception {\r
Matcher mtrseparate = Common.ptnseparate.matcher(src);\r
if (mtrseparate.find()) {\r
dirCopy(src, mtrseparate.group(1) + File.separator + "_" + mtrseparate.group(2));\r
return mtrseparate.group(1) + File.separator + "_" + mtrseparate.group(2);\r
}\r
\r
- public static void dirCopy(String src, String des) throws Exception {\r
+ public static final void dirCopy(String src, String des) throws Exception {\r
String[] list = new File(src).list();\r
File test;\r
\r
}\r
}\r
}\r
+\r
+ //--------------------------------------dir--------------------------------------------//\r
+\r
+ //-------------------------------like python walk-----------------------------------------//\r
+ \r
+ public static final void toDoAll(String path, Method md, Object obj, Object[] args, int type) throws Exception {\r
+ String[] list = new File(path).list();\r
+ ArrayList<Object> _args = new ArrayList<Object>();\r
+ \r
+ _args.add(path);\r
+ if (args != null) {\r
+ for (int i = 0; i < args.length; i++) {\r
+ _args.add(args[i]);\r
+ }\r
+ }\r
+\r
+ if (type == DIR || type == BOTH) {\r
+ md.invoke(obj, _args.toArray());\r
+ }\r
+ for (int i = 0 ; i < list.length ; i++) {\r
+ if (new File(path + File.separator + list[i]).isDirectory()) {\r
+ toDoAll(path + File.separator + list[i], md, obj, args, type);\r
+ } else {\r
+ if (type == FILE || type == BOTH) {\r
+ _args.set(0, path + File.separator + list[i]);\r
+ md.invoke(obj, _args.toArray());\r
+ }\r
+ }\r
+ }\r
+ }\r
\r
public static void toDoAll(String path, ForDoAll fda) throws Exception { // filter of file type can be done in toDo\r
String[] list = new File(path).list();\r
import java.util.regex.*;\r
import java.io.*;\r
\r
-public class Critic implements Common.ForDoAll {\r
+public class Critic {\r
private static Pattern ptnheadcomment = Pattern.compile("^\\/\\*\\+\\+(.*?)\\-\\-\\*\\/",Pattern.DOTALL);\r
private static Pattern ptnfunccomment = Pattern.compile("([\\};\\/]\\s*)([\\w\\s]*?[_\\w][_\\w\\d]*\\s*\\([^\\)\\(]*\\)\\s*)\\/\\*\\+\\+(.*?)\\-\\-\\*\\/(\\s*.*?)([\\{;])",Pattern.DOTALL);\r
//private static Pattern ptncommentstructure = Pattern.compile("\\/\\*\\+\\+\\s*Routine Description:\\s*(.*?)\\s*Arguments:\\s*(.*?)\\s*Returns:\\s*(.*?)\\s*\\-\\-\\*\\/",Pattern.DOTALL);\r
- private static Pattern ptninfequation = Pattern.compile("([^\\s]*)\\s*-\\s*(.*)\\s*");\r
- private static Matcher mtrinfequation;\r
+ private static Pattern ptncommentequation = Pattern.compile("([^\\s]*)\\s+-\\s+(.*)\\s*");\r
+ private static Matcher mtrcommentequation;\r
+ private static Pattern ptnnewcomment = Pattern.compile("(\\s*@(param|retval)\\s+[^\\s]+)\\s+(.*)");\r
+ private static Matcher mtrnewcomment;\r
\r
- public void toDo(String filepath) throws Exception {\r
+ private static final int totallinelength = 82;\r
+ \r
+ public static final void critic(String filepath) throws Exception {\r
if (filepath.contains(".c") || filepath.contains(".h")) {\r
BufferedReader rd = null;\r
String line = null;\r
StringBuffer templine = new StringBuffer();\r
boolean incomment = false;\r
- boolean description = false;\r
- boolean arguments = false;\r
- boolean returns = false;\r
- boolean inequation = false;\r
\r
System.out.println("Criticing " + filepath);\r
String wholeline = Common.file2string(filepath);\r
wholeline = Common.replaceAll(wholeline, ptnheadcomment, "/** @file$1**/");\r
wholeline = Common.replaceAll(wholeline, ptnfunccomment, "$1/**$3**/$4$2$5");\r
//wholeline = Common.replaceAll(wholeline, ptncommentstructure, "/**\n#%\n$1\n%#\n#%%\n$2\n%%#\n#%%%\n$3\n%%%#\n**/");\r
- \r
+\r
+ // first scan\r
+ boolean description = false;\r
+ boolean arguments = false;\r
+ boolean returns = false;\r
+ boolean inequation = false;\r
rd = new BufferedReader(new StringReader(wholeline));\r
while ((line = rd.readLine()) != null) {\r
if (line.matches("\\/\\*\\*")) {\r
arguments = false;\r
returns = true;\r
} else if (incomment && description) {\r
- templine.append(line + "\n");\r
+ templine.append(" " + line.trim() + "\n");\r
} else if (incomment && arguments) {\r
- mtrinfequation = ptninfequation.matcher(line);\r
- if (mtrinfequation.find()) {\r
+ mtrcommentequation = ptncommentequation.matcher(line);\r
+ if (mtrcommentequation.find()) {\r
inequation = true;\r
- templine.append(" @param " + mtrinfequation.group(1) + " " + mtrinfequation.group(2) + "\n");\r
+ templine.append(" @param " + mtrcommentequation.group(1) + " " + mtrcommentequation.group(2) + "\n");\r
} else if (inequation && line.trim().length() == 0) {\r
inequation = false;\r
templine.append(line + "\n");\r
} else if (inequation && line.trim().length() != 0) {\r
templine.append("#%#%" + line + "\n");\r
} else {\r
- templine.append(line + "\n");\r
+ templine.append(" " + line.trim() + "\n");\r
}\r
} else if (incomment && returns) {\r
- mtrinfequation = ptninfequation.matcher(line);\r
- if (mtrinfequation.find()) {\r
+ mtrcommentequation = ptncommentequation.matcher(line);\r
+ if (mtrcommentequation.find()) {\r
inequation = true;\r
- templine.append(" @retval " + mtrinfequation.group(1) + " " + mtrinfequation.group(2) + "\n");\r
+ templine.append(" @retval " + mtrcommentequation.group(1) + " " + mtrcommentequation.group(2) + "\n");\r
} else if (inequation && line.trim().length() == 0) {\r
inequation = false;\r
templine.append(line + "\n");\r
} else if (inequation && line.trim().length() != 0) {\r
templine.append("#%#%" + line + "\n");\r
} else {\r
- templine.append(line + "\n");\r
+ templine.append(" " + line.trim() + "\n");\r
}\r
} else {\r
templine.append(line + "\n");\r
}\r
wholeline = templine.toString();\r
wholeline = wholeline.replaceAll("\n#%#%\\s*", " ");\r
+ //\r
+ \r
+ // secend scan\r
+ int startmax = 0;\r
+ rd = new BufferedReader(new StringReader(wholeline));\r
+ while ((line = rd.readLine()) != null) {\r
+ if (line.matches("\\/\\*\\*")) {\r
+ incomment = true;\r
+ templine.append(line + "\n");\r
+ } else if (line.matches("\\*\\*\\/")) {\r
+ incomment = false;\r
+ templine.append(line + "\n");\r
+ } else if (incomment) {\r
+ mtrnewcomment = ptnnewcomment.matcher(line);\r
+ if (mtrnewcomment.find()) {\r
+ startmax = mtrnewcomment.group(1).length() > startmax ? mtrnewcomment.group(1).length() : startmax;\r
+ }\r
+ }\r
+ }\r
+ startmax++;\r
+ //\r
+ \r
+ // third scan\r
+ int n = 0;\r
+ String temp = null;\r
+ String[] tempcont = null;\r
+ int count = 0;\r
+ templine = new StringBuffer();\r
+ rd = new BufferedReader(new StringReader(wholeline));\r
+ while ((line = rd.readLine()) != null) {\r
+ if (line.matches("\\/\\*\\*")) {\r
+ incomment = true;\r
+ templine.append(line + "\n");\r
+ } else if (line.matches("\\*\\*\\/")) {\r
+ incomment = false;\r
+ templine.append(line + "\n");\r
+ } else if (incomment) {\r
+ mtrnewcomment = ptnnewcomment.matcher(line);\r
+ if (mtrnewcomment.find()) {\r
+ n = startmax - mtrnewcomment.group(1).length();\r
+ templine.append(mtrnewcomment.group(1));\r
+ while (n-- >= 0) {\r
+ templine.append(" ");\r
+ }\r
+ temp = mtrnewcomment.group(3);\r
+ tempcont = temp.split(" "); // use \\s+ ?\r
+ \r
+ count = 0;\r
+ for (int i = 0; i < tempcont.length; i++) {\r
+ count += tempcont[i].length();\r
+ if (count <= (totallinelength - startmax)) {\r
+ templine.append(tempcont[i] + " ");\r
+ count += 1;\r
+ } else {\r
+ templine.append("\n");\r
+ n = startmax;\r
+ while (n-- >= 0) {\r
+ templine.append(" ");\r
+ }\r
+ templine.append(tempcont[i] + " ");\r
+ count = tempcont[i].length() + 1;\r
+ }\r
+ }\r
+ templine.append("\n");\r
+ } else {\r
+ templine.append(line + "\n");\r
+ }\r
+ } else {\r
+ templine.append(line + "\n");\r
+ }\r
+ }\r
+ wholeline = templine.toString();\r
+ //\r
\r
/* -----slow edition of replacefirst with stringbuffer-----\r
line.append(wholeline);\r
}\r
}\r
\r
- public static void fireAt(String path) throws Exception {\r
- Critic critic = new Critic();\r
- Common.toDoAll(Common.dirCopy_(path), critic);\r
+ public static final void fireAt(String path) throws Exception {\r
+ Common.toDoAll(Common.dirCopy_(path), Critic.class.getMethod("critic", String.class), null, null, Common.FILE);\r
+ //Common.toDoAll(Common.dirCopy_(path), critic, Common.FILE);\r
System.out.println("Critic Done");\r
}\r
}\r
import java.util.*;\r
import javax.swing.*;\r
\r
-public class FirstPanel extends JPanel implements ActionListener, UI {\r
+public final class FirstPanel extends JPanel implements ActionListener, UI {\r
/**\r
* Define class Serial Version UID\r
*/\r
modulePanel.add(filebox);\r
modulePanel.add(screenbox);\r
modulePanel.add(goButton);\r
- modulePanel.add(msaEditorButton);\r
+ //modulePanel.add(msaEditorButton);\r
modulePanel.add(criticButton);\r
add(modulePanel);\r
\r
\r
//---------------------------------------------------------------------------------------//\r
\r
+ public String getFilepath() {\r
+ if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {\r
+ log.append(fc.getSelectedFile().getAbsolutePath() + "\n");\r
+ return fc.getSelectedFile().getAbsolutePath();\r
+ }\r
+ return null;\r
+ }\r
+\r
+ //---------------------------------------------------------------------------------------//\r
+\r
public void actionPerformed(ActionEvent e) {\r
if ( e.getSource() == moduleButton ) {\r
+ modulepath = getFilepath();\r
+ /*\r
int ret = fc.showOpenDialog(this);\r
if (ret == JFileChooser.APPROVE_OPTION) {\r
modulepath = fc.getSelectedFile().getAbsolutePath();\r
moduletext.setText(modulepath);\r
log.append("ModulePath: " + modulepath + "\n");\r
}\r
+ */\r
}\r
if ( e.getSource() == goButton ) {\r
try {\r
logfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "migration.log")));\r
println("Project MsaGen");\r
println("Copyright (c) 2006, Intel Corporation");\r
- mi = new ModuleInfo(modulepath, this, new Database());\r
+ Common.toDoAll(modulepath, ModuleInfo.class.getMethod("seekModule", String.class), null, null, Common.DIR);\r
logfile.flush();\r
} catch (Exception en) {\r
println(en.getMessage());\r
\r
//---------------------------------------------------------------------------------------//\r
\r
- public static void init() throws Exception {\r
+ public static FirstPanel init() throws Exception {\r
\r
//UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());\r
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());\r
\r
frame.pack();\r
frame.setVisible(true);\r
+ \r
+ return fp;\r
}\r
}
\ No newline at end of file
information and all the temporary data.\r
*/\r
public class ModuleInfo {\r
- ModuleInfo(String modulepath, UI ui, Database db) throws Exception {\r
+ ModuleInfo(String modulepath) throws Exception {\r
this.modulepath = modulepath;\r
- this.ui = ui;\r
- this.db = db;\r
+ \r
+ ui.println("Choose where to place the result");\r
+ if ((outputpath = ui.getFilepath()) == null) {\r
+ outputpath = modulepath; \r
+ }\r
+ ui.println(outputpath);\r
+ \r
moduleScan();\r
}\r
+\r
+ private static UI ui = null; //if MIM is still usefull, this can be given to it\r
+ private static Database db = null; //if MIM is still usefull, this can be given to it\r
+ \r
+ public String modulepath = null;\r
\r
- private String modulepath = null;\r
- private Database db = null;\r
- private UI ui = null;\r
+ public String outputpath = null;\r
\r
public String modulename = null;\r
public String guidvalue = null;\r
\r
private static String migrationcomment = "//%$//";\r
\r
- private void dirScan(String subpath) throws Exception {\r
- String[] list = new File(modulepath + File.separator + subpath).list(); // if no sub , separator need?\r
- File test;\r
- \r
- for (int i = 0 ; i < list.length ; i++) {\r
- test = new File(modulepath + File.separator + subpath + list[i]);\r
- if (test.isDirectory()) {\r
- if (list[i].contains("result") || list[i].contains("temp")) {\r
- } else {\r
- dirScan(subpath + list[i] + File.separator);\r
- }\r
- } else {\r
- if (list[i].contains(".c") || list[i].contains(".C") || list[i].contains(".h") || \r
- list[i].contains(".H") || list[i].contains(".dxs") || list[i].contains(".uni")) {\r
- localmodulesources.add(subpath + list[i]);\r
- } else if (list[i].contains(".inf") || list[i].contains(".msa")) {\r
- msaorinf.add(subpath + list[i]);\r
- }\r
- }\r
- }\r
- }\r
- \r
private void moduleScan() throws Exception {\r
- dirScan("");\r
+ Common.toDoAll(modulepath, ModuleInfo.class.getMethod("enroll", String.class), this, null, Common.FILE);\r
+ \r
String filename = null;\r
if (msaorinf.isEmpty()) {\r
ui.println("No INF nor MSA file found!");\r
System.exit(0);\r
} else {\r
- filename = ui.choose("Found .inf or .msa file in the module\nChoose one Please", msaorinf.toArray());\r
+ filename = ui.choose("Found .inf or .msa file for module\n" + modulepath + "\nChoose one Please", msaorinf.toArray());\r
}\r
- ModuleReader mr = new ModuleReader(modulepath, this, db, ui);\r
+ //ModuleReader mr = new ModuleReader(modulepath, this, db, ui);\r
if (filename.contains(".inf")) {\r
- mr.readInf(filename);\r
+ ModuleReader.readInf(filename, this);\r
} else if (filename.contains(".msa")) {\r
- mr.readMsa(filename);\r
+ ModuleReader.readMsa(filename, this);\r
}\r
\r
CommentOutNonLocalHFile();\r
parsePreProcessedSourceCode();\r
- \r
- new SourceFileReplacer(modulepath, this, db, ui).flush(); // some adding library actions are taken here,so it must be put before "MsaWriter"\r
+\r
+ new SourceFileReplacer(modulepath, outputpath, this, db, ui).flush(); // some adding library actions are taken here,so it must be put before "MsaWriter"\r
\r
// show result\r
if (ui.yesOrNo("Parse of the Module Information has completed. View details?")) {\r
show(hashr8only, "hashr8only : ");\r
}\r
\r
- new MsaWriter(modulepath, this, db, ui).flush();\r
- \r
- // remove temp directory\r
- //File tempdir = new File(modulepath + File.separator + "temp");\r
- //System.out.println("Deleting Dir");\r
- //if (tempdir.exists()) tempdir.d;\r
+ new MsaWriter(modulepath, outputpath, this, db, ui).flush();\r
+\r
+ Common.deleteDir(modulepath + File.separator + "temp");\r
+ //Common.toDoAll(modulepath + File.separator + "temp", Common.class.getMethod("deleteDir", String.class), null, null, Common.DIR);\r
\r
ui.println("Errors Left : " + db.error);\r
ui.println("Complete!");\r
\r
Pattern ptninclude = Pattern.compile("[\"<](.*[.]h)[\">]");\r
Matcher mtrinclude;\r
- \r
+\r
Iterator<String> ii = localmodulesources.iterator();\r
while ( ii.hasNext() ) {\r
curFile = ii.next();\r
// find guid\r
matguid = Guid.ptnguid.matcher(line); // several ways to implement this , which one is faster ? :\r
while (matguid.find()) { // 1.currently , find once , then call to identify which is it\r
- if ((temp = Guid.register(matguid, this, db)) != null) { // 2.use 3 different matchers , search 3 times to find each\r
+ if ((temp = Guid.register(matguid, this, db)) != null) { // 2.use 3 different matchers , search 3 times to find each\r
//matguid.appendReplacement(result, db.getR9Guidname(temp)); // search the database for all 3 kinds of guids , high cost\r
}\r
}\r
}\r
}\r
\r
- public static void main(String[] args) throws Exception {\r
- FirstPanel.init();\r
+ public final void enroll(String filepath) throws Exception {\r
+ String[] temp;\r
+ if (filepath.contains(".c") || filepath.contains(".C") || filepath.contains(".h") || \r
+ filepath.contains(".H") || filepath.contains(".dxs") || filepath.contains(".uni")) {\r
+ temp = filepath.split("\\\\");\r
+ localmodulesources.add(temp[temp.length - 1]);\r
+ } else if (filepath.contains(".inf") || filepath.contains(".msa")) {\r
+ temp = filepath.split("\\\\");\r
+ msaorinf.add(temp[temp.length - 1]);\r
+ }\r
+ }\r
+ \r
+ public static final void seekModule(String filepath) throws Exception {\r
+ if (isModule(filepath)) {\r
+ //System.out.println("I'm in");\r
+ new ModuleInfo(filepath);\r
+ }\r
+ }\r
+\r
+ private static final boolean isModule(String path) {\r
+ String[] list = new File(path).list();\r
+ for (int i = 0 ; i < list.length ; i++) {\r
+ if (!new File(list[i]).isDirectory()) {\r
+ if (list[i].contains(".inf") || list[i].contains(".msa")) {\r
+ return true;\r
+ }\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ public static final void main(String[] args) throws Exception {\r
+ ui = FirstPanel.init();\r
+ db = new Database();\r
}\r
}
\ No newline at end of file
import java.util.regex.*;\r
import org.tianocore.*;\r
\r
-public class ModuleReader {\r
+public final class ModuleReader {\r
ModuleReader(String path, ModuleInfo moduleinfo, Database database, UI u) {\r
- modulepath = path;\r
- mi = moduleinfo;\r
+ //modulepath = path;\r
+ //mi = moduleinfo;\r
db = database;\r
ui = u;\r
}\r
- private String modulepath;\r
- private ModuleInfo mi;\r
- private Database db;\r
- private UI ui;\r
+ //private static String modulepath;\r
+ //private static ModuleInfo mi;\r
+ private static Database db;\r
+ private static UI ui;\r
\r
- private static Pattern ptninfequation = Pattern.compile("([^\\s]*)\\s*=\\s*([^\\s]*)");\r
- private static Pattern ptnsection = Pattern.compile("\\[([^\\[\\]]*)\\]([^\\[\\]]*)\\n", Pattern.MULTILINE);\r
- private static Pattern ptnfilename = Pattern.compile("[^\\s]+");\r
+ private static final Pattern ptninfequation = Pattern.compile("([^\\s]*)\\s*=\\s*([^\\s]*)");\r
+ private static final Pattern ptnsection = Pattern.compile("\\[([^\\[\\]]*)\\]([^\\[\\]]*)\\n", Pattern.MULTILINE);\r
+ private static final Pattern ptnfilename = Pattern.compile("[^\\s]+");\r
\r
- public void readMsa(String name) throws Exception {\r
- ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.parse(new File(modulepath + File.separator + name));\r
+ public static final void readMsa(String name, ModuleInfo mi) throws Exception {\r
+ ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.parse(new File(mi.modulepath + File.separator + name));\r
ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = msadoc.getModuleSurfaceArea();\r
MsaHeaderDocument.MsaHeader msaheader = msa.getMsaHeader();\r
\r
}\r
}\r
\r
- public void readInf(String name) throws Exception {\r
+ public static final void readInf(String name, ModuleInfo mi) throws Exception {\r
System.out.println("\nParsing INF file: " + name);\r
String wholeline;\r
Matcher mtrinfequation;\r
Matcher mtrsection;\r
Matcher mtrfilename;\r
\r
- wholeline = Common.file2string(modulepath + File.separator + name);\r
+ wholeline = Common.file2string(mi.modulepath + File.separator + name);\r
mtrsection = ptnsection.matcher(wholeline);\r
while (mtrsection.find()) {\r
if (mtrsection.group(1).matches("defines")) {\r
import org.apache.xmlbeans.*;\r
\r
public class MsaWriter {\r
- MsaWriter(String path, ModuleInfo moduleinfo, Database database, UI u) {\r
+ MsaWriter(String path, String outpath, ModuleInfo moduleinfo, Database database, UI u) {\r
modulepath = path;\r
+ outputpath = outpath;\r
mi = moduleinfo;\r
db = database;\r
ui = u;\r
}\r
\r
private String modulepath;\r
+ private String outputpath;\r
private ModuleInfo mi;\r
private Database db;\r
private UI ui;\r
options.setSavePrettyPrintIndent(2);\r
options.setUseDefaultNamespace();\r
\r
- BufferedWriter bw = new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + mi.modulename + ".msa"));\r
+ BufferedWriter bw = new BufferedWriter(new FileWriter(outputpath + File.separator + "Migration_" + mi.modulename + File.separator + mi.modulename + ".msa"));\r
fulfillMsadoc().save(bw, options);\r
//MsaTreeEditor.init(mi, ui, msadoc);\r
bw.flush();\r
import java.util.regex.Matcher;\r
import java.util.regex.Pattern;\r
\r
-public class SourceFileReplacer {\r
- SourceFileReplacer(String path, ModuleInfo moduleinfo, Database database, UI fp) {\r
+public final class SourceFileReplacer {\r
+ SourceFileReplacer(String path, String outpath, ModuleInfo moduleinfo, Database database, UI fp) {\r
modulepath = path;\r
+ outputpath = outpath;\r
mi = moduleinfo;\r
db = database;\r
ui = fp;\r
}\r
private String modulepath;\r
+ private String outputpath;\r
private ModuleInfo mi;\r
private Database db;\r
private UI ui;\r
private Set<r8tor9> fileprotocol = new HashSet<r8tor9>();\r
private Set<String> filer8only = new HashSet<String>();\r
\r
- private String r8only = "EfiLibInstallDriverBinding " +\r
+ private static final String r8only = "EfiLibInstallDriverBinding " +\r
"EfiLibInstallAllDriverProtocols " +\r
"EfiLibCompareLanguage " +\r
"BufToHexString " +\r
"GetIoPortSpaceAddressHobInfo ";\r
\r
public void flush() throws Exception {\r
- PrintWriter outfile;\r
String outname = null;\r
String inname = null;\r
if (ui.yesOrNo("Changes will be made to the Source Code. View details?")) {\r
outname = inname;\r
}\r
ui.println("\nModifying file: " + inname);\r
- Common.string2file(sourcefilereplace(modulepath + File.separator + "temp" + File.separator + inname), modulepath + File.separator + "result" + File.separator + outname);\r
- /*\r
- Common.ensureDir(modulepath + File.separator + "result" + File.separator + outname);\r
- outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + outname)));\r
- outfile.append(sourcefilereplace(modulepath + File.separator + "temp" + File.separator + inname));\r
- outfile.flush();\r
- outfile.close();\r
- */\r
+ Common.string2file(sourcefilereplace(modulepath + File.separator + "temp" + File.separator + inname), 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
ui.println("\nCopying file: " + inname);\r
- Common.string2file(Common.file2string(modulepath + File.separator + "temp" + File.separator + inname), modulepath + File.separator + "result" + File.separator + outname);\r
- /*\r
- Common.ensureDir(modulepath + File.separator + "result" + File.separator + outname);\r
- outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + outname)));\r
- outfile.append(Common.file2string(modulepath + File.separator + "temp" + File.separator + inname));\r
- outfile.flush();\r
- outfile.close();\r
- */\r
+ Common.string2file(Common.file2string(modulepath + File.separator + "temp" + File.separator + inname), outputpath + File.separator + "Migration_" + mi.modulename + File.separator + outname);\r
}\r
}\r
\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(modulepath + File.separator + "result" + File.separator + "R8Lib.c")));\r
- PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + "R8Lib.h")));\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
Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL);\r
Matcher mtrr8only = ptnr8only.matcher(line);\r
Matcher mtrr8onlyhead;\r
public String choose(String message, Object[] choicelist);\r
\r
public String getInput(String message);\r
+ \r
+ public String getFilepath(); // necessary ?\r
}\r