diff options
author | alfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-08-22 07:39:14 +0000 |
---|---|---|
committer | alfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-08-22 07:39:14 +0000 |
commit | eee63a7bcad36a2100adb951a2f04ff18a415240 (patch) | |
tree | 0e52cda2888a4f6c60b6f430fd08b74c705c2dda /Tools | |
parent | a61513d6f94b0fb4d5498609cbaef60c324858ba (diff) | |
download | edk2-eee63a7bcad36a2100adb951a2f04ff18a415240.zip edk2-eee63a7bcad36a2100adb951a2f04ff18a415240.tar.gz edk2-eee63a7bcad36a2100adb951a2f04ff18a415240.tar.bz2 |
r8lib in database
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1349 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools')
5 files changed, 72 insertions, 75 deletions
diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java b/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java index 5747a42..28bfd08 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/Critic.java @@ -15,13 +15,13 @@ package org.tianocore.migration; import java.util.regex.*;
import java.io.*;
-public class Critic {
- private static Pattern ptnheadcomment = Pattern.compile("^\\/\\*\\+\\+(.*?)\\-\\-\\*\\/",Pattern.DOTALL);
- private static Pattern ptnfunccomment = Pattern.compile("([\\};\\/\">]\\s*)([\\w\\s]*?[_\\w][_\\w\\d]*\\s*\\([^\\)\\(]*\\)\\s*)\\/\\*\\+\\+(.*?)\\-\\-\\*\\/(\\s*.*?)([\\{;])",Pattern.DOTALL); // find function with {;">/ , may be unsafe
+public final class Critic {
+ private static final Pattern ptnheadcomment = Pattern.compile("^\\/\\*\\+\\+(.*?)\\-\\-\\*\\/",Pattern.DOTALL);
+ private static final Pattern ptnfunccomment = Pattern.compile("([\\};\\/\">]\\s*)([\\w\\s]*?[_\\w][_\\w\\d]*\\s*\\([^\\)\\(]*\\)\\s*)\\/\\*\\+\\+(.*?)\\-\\-\\*\\/(\\s*.*?)([\\{;])",Pattern.DOTALL); // find function with {;">/ , may be unsafe
//private static Pattern ptncommentstructure = Pattern.compile("\\/\\*\\+\\+\\s*Routine Description:\\s*(.*?)\\s*Arguments:\\s*(.*?)\\s*Returns:\\s*(.*?)\\s*\\-\\-\\*\\/",Pattern.DOTALL);
- private static Pattern ptncommentequation = Pattern.compile("([^\\s]*)\\s+-\\s+(.*)\\s*");
+ private static final Pattern ptncommentequation = Pattern.compile("([^\\s]*)\\s+-\\s+(.*)\\s*");
private static Matcher mtrcommentequation;
- private static Pattern ptnnewcomment = Pattern.compile("(\\s*@(param|retval)\\s+[^\\s]+)\\s+(.*)");
+ private static final Pattern ptnnewcomment = Pattern.compile("(\\s*@(param|retval)\\s+[^\\s]+)\\s+(.*)");
private static Matcher mtrnewcomment;
private static final int totallinelength = 82;
diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/Database.java b/Tools/Source/MigrationTools/org/tianocore/migration/Database.java index a4b0d47..8b088c9 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/Database.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/Database.java @@ -14,6 +14,7 @@ package org.tianocore.migration; import java.io.*;
import java.util.*;
+import java.util.regex.*;
public final class Database {
Database(String path) throws Exception {
@@ -24,17 +25,19 @@ public final class Database { importDBGuid("Ppi.csv", "Ppi");
importDBGuid("Protocol.csv", "Protocol");
importDBMacro("Macro.csv");
+ importListR8Only();
}
- public static String defaultpath = "C:" + File.separator + "tianocore" + File.separator + "edk2" + File.separator + "Tools" + File.separator + "Conf" + File.separator + "Migration";
-
public String DatabasePath;
public Set<String> error = new HashSet<String>();
+ public Set<String> r8only = new HashSet<String>();
private Map<String,Guid> hashguid = new HashMap<String,Guid>();
private Map<String,Func> hashfunc = new HashMap<String,Func>();
private Map<String,Macro> hashmacro = new HashMap<String,Macro>();
+ //-------------------------------------import------------------------------------------//
+
private void importDBLib(String filename) throws Exception {
BufferedReader rd = new BufferedReader(new FileReader(DatabasePath + File.separator + filename));
String line;
@@ -88,7 +91,21 @@ public final class Database { }
}
}
+
+ private void importListR8Only() throws Exception {
+ Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(.*?)\\s*\\(.*?////~", Pattern.DOTALL);
+ String wholeline = Common.file2string(DatabasePath + File.separator + "R8Lib.c");
+ System.out.println("Found " + "R8Lib.c" + ", Importing R8Lib Database.");
+ Matcher mtrr8only = ptnr8only.matcher(wholeline);
+ while (mtrr8only.find()) {
+ r8only.add(mtrr8only.group(2));
+ }
+ }
+ //-------------------------------------import------------------------------------------//
+
+ //-------------------------------------get------------------------------------------//
+
public String getR9Lib(String r8funcname) {
String temp = null;
if (hashfunc.containsKey(r8funcname)) {
@@ -105,18 +122,6 @@ public final class Database { return temp;
}
- public boolean hasFunc(String r8lib) {
- return hashfunc.containsKey(r8lib);
- }
-
- public boolean hasGuid(String r8guid) {
- return hashguid.containsKey(r8guid);
- }
-
- public boolean hasMacro(String r8macro) {
- return hashmacro.containsKey(r8macro);
- }
-
public String getR9Macro(String r8macro) {
return hashmacro.get(r8macro).r9name; // the verification job of if the macro exists in the database is done when registering it
}
@@ -141,6 +146,26 @@ public final class Database { return temp;
}
+ //-------------------------------------get------------------------------------------//
+
+ //-------------------------------------has------------------------------------------//
+
+ public boolean hasFunc(String r8lib) {
+ return hashfunc.containsKey(r8lib);
+ }
+
+ public boolean hasGuid(String r8guid) {
+ return hashguid.containsKey(r8guid);
+ }
+
+ public boolean hasMacro(String r8macro) {
+ return hashmacro.containsKey(r8macro);
+ }
+
+ //-------------------------------------has------------------------------------------//
+
+ //-------------------------------------init------------------------------------------//
+
public static Database init() throws Exception {
if (System.getenv("WORKSPACE") == null) {
return new Database("C:" + File.separator + "tianocore" + File.separator + "edk2" + File.separator + "Tools" + File.separator + "Conf" + File.separator + "Migration");
diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java b/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java index 5502cbb..4d59a9e 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java @@ -83,7 +83,7 @@ public class ModuleInfo { CommentOutNonLocalHFile();
parsePreProcessedSourceCode();
- new SourceFileReplacer(modulepath, outputpath, this).flush(); // some adding library actions are taken here,so it must be put before "MsaWriter"
+ SourceFileReplacer.flush(this); // some adding library actions are taken here,so it must be put before "MsaWriter"
// show result
if (MigrationTool.ui.yesOrNo("Parse of the Module Information has completed. View details?")) {
@@ -100,7 +100,7 @@ public class ModuleInfo { show(hashr8only, "hashr8only : ");
}
- new MsaWriter(modulepath, outputpath, this).flush();
+ new MsaWriter(this).flush();
Common.deleteDir(modulepath + File.separator + "temp");
//Common.toDoAll(modulepath + File.separator + "temp", Common.class.getMethod("deleteDir", String.class), null, null, Common.DIR);
diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/MsaWriter.java b/Tools/Source/MigrationTools/org/tianocore/migration/MsaWriter.java index f798433..cf4426d 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/MsaWriter.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/MsaWriter.java @@ -20,14 +20,10 @@ import org.tianocore.SupportedArchitectures.Enum; import org.apache.xmlbeans.*;
public class MsaWriter {
- MsaWriter(String path, String outpath, ModuleInfo moduleinfo) {
- modulepath = path;
- outputpath = outpath;
+ MsaWriter(ModuleInfo moduleinfo) {
mi = moduleinfo;
}
- private String modulepath;
- private String outputpath;
private ModuleInfo mi;
private ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.newInstance();
@@ -185,7 +181,7 @@ public class MsaWriter { options.setSavePrettyPrintIndent(2);
options.setUseDefaultNamespace();
- BufferedWriter bw = new BufferedWriter(new FileWriter(outputpath + File.separator + "Migration_" + mi.modulename + File.separator + mi.modulename + ".msa"));
+ BufferedWriter bw = new BufferedWriter(new FileWriter(mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + mi.modulename + ".msa"));
fulfillMsadoc().save(bw, options);
//MsaTreeEditor.init(mi, ui, msadoc);
bw.flush();
diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java b/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java index bc579ac..868509a 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java @@ -18,17 +18,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern;
public final class SourceFileReplacer {
- SourceFileReplacer(String path, String outpath, ModuleInfo moduleinfo) {
- modulepath = path;
- outputpath = outpath;
- mi = moduleinfo;
- }
- private String modulepath;
- private String outputpath;
- private ModuleInfo mi;
- private boolean showdetails = false;
+ private static ModuleInfo mi;
+ private static boolean showdetails = false;
- private class r8tor9 {
+ private static class r8tor9 {
r8tor9(String r8, String r9) {
r8thing = r8;
r9thing = r9;
@@ -38,34 +31,17 @@ public final class SourceFileReplacer { }
// these sets are used only for printing log of the changes in current file
- private Set<r8tor9> filefunc = new HashSet<r8tor9>();
- private Set<r8tor9> filemacro = new HashSet<r8tor9>();
- private Set<r8tor9> fileguid = new HashSet<r8tor9>();
- private Set<r8tor9> fileppi = new HashSet<r8tor9>();
- private Set<r8tor9> fileprotocol = new HashSet<r8tor9>();
- private Set<String> filer8only = new HashSet<String>();
-
- private static final String r8only = "EfiLibInstallDriverBinding " +
- "EfiLibInstallAllDriverProtocols " +
- "EfiLibCompareLanguage " +
- "BufToHexString " +
- "EfiStrTrim " + //is the r8only lib going to be enlarged???? Caution !!!!
- "EfiValueToHexStr " +
- "HexStringToBuf " +
- "IsHexDigit " +
- "NibbleToHexChar " +
- "GetHob " +
- "GetHobListSize " +
- "GetHobVersion " +
- "GetHobBootMode " +
- "GetCpuHobInfo " +
- "GetDxeCoreHobInfo " +
- "GetNextFirmwareVolumeHob " +
- "GetNextGuidHob " +
- "GetPalEntryHobInfo " +
- "GetIoPortSpaceAddressHobInfo ";
+ private static final Set<r8tor9> filefunc = new HashSet<r8tor9>();
+ private static final Set<r8tor9> filemacro = new HashSet<r8tor9>();
+ private static final Set<r8tor9> fileguid = new HashSet<r8tor9>();
+ private static final Set<r8tor9> fileppi = new HashSet<r8tor9>();
+ private static final Set<r8tor9> fileprotocol = new HashSet<r8tor9>();
+ private static final Set<String> filer8only = new HashSet<String>();
- public void flush() throws Exception {
+ public static final void flush(ModuleInfo moduleinfo) throws Exception {
+
+ mi = moduleinfo;
+
String outname = null;
String inname = null;
if (MigrationTool.ui.yesOrNo("Changes will be made to the Source Code. View details?")) {
@@ -82,7 +58,7 @@ public final class SourceFileReplacer { outname = inname;
}
MigrationTool.ui.println("\nModifying file: " + inname);
- Common.string2file(sourcefilereplace(modulepath + File.separator + "temp" + File.separator + inname), outputpath + File.separator + "Migration_" + mi.modulename + File.separator + outname);
+ Common.string2file(sourcefilereplace(mi.modulepath + File.separator + "temp" + File.separator + inname), mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + outname);
} else if (inname.contains(".h") || inname.contains(".H") || inname.contains(".dxs") || inname.contains(".uni")) {
if (inname.contains(".H")) {
outname = inname.replaceFirst(".H", ".h");
@@ -90,7 +66,7 @@ public final class SourceFileReplacer { outname = inname;
}
MigrationTool.ui.println("\nCopying file: " + inname);
- Common.string2file(Common.file2string(modulepath + File.separator + "temp" + File.separator + inname), outputpath + File.separator + "Migration_" + mi.modulename + File.separator + outname);
+ Common.string2file(Common.file2string(mi.modulepath + File.separator + "temp" + File.separator + inname), mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + outname);
}
}
@@ -99,12 +75,12 @@ public final class SourceFileReplacer { }
}
- private void addr8only() throws Exception {
+ private static final void addr8only() throws Exception {
String paragraph = null;
- String line = Common.file2string(Database.defaultpath + File.separator + "R8Lib.c");
- Common.ensureDir(modulepath + File.separator + "result" + File.separator + "R8Lib.c");
- PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(outputpath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c")));
- PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(outputpath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.h")));
+ String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");
+ Common.ensureDir(mi.modulepath + File.separator + "result" + File.separator + "R8Lib.c");
+ PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c")));
+ PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(mi.outputpath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.h")));
Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL);
Matcher mtrr8only = ptnr8only.matcher(line);
Matcher mtrr8onlyhead;
@@ -132,7 +108,7 @@ public final class SourceFileReplacer { }
// Caution : if there is @ in file , it will be replaced with \n , so is you use Doxygen ... God Bless you!
- private String sourcefilereplace(String filename) throws Exception {
+ private static final String sourcefilereplace(String filename) throws Exception {
BufferedReader rd = new BufferedReader(new FileReader(filename));
StringBuffer wholefile = new StringBuffer();
String line;
@@ -198,7 +174,7 @@ public final class SourceFileReplacer { Iterator<r8tor9> rt = filefunc.iterator();
while (rt.hasNext()) {
temp = rt.next();
- if (r8only.contains(temp.r8thing)) {
+ if (MigrationTool.db.r8only.contains(temp.r8thing)) {
filer8only.add(r8thing);
mi.hashr8only.add(r8thing);
addr8 = true;
@@ -297,7 +273,7 @@ public final class SourceFileReplacer { return line;
}
- private void show(Set<r8tor9> hash, String sh) {
+ private static final void show(Set<r8tor9> hash, String sh) {
Iterator<r8tor9> it = hash.iterator();
r8tor9 temp;
if (showdetails) {
@@ -312,7 +288,7 @@ public final class SourceFileReplacer { }
}
- private void replaceGuid(String line, Set<String> hash, String kind, Set<r8tor9> filehash) {
+ private static final void replaceGuid(String line, Set<String> hash, String kind, Set<r8tor9> filehash) {
Iterator<String> it;
String r8thing;
String r9thing;
|