From 32648c62db4a98cdc7d16cd3d53dc3c76dd1e110 Mon Sep 17 00:00:00 2001 From: qwang12 Date: Fri, 26 May 2006 02:05:28 +0000 Subject: [PATCH] Replace all tab to spaces. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@287 6f19259b-4bc3-4df7-8a09-765794883524 --- .../build/pcd/action/CollectPCDAction.java | 1364 ++++++++--------- .../build/pcd/action/PCDAutoGenAction.java | 26 +- .../pcd/entity/MemoryDatabaseManager.java | 28 +- .../org/tianocore/build/pcd/entity/Token.java | 42 +- 4 files changed, 730 insertions(+), 730 deletions(-) diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java index da9880161c..6cc73ff228 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java +++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java @@ -48,19 +48,19 @@ import org.tianocore.build.pcd.exception.EntityException; class StringTable { private ArrayList al; - private ArrayList alComments; + private ArrayList alComments; private String phase; int len; - int bodyStart; - int bodyLineNum; + int bodyStart; + int bodyLineNum; public StringTable (String phase) { this.phase = phase; al = new ArrayList(); - alComments = new ArrayList(); + alComments = new ArrayList(); len = 0; - bodyStart = 0; - bodyLineNum = 0; + bodyStart = 0; + bodyLineNum = 0; } public String getSizeMacro () { @@ -68,15 +68,15 @@ class StringTable { } private int getSize () { - // - // We have at least one Unicode Character in the table. - // + // + // We have at least one Unicode Character in the table. + // return len == 0 ? 1 : len; } - public int getTableLen () { - return al.size() == 0 ? 1 : al.size(); - } + public int getTableLen () { + return al.size() == 0 ? 1 : al.size(); + } public String getExistanceMacro () { return String.format(PcdDatabase.StringTableExistenceMacro, phase, (al.size() == 0)? "TRUE":"FALSE"); @@ -84,53 +84,53 @@ class StringTable { public String getTypeDeclaration () { - String output; + String output; - final String stringTable = "StringTable"; - final String tab = "\t"; - final String newLine = ";\r\n"; + final String stringTable = "StringTable"; + final String tab = "\t"; + final String newLine = ";\r\n"; - output = "/* StringTable */\r\n"; + output = "/* StringTable */\r\n"; - if (al.size() == 0) { - output += tab + String.format("UINT16 %s[1] /* StringTable is Empty */", stringTable) + newLine; - } + if (al.size() == 0) { + output += tab + String.format("UINT16 %s[1] /* StringTable is Empty */", stringTable) + newLine; + } - for (int i = 0; i < al.size(); i++) { - String str = al.get(i); + for (int i = 0; i < al.size(); i++) { + String str = al.get(i); - if (i == 0) { - // - // StringTable is a well-known name in the PCD DXE driver - // - output += tab + String.format("UINT16 %s[%d] /* %s */", stringTable, str.length() + 1, alComments.get(i)) + newLine; - } else { - output += tab + String.format("UINT16 %s_%d[%d] /* %s */", stringTable, i, str.length() + 1, alComments.get(i)) + newLine; - } - } + if (i == 0) { + // + // StringTable is a well-known name in the PCD DXE driver + // + output += tab + String.format("UINT16 %s[%d] /* %s */", stringTable, str.length() + 1, alComments.get(i)) + newLine; + } else { + output += tab + String.format("UINT16 %s_%d[%d] /* %s */", stringTable, i, str.length() + 1, alComments.get(i)) + newLine; + } + } - return output; + return output; } public ArrayList getInstantiation () { - ArrayList output = new ArrayList(); + ArrayList output = new ArrayList(); - output.add("/* StringTable */"); + output.add("/* StringTable */"); - if (al.size() == 0) { - output.add("{ 0 }"); - } else { - String str; + if (al.size() == 0) { + output.add("{ 0 }"); + } else { + String str; - for (int i = 0; i < al.size(); i++) { - str = String.format("L\"%s\" /* %s */", al.get(i), alComments.get(i)); - if (i != al.size() - 1) { - str += ","; - } - output.add(str); - } - } + for (int i = 0; i < al.size(); i++) { + str = String.format("L\"%s\" /* %s */", al.get(i), alComments.get(i)); + if (i != al.size() - 1) { + str += ","; + } + output.add(str); + } + } return output; } @@ -144,7 +144,7 @@ class StringTable { // len += str.length() + 1; al.add(str); - alComments.add(token.getPrimaryKeyString()); + alComments.add(token.getPrimaryKeyString()); return i; } @@ -152,19 +152,19 @@ class StringTable { class SizeTable { private ArrayList al; - private ArrayList alComments; + private ArrayList alComments; private String phase; private int len; - private int bodyStart; - private int bodyLineNum; + private int bodyStart; + private int bodyLineNum; public SizeTable (String phase) { this.phase = phase; al = new ArrayList(); - alComments = new ArrayList(); + alComments = new ArrayList(); len = 0; - bodyStart = 0; - bodyLineNum = 0; + bodyStart = 0; + bodyLineNum = 0; } public String getTypeDeclaration () { @@ -172,85 +172,85 @@ class SizeTable { } public ArrayList getInstantiation () { - ArrayList Output = new ArrayList(); + ArrayList Output = new ArrayList(); Output.add("/* SizeTable */"); Output.add("{"); - bodyStart = 2; + bodyStart = 2; - if (al.size() == 0) { - Output.add("0"); - } else { - for (int index = 0; index < al.size(); index++) { - Integer n = al.get(index); - String str = n.toString(); + if (al.size() == 0) { + Output.add("0"); + } else { + for (int index = 0; index < al.size(); index++) { + Integer n = al.get(index); + String str = n.toString(); - if (index != (al.size() - 1)) { - str += ","; - } + if (index != (al.size() - 1)) { + str += ","; + } - str += " /* " + alComments.get(index) + " */"; - Output.add(str); - bodyLineNum++; - - } - } - Output.add("}"); + str += " /* " + alComments.get(index) + " */"; + Output.add(str); + bodyLineNum++; + + } + } + Output.add("}"); return Output; } - public int getBodyStart() { - return bodyStart; - } + public int getBodyStart() { + return bodyStart; + } - public int getBodyLineNum () { - return bodyLineNum; - } + public int getBodyLineNum () { + return bodyLineNum; + } public int add (Token token) { int index = len; len++; al.add(token.datumSize); - alComments.add(token.getPrimaryKeyString()); + alComments.add(token.getPrimaryKeyString()); return index; } - private int getDatumSize(Token token) { - /* - switch (token.datumType) { - case Token.DATUM_TYPE.UINT8: - return 1; - default: - return 0; - } - */ - return 0; - } + private int getDatumSize(Token token) { + /* + switch (token.datumType) { + case Token.DATUM_TYPE.UINT8: + return 1; + default: + return 0; + } + */ + return 0; + } - public int getTableLen () { - return al.size() == 0 ? 1 : al.size(); - } + public int getTableLen () { + return al.size() == 0 ? 1 : al.size(); + } } class GuidTable { private ArrayList al; - private ArrayList alComments; + private ArrayList alComments; private String phase; private int len; - private int bodyStart; - private int bodyLineNum; + private int bodyStart; + private int bodyLineNum; public GuidTable (String phase) { this.phase = phase; al = new ArrayList(); - alComments = new ArrayList(); + alComments = new ArrayList(); len = 0; - bodyStart = 0; - bodyLineNum = 0; + bodyStart = 0; + bodyLineNum = 0; } public String getSizeMacro () { @@ -269,60 +269,60 @@ class GuidTable { return String.format(PcdDatabase.GuidTableDeclaration, phase); } - private String getUuidCString (UUID uuid) { - String[] guidStrArray; + private String getUuidCString (UUID uuid) { + String[] guidStrArray; - guidStrArray =(uuid.toString()).split("-"); + guidStrArray =(uuid.toString()).split("-"); - return String.format("{ 0x%s, 0x%s, 0x%s, { 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s } }", - guidStrArray[0], - guidStrArray[1], - guidStrArray[2], - (guidStrArray[3].substring(0, 2)), - (guidStrArray[3].substring(2, 4)), - (guidStrArray[4].substring(0, 2)), - (guidStrArray[4].substring(2, 4)), - (guidStrArray[4].substring(4, 6)), - (guidStrArray[4].substring(6, 8)), - (guidStrArray[4].substring(8, 10)), - (guidStrArray[4].substring(10, 12)) - ); - } + return String.format("{ 0x%s, 0x%s, 0x%s, { 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s } }", + guidStrArray[0], + guidStrArray[1], + guidStrArray[2], + (guidStrArray[3].substring(0, 2)), + (guidStrArray[3].substring(2, 4)), + (guidStrArray[4].substring(0, 2)), + (guidStrArray[4].substring(2, 4)), + (guidStrArray[4].substring(4, 6)), + (guidStrArray[4].substring(6, 8)), + (guidStrArray[4].substring(8, 10)), + (guidStrArray[4].substring(10, 12)) + ); + } public ArrayList getInstantiation () { - ArrayList Output = new ArrayList(); + ArrayList Output = new ArrayList(); Output.add("/* GuidTable */"); Output.add("{"); - bodyStart = 2; + bodyStart = 2; - if (al.size() == 0) { - Output.add(getUuidCString(new UUID(0, 0))); - } + if (al.size() == 0) { + Output.add(getUuidCString(new UUID(0, 0))); + } for (Object u : al) { UUID uuid = (UUID)u; - String str = getUuidCString(uuid); + String str = getUuidCString(uuid); - if (al.indexOf(u) != (al.size() - 1)) { - str += ","; - } + if (al.indexOf(u) != (al.size() - 1)) { + str += ","; + } Output.add(str); - bodyLineNum++; + bodyLineNum++; } - Output.add("}"); + Output.add("}"); return Output; } - public int getBodyStart() { - return bodyStart; - } + public int getBodyStart() { + return bodyStart; + } - public int getBodyLineNum () { - return bodyLineNum; - } + public int getBodyLineNum () { + return bodyLineNum; + } public int add (UUID uuid, String name) { int index = len; @@ -335,26 +335,26 @@ class GuidTable { return index; } - public int getTableLen () { - return al.size() == 0 ? 0 : al.size(); - } + public int getTableLen () { + return al.size() == 0 ? 0 : al.size(); + } } class SkuIdTable { private ArrayList al; - private ArrayList alComment; + private ArrayList alComment; private String phase; private int len; - private int bodyStart; - private int bodyLineNum; + private int bodyStart; + private int bodyLineNum; public SkuIdTable (String phase) { this.phase = phase; al = new ArrayList(); - alComment = new ArrayList(); - bodyStart = 0; - bodyLineNum = 0; + alComment = new ArrayList(); + bodyStart = 0; + bodyLineNum = 0; len = 0; } @@ -375,82 +375,82 @@ class SkuIdTable { } public ArrayList getInstantiation () { - ArrayList Output = new ArrayList (); + ArrayList Output = new ArrayList (); Output.add("/* SkuIdTable */"); Output.add("{"); - bodyStart = 2; + bodyStart = 2; - if (al.size() == 0) { - Output.add("0"); - } + if (al.size() == 0) { + Output.add("0"); + } for (int index = 0; index < al.size(); index++) { - String str; + String str; - str = "/* " + alComment.get(index) + "*/ "; - str += "/* MaxSku */ "; + str = "/* " + alComment.get(index) + "*/ "; + str += "/* MaxSku */ "; - Integer[] ia = al.get(index); + Integer[] ia = al.get(index); - str += ia[0].toString() + ", "; - for (int index2 = 1; index2 < ia.length; index2++) { - str += ia[index2].toString(); - if (index != al.size() - 1) { - str += ", "; - } - } + str += ia[0].toString() + ", "; + for (int index2 = 1; index2 < ia.length; index2++) { + str += ia[index2].toString(); + if (index != al.size() - 1) { + str += ", "; + } + } Output.add(str); - bodyLineNum++; + bodyLineNum++; } - Output.add("}"); + Output.add("}"); return Output; } public int add (Token token) { - int index; + int index; - Integer [] skuIds = new Integer[token.maxSkuCount + 1]; - skuIds[0] = new Integer(token.maxSkuCount); - for (index = 1; index < skuIds.length; index++) { - skuIds[index] = new Integer(token.skuData.get(index - 1).id); - } + Integer [] skuIds = new Integer[token.maxSkuCount + 1]; + skuIds[0] = new Integer(token.maxSkuCount); + for (index = 1; index < skuIds.length; index++) { + skuIds[index] = new Integer(token.skuData.get(index - 1).id); + } index = len; len += skuIds.length; al.add(skuIds); - alComment.add(token.getPrimaryKeyString()); + alComment.add(token.getPrimaryKeyString()); return index; } - public int getTableLen () { - return al.size() == 0 ? 1 : al.size(); - } + public int getTableLen () { + return al.size() == 0 ? 1 : al.size(); + } } class LocalTokenNumberTable { private ArrayList al; - private ArrayList alComment; + private ArrayList alComment; private String phase; private int len; - private int bodyStart; - private int bodyLineNum; + private int bodyStart; + private int bodyLineNum; public LocalTokenNumberTable (String phase) { this.phase = phase; al = new ArrayList(); - alComment = new ArrayList(); - bodyStart = 0; - bodyLineNum = 0; + alComment = new ArrayList(); + bodyStart = 0; + bodyLineNum = 0; len = 0; } @@ -472,65 +472,65 @@ class LocalTokenNumberTable { } public ArrayList getInstantiation () { - ArrayList output = new ArrayList(); + ArrayList output = new ArrayList(); output.add("/* LocalTokenNumberTable */"); output.add("{"); - bodyStart = 2; + bodyStart = 2; - if (al.size() == 0) { - output.add("0"); - } + if (al.size() == 0) { + output.add("0"); + } for (int index = 0; index < al.size(); index++) { - String str; + String str; - str = (String)al.get(index); + str = (String)al.get(index); - str += " /* " + alComment.get(index) + " */ "; + str += " /* " + alComment.get(index) + " */ "; - if (index != (al.size() - 1)) { - str += ","; - } + if (index != (al.size() - 1)) { + str += ","; + } output.add(str); } - bodyLineNum = al.size(); + bodyLineNum = al.size(); - output.add("}"); + output.add("}"); return output; } public int add (Token token) { int index = len; - String str; + String str; len++; - str = String.format(PcdDatabase.offsetOfStrTemplate, phase, token.hasDefaultValue() ? "Init" : "Uninit", token.getPrimaryKeyString()); + str = String.format(PcdDatabase.offsetOfStrTemplate, phase, token.hasDefaultValue() ? "Init" : "Uninit", token.getPrimaryKeyString()); - if (token.isStringType()) { - str += " | PCD_TYPE_STRING"; - } + if (token.isStringType()) { + str += " | PCD_TYPE_STRING"; + } - if (token.skuEnabled) { - str += " | PCD_TYPE_SKU_ENABLED"; - } + if (token.skuEnabled) { + str += " | PCD_TYPE_SKU_ENABLED"; + } - if (token.hiiEnabled) { - str += " | PCD_TYPE_HII"; - } + if (token.hiiEnabled) { + str += " | PCD_TYPE_HII"; + } - if (token.vpdEnabled) { - str += " | PCD_TYPE_VPD"; - } - + if (token.vpdEnabled) { + str += " | PCD_TYPE_VPD"; + } + al.add(str); - alComment.add(token.getPrimaryKeyString()); + alComment.add(token.getPrimaryKeyString()); return index; } @@ -538,38 +538,38 @@ class LocalTokenNumberTable { class ExMapTable { - class ExTriplet { - public Integer guidTableIdx; - public Long exTokenNumber; - public Long localTokenIdx; - - public ExTriplet (int guidTableIdx, long exTokenNumber, long localTokenIdx) { - this.guidTableIdx = new Integer(guidTableIdx); - this.exTokenNumber = new Long(exTokenNumber); - this.localTokenIdx = new Long(localTokenIdx); - } - } + class ExTriplet { + public Integer guidTableIdx; + public Long exTokenNumber; + public Long localTokenIdx; + + public ExTriplet (int guidTableIdx, long exTokenNumber, long localTokenIdx) { + this.guidTableIdx = new Integer(guidTableIdx); + this.exTokenNumber = new Long(exTokenNumber); + this.localTokenIdx = new Long(localTokenIdx); + } + } private ArrayList al; - private ArrayList alComment; + private ArrayList alComment; private String phase; private int len; - private int bodyStart; - private int bodyLineNum; - private int base; + private int bodyStart; + private int bodyLineNum; + private int base; public ExMapTable (String phase) { this.phase = phase; al = new ArrayList(); - alComment = new ArrayList(); - bodyStart = 0; - bodyLineNum = 0; + alComment = new ArrayList(); + bodyStart = 0; + bodyLineNum = 0; len = 0; } public String getSizeMacro () { return String.format(PcdDatabase.ExMapTableSizeMacro, phase, getTableLen()) - + String.format(PcdDatabase.ExTokenNumber, phase, al.size()); + + String.format(PcdDatabase.ExTokenNumber, phase, al.size()); } private int getSize () { @@ -585,38 +585,38 @@ class ExMapTable { } public ArrayList getInstantiation () { - ArrayList Output = new ArrayList(); + ArrayList Output = new ArrayList(); Output.add("/* ExMapTable */"); Output.add("{"); - bodyStart = 2; + bodyStart = 2; - if (al.size() == 0) { - Output.add("{0, 0, 0}"); - } + if (al.size() == 0) { + Output.add("{0, 0, 0}"); + } - int index; + int index; for (index = 0; index < al.size(); index++) { - String str; + String str; - ExTriplet e = (ExTriplet)al.get(index); + ExTriplet e = (ExTriplet)al.get(index); - str = "{ " + e.exTokenNumber.toString() + ", "; - str += e.localTokenIdx.toString() + ", "; - str += e.guidTableIdx.toString(); + str = "{ " + e.exTokenNumber.toString() + ", "; + str += e.localTokenIdx.toString() + ", "; + str += e.guidTableIdx.toString(); - str += " /* " + alComment.get(index) + " */"; + str += " /* " + alComment.get(index) + " */"; - if (index != al.size() - 1) { - str += ","; - } + if (index != al.size() - 1) { + str += ","; + } Output.add(str); - bodyLineNum++; + bodyLineNum++; } - Output.add("}"); + Output.add("}"); return Output; } @@ -626,14 +626,14 @@ class ExMapTable { len++; al.add(new ExTriplet(guidTableIdx, exTokenNum, localTokenIdx)); - alComment.add(name); + alComment.add(name); return index; } - public int getTableLen () { - return al.size() == 0 ? 1 : al.size(); - } + public int getTableLen () { + return al.size() == 0 ? 1 : al.size(); + } } @@ -648,7 +648,7 @@ class PcdDatabase { public final static String ExMapTableSizeMacro = "#define %s_EXMAPPING_TABLE_SIZE %d\r\n"; - public final static String ExTokenNumber = "#define %s_EX_TOKEN_NUMBER %d\r\n"; + public final static String ExTokenNumber = "#define %s_EX_TOKEN_NUMBER %d\r\n"; public final static String GuidTableSizeMacro = "#define %s_GUID_TABLE_SIZE %d\r\n"; public final static String LocalTokenNumberTableSizeMacro = "#define %s_LOCAL_TOKEN_NUMBER %d\r\n"; public final static String StringTableSizeMacro = "#define %s_STRING_TABLE_SIZE %d\r\n"; @@ -661,461 +661,461 @@ class PcdDatabase { public final static String StringTableExistenceMacro = "#define %s_STRING_TABLE_EMPTY %s\r\n"; public final static String SkuTableExistenceMacro = "#define %s_SKUID_TABLE_EMPTY %s\r\n"; - public final static String offsetOfSkuHeadStrTemplate = "offsetof(%s_PCD_DATABASE, %s.%s_SkuDataTable)"; - public final static String offsetOfStrTemplate = "offsetof(%s_PCD_DATABASE, %s.%s)"; + public final static String offsetOfSkuHeadStrTemplate = "offsetof(%s_PCD_DATABASE, %s.%s_SkuDataTable)"; + public final static String offsetOfStrTemplate = "offsetof(%s_PCD_DATABASE, %s.%s)"; - private StringTable stringTable; - private GuidTable guidTable; - private LocalTokenNumberTable localTokenNumberTable; - private SkuIdTable skuIdTable; - private SizeTable sizeTable; - private ExMapTable exMapTable; + private StringTable stringTable; + private GuidTable guidTable; + private LocalTokenNumberTable localTokenNumberTable; + private SkuIdTable skuIdTable; + private SizeTable sizeTable; + private ExMapTable exMapTable; - private ArrayList alTokens; - private String phase; - private int assignedTokenNumber; + private ArrayList alTokens; + private String phase; + private int assignedTokenNumber; - private String hString; - private String cString; + private String hString; + private String cString; - class AlignmentSizeComp implements Comparator { + class AlignmentSizeComp implements Comparator { public int compare (Token a, Token b) { - return getAlignmentSize(b) - - getAlignmentSize(a); - } - } + return getAlignmentSize(b) + - getAlignmentSize(a); + } + } - public PcdDatabase (ArrayList alTokens, String exePhase, int startLen) { - phase = exePhase; + public PcdDatabase (ArrayList alTokens, String exePhase, int startLen) { + phase = exePhase; - stringTable = new StringTable(phase); - guidTable = new GuidTable(phase); - localTokenNumberTable = new LocalTokenNumberTable(phase); - skuIdTable = new SkuIdTable(phase); - sizeTable = new SizeTable(phase); - exMapTable = new ExMapTable(phase); + stringTable = new StringTable(phase); + guidTable = new GuidTable(phase); + localTokenNumberTable = new LocalTokenNumberTable(phase); + skuIdTable = new SkuIdTable(phase); + sizeTable = new SizeTable(phase); + exMapTable = new ExMapTable(phase); - assignedTokenNumber = startLen; - this.alTokens = alTokens; - } + assignedTokenNumber = startLen; + this.alTokens = alTokens; + } - private void getTwoGroupsOfTokens (ArrayList alTokens, List initTokens, List uninitTokens) { - for (int i = 0; i < alTokens.size(); i++) { - Token t = (Token)alTokens.get(i); - if (t.hasDefaultValue()) { - initTokens.add(t); - } else { - uninitTokens.add(t); - } - } + private void getTwoGroupsOfTokens (ArrayList alTokens, List initTokens, List uninitTokens) { + for (int i = 0; i < alTokens.size(); i++) { + Token t = (Token)alTokens.get(i); + if (t.hasDefaultValue()) { + initTokens.add(t); + } else { + uninitTokens.add(t); + } + } - return; - } + return; + } - private int getAlignmentSize (Token token) { - if (token.hiiEnabled) { - return 2; - } + private int getAlignmentSize (Token token) { + if (token.hiiEnabled) { + return 2; + } - if (token.vpdEnabled) { - return 4; - } + if (token.vpdEnabled) { + return 4; + } - if (token.isStringType()) { - return 2; - } + if (token.isStringType()) { + return 2; + } - switch (token.datumType) { - case UINT8: - return 1; - case UINT16: - return 2; - case UINT32: - return 4; - case UINT64: - return 8; - case POINTER: - return 1; - case BOOLEAN: - return 1; - } - return 1; - } + switch (token.datumType) { + case UINT8: + return 1; + case UINT16: + return 2; + case UINT32: + return 4; + case UINT64: + return 8; + case POINTER: + return 1; + case BOOLEAN: + return 1; + } + return 1; + } - public String getCString () { - return cString; - } + public String getCString () { + return cString; + } - public String getHString () { - return hString; - } + public String getHString () { + return hString; + } public void genCode () { - final String newLine = "\r\n"; - final String instNewLine = "\\\r\n"; - final String declNewLine = ";\r\n"; - final String tab = "\t"; - final String commaInstNewLine = "\t,\\\r\n"; - final String commaNewLine = ", \r\n"; + final String newLine = "\r\n"; + final String instNewLine = "\\\r\n"; + final String declNewLine = ";\r\n"; + final String tab = "\t"; + final String commaInstNewLine = "\t,\\\r\n"; + final String commaNewLine = ", \r\n"; - int i; - ArrayList decla; - ArrayList inst; + int i; + ArrayList decla; + ArrayList inst; - String macroStr = ""; - String initDeclStr = ""; - String initInstStr = ""; - String uninitDeclStr = ""; + String macroStr = ""; + String initDeclStr = ""; + String initInstStr = ""; + String uninitDeclStr = ""; - List initTokens = new ArrayList (); - List uninitTokens = new ArrayList (); - - HashMap > initCode = new HashMap> (); - HashMap > uninitCode = new HashMap> (); + List initTokens = new ArrayList (); + List uninitTokens = new ArrayList (); + + HashMap > initCode = new HashMap> (); + HashMap > uninitCode = new HashMap> (); - getTwoGroupsOfTokens (alTokens, initTokens, uninitTokens); + getTwoGroupsOfTokens (alTokens, initTokens, uninitTokens); - // - // Generate Structure Declaration for PcdTokens without Default Value - // PEI_PCD_DATABASE_INIT - // - java.util.Comparator comparator = new AlignmentSizeComp(); - List list = initTokens; - java.util.Collections.sort(list, comparator); - initCode = processTokens(initTokens); + // + // Generate Structure Declaration for PcdTokens without Default Value + // PEI_PCD_DATABASE_INIT + // + java.util.Comparator comparator = new AlignmentSizeComp(); + List list = initTokens; + java.util.Collections.sort(list, comparator); + initCode = processTokens(initTokens); - // - // Generate Structure Declaration for PcdTokens without Default Value - // PEI_PCD_DATABASE_UNINIT - // - java.util.Collections.sort(uninitTokens, comparator); - uninitCode = processTokens(uninitTokens); + // + // Generate Structure Declaration for PcdTokens without Default Value + // PEI_PCD_DATABASE_UNINIT + // + java.util.Collections.sort(uninitTokens, comparator); + uninitCode = processTokens(uninitTokens); - // - // Generate size info Macro for all Tables - // - macroStr += guidTable.getSizeMacro(); - macroStr += stringTable.getSizeMacro(); - macroStr += skuIdTable.getSizeMacro(); - macroStr += localTokenNumberTable.getSizeMacro(); - macroStr += exMapTable.getSizeMacro(); + // + // Generate size info Macro for all Tables + // + macroStr += guidTable.getSizeMacro(); + macroStr += stringTable.getSizeMacro(); + macroStr += skuIdTable.getSizeMacro(); + macroStr += localTokenNumberTable.getSizeMacro(); + macroStr += exMapTable.getSizeMacro(); - // - // Generate existance info Macro for all Tables - // - macroStr += guidTable.getExistanceMacro(); - macroStr += stringTable.getExistanceMacro(); - macroStr += skuIdTable.getExistanceMacro(); - macroStr += localTokenNumberTable.getExistanceMacro(); - macroStr += exMapTable.getExistanceMacro(); + // + // Generate existance info Macro for all Tables + // + macroStr += guidTable.getExistanceMacro(); + macroStr += stringTable.getExistanceMacro(); + macroStr += skuIdTable.getExistanceMacro(); + macroStr += localTokenNumberTable.getExistanceMacro(); + macroStr += exMapTable.getExistanceMacro(); - // - // Generate Structure Declaration for PcdTokens with Default Value - // for example PEI_PCD_DATABASE_INIT - // - initDeclStr += "typedef struct {" + newLine; - { - initDeclStr += tab + exMapTable.getTypeDeclaration(); - initDeclStr += tab + guidTable.getTypeDeclaration(); - initDeclStr += tab + localTokenNumberTable.getTypeDeclaration(); - initDeclStr += tab + stringTable.getTypeDeclaration(); - initDeclStr += tab + sizeTable.getTypeDeclaration(); - initDeclStr += tab + skuIdTable.getTypeDeclaration(); - if (phase.equalsIgnoreCase("PEI")) { - initDeclStr += tab + "SKU_ID SystemSkuId;" + newLine; - } + // + // Generate Structure Declaration for PcdTokens with Default Value + // for example PEI_PCD_DATABASE_INIT + // + initDeclStr += "typedef struct {" + newLine; + { + initDeclStr += tab + exMapTable.getTypeDeclaration(); + initDeclStr += tab + guidTable.getTypeDeclaration(); + initDeclStr += tab + localTokenNumberTable.getTypeDeclaration(); + initDeclStr += tab + stringTable.getTypeDeclaration(); + initDeclStr += tab + sizeTable.getTypeDeclaration(); + initDeclStr += tab + skuIdTable.getTypeDeclaration(); + if (phase.equalsIgnoreCase("PEI")) { + initDeclStr += tab + "SKU_ID SystemSkuId;" + newLine; + } - decla = initCode.get(new String("Declaration")); - for (i = 0; i < decla.size(); i++) { - initDeclStr += tab + decla.get(i) + declNewLine; - } + decla = initCode.get(new String("Declaration")); + for (i = 0; i < decla.size(); i++) { + initDeclStr += tab + decla.get(i) + declNewLine; + } - // - // Generate Structure Declaration for PcdToken with SkuEnabled - // - decla = initCode.get("DeclarationForSku"); + // + // Generate Structure Declaration for PcdToken with SkuEnabled + // + decla = initCode.get("DeclarationForSku"); - for (i = 0; i < decla.size(); i++) { - initDeclStr += tab + decla.get(i) + declNewLine; - } - } - initDeclStr += String.format("} %s_PCD_DATABASE_INIT;\r\n\r\n", phase); + for (i = 0; i < decla.size(); i++) { + initDeclStr += tab + decla.get(i) + declNewLine; + } + } + initDeclStr += String.format("} %s_PCD_DATABASE_INIT;\r\n\r\n", phase); - // - // Generate MACRO for structure intialization of PCDTokens with Default Value - // The sequence must match the sequence of declaration of the memembers in the structure - String tmp = String.format("%s_PCD_DATABASE_INIT g%sPcdDbInit = { ", phase.toUpperCase(), phase.toUpperCase()); - initInstStr += tmp + newLine; - initInstStr += tab + genInstantiationStr(exMapTable.getInstantiation()) + commaNewLine; - initInstStr += tab + genInstantiationStr(guidTable.getInstantiation()) + commaNewLine; - initInstStr += tab + genInstantiationStr(localTokenNumberTable.getInstantiation()) + commaNewLine; - /* - inst = stringTable.getInstantiation(); - for (i = 0; i < inst.size(); i++ ) { - initInstStr += tab + inst.get(i) + commaNewLine; - } - */ - initInstStr += tab + genInstantiationStr(stringTable.getInstantiation()) + commaNewLine; - initInstStr += tab + genInstantiationStr(sizeTable.getInstantiation()) + commaNewLine; - initInstStr += tab + genInstantiationStr(skuIdTable.getInstantiation()) + commaNewLine; - // - // For SystemSkuId - // - if (phase.equalsIgnoreCase("PEI")) { - initInstStr += tab + "0" + tab + "/* SystemSkuId */" + commaNewLine; - } + // + // Generate MACRO for structure intialization of PCDTokens with Default Value + // The sequence must match the sequence of declaration of the memembers in the structure + String tmp = String.format("%s_PCD_DATABASE_INIT g%sPcdDbInit = { ", phase.toUpperCase(), phase.toUpperCase()); + initInstStr += tmp + newLine; + initInstStr += tab + genInstantiationStr(exMapTable.getInstantiation()) + commaNewLine; + initInstStr += tab + genInstantiationStr(guidTable.getInstantiation()) + commaNewLine; + initInstStr += tab + genInstantiationStr(localTokenNumberTable.getInstantiation()) + commaNewLine; + /* + inst = stringTable.getInstantiation(); + for (i = 0; i < inst.size(); i++ ) { + initInstStr += tab + inst.get(i) + commaNewLine; + } + */ + initInstStr += tab + genInstantiationStr(stringTable.getInstantiation()) + commaNewLine; + initInstStr += tab + genInstantiationStr(sizeTable.getInstantiation()) + commaNewLine; + initInstStr += tab + genInstantiationStr(skuIdTable.getInstantiation()) + commaNewLine; + // + // For SystemSkuId + // + if (phase.equalsIgnoreCase("PEI")) { + initInstStr += tab + "0" + tab + "/* SystemSkuId */" + commaNewLine; + } - inst = initCode.get("Instantiation"); - for (i = 0; i < inst.size(); i++) { - initInstStr += tab + inst.get(i) + commaNewLine; - } + inst = initCode.get("Instantiation"); + for (i = 0; i < inst.size(); i++) { + initInstStr += tab + inst.get(i) + commaNewLine; + } - inst = initCode.get("InstantiationForSku"); - for (i = 0; i < inst.size(); i++) { - initInstStr += tab + inst.get(i); - if (i != inst.size() - 1) { - initInstStr += commaNewLine; - } - } + inst = initCode.get("InstantiationForSku"); + for (i = 0; i < inst.size(); i++) { + initInstStr += tab + inst.get(i); + if (i != inst.size() - 1) { + initInstStr += commaNewLine; + } + } - initInstStr += "};"; + initInstStr += "};"; - uninitDeclStr += "typedef struct {" + newLine; - { - decla = uninitCode.get("Declaration"); - if (decla.size() == 0) { - uninitDeclStr += "UINT8 dummy /* The UINT struct is empty */" + declNewLine; - } else { - - for (i = 0; i < decla.size(); i++) { - uninitDeclStr += tab + decla.get(i) + declNewLine; - } - - decla = uninitCode.get("DeclarationForSku"); - - for (i = 0; i < decla.size(); i++) { - uninitDeclStr += tab + decla.get(i) + declNewLine; - } - } - } - uninitDeclStr += String.format("} %s_PCD_DATABASE_UNINIT;\r\n\r\n", phase); + uninitDeclStr += "typedef struct {" + newLine; + { + decla = uninitCode.get("Declaration"); + if (decla.size() == 0) { + uninitDeclStr += "UINT8 dummy /* The UINT struct is empty */" + declNewLine; + } else { + + for (i = 0; i < decla.size(); i++) { + uninitDeclStr += tab + decla.get(i) + declNewLine; + } + + decla = uninitCode.get("DeclarationForSku"); + + for (i = 0; i < decla.size(); i++) { + uninitDeclStr += tab + decla.get(i) + declNewLine; + } + } + } + uninitDeclStr += String.format("} %s_PCD_DATABASE_UNINIT;\r\n\r\n", phase); - cString = initInstStr + newLine; - hString = macroStr + newLine - + initDeclStr + newLine - + uninitDeclStr + newLine - + newLine; + cString = initInstStr + newLine; + hString = macroStr + newLine + + initDeclStr + newLine + + uninitDeclStr + newLine + + newLine; - } + } - private String genInstantiationStr (ArrayList alStr) { - String str = ""; - for (int i = 0; i< alStr.size(); i++) { - str += "\t" + alStr.get(i); - if (i != alStr.size() - 1) { - str += "\r\n"; - } - } + private String genInstantiationStr (ArrayList alStr) { + String str = ""; + for (int i = 0; i< alStr.size(); i++) { + str += "\t" + alStr.get(i); + if (i != alStr.size() - 1) { + str += "\r\n"; + } + } - return str; - } + return str; + } - private HashMap> processTokens (List alToken) { + private HashMap> processTokens (List alToken) { - ArrayList[] output = new ArrayList[4]; - HashMap > map = new HashMap>(); + ArrayList[] output = new ArrayList[4]; + HashMap > map = new HashMap>(); - ArrayList decl = new ArrayList(); - ArrayList declForSkuEnableType = new ArrayList(); - ArrayList inst = new ArrayList(); - ArrayList instForSkuEnableType = new ArrayList(); + ArrayList decl = new ArrayList(); + ArrayList declForSkuEnableType = new ArrayList(); + ArrayList inst = new ArrayList(); + ArrayList instForSkuEnableType = new ArrayList(); - for (int index = 0; index < alToken.size(); index++) { - Token token = alToken.get(index); + for (int index = 0; index < alToken.size(); index++) { + Token token = alToken.get(index); - if (token.skuEnabled) { - // - // BugBug: Schema only support Data type now - // - int tableIdx; + if (token.skuEnabled) { + // + // BugBug: Schema only support Data type now + // + int tableIdx; - tableIdx = skuIdTable.add(token); + tableIdx = skuIdTable.add(token); - decl.add(getSkuEnabledTypeDeclaration(token)); - if (token.hasDefaultValue()) { - inst.add(getSkuEnabledTypeInstantiaion(token, tableIdx)); - } + decl.add(getSkuEnabledTypeDeclaration(token)); + if (token.hasDefaultValue()) { + inst.add(getSkuEnabledTypeInstantiaion(token, tableIdx)); + } - declForSkuEnableType.add(getDataTypeDeclarationForSkuEnabled(token)); - if (token.hasDefaultValue()) { - instForSkuEnableType.add(getDataTypeInstantiationForSkuEnabled(token)); - } + declForSkuEnableType.add(getDataTypeDeclarationForSkuEnabled(token)); + if (token.hasDefaultValue()) { + instForSkuEnableType.add(getDataTypeInstantiationForSkuEnabled(token)); + } - } else { - if (token.hiiEnabled) { - decl.add(getVariableEnableTypeDeclaration(token)); - inst.add(getVariableEnableInstantiation(token)); - } else if (token.vpdEnabled) { - decl.add(getVpdEnableTypeDeclaration(token)); - inst.add(getVpdEnableTypeInstantiation(token)); - } else if (token.isStringType()) { - decl.add(getStringTypeDeclaration(token)); - inst.add(getStringTypeInstantiation(stringTable.add(token.getStringTypeString(), token), token)); - } - else { - decl.add(getDataTypeDeclaration(token)); - if (token.hasDefaultValue()) { - inst.add(getDataTypeInstantiation(token)); - } - } - } + } else { + if (token.hiiEnabled) { + decl.add(getVariableEnableTypeDeclaration(token)); + inst.add(getVariableEnableInstantiation(token)); + } else if (token.vpdEnabled) { + decl.add(getVpdEnableTypeDeclaration(token)); + inst.add(getVpdEnableTypeInstantiation(token)); + } else if (token.isStringType()) { + decl.add(getStringTypeDeclaration(token)); + inst.add(getStringTypeInstantiation(stringTable.add(token.getStringTypeString(), token), token)); + } + else { + decl.add(getDataTypeDeclaration(token)); + if (token.hasDefaultValue()) { + inst.add(getDataTypeInstantiation(token)); + } + } + } - sizeTable.add(token); - localTokenNumberTable.add(token); - token.assignedtokenNumber = assignedTokenNumber++; + sizeTable.add(token); + localTokenNumberTable.add(token); + token.assignedtokenNumber = assignedTokenNumber++; - } + } - map.put("Declaration", decl); - map.put("DeclarationForSku", declForSkuEnableType); - map.put("Instantiation", inst); - map.put("InstantiationForSku", instForSkuEnableType); + map.put("Declaration", decl); + map.put("DeclarationForSku", declForSkuEnableType); + map.put("Instantiation", inst); + map.put("InstantiationForSku", instForSkuEnableType); - return map; - } + return map; + } - private String getSkuEnabledTypeDeclaration (Token token) { - return String.format("SKU_HEAD %s;\r\n", token.getPrimaryKeyString()); - } + private String getSkuEnabledTypeDeclaration (Token token) { + return String.format("SKU_HEAD %s;\r\n", token.getPrimaryKeyString()); + } - private String getSkuEnabledTypeInstantiaion (Token token, int SkuTableIdx) { + private String getSkuEnabledTypeInstantiaion (Token token, int SkuTableIdx) { - String offsetof = String.format(PcdDatabase.offsetOfSkuHeadStrTemplate, phase, token.hasDefaultValue()? "Init" : "Uninit", token.getPrimaryKeyString()); - return String.format("{ %s, %d }", offsetof, SkuTableIdx); - } + String offsetof = String.format(PcdDatabase.offsetOfSkuHeadStrTemplate, phase, token.hasDefaultValue()? "Init" : "Uninit", token.getPrimaryKeyString()); + return String.format("{ %s, %d }", offsetof, SkuTableIdx); + } - private String getDataTypeDeclarationForSkuEnabled (Token token) { - String typeStr = ""; + private String getDataTypeDeclarationForSkuEnabled (Token token) { + String typeStr = ""; - if (token.datumType == Token.DATUM_TYPE.UINT8) { - typeStr = "UINT8 %s_%s[%d];\r\n"; - } else if (token.datumType == Token.DATUM_TYPE.UINT16) { - typeStr = "UINT16 %s_%s[%d];\r\n"; - } else if (token.datumType == Token.DATUM_TYPE.UINT32) { - typeStr = "UINT32 %s_%s[%d];\r\n"; - } else if (token.datumType == Token.DATUM_TYPE.UINT64) { - typeStr = "UINT64 %s_%s[%d];\r\n"; - } else if (token.datumType == Token.DATUM_TYPE.BOOLEAN) { - typeStr = "BOOLEAN %s_%s[%d];\r\n"; - } else if (token.datumType == Token.DATUM_TYPE.POINTER) { - return String.format("UINT8 %s_s[%d];\r\n", token.getPrimaryKeyString(), "SkuDataTable", token.datumSize * token.maxSkuCount); - } + if (token.datumType == Token.DATUM_TYPE.UINT8) { + typeStr = "UINT8 %s_%s[%d];\r\n"; + } else if (token.datumType == Token.DATUM_TYPE.UINT16) { + typeStr = "UINT16 %s_%s[%d];\r\n"; + } else if (token.datumType == Token.DATUM_TYPE.UINT32) { + typeStr = "UINT32 %s_%s[%d];\r\n"; + } else if (token.datumType == Token.DATUM_TYPE.UINT64) { + typeStr = "UINT64 %s_%s[%d];\r\n"; + } else if (token.datumType == Token.DATUM_TYPE.BOOLEAN) { + typeStr = "BOOLEAN %s_%s[%d];\r\n"; + } else if (token.datumType == Token.DATUM_TYPE.POINTER) { + return String.format("UINT8 %s_s[%d];\r\n", token.getPrimaryKeyString(), "SkuDataTable", token.datumSize * token.maxSkuCount); + } - return String.format(typeStr, token.getPrimaryKeyString(), "SkuDataTable", token.maxSkuCount); + return String.format(typeStr, token.getPrimaryKeyString(), "SkuDataTable", token.maxSkuCount); - } + } - private String getDataTypeInstantiationForSkuEnabled (Token token) { - String str = ""; + private String getDataTypeInstantiationForSkuEnabled (Token token) { + String str = ""; - if (token.datumType == Token.DATUM_TYPE.POINTER) { - return String.format("UINT8 %s_s[%d]", token.getPrimaryKeyString(), "SkuDataTable", token.datumSize * token.maxSkuCount); - } else { - str = "{ "; - for (int idx = 0; idx < token.maxSkuCount; idx++) { - str += token.skuData.get(idx).toString(); - if (idx != token.maxSkuCount - 1) { - str += ", "; - } - } - str += "}"; + if (token.datumType == Token.DATUM_TYPE.POINTER) { + return String.format("UINT8 %s_s[%d]", token.getPrimaryKeyString(), "SkuDataTable", token.datumSize * token.maxSkuCount); + } else { + str = "{ "; + for (int idx = 0; idx < token.maxSkuCount; idx++) { + str += token.skuData.get(idx).toString(); + if (idx != token.maxSkuCount - 1) { + str += ", "; + } + } + str += "}"; - return str; - } + return str; + } - } + } - private String getDataTypeInstantiation (Token token) { + private String getDataTypeInstantiation (Token token) { - String typeStr = ""; + String typeStr = ""; - if (token.datumType == Token.DATUM_TYPE.POINTER) { - return String.format("%s /* %s */", token.datum.toString(), token.getPrimaryKeyString()); - } else { - return String.format("%s /* %s */", token.datum.toString(), token.getPrimaryKeyString()); - } - } + if (token.datumType == Token.DATUM_TYPE.POINTER) { + return String.format("%s /* %s */", token.datum.toString(), token.getPrimaryKeyString()); + } else { + return String.format("%s /* %s */", token.datum.toString(), token.getPrimaryKeyString()); + } + } - private String getDataTypeDeclaration (Token token) { + private String getDataTypeDeclaration (Token token) { - String typeStr = ""; + String typeStr = ""; - if (token.datumType == Token.DATUM_TYPE.UINT8) { - typeStr = "UINT8"; - } else if (token.datumType == Token.DATUM_TYPE.UINT16) { - typeStr = "UINT16"; - } else if (token.datumType == Token.DATUM_TYPE.UINT32) { - typeStr = "UINT32"; - } else if (token.datumType == Token.DATUM_TYPE.UINT64) { - typeStr = "UINT64"; - } else if (token.datumType == Token.DATUM_TYPE.BOOLEAN) { - typeStr = "BOOLEAN"; - } else if (token.datumType == Token.DATUM_TYPE.POINTER) { - return String.format("UINT8 %s[%d]", token.getPrimaryKeyString(), token.datumSize); - } else { - } + if (token.datumType == Token.DATUM_TYPE.UINT8) { + typeStr = "UINT8"; + } else if (token.datumType == Token.DATUM_TYPE.UINT16) { + typeStr = "UINT16"; + } else if (token.datumType == Token.DATUM_TYPE.UINT32) { + typeStr = "UINT32"; + } else if (token.datumType == Token.DATUM_TYPE.UINT64) { + typeStr = "UINT64"; + } else if (token.datumType == Token.DATUM_TYPE.BOOLEAN) { + typeStr = "BOOLEAN"; + } else if (token.datumType == Token.DATUM_TYPE.POINTER) { + return String.format("UINT8 %s[%d]", token.getPrimaryKeyString(), token.datumSize); + } else { + } - return String.format("%s %s", typeStr, token.getPrimaryKeyString()); - } + return String.format("%s %s", typeStr, token.getPrimaryKeyString()); + } - private String getVpdEnableTypeDeclaration (Token token) { - return String.format("VPD_HEAD %s", token.getPrimaryKeyString()); - } + private String getVpdEnableTypeDeclaration (Token token) { + return String.format("VPD_HEAD %s", token.getPrimaryKeyString()); + } - private String getVpdEnableTypeInstantiation (Token token) { - return String.format("{ %d } /* %s */", token.vpdOffset, - token.getPrimaryKeyString()); - } + private String getVpdEnableTypeInstantiation (Token token) { + return String.format("{ %d } /* %s */", token.vpdOffset, + token.getPrimaryKeyString()); + } - private String getStringTypeDeclaration (Token token) { - return String.format("UINT16 %s", token.getPrimaryKeyString()); - } + private String getStringTypeDeclaration (Token token) { + return String.format("UINT16 %s", token.getPrimaryKeyString()); + } - private String getStringTypeInstantiation (int StringTableIdx, Token token) { - return String.format ("%d /* %s */", StringTableIdx, - token.getPrimaryKeyString()); - } + private String getStringTypeInstantiation (int StringTableIdx, Token token) { + return String.format ("%d /* %s */", StringTableIdx, + token.getPrimaryKeyString()); + } - private String getVariableEnableTypeDeclaration (Token token) { - return String.format("VARIABLE_HEAD %s", token.getPrimaryKeyString()); - } + private String getVariableEnableTypeDeclaration (Token token) { + return String.format("VARIABLE_HEAD %s", token.getPrimaryKeyString()); + } - private String getVariableEnableInstantiation (Token token) { - return String.format("{ %d, %d, %d } /* %s */", guidTable.add(token.variableGuid, token.getPrimaryKeyString()), - stringTable.add(token.variableName, token), - token.variableOffset, - token.getPrimaryKeyString()); - } + private String getVariableEnableInstantiation (Token token) { + return String.format("{ %d, %d, %d } /* %s */", guidTable.add(token.variableGuid, token.getPrimaryKeyString()), + stringTable.add(token.variableName, token), + token.variableOffset, + token.getPrimaryKeyString()); + } - public int getTotalTokenNumber () { - return sizeTable.getTableLen(); - } + public int getTotalTokenNumber () { + return sizeTable.getTableLen(); + } public static String getPcdDatabaseCommonDefinitions () throws EntityException { String retStr = ""; try { - File file = new File(GlobalData.getWorkspacePath() + File.separator + - "Tools" + File.separator + - "Conf" + File.separator + - "Pcd" + File.separator + - "PcdDatabaseCommonDefinitions.sample"); - System.out.println(GlobalData.getWorkspacePath()); + File file = new File(GlobalData.getWorkspacePath() + File.separator + + "Tools" + File.separator + + "Conf" + File.separator + + "Pcd" + File.separator + + "PcdDatabaseCommonDefinitions.sample"); + System.out.println(GlobalData.getWorkspacePath()); FileReader reader = new FileReader(file); BufferedReader in = new BufferedReader(reader); String str; @@ -1129,51 +1129,51 @@ class PcdDatabase { return retStr; } - public static String getPcdDxeDatabaseDefinitions () - throws EntityException { + public static String getPcdDxeDatabaseDefinitions () + throws EntityException { - String retStr = ""; - try { - File file = new File(GlobalData.getWorkspacePath() + File.separator + - "Tools" + File.separator + - "Conf" + File.separator + - "Pcd" + File.separator + - "PcdDatabaseDxeDefinitions.sample"); - FileReader reader = new FileReader(file); - BufferedReader in = new BufferedReader(reader); - String str; - while ((str = in.readLine()) != null) { - retStr = retStr +"\r\n" + str; - } - } catch (Exception ex) { - throw new EntityException("Fatal error when generating PcdDatabase Dxe Definitions"); - } + String retStr = ""; + try { + File file = new File(GlobalData.getWorkspacePath() + File.separator + + "Tools" + File.separator + + "Conf" + File.separator + + "Pcd" + File.separator + + "PcdDatabaseDxeDefinitions.sample"); + FileReader reader = new FileReader(file); + BufferedReader in = new BufferedReader(reader); + String str; + while ((str = in.readLine()) != null) { + retStr = retStr +"\r\n" + str; + } + } catch (Exception ex) { + throw new EntityException("Fatal error when generating PcdDatabase Dxe Definitions"); + } - return retStr; - } + return retStr; + } - public static String getPcdPeiDatabaseDefinitions () - throws EntityException { + public static String getPcdPeiDatabaseDefinitions () + throws EntityException { - String retStr = ""; - try { - File file = new File(GlobalData.getWorkspacePath() + File.separator + - "Tools" + File.separator + - "Conf" + File.separator + - "Pcd" + File.separator + - "PcdDatabasePeiDefinitions.sample"); - FileReader reader = new FileReader(file); - BufferedReader in = new BufferedReader(reader); - String str; - while ((str = in.readLine()) != null) { - retStr = retStr +"\r\n" + str; - } - } catch (Exception ex) { - throw new EntityException("Fatal error when generating PcdDatabase Pei Definitions"); - } + String retStr = ""; + try { + File file = new File(GlobalData.getWorkspacePath() + File.separator + + "Tools" + File.separator + + "Conf" + File.separator + + "Pcd" + File.separator + + "PcdDatabasePeiDefinitions.sample"); + FileReader reader = new FileReader(file); + BufferedReader in = new BufferedReader(reader); + String str; + while ((str = in.readLine()) != null) { + retStr = retStr +"\r\n" + str; + } + } catch (Exception ex) { + throw new EntityException("Fatal error when generating PcdDatabase Pei Definitions"); + } - return retStr; - } + return retStr; + } } @@ -1350,44 +1350,44 @@ public class CollectPCDAction { // // Call Private function genPcdDatabaseSourceCode (void); ComponentTypeBsDriver // 1) Generate for PEI, DXE PCD DATABASE's definition and initialization. - // - genPcdDatabaseSourceCode (); - + // + genPcdDatabaseSourceCode (); + } - /** - This function generates source code for PCD Database. - - @param void - @throws EntityException If the token does *not* exist in memory database. + /** + This function generates source code for PCD Database. + + @param void + @throws EntityException If the token does *not* exist in memory database. - **/ + **/ - private void genPcdDatabaseSourceCode () - throws EntityException { - String PcdCommonHeaderString = PcdDatabase.getPcdDatabaseCommonDefinitions (); + private void genPcdDatabaseSourceCode () + throws EntityException { + String PcdCommonHeaderString = PcdDatabase.getPcdDatabaseCommonDefinitions (); - ArrayList alPei = new ArrayList (); - ArrayList alDxe = new ArrayList (); + ArrayList alPei = new ArrayList (); + ArrayList alDxe = new ArrayList (); - dbManager.getTwoPhaseDynamicRecordArray(alPei, alDxe); + dbManager.getTwoPhaseDynamicRecordArray(alPei, alDxe); PcdDatabase pcdPeiDatabase = new PcdDatabase (alPei, "PEI", 0); - pcdPeiDatabase.genCode(); - dbManager.PcdPeimHString = PcdCommonHeaderString + pcdPeiDatabase.getHString() - + PcdDatabase.getPcdPeiDatabaseDefinitions(); - dbManager.PcdPeimCString = pcdPeiDatabase.getCString(); + pcdPeiDatabase.genCode(); + dbManager.PcdPeimHString = PcdCommonHeaderString + pcdPeiDatabase.getHString() + + PcdDatabase.getPcdPeiDatabaseDefinitions(); + dbManager.PcdPeimCString = pcdPeiDatabase.getCString(); PcdDatabase pcdDxeDatabase = new PcdDatabase (alDxe, - "DXE", - alPei.size() - ); - pcdDxeDatabase.genCode(); - dbManager.PcdDxeHString = dbManager.PcdPeimHString + pcdDxeDatabase.getHString() - + PcdDatabase.getPcdDxeDatabaseDefinitions(); - dbManager.PcdDxeCString = pcdDxeDatabase.getCString(); - } + "DXE", + alPei.size() + ); + pcdDxeDatabase.genCode(); + dbManager.PcdDxeHString = dbManager.PcdPeimHString + pcdDxeDatabase.getHString() + + PcdDatabase.getPcdDxeDatabaseDefinitions(); + dbManager.PcdDxeCString = pcdDxeDatabase.getCString(); + } - /** + /** This function will collect inherit PCD information from library for a module. This function will create two usage instance for inherited PCD token, one is @@ -1679,7 +1679,7 @@ public class CollectPCDAction { token.assignedtokenNumber = Integer.decode(pcdBuildData.getToken().getStringValue()); skuDataArray = pcdBuildData.getSkuDataArray1(); token.datumType = Token.getdatumTypeFromString(pcdBuildData.getDatumType().toString()); - token.datumSize = pcdBuildData.getDatumSize(); + token.datumSize = pcdBuildData.getDatumSize(); if(skuDataArray != null) { for(skuIndex = 0; skuIndex < skuDataArray.size(); skuIndex ++) { diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java index 3d1f1baf63..bbf54119e4 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java +++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java @@ -190,13 +190,13 @@ public class PCDAutoGenAction extends BuildAction { } } - if (moduleName.equalsIgnoreCase("PcdPeim")) { - hAutoGenString += dbManager.PcdPeimHString; - cAutoGenString += dbManager.PcdPeimCString; - } else if (moduleName.equalsIgnoreCase("PcdDxe")) { - hAutoGenString += dbManager.PcdDxeHString; - cAutoGenString += dbManager.PcdDxeCString; - } + if (moduleName.equalsIgnoreCase("PcdPeim")) { + hAutoGenString += dbManager.PcdPeimHString; + cAutoGenString += dbManager.PcdPeimCString; + } else if (moduleName.equalsIgnoreCase("PcdDxe")) { + hAutoGenString += dbManager.PcdDxeHString; + cAutoGenString += dbManager.PcdDxeCString; + } ActionMessage.debug(this, "Module " + moduleName + "'s PCD header file:\r\n" + hAutoGenString + "\r\n" @@ -527,7 +527,7 @@ public class PCDAutoGenAction extends BuildAction { **/ public static void main(String argv[]) { - String WorkSpace = "G:/edk2"; + String WorkSpace = "G:/edk2"; String logFilePath = WorkSpace + "/EdkNt32Pkg/Nt32.fpd"; // @@ -552,13 +552,13 @@ public class PCDAutoGenAction extends BuildAction { // Then execute the PCDAuotoGenAction to get generated Autogen.h and Autogen.c // PCDAutoGenAction autogenAction = new PCDAutoGenAction("PcdDxe", - false + false ); - autogenAction.execute(); + autogenAction.execute(); - System.out.println(autogenAction.OutputH()); - System.out.println("WQWQWQWQWQ"); - System.out.println(autogenAction.OutputC()); + System.out.println(autogenAction.OutputH()); + System.out.println("WQWQWQWQWQ"); + System.out.println(autogenAction.OutputC()); System.out.println (autogenAction.hAutoGenString); diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/MemoryDatabaseManager.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/MemoryDatabaseManager.java index 7b22b271f9..7df96398ef 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/MemoryDatabaseManager.java +++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/MemoryDatabaseManager.java @@ -44,9 +44,9 @@ public class MemoryDatabaseManager { private static String logFileName = null; public static String PcdPeimHString = ""; - public static String PcdPeimCString = ""; - public static String PcdDxeHString = ""; - public static String PcdDxeCString = ""; + public static String PcdPeimCString = ""; + public static String PcdDxeHString = ""; + public static String PcdDxeCString = ""; /** Constructure function @@ -174,8 +174,8 @@ public class MemoryDatabaseManager { List usageInstanceArray = null; UsageInstance usageInstance = null; - //pei = new ArrayList(); - //dxe = new ArrayList(); + //pei = new ArrayList(); + //dxe = new ArrayList(); for (index = 0; index < tokenArrayList.size(); index++) { boolean found = false; @@ -199,25 +199,25 @@ public class MemoryDatabaseManager { usageInstance =(UsageInstance) usageInstanceArray.get(usageInstanceIndex); if (CommonDefinition.isPeiPhaseComponent(usageInstance.componentType)) { pei.add(token); - found = true; + found = true; break; } } } } - // - // If no PEI components reference the PCD entry, we insert it to DXE list - // - if (!found) { - dxe.add(token); - } + // + // If no PEI components reference the PCD entry, we insert it to DXE list + // + if (!found) { + dxe.add(token); + } } - return; + return; } - /** + /** Get all PCD record for a module according to module's name. @param moduleName the name of module. diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/Token.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/Token.java index b40e244c73..5931b8bceb 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/Token.java +++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/entity/Token.java @@ -258,9 +258,9 @@ public class Token { } } - public String getPrimaryKeyString () { - return cName + "_" + tokenSpaceName.toString().replace('-', '_'); - } + public String getPrimaryKeyString () { + return cName + "_" + tokenSpaceName.toString().replace('-', '_'); + } /** Judge datumType is valid @@ -645,13 +645,13 @@ public class Token { // public boolean hasDefaultValue () { - if (hiiEnabled) { - return true; - } + if (hiiEnabled) { + return true; + } - if (vpdEnabled) { - return true; - } + if (vpdEnabled) { + return true; + } if (datum.toString().compareTo("NoDefault") == 0) { return false; @@ -660,21 +660,21 @@ public class Token { return true; } - public boolean isStringType () { - String str = datum.toString(); + public boolean isStringType () { + String str = datum.toString(); - if (datumType == Token.DATUM_TYPE.POINTER && - str.startsWith("L\"") && - str.endsWith("\"")) { - return true; - } + if (datumType == Token.DATUM_TYPE.POINTER && + str.startsWith("L\"") && + str.endsWith("\"")) { + return true; + } - return false; - } + return false; + } - public String getStringTypeString () { - return datum.toString().substring(2, datum.toString().length() - 1); - } + public String getStringTypeString () { + return datum.toString().substring(2, datum.toString().length() - 1); + } }