Database singleton
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1862 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -31,7 +31,7 @@ import org.tianocore.LibraryClassDeclarationsDocument.LibraryClassDeclarations;
|
|||||||
import org.tianocore.LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass;
|
import org.tianocore.LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass;
|
||||||
|
|
||||||
public final class Database {
|
public final class Database {
|
||||||
private static final Database INSTANCE = null;
|
private static final Database INSTANCE = Database.init();;
|
||||||
|
|
||||||
Database(String path) {
|
Database(String path) {
|
||||||
DatabasePath = path;
|
DatabasePath = path;
|
||||||
@ -220,41 +220,38 @@ public final class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final Database getInstance() {
|
public static final Database getInstance() {
|
||||||
if (INSTANCE == null) {
|
|
||||||
Database.init();
|
|
||||||
}
|
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static String workspacePath;
|
private String workspacePath;
|
||||||
private static HashMap<String, String> hashDbGuids = new HashMap<String, String>();
|
private HashMap<String, String> hashDbGuids = new HashMap<String, String>();
|
||||||
private static HashMap<String, String> hashDbPpis = new HashMap<String, String>();
|
private HashMap<String, String> hashDbPpis = new HashMap<String, String>();
|
||||||
private static HashMap<String, String> hashDbProtocols = new HashMap<String, String>();
|
private HashMap<String, String> hashDbProtocols = new HashMap<String, String>();
|
||||||
private static HashMap<String, String> hashDbLibSymbols = new HashMap<String, String>();
|
private HashMap<String, String> hashDbLibSymbols = new HashMap<String, String>();
|
||||||
private static HashMap<String, String> hashDbLibFunctions = new HashMap<String, String>();
|
private HashMap<String, String> hashDbLibFunctions = new HashMap<String, String>();
|
||||||
private static HashMap<String, String> hashDbLibExterns = new HashMap<String, String>();
|
private HashMap<String, String> hashDbLibExterns = new HashMap<String, String>();
|
||||||
|
|
||||||
private static final String regLibClassName = ".*\\W(\\w[\\w\\d]*)\\.h";
|
private final String regLibClassName = ".*\\W(\\w[\\w\\d]*)\\.h";
|
||||||
private static final Pattern ptnLibClassName = Pattern.compile(regLibClassName);
|
private final Pattern ptnLibClassName = Pattern.compile(regLibClassName);
|
||||||
|
|
||||||
private static final String regLibSymbol = "#define\\s+(\\w[\\w\\d]*)";
|
private final String regLibSymbol = "#define\\s+(\\w[\\w\\d]*)";
|
||||||
private static final Pattern ptnLibSymbol = Pattern.compile(regLibSymbol);
|
private final Pattern ptnLibSymbol = Pattern.compile(regLibSymbol);
|
||||||
|
|
||||||
private static final String regLibDataType = "[A-Z][A-Z0-9_]*\\s*\\**";
|
private final String regLibDataType = "[A-Z][A-Z0-9_]*\\s*\\**";
|
||||||
private static final String regLibFunction = regLibDataType + "\\s*(?:EFIAPI)?\\s+" +
|
private final String regLibFunction = regLibDataType + "\\s*(?:EFIAPI)?\\s+" +
|
||||||
"(\\w[\\w\\d]*)\\s*\\([^)]*\\)\\s*;";
|
"(\\w[\\w\\d]*)\\s*\\([^)]*\\)\\s*;";
|
||||||
private static final Pattern ptnLibFunction = Pattern.compile(regLibFunction);
|
private Pattern ptnLibFunction = Pattern.compile(regLibFunction);
|
||||||
|
|
||||||
private static final String regLibExtern = "extern\\s+" + regLibDataType +
|
private final String regLibExtern = "extern\\s+" + regLibDataType +
|
||||||
"\\s*(\\w[\\w\\d]*)";
|
"\\s*(\\w[\\w\\d]*)";
|
||||||
private static final Pattern ptnLibExtern = Pattern.compile(regLibExtern);
|
private final Pattern ptnLibExtern = Pattern.compile(regLibExtern);
|
||||||
|
|
||||||
private static final String convertToOsFilePath(String filePath) {
|
private final String convertToOsFilePath(String filePath) {
|
||||||
return filePath.replace("/", File.separator).replace("\\", File.separator);
|
return filePath.replace("/", File.separator).replace("\\", File.separator);
|
||||||
}
|
}
|
||||||
private static final void collectLibHeaderFileInfo(String libHeaderFile, String pkgGuid) throws Exception {
|
private final void collectLibHeaderFileInfo(String libHeaderFile, String pkgGuid) throws Exception {
|
||||||
String fileContents;
|
String fileContents;
|
||||||
String libClassName;
|
String libClassName;
|
||||||
String libContainer;
|
String libContainer;
|
||||||
@ -320,7 +317,7 @@ public final class Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static final void collectLibDataBase(PackageSurfaceArea spdDatabase, String pkgDirectory) throws Exception {
|
private final void collectLibDataBase(PackageSurfaceArea spdDatabase, String pkgDirectory) throws Exception {
|
||||||
String pkgGuid;
|
String pkgGuid;
|
||||||
LibraryClassDeclarations libClassDeclarations;
|
LibraryClassDeclarations libClassDeclarations;
|
||||||
|
|
||||||
@ -348,7 +345,7 @@ public final class Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static final void collectGuidDatabase(PackageSurfaceArea spdDatabase) throws Exception {
|
private final void collectGuidDatabase(PackageSurfaceArea spdDatabase) throws Exception {
|
||||||
String pkgGuid;
|
String pkgGuid;
|
||||||
GuidDeclarations guidDeclarations;
|
GuidDeclarations guidDeclarations;
|
||||||
|
|
||||||
@ -365,7 +362,7 @@ public final class Database {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final void collectPpiDatabase(PackageSurfaceArea spdDatabase) throws Exception {
|
private final void collectPpiDatabase(PackageSurfaceArea spdDatabase) throws Exception {
|
||||||
String pkgGuid;
|
String pkgGuid;
|
||||||
PpiDeclarations ppiDeclarations;
|
PpiDeclarations ppiDeclarations;
|
||||||
|
|
||||||
@ -383,7 +380,7 @@ public final class Database {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final void collectProtocolDatabase(PackageSurfaceArea spdDatabase) throws Exception {
|
private final void collectProtocolDatabase(PackageSurfaceArea spdDatabase) throws Exception {
|
||||||
String pkgGuid;
|
String pkgGuid;
|
||||||
ProtocolDeclarations protocolDeclarations;
|
ProtocolDeclarations protocolDeclarations;
|
||||||
|
|
||||||
@ -401,7 +398,7 @@ public final class Database {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final void collectPackageDatabase(String packageFileName) throws Exception {
|
private final void collectPackageDatabase(String packageFileName) throws Exception {
|
||||||
XmlObject xmlPackage;
|
XmlObject xmlPackage;
|
||||||
PackageSurfaceArea spdDatabase;
|
PackageSurfaceArea spdDatabase;
|
||||||
File pkgFile;
|
File pkgFile;
|
||||||
@ -417,7 +414,7 @@ public final class Database {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public static final void collectWorkSpaceDatabase() throws Exception {
|
public final void collectWorkSpaceDatabase() throws Exception {
|
||||||
String databaseFileName;
|
String databaseFileName;
|
||||||
File databaseFile;
|
File databaseFile;
|
||||||
XmlObject xmlDatabase;
|
XmlObject xmlDatabase;
|
||||||
|
Reference in New Issue
Block a user