Refine the code for PCD tools.
[mirror_edk2.git] / Tools / Source / PcdTools / org / tianocore / pcd / entity / UsageInstance.java
index 6fc66055eb8043bd8ba80e98cb22e1af4044de43..e38bc91aedb8eb4314a8b6ea2e37dfb5952985a8 100644 (file)
@@ -72,7 +72,7 @@ public class UsageInstance {
        Constructure function for UsageInstance\r
 \r
        @param parentToken         The token instance for this usgaInstance\r
-       @param id                  The identification for usage instance\r
+       @param usageId             The identification for usage instance\r
        @param modulePcdType       The PCD type for this usage instance\r
        @param value               The value of this PCD in this usage instance\r
        @param maxDatumSize        The max datum size of this PCD in this usage\r
@@ -193,20 +193,40 @@ public class UsageInstance {
 \r
         switch (modulePcdType) {\r
         case FEATURE_FLAG:\r
+            //\r
+            // Example autogen string for following generation:\r
+            // "extern const BOOLEAN _gPcd_FixedAtBuild_PcdSampleToken";\r
+            // \r
             hAutogenStr += String.format("extern const BOOLEAN _gPcd_FixedAtBuild_%s;\r\n",\r
                                          parentToken.cName);\r
+            //\r
+            // Example autogen string for following generation:\r
+            // "#define _PCD_GET_MODE_8_PcdSampleToken _gPcd_FixedAtBuild_PcdSampleToken";\r
+            // \r
             hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  _gPcd_FixedAtBuild_%s\r\n",\r
                                          Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                          parentToken.cName,\r
                                          parentToken.cName);\r
+            //\r
+            // Example autogen string for following generation:\r
+            // "//#define _PCD_SET_MODE_8_PcdSampleToken ASSERT(FALSE) If is not allowed to set value...";\r
+            // \r
             hAutogenStr += String.format("//#define _PCD_SET_MODE_%s_%s ASSERT(FALSE) If is not allowed to set value for a FEATURE_FLAG PCD\r\n",\r
                                          Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                          parentToken.cName);\r
 \r
             if (!isBuildUsedLibrary) {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_VALUE_PcdSampleToken 0x1000"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n",\r
                                              parentToken.cName,\r
                                              printDatum);\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_PcdSampleToken = _PCD_VALUE_PcdSampleToken;"\r
+                // \r
                 cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const BOOLEAN _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
                                              parentToken.cName,\r
                                              parentToken.cName);\r
@@ -214,47 +234,91 @@ public class UsageInstance {
             break;\r
         case FIXED_AT_BUILD:\r
             if (isByteArray) {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "extern const BOOLEAN _gPcd_FixedAtBuild_PcdSampleToken";\r
+                // \r
                 hAutogenStr += String.format("extern const UINT8 _gPcd_FixedAtBuild_%s[];\r\n",\r
                                              parentToken.cName);\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_GET_MODE_8_PcdSampleToken (VOID*)_gPcd_FixedAtBuild_PcdSampleToken";\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  (VOID*)_gPcd_FixedAtBuild_%s\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
                                              parentToken.cName);\r
             } else {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "extern const UINT8 _gPcd_FixedAtBuild_PcdSampleToken";\r
+                // \r
                 hAutogenStr += String.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",\r
                                              Token.getAutogendatumTypeString(parentToken.datumType),\r
                                              parentToken.cName);\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_GET_MODE_8_PcdSampleToken _gPcd_FixedAtBuild_PcdSampleToken";\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  _gPcd_FixedAtBuild_%s\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
                                              parentToken.cName);\r
             }\r
 \r
+            //\r
+            // Example autogen string for following generation:\r
+            // "//#define _PCD_SET_MODE_8_PcdSampleToken ASSERT(FALSE) If is not allowed to set value...";\r
+            // \r
             hAutogenStr += String.format("//#define _PCD_SET_MODE_%s_%s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\r\n",\r
                                          Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                          parentToken.cName);\r
             if (!isBuildUsedLibrary) {\r
                 if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
                     if (isByteArray) {\r
+                        //\r
+                        // Example autogen string for following generation:\r
+                        // "#define _PCD_VALUE_PcdSampleToken (VOID*)_gPcd_FixedAtBuild_PcdSampleToken"\r
+                        // \r
                         hAutogenStr += String.format("#define _PCD_VALUE_%s   (VOID*)_gPcd_FixedAtBuild_%s\r\n",\r
                                                      parentToken.cName,\r
                                                      parentToken.cName);\r
+                        //\r
+                        // Example autogen string for following generation:\r
+                        // "GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdSampleToken[] = 'dfdf';"\r
+                        // \r
                         cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_%s[] = %s;\r\n",\r
                                                      parentToken.cName,\r
                                                      printDatum);\r
                     } else {\r
+                        //\r
+                        // Example autogen string for following generation:\r
+                        // "#define _PCD_VALUE_PcdSampleToken 0x222"\r
+                        // \r
                         hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n",\r
                                                      parentToken.cName,\r
                                                      printDatum);\r
+                        //\r
+                        // Example autogen string for following generation:\r
+                        // "GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
+                        // \r
                         cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
                                                      Token.getAutogendatumTypeString(parentToken.datumType),\r
                                                      parentToken.cName,\r
                                                      parentToken.cName);\r
                     }\r
                 } else {\r
+                    //\r
+                    // Example autogen string for following generation:\r
+                    // "#define _PCD_VALUE_PcdSampleToken 0x222"\r
+                    // \r
                     hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n",\r
                                                  parentToken.cName,\r
                                                  printDatum);\r
+                    //\r
+                    // Example autogen string for following generation:\r
+                    // "GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
+                    // \r
                     cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
                                                  Token.getAutogendatumTypeString(parentToken.datumType),\r
                                                  parentToken.cName,\r
@@ -264,16 +328,32 @@ public class UsageInstance {
             break;\r
         case PATCHABLE_IN_MODULE:\r
             if (isByteArray) {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "extern UINT8 _gPcd_BinaryPatch_PcdSampleToken[];"\r
+                // \r
                 hAutogenStr += String.format("extern UINT8 _gPcd_BinaryPatch_%s[];\r\n",\r
                                              parentToken.cName);\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_GET_MODE_8_PcdSampleToken  (VOID*)_gPcd_BinaryPatch_PcdSampleToken"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  (VOID*)_gPcd_BinaryPatch_%s\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
                                              parentToken.cName);\r
             } else {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "extern UINT8 _gPcd_BinaryPatch_PcdSampleToken;"\r
+                // \r
                 hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",\r
                                              Token.getAutogendatumTypeString(parentToken.datumType),\r
                                              parentToken.cName);\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_GET_MODE_8_PcdSampleToken  _gPcd_BinaryPatch_PcdSampleToken"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  _gPcd_BinaryPatch_%s\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
@@ -284,11 +364,19 @@ public class UsageInstance {
             // Generate _PCD_SET_MODE_xx macro for using set BinaryPatch value via PcdSet macro\r
             //\r
             if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_PcdSampleToken, (Buffer), (SizeOfBuffer))"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) CopyMem (_gPcd_BinaryPatch_%s, (Buffer), (SizeOfBuffer))\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
                                              parentToken.cName);\r
             } else {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) (_gPcd_BinaryPatch_PcdSampleToken = (Value))"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) (_gPcd_BinaryPatch_%s = (Value))\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
@@ -296,14 +384,26 @@ public class UsageInstance {
             }\r
 \r
             if (!isBuildUsedLibrary) {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_VALUE_PcdSampleToken   0x111"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n",\r
                                              parentToken.cName,\r
                                              printDatum);\r
                 if (isByteArray) {\r
+                    //\r
+                    // Example autogen string for following generation:\r
+                    // "GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
+                    // \r
                     cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_%s[] = _PCD_VALUE_%s;\r\n",\r
                                                  parentToken.cName,\r
                                                  parentToken.cName);\r
                 } else {\r
+                    //\r
+                    // Example autogen string for following generation:\r
+                    // "GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_PcdSampleToken[] = _PCD_VALUE_PcdSampleToken;"\r
+                    // \r
                     cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED %s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;\r\n",\r
                                                  Token.getAutogendatumTypeString(parentToken.datumType),\r
                                                  parentToken.cName,\r
@@ -313,18 +413,30 @@ public class UsageInstance {
 \r
             break;\r
         case DYNAMIC:\r
+            //\r
+            // Example autogen string for following generation:\r
+            // "#define _PCD_GET_MODE_8_PcdSampleToken  LibPcdGet%s(_PCD_TOKEN_PcdSampleToken)"\r
+            // \r
             hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s  LibPcdGet%s(_PCD_TOKEN_%s)\r\n",\r
                                          Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                          parentToken.cName,\r
                                          Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
                                          parentToken.cName);\r
             if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer)  LibPcdSet%s(_PCD_TOKEN_PcdSampleToken, (SizeOfBuffer), (Buffer))"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer)  LibPcdSet%s(_PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
                                              Token.getAutogenLibrarydatumTypeString(parentToken.datumType),\r
                                              parentToken.cName);\r
             } else {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_SET_MODE_8_PcdSampleToken(Value)  LibPcdSet%s(_PCD_TOKEN_PcdSampleToken, (Value))"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value)  LibPcdSet%s(_PCD_TOKEN_%s, (Value))\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
@@ -336,6 +448,10 @@ public class UsageInstance {
             guidStringCName = "_gPcd_TokenSpaceGuid_" +\r
                               parentToken.tokenSpaceName.toString().replaceAll("-", "_");\r
 \r
+            //\r
+            // Example autogen string for following generation:\r
+            // "#define _PCD_GET_MODE_8_PcdSampleToken LibPcdGetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken)"\r
+            // \r
             hAutogenStr += String.format("#define _PCD_GET_MODE_%s_%s LibPcdGetEx%s(&%s, _PCD_TOKEN_%s)\r\n",\r
                                          Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                          parentToken.cName,\r
@@ -344,6 +460,10 @@ public class UsageInstance {
                                          parentToken.cName);\r
 \r
             if (parentToken.datumType == Token.DATUM_TYPE.POINTER) {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_SET_MODE_8_PcdSampleToken(SizeOfBuffer, Buffer) LibPcdSetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken, (SizeOfBuffer), (Buffer))"\r
+                // \r
                 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (SizeOfBuffer), (Buffer))\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r
@@ -351,6 +471,10 @@ public class UsageInstance {
                                              guidStringCName,\r
                                              parentToken.cName);\r
             } else {\r
+                //\r
+                // Example autogen string for following generation:\r
+                // "#define _PCD_SET_MODE_8_PcdSampleToken(Value) LibPcdSetEx%s(&_gPcd_TokenSpaceGuid_00_00_00, _PCD_TOKEN_PcdSampleToken, (Value))"\r
+                //\r
                 hAutogenStr += String.format("#define _PCD_SET_MODE_%s_%s(Value) LibPcdSetEx%s(&%s, _PCD_TOKEN_%s, (Value))\r\n",\r
                                              Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
                                              parentToken.cName,\r