]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java
1) correct the assert condition for LibPcdSetPtr and LibPcdSetExPtr
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / pcd / action / CollectPCDAction.java
index f6ea239b3830ef5a189c0116e6b90d22b88f8a0b..40a462c3d0c3e85564e03a6e7769fb4d732a1838 100644 (file)
@@ -107,7 +107,7 @@ class StringTable {
         // If we have a empty StringTable\r
         //\r
         if (al.size() == 0) {\r
-            cDeclCode += tab + String.format("UINT16             %s[1]; /* StringTable is Empty */", stringTable) + newLine; \r
+            cDeclCode += String.format("%-20s%s[1]; /* StringTable is empty */", "UINT16", stringTable) + newLine; \r
             decl = new CStructTypeDeclaration (\r
                                                 stringTable,\r
                                                 2,\r
@@ -116,7 +116,7 @@ class StringTable {
                                         );  \r
             declaList.add(decl);\r
 \r
-            cInstCode = " { 0 } " + String.format("/* %s */", stringTable);\r
+            cInstCode = String.format("/* %s */", stringTable) + newLine + tab + "{ 0 }";\r
             instTable.put(stringTable, cInstCode);\r
         } else {\r
 \r
@@ -137,7 +137,7 @@ class StringTable {
                     stringTableName = String.format("%s_%d", stringTable, i);\r
                     cDeclCode += tab;\r
                 }\r
-                cDeclCode += String.format("UINT16              %s[%d]; /* %s */", stringTableName, str.length() + 1, alComments.get(i)) + newLine;\r
+                cDeclCode += String.format("%-20s%s[%d]; /* %s */", "UINT16", stringTableName, str.length() + 1, alComments.get(i)) + newLine;\r
                 \r
                 if (i == 0) {\r
                     cInstCode = "/* StringTable */" + newLine;\r
@@ -295,7 +295,7 @@ class SizeTable {
         Output.add("/* SizeTable */");\r
         Output.add("{");\r
         if (al.size() == 0) {\r
-            Output.add("0");\r
+            Output.add("\t0");\r
         } else {\r
             for (int index = 0; index < al.size(); index++) {\r
                 Integer n = al.get(index);\r
@@ -387,7 +387,7 @@ class GuidTable {
 \r
         guidStrArray =(uuid.toString()).split("-");\r
 \r
-        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 } }",\r
+        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}}",\r
                                          guidStrArray[0],\r
                                          guidStrArray[1],\r
                                          guidStrArray[2],\r
@@ -408,7 +408,7 @@ class GuidTable {
         Output.add("/* GuidTable */");\r
         Output.add("{");\r
         if (al.size() == 0) {\r
-            Output.add(getUuidCString(new UUID(0, 0)));\r
+            Output.add("\t" + getUuidCString(new UUID(0, 0)));\r
         }\r
         \r
         for (int i = 0; i < al.size(); i++) {\r
@@ -505,7 +505,7 @@ class SkuIdTable {
             decl = new CStructTypeDeclaration (\r
                                                 "SystemSkuId",\r
                                                 1,\r
-                                                "SKU_ID          SystemSkuId;\r\n",\r
+                                                String.format("%-20sSystemSkuId;\r\n", "SKU_ID"),\r
                                                 true\r
                                               );\r
             declaList.add(decl);\r
@@ -662,7 +662,7 @@ class LocalTokenNumberTable {
         output.add("{");\r
 \r
         if (al.size() == 0) {\r
-            output.add("0");\r
+            output.add("\t0");\r
         }\r
         \r
         for (int index = 0; index < al.size(); index++) {\r
@@ -864,12 +864,12 @@ class PcdDatabase {
     private final String        newLine                         = "\r\n";\r
     private final String        commaNewLine                    = ",\r\n";\r
     private final String        tab                             = "\t";\r
-    public final static String ExMapTableDeclaration            = "DYNAMICEX_MAPPING ExMapTable[%s_EXMAPPING_TABLE_SIZE];\r\n";\r
-    public final static String GuidTableDeclaration             = "EFI_GUID          GuidTable[%s_GUID_TABLE_SIZE];\r\n";\r
-    public final static String LocalTokenNumberTableDeclaration = "UINT32            LocalTokenNumberTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n";\r
-    public final static String StringTableDeclaration           = "UINT16            StringTable[%s_STRING_TABLE_SIZE];\r\n";\r
-    public final static String SizeTableDeclaration             = "UINT16            SizeTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n";\r
-    public final static String SkuIdTableDeclaration            = "UINT8             SkuIdTable[%s_SKUID_TABLE_SIZE];\r\n";\r
+    public final static String ExMapTableDeclaration            = "DYNAMICEX_MAPPING   ExMapTable[%s_EXMAPPING_TABLE_SIZE];\r\n";\r
+    public final static String GuidTableDeclaration             = "EFI_GUID            GuidTable[%s_GUID_TABLE_SIZE];\r\n";\r
+    public final static String LocalTokenNumberTableDeclaration = "UINT32              LocalTokenNumberTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n";\r
+    public final static String StringTableDeclaration           = "UINT16              StringTable[%s_STRING_TABLE_SIZE];\r\n";\r
+    public final static String SizeTableDeclaration             = "UINT16              SizeTable[%s_LOCAL_TOKEN_NUMBER_TABLE_SIZE];\r\n";\r
+    public final static String SkuIdTableDeclaration            = "UINT8               SkuIdTable[%s_SKUID_TABLE_SIZE];\r\n";\r
 \r
 \r
     public final static String ExMapTableSizeMacro              = "#define %s_EXMAPPING_TABLE_SIZE  %d\r\n";\r
@@ -1206,7 +1206,8 @@ class PcdDatabase {
                 //\r
                 // We made a assumption that both PEI_PCD_DATABASE and DXE_PCD_DATABASE\r
                 // has a least one data memember with alignment size of 1. So we can\r
-                // remove the last "," in the C structure instantiation string.\r
+                // remove the last "," in the C structure instantiation string. Luckily,\r
+                // this is true as both data structure has SKUID_TABLE anyway.\r
                 //\r
                 if ((align == 1) && (i == declaListBasedOnAlignment.size() - 1)) {\r
                     initInstStr += newLine;\r
@@ -1228,7 +1229,7 @@ class PcdDatabase {
         }\r
         \r
         if (uinitDatabaseEmpty) {\r
-            uninitDeclStr += tab + "   UINT8        dummy; /* PCD_DATABASE_UNINIT is emptry */\r\n";\r
+            uninitDeclStr += tab + String.format("%-20sdummy; /* PCD_DATABASE_UNINIT is emptry */\r\n", "UINT8");\r
         }\r
         \r
         initDeclStr += String.format("} %s_PCD_DATABASE_INIT;", phase) + newLine + newLine;\r
@@ -1475,7 +1476,7 @@ class PcdDatabase {
     }\r
 \r
     private String getSkuEnabledTypeDeclaration (Token token) {\r
-        return String.format("SKU_HEAD %s;\r\n", token.getPrimaryKeyString());\r
+        return String.format("%-20s%s;\r\n", "SKU_HEAD", token.getPrimaryKeyString());\r
     }\r
 \r
     private String getSkuEnabledTypeInstantiaion (Token token, int SkuTableIdx) {\r
@@ -1581,20 +1582,29 @@ class PcdDatabase {
         }\r
 \r
         if (t.isUnicodeStringType()) {\r
-            privateGlobalCCode = String.format("STRING_HEAD              %s[%d];\r\n", t.getPrimaryKeyString(), t.getSkuIdCount());\r
+            privateGlobalCCode = String.format("%-20s%s[%d];\r\n", "STRING_HEAD", t.getPrimaryKeyString(), t.getSkuIdCount());\r
         } else {\r
             String type = getCType(t);\r
             if (t.datumType == Token.DATUM_TYPE.POINTER) {\r
-                privateGlobalCCode = String.format("%s              %s[%d][%d];\r\n", type, privateGlobalName, t.getSkuIdCount(), t.datumSize);\r
+                int bufferSize;\r
+                if (t.isASCIIStringType()) {\r
+                    //\r
+                    // Build tool will add a NULL string at the end of the ASCII string\r
+                    //\r
+                    bufferSize = t.datumSize + 1;\r
+                } else {\r
+                    bufferSize = t.datumSize;\r
+                }\r
+                privateGlobalCCode = String.format("%-20s%s[%d][%d];\r\n", type, privateGlobalName, t.getSkuIdCount(), bufferSize);\r
             } else {\r
-                privateGlobalCCode = String.format("%s              %s[%d];\r\n", type, privateGlobalName, t.getSkuIdCount());\r
+                privateGlobalCCode = String.format("%-20s%s[%d];\r\n", type, privateGlobalName, t.getSkuIdCount());\r
             }\r
         }\r
     }\r
     \r
     private String getDataTypeDeclarationForVariableDefault_new (Token token, String cName, int skuId) {\r
 \r
-        String typeStr = "";\r
+        String typeStr;\r
 \r
         if (token.datumType == Token.DATUM_TYPE.UINT8) {\r
             typeStr = "UINT8";\r
@@ -1607,11 +1617,12 @@ class PcdDatabase {
         } else if (token.datumType == Token.DATUM_TYPE.BOOLEAN) {\r
             typeStr = "BOOLEAN";\r
         } else if (token.datumType == Token.DATUM_TYPE.POINTER) {\r
-            return String.format("UINT8 %s[%d]", cName, token.datumSize);\r
+            return String.format("%-20s%s[%d];\r\n", cName, token.datumSize);\r
         } else {\r
+            typeStr = "";\r
         }\r
 \r
-        return String.format("%s             %s;\r\n", typeStr, cName);\r
+        return String.format("%-20s%s;\r\n", typeStr, cName);\r
     }\r
     \r
     private String getDataTypeDeclaration (Token token) {\r