X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FMigrationTools%2Forg%2Ftianocore%2Fmigration%2FDatabase.java;fp=Tools%2FSource%2FMigrationTools%2Forg%2Ftianocore%2Fmigration%2FDatabase.java;h=68ddf40b3060a77380445cc722bddfa8854ce321;hp=c986d3b59bb8d853a9dfb571e6ccd689ca0702a4;hb=27e0221a8578226815bf0d7f3606dc6136c90de4;hpb=7242606411f2b8e74e0bd7dd16c62824ebfef815 diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/Database.java b/Tools/Source/MigrationTools/org/tianocore/migration/Database.java index c986d3b59b..68ddf40b30 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/Database.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/Database.java @@ -17,170 +17,170 @@ import java.util.*; import java.util.regex.*; public final class Database { - private static final Database INSTANCE = Database.init(); - - Database(String path) { - DatabasePath = path; + private static final Database INSTANCE = Database.init(); + + Database(String path) { + DatabasePath = path; - try { - importDBLib("Library.csv"); - importDBGuid("Guid.csv", "Guid"); - importDBGuid("Ppi.csv", "Ppi"); - importDBGuid("Protocol.csv", "Protocol"); - importDBMacro("Macro.csv"); - importListR8Only(); - } catch (Exception e) { - System.out.println(e.getMessage()); - } - } - - public String DatabasePath; - public Set error = new HashSet(); - public Set r8only = new HashSet(); - - private Map hashguid = new HashMap(); - private Map hashfunc = new HashMap(); - private Map hashmacro = new HashMap(); - - //-------------------------------------import------------------------------------------// - - private void importDBLib(String filename) throws Exception { - BufferedReader rd = new BufferedReader(new FileReader(DatabasePath + File.separator + filename)); - String line; - String[] linecontext; - Func lf; - - if (rd.ready()) { - System.out.println("Found " + filename + ", Importing Library Database."); - while ((line = rd.readLine()) != null) { - if (line.length() != 0) { - linecontext = line.split(","); - lf = new Func(linecontext); - hashfunc.put(lf.r8funcname,lf); - } - } - } - } - - private void importDBGuid(String filename, String type) throws Exception { - BufferedReader rd = new BufferedReader(new FileReader(DatabasePath + File.separator + filename)); - String line; - String[] linecontext; - Guid gu; - - if (rd.ready()) { - System.out.println("Found " + filename + ", Importing " + type + " Database."); - while ((line = rd.readLine()) != null) { - if (line.length() != 0) { - linecontext = line.split(","); - gu = new Guid(linecontext, type); - hashguid.put(gu.r8name,gu); - } - } - } - } - - private void importDBMacro(String filename) throws Exception { - BufferedReader rd = new BufferedReader(new FileReader(DatabasePath + File.separator + filename)); - String line; - String[] linecontext; - Macro mc; - - if (rd.ready()) { - System.out.println("Found " + filename + ", Importing Macro Database."); - while ((line = rd.readLine()) != null) { - if (line.length() != 0) { - linecontext = line.split(","); - mc = new Macro(linecontext); - hashmacro.put(mc.r8name,mc); - } - } - } - } + try { + importDBLib("Library.csv"); + importDBGuid("Guid.csv", "Guid"); + importDBGuid("Ppi.csv", "Ppi"); + importDBGuid("Protocol.csv", "Protocol"); + importDBMacro("Macro.csv"); + importListR8Only(); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + } + + public String DatabasePath; + public Set error = new HashSet(); + public Set r8only = new HashSet(); + + private Map hashguid = new HashMap(); + private Map hashfunc = new HashMap(); + private Map hashmacro = new HashMap(); + + //-------------------------------------import------------------------------------------// + + private void importDBLib(String filename) throws Exception { + BufferedReader rd = new BufferedReader(new FileReader(DatabasePath + File.separator + filename)); + String line; + String[] linecontext; + Func lf; + + if (rd.ready()) { + System.out.println("Found " + filename + ", Importing Library Database."); + while ((line = rd.readLine()) != null) { + if (line.length() != 0) { + linecontext = line.split(","); + lf = new Func(linecontext); + hashfunc.put(lf.r8funcname,lf); + } + } + } + } + + private void importDBGuid(String filename, String type) throws Exception { + BufferedReader rd = new BufferedReader(new FileReader(DatabasePath + File.separator + filename)); + String line; + String[] linecontext; + Guid gu; + + if (rd.ready()) { + System.out.println("Found " + filename + ", Importing " + type + " Database."); + while ((line = rd.readLine()) != null) { + if (line.length() != 0) { + linecontext = line.split(","); + gu = new Guid(linecontext, type); + hashguid.put(gu.r8name,gu); + } + } + } + } + + private void importDBMacro(String filename) throws Exception { + BufferedReader rd = new BufferedReader(new FileReader(DatabasePath + File.separator + filename)); + String line; + String[] linecontext; + Macro mc; + + if (rd.ready()) { + System.out.println("Found " + filename + ", Importing Macro Database."); + while ((line = rd.readLine()) != null) { + if (line.length() != 0) { + linecontext = line.split(","); + mc = new Macro(linecontext); + hashmacro.put(mc.r8name,mc); + } + } + } + } - 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------------------------------------------// + 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------------------------------------------// + //-------------------------------------get------------------------------------------// - public String getR9Lib(String r8funcname) { - String temp = null; - if (hashfunc.containsKey(r8funcname)) { - temp = hashfunc.get(r8funcname).r9libname; - } - return temp; - } - - public String getR9Func(String r8funcname) { - String temp = null; - if (hashfunc.containsKey(r8funcname)) { - temp = hashfunc.get(r8funcname).r9funcname; - } - return temp; - } - - 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 - } + public String getR9Lib(String r8funcname) { + String temp = null; + if (hashfunc.containsKey(r8funcname)) { + temp = hashfunc.get(r8funcname).r9libname; + } + return temp; + } + + public String getR9Func(String r8funcname) { + String temp = null; + if (hashfunc.containsKey(r8funcname)) { + temp = hashfunc.get(r8funcname).r9funcname; + } + return temp; + } + + 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 + } - public String getR9Guidname(String r8Guid) { - String temp = null; - try { - temp = hashguid.get(r8Guid).r9name; - } catch (NullPointerException e) { - error.add("getR9Guidname :" + r8Guid); - } - return temp; - } + public String getR9Guidname(String r8Guid) { + String temp = null; + try { + temp = hashguid.get(r8Guid).r9name; + } catch (NullPointerException e) { + error.add("getR9Guidname :" + r8Guid); + } + return temp; + } - public String getGuidType(String r8Guid) { - String temp = null; - try { - temp = hashguid.get(r8Guid).type; - } catch (NullPointerException e) { - error.add("getR9Guidname :" + r8Guid); - } - return temp; - } + public String getGuidType(String r8Guid) { + String temp = null; + try { + temp = hashguid.get(r8Guid).type; + } catch (NullPointerException e) { + error.add("getR9Guidname :" + r8Guid); + } + return temp; + } - //-------------------------------------get------------------------------------------// + //-------------------------------------get------------------------------------------// - //-------------------------------------has------------------------------------------// + //-------------------------------------has------------------------------------------// - public boolean hasFunc(String r8lib) { - return hashfunc.containsKey(r8lib); - } + public boolean hasFunc(String r8lib) { + return hashfunc.containsKey(r8lib); + } - public boolean hasGuid(String r8guid) { - return hashguid.containsKey(r8guid); - } + public boolean hasGuid(String r8guid) { + return hashguid.containsKey(r8guid); + } - public boolean hasMacro(String r8macro) { - return hashmacro.containsKey(r8macro); - } - - //-------------------------------------has------------------------------------------// - - //-------------------------------------init------------------------------------------// + public boolean hasMacro(String r8macro) { + return hashmacro.containsKey(r8macro); + } + + //-------------------------------------has------------------------------------------// + + //-------------------------------------init------------------------------------------// - private static final Database init() { - if (System.getenv("WORKSPACE") == null) { - return new Database("C:" + File.separator + "tianocore" + File.separator + "edk2" + File.separator + "Tools" + File.separator + "Conf" + File.separator + "Migration"); - } else { - return new Database(System.getenv("WORKSPACE") + File.separator + "Tools" + File.separator + "Conf" + File.separator + "Migration"); - } - } - - public static final Database getInstance() { - return INSTANCE; - } + private static final Database init() { + if (System.getenv("WORKSPACE") == null) { + return new Database("C:" + File.separator + "tianocore" + File.separator + "edk2" + File.separator + "Tools" + File.separator + "Conf" + File.separator + "Migration"); + } else { + return new Database(System.getenv("WORKSPACE") + File.separator + "Tools" + File.separator + "Conf" + File.separator + "Migration"); + } + } + + public static final Database getInstance() { + return INSTANCE; + } }