]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Common/Misc.py
BaseTools: Collect DynamicHii PCD values and assign it to VPD PCD Value
[mirror_edk2.git] / BaseTools / Source / Python / Common / Misc.py
index 2bbd9945fc0ad702cd2272fbe88b068dceb124c1..3ae2ec5b59b2204a505e7f06e115d9235ff2eb33 100644 (file)
@@ -2201,6 +2201,29 @@ def BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, Val
         elif Value == 'FALSE' or Value == '0':\r
             Value = '0'\r
     return  Value\r
+##  Get the integer value from string like "14U" or integer like 2\r
+#\r
+#   @param      Input   The object that may be either a integer value or a string\r
+#\r
+#   @retval     Value    The integer value that the input represents\r
+#\r
+def GetIntegerValue(Input):\r
+    if type(Input) in (int, long):\r
+        return Input\r
+    String = Input\r
+    if String.endswith("U"):\r
+        String = String[:-1]\r
+    if String.endswith("ULL"):\r
+        String = String[:-3]\r
+    if String.endswith("LL"):\r
+        String = String[:-2]\r
+\r
+    if String.startswith("0x") or String.startswith("0X"):\r
+        return int(String, 16)\r
+    elif String == '':\r
+        return 0\r
+    else:\r
+        return int(String)\r
 \r
 ##\r
 #\r