]> git.proxmox.com Git - mirror_edk2.git/commitdiff
This patch make sure that Pcd Dynamic database generation tool is able to handle...
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 21 Aug 2006 05:53:51 +0000 (05:53 +0000)
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 21 Aug 2006 05:53:51 +0000 (05:53 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1329 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/GenBuild/org/tianocore/build/pcd/action/PcdDatabase.java
Tools/Source/PcdTools/org/tianocore/pcd/entity/DynamicTokenValue.java

index 2af4e9331813a3e3091314f222a4186cb47d763c..70adb9a6afe63fddbc872c756fb5452b9b80debf 100644 (file)
@@ -53,16 +53,42 @@ class CStructTypeDeclaration {
 \r
 **/\r
 class StringTable {\r
-    private ArrayList<String>   al;\r
+    class UnicodeString {\r
+        //\r
+        // In Schema, we define VariableName in DynamicPcdBuildDefinitions in FPD\r
+        // file to be HexWordArrayType. For example, Unicode String L"Setup" is \r
+        // <VariableName>0x0053 0x0065 0x0074 0x0075 0x0070</VariableName>. \r
+        // We use raw to differentiate if the String is in form of L"Setup" (raw is false) or\r
+        // in form of {0x0053, 0x0065, 0x0074, 0x0075, 0x0070}\r
+        //\r
+        // This str is the string that can be pasted directly into the C structure. \r
+        // For example, this str can be two forms:\r
+        //      \r
+        //      L"Setup",\r
+        //      {0x0053, 0065, 0x0074, 0x0075, 0x0070, 0x0000}, //This is another form of L"Setup"\r
+        //\r
+        public String      str;\r
+        //\r
+        // This len includes the NULL character at the end of the String.\r
+        //\r
+        public int         len;\r
+        \r
+        public UnicodeString (String str, int len) {\r
+            this.str = str;\r
+            this.len = len;\r
+        }\r
+    }\r
+    \r
+    private ArrayList<UnicodeString>   al;\r
     private ArrayList<String>   alComments;\r
     private String              phase;\r
-    int                         len;\r
+    int                         stringTableCharNum;\r
 \r
     public StringTable (String phase) {\r
         this.phase = phase;\r
-        al = new ArrayList<String>();\r
+        al = new ArrayList<UnicodeString>();\r
         alComments = new ArrayList<String>();\r
-        len = 0;\r
+        stringTableCharNum = 0;\r
     }\r
 \r
     public String getSizeMacro () {\r
@@ -73,7 +99,7 @@ class StringTable {
         //\r
         // We have at least one Unicode Character in the table.\r
         //\r
-        return len == 0 ? 1 : len;\r
+        return stringTableCharNum == 0 ? 1 : stringTableCharNum;\r
     }\r
 \r
     public String getExistanceMacro () {\r
@@ -112,7 +138,7 @@ class StringTable {
             // If there is any String in the StringTable\r
             //\r
             for (int i = 0; i < al.size(); i++) {\r
-                String str = al.get(i);\r
+                UnicodeString uStr = al.get(i);\r
                 String stringTableName;\r
 \r
                 if (i == 0) {\r
@@ -126,7 +152,7 @@ class StringTable {
                     cDeclCode += tab;\r
                 }\r
                 cDeclCode += String.format("%-20s%s[%d]; /* %s */", "UINT16",\r
-                                           stringTableName, str.length() + 1,\r
+                                           stringTableName, uStr.len,\r
                                            alComments.get(i))\r
                              + newLine;\r
 \r
@@ -134,7 +160,7 @@ class StringTable {
                     cInstCode = "/* StringTable */" + newLine;\r
                 }\r
 \r
-                cInstCode += tab + String.format("L\"%s\" /* %s */", al.get(i), alComments.get(i));\r
+                cInstCode += tab + String.format("%s /* %s */", uStr.str, alComments.get(i));\r
                 if (i != al.size() - 1) {\r
                     cInstCode += commaNewLine;\r
                 }\r
@@ -151,11 +177,28 @@ class StringTable {
             instTable.put(stringTable, cInstCode);\r
         }\r
     }\r
+    \r
+    public int add (List inputStr, Token token) {\r
+        String str;\r
+        \r
+        str = "{";\r
+        \r
+        for (int i = 0; i < inputStr.size(); i++) {\r
+            str += " " + inputStr.get(i) + ",";\r
+        }\r
+        \r
+        str +=  " 0x0000";\r
+            \r
+        str += "}";\r
+        //\r
+        // This is a raw Unicode String\r
+        //\r
+        return addToTable (str, inputStr.size() + 1, token);\r
+    }\r
 \r
     public int add (String inputStr, Token token) {\r
-        int i;\r
-        int pos;\r
 \r
+        int len;\r
         String str = inputStr;\r
 \r
         //\r
@@ -163,27 +206,48 @@ class StringTable {
         // "L\"Bootmode\"" or "Bootmode".\r
         // We drop the L\" and \" for the first type.\r
         if (str.startsWith("L\"") && str.endsWith("\"")) {\r
-            str = str.substring(2, str.length() - 1);\r
+            //\r
+            // Substract the character of "L", """, """.\r
+            // and add in the NULL character. So it is 2.\r
+            //\r
+            len = str.length() - 2;\r
+        } else {\r
+            //\r
+            // Include the NULL character.\r
+            //\r
+            len = str.length() + 1;\r
+            str = "L\"" + str + "\"";\r
         }\r
+        \r
+        //\r
+        // After processing, this is L"A String Sample" type of string.\r
+        //\r
+        return addToTable (str, len, token);\r
+    }\r
+    \r
+    private int addToTable (String inputStr, int len, Token token) {\r
+        int i;\r
+        int pos;\r
+\r
         //\r
         // Check if StringTable has this String already.\r
         // If so, return the current pos.\r
         //\r
         for (i = 0, pos = 0; i < al.size(); i++) {\r
-            String s = al.get(i);;\r
+            UnicodeString s = al.get(i);;\r
 \r
-            if (str.equals(s)) {\r
+            if (inputStr.equals(s.str)) {\r
                 return pos;\r
             }\r
-            pos = s.length() + 1;\r
+            pos += s.len;\r
         }\r
 \r
-        i = len;\r
+        i = stringTableCharNum;\r
         //\r
         // Include the NULL character at the end of String\r
         //\r
-        len += str.length() + 1;\r
-        al.add(str);\r
+        stringTableCharNum += len;\r
+        al.add(new UnicodeString(inputStr, len));\r
         alComments.add(token.getPrimaryKeyString());\r
 \r
         return i;\r
index d1e113352bbdb85e117ddb734363b6bfc35f8077..15d003622c1b9055def07cb8054947f0bd7a128b 100644 (file)
@@ -125,30 +125,12 @@ public class DynamicTokenValue {
     }\r
 \r
     /**\r
-       Get the string like L"xxx" for a variable Name.\r
-\r
-       BUGBUG: In fact, it is not correctly, variable name should be\r
-               treated as unicode UINT16 array.\r
+       Get the variable Name.\r
 \r
        @return String\r
     **/\r
-    public String getStringOfVariableName()\r
-        throws EntityException {\r
-        String str;\r
-        int    index, num;\r
-        int    size;\r
-\r
-        str  = "";\r
-        size = variableName.size();\r
-        for (index = 0; index < size; index++) {\r
-            num = Integer.decode(variableName.get(index).toString());\r
-            if ((num > 127 ) || (num < 0)) {\r
-                throw new EntityException(String.format("The variable name contains more than 0x80 characters; this is not supported at thist time!"));\r
-            }\r
-            str += (char)num;\r
-        }\r
-\r
-        return str;\r
+    public List getStringOfVariableName() {\r
+        return variableName;\r
     }\r
 \r
     /**\r