\r
str = String.format(PcdDatabase.offsetOfStrTemplate, phase, token.hasDefaultValue() ? "Init" : "Uninit", token.getPrimaryKeyString());\r
\r
- if (token.isStringType()) {\r
+ if (token.isUnicodeStringType()) {\r
str += " | PCD_TYPE_STRING";\r
}\r
\r
return 4;\r
}\r
\r
- if (token.isStringType()) {\r
+ if (token.isUnicodeStringType()) {\r
return 2;\r
}\r
\r
} else if (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.VPD_TYPE) {\r
decl.add(getVpdEnableTypeDeclaration(token));\r
inst.add(getVpdEnableTypeInstantiation(token));\r
- } else if (token.isStringType()) {\r
+ } else if (token.isUnicodeStringType()) {\r
decl.add(getStringTypeDeclaration(token));\r
inst.add(getStringTypeInstantiation(stringTable.add(token.getStringTypeString(), token), token));\r
}\r
int value;\r
BigInteger value64;\r
String subStr;\r
+ int index;\r
\r
if (moduleName == null) {\r
moduleName = "section <DynamicPcdBuildDefinitions>";\r
if ((start > end) || \r
(end > datum.length())||\r
((start == end) && (datum.length() > 0))) {\r
- exceptionString = String.format("The datum type of PCD %s in %s is VOID* and datum is "+\r
+ exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID* and datum is "+\r
"a UNICODE string because start with L\", but format maybe"+\r
"is not right, correct UNICODE string is L\"...\"!",\r
cName,\r
\r
strValue = datum.substring(start + 1, end);\r
if ((strValue.length() * 2) > maxDatumSize) {\r
- exceptionString = String.format("The datum type of PCD %s in %s is VOID*, and datum is "+\r
+ exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and datum is "+\r
"a UNICODE string, but the datum size is %d exceed to <MaxDatumSize> : %d",\r
cName,\r
moduleName,\r
if ((start > end) || \r
(end > datum.length())||\r
((start == end) && (datum.length() > 0))) {\r
- exceptionString = String.format("The datum type of PCD %s in %s is VOID* and datum is "+\r
+ exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID* and datum is "+\r
"a ANSCII string because start with \", but format maybe"+\r
"is not right, correct ANSIC string is \"...\"!",\r
cName,\r
}\r
strValue = datum.substring(start + 1, end);\r
if ((strValue.length()) > maxDatumSize) {\r
- exceptionString = String.format("The datum type of PCD %s in %s is VOID*, and datum is "+\r
+ exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and datum is "+\r
"a ANSCI string, but the datum size is %d which exceed to <MaxDatumSize> : %d",\r
cName,\r
moduleName,\r
\r
start = datum.indexOf('{');\r
end = datum.lastIndexOf('}');\r
- strValue = datum.substring(start, end);\r
+ strValue = datum.substring(start + 1, end);\r
+ strValue = strValue.trim();\r
+ if (strValue.length() == 0) {\r
+ break;\r
+ }\r
strValueArray = strValue.split(",");\r
+ for (index = 0; index < strValueArray.length; index ++) {\r
+ try{\r
+ value = Integer.decode(strValueArray[index]);\r
+ } catch (NumberFormatException nfeEx) {\r
+ exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and "+\r
+ "it is byte array in fact. For every byte in array should be a valid"+\r
+ "byte digital, but element %s is not a valid byte digital!",\r
+ cName,\r
+ moduleName,\r
+ strValueArray[index]);\r
+ return exceptionString;\r
+ }\r
+ if (value > 0xFF) {\r
+ exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, "+\r
+ "it is byte array in fact. But the element of %s exceed the byte range",\r
+ cName,\r
+ moduleName,\r
+ strValueArray[index]);\r
+ return exceptionString;\r
+ }\r
+ }\r
+\r
if (strValueArray.length > maxDatumSize) {\r
- exceptionString = String.format("The datum type of PCD %s in %s is VOID*, and datum is byte"+\r
+ exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and datum is byte"+\r
"array, but the number of bytes is %d which exceed to <MaxDatumSzie> : %d!",\r
cName,\r
moduleName,\r
return exceptionString;\r
}\r
} else {\r
- exceptionString = String.format("The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+\r
+ exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+\r
"1) UNICODE string: like L\"xxxx\";\r\n"+\r
"2) ANSIC string: like \"xxx\";\r\n"+\r
"3) Byte array: like {0x2, 0x45, 0x23}\r\n"+\r
\r
return null;\r
}\r
+\r
+ /**\r
+ Get default value for a token, For HII type, HiiDefaultValue of default\r
+ SKU 0 will be returned; For Default type, the defaultvalue of default SKU\r
+ 0 will be returned.\r
+ \r
+ @return String\r
+ */\r
+ public String getDynamicDefaultValue() {\r
+ DynamicTokenValue dynamicData = getDefaultSku();\r
+ if (hasDefaultValue()) {\r
+ switch (dynamicData.type) {\r
+ case HII_TYPE:\r
+ return dynamicData.hiiDefaultValue;\r
+ case DEFAULT_TYPE:\r
+ return dynamicData.value;\r
+ }\r
+ }\r
+\r
+ return null;\r
+ }\r
+\r
//\r
// BugBug: We need change this algorithm accordingly when schema is updated\r
// to support no default value.\r
return false;\r
}\r
\r
- public boolean isStringType () {\r
- String str = getDefaultSku().value;\r
+ /**\r
+ Judege whether current value is UNICODE string type.\r
+ @return boolean\r
+ */\r
+ public boolean isUnicodeStringType () {\r
+ String str = getDynamicDefaultValue();\r
+\r
+ if (str == null) {\r
+ return false;\r
+ }\r
\r
- //\r
- // BUGBUG: need scott confirmation.\r
- // \r
- if (datumType == Token.DATUM_TYPE.POINTER) {\r
+ if (datumType == Token.DATUM_TYPE.POINTER &&\r
+ str.startsWith("L\"") && \r
+ str.endsWith("\"")) {\r
return true;\r
}\r
\r