* [PATCH v1 1/4] BaseTools: no need to do int() API work for it
2018-03-29 0:02 [PATCH v1 0/4] BaseTools: eliminate some redundant code Jaben Carsey
@ 2018-03-29 0:02 ` Jaben Carsey
2018-03-29 0:02 ` [PATCH v1 2/4] BaseTools: use in to compare single chars Jaben Carsey
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jaben Carsey @ 2018-03-29 0:02 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
int() with base=0 will already auto determine base from preceeding 0x/0X
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
BaseTools/Source/Python/AutoGen/GenC.py | 5 +----
BaseTools/Source/Python/Common/Expression.py | 4 ++--
BaseTools/Source/Python/GenFds/FdfParser.py | 5 +----
BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py | 10 ++--------
4 files changed, 6 insertions(+), 18 deletions(-)
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 481c4dda1447..211b27e6997c 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1032,10 +1032,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
try:
if Value.upper().endswith('L'):
Value = Value[:-1]
- if Value.upper().startswith('0X'):
- ValueNumber = int (Value, 16)
- else:
- ValueNumber = int (Value)
+ ValueNumber = int (Value, 0)
except:
EdkLogger.error("build", AUTOGEN_ERROR,
"PCD value is not valid dec or hex number for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName),
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 4f0f377f3788..4a3dea1190b2 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -845,7 +845,7 @@ class ValueExpressionEx(ValueExpression):
if ItemSize == 0:
try:
- tmpValue = int(Item, 16) if Item.upper().startswith('0X') else int(Item, 0)
+ tmpValue = int(Item, 0)
if tmpValue > 255:
raise BadExpression("Byte array number %s should less than 0xFF." % Item)
except BadExpression, Value:
@@ -857,7 +857,7 @@ class ValueExpressionEx(ValueExpression):
ItemValue = ParseFieldValue(Item)[0]
if type(ItemValue) == type(''):
- ItemValue = int(ItemValue, 16) if ItemValue.startswith('0x') else int(ItemValue)
+ ItemValue = int(ItemValue, 0)
TmpValue = (ItemValue << (Size * 8)) | TmpValue
Size = Size + ItemSize
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index e35057931f03..bf78baac2185 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1145,10 +1145,7 @@ class FdfParser:
if Scope in ['UINT64', 'UINT8']:
ValueNumber = 0
try:
- if Value.upper().startswith('0X'):
- ValueNumber = int (Value, 16)
- else:
- ValueNumber = int (Value)
+ ValueNumber = int (Value, 0)
except:
EdkLogger.error("FdfParser", FORMAT_INVALID, "The value is not valid dec or hex number for %s." % Name)
if ValueNumber < 0:
diff --git a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
index 942ba88d200f..3db480d0cdc6 100644
--- a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
+++ b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
@@ -110,10 +110,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
ValueNumber = 1
elif ValueString == 'FALSE':
ValueNumber = 0
- elif ValueString.startswith('0X'):
- ValueNumber = int (ValueString, 16)
- else:
- ValueNumber = int (ValueString)
+ ValueNumber = int (ValueString, 0)
if ValueNumber != 0:
ValueNumber = 1
except:
@@ -127,10 +124,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
# Get PCD value for UINT* data type
#
try:
- if ValueString.startswith('0X'):
- ValueNumber = int (ValueString, 16)
- else:
- ValueNumber = int (ValueString)
+ ValueNumber = int (ValueString, 0)
except:
return PARAMETER_INVALID, "PCD Value %s is not valid dec or hex string." % (ValueString)
#
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 2/4] BaseTools: use in to compare single chars
2018-03-29 0:02 [PATCH v1 0/4] BaseTools: eliminate some redundant code Jaben Carsey
2018-03-29 0:02 ` [PATCH v1 1/4] BaseTools: no need to do int() API work for it Jaben Carsey
@ 2018-03-29 0:02 ` Jaben Carsey
2018-03-29 0:02 ` [PATCH v1 3/4] BaseTools: remove loop and variables Jaben Carsey
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jaben Carsey @ 2018-03-29 0:02 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
instead if 3 Startswith for single chars, just use in with a list of chars
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
BaseTools/Source/Python/Common/Expression.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 4a3dea1190b2..51f83ad4c7a4 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -835,7 +835,7 @@ class ValueExpressionEx(ValueExpression):
elif Item.startswith('UINT64'):
ItemSize = 8
ValueType = 'UINT64'
- elif Item.startswith('"') or Item.startswith("'") or Item.startswith('L'):
+ elif Item[0] in ['"',"'",'L']:
ItemSize = 0
ValueType = 'VOID*'
else:
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 3/4] BaseTools: remove loop and variables.
2018-03-29 0:02 [PATCH v1 0/4] BaseTools: eliminate some redundant code Jaben Carsey
2018-03-29 0:02 ` [PATCH v1 1/4] BaseTools: no need to do int() API work for it Jaben Carsey
2018-03-29 0:02 ` [PATCH v1 2/4] BaseTools: use in to compare single chars Jaben Carsey
@ 2018-03-29 0:02 ` Jaben Carsey
2018-03-29 0:02 ` [PATCH v1 4/4] BaseTools: cleanup class heirarchy Jaben Carsey
2018-03-30 1:12 ` [PATCH v1 0/4] BaseTools: eliminate some redundant code Zhu, Yonghong
4 siblings, 0 replies; 6+ messages in thread
From: Jaben Carsey @ 2018-03-29 0:02 UTC (permalink / raw)
To: edk2-devel; +Cc: Yonghong Zhu, Liming Gao
this loop does nothing. none of Key, Item, nor DevicePathList
are ever used.
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
BaseTools/Source/Python/Common/Misc.py | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 7d44fdcf8ba7..834c3a5321f0 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1495,21 +1495,8 @@ def AnalyzePcdExpression(Setting):
return FieldList
def ParseDevPathValue (Value):
- DevPathList = [ "Path","HardwarePath","Pci","PcCard","MemoryMapped","VenHw","Ctrl","BMC","AcpiPath","Acpi","PciRoot",
- "PcieRoot","Floppy","Keyboard","Serial","ParallelPort","AcpiEx","AcpiExp","AcpiAdr","Msg","Ata","Scsi",
- "Fibre","FibreEx","I1394","USB","I2O","Infiniband","VenMsg","VenPcAnsi","VenVt100","VenVt100Plus",
- "VenUtf8","UartFlowCtrl","SAS","SasEx","NVMe","UFS","SD","eMMC","DebugPort","MAC","IPv4","IPv6","Uart",
- "UsbClass","UsbAudio","UsbCDCControl","UsbHID","UsbImage","UsbPrinter","UsbMassStorage","UsbHub",
- "UsbCDCData","UsbSmartCard","UsbVideo","UsbDiagnostic","UsbWireless","UsbDeviceFirmwareUpdate",
- "UsbIrdaBridge","UsbTestAndMeasurement","UsbWwid","Unit","iSCSI","Vlan","Uri","Bluetooth","Wi-Fi",
- "MediaPath","HD","CDROM","VenMedia","Media","Fv","FvFile","Offset","RamDisk","VirtualDisk","VirtualCD",
- "PersistentVirtualDisk","PersistentVirtualCD","BbsPath","BBS","Sata" ]
if '\\' in Value:
Value.replace('\\', '/').replace(' ', '')
- for Item in Value.split('/'):
- Key = Item.strip().split('(')[0]
- if Key not in DevPathList:
- pass
Cmd = 'DevicePath ' + '"' + Value + '"'
try:
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 4/4] BaseTools: cleanup class heirarchy
2018-03-29 0:02 [PATCH v1 0/4] BaseTools: eliminate some redundant code Jaben Carsey
` (2 preceding siblings ...)
2018-03-29 0:02 ` [PATCH v1 3/4] BaseTools: remove loop and variables Jaben Carsey
@ 2018-03-29 0:02 ` Jaben Carsey
2018-03-30 1:12 ` [PATCH v1 0/4] BaseTools: eliminate some redundant code Zhu, Yonghong
4 siblings, 0 replies; 6+ messages in thread
From: Jaben Carsey @ 2018-03-29 0:02 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu
remove totally empty classes from class heirarchy
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
BaseTools/Source/Python/Common/DecClassObject.py | 13 +------------
BaseTools/Source/Python/Common/DscClassObject.py | 13 +------------
BaseTools/Source/Python/Common/FdfClassObject.py | 12 +-----------
BaseTools/Source/Python/Common/InfClassObject.py | 13 +------------
BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py | 13 +------------
5 files changed, 5 insertions(+), 59 deletions(-)
diff --git a/BaseTools/Source/Python/Common/DecClassObject.py b/BaseTools/Source/Python/Common/DecClassObject.py
index d7c70a7336a0..4d267f147f05 100644
--- a/BaseTools/Source/Python/Common/DecClassObject.py
+++ b/BaseTools/Source/Python/Common/DecClassObject.py
@@ -48,21 +48,10 @@ Section = {TAB_UNKNOWN.upper() : MODEL_UNKNOWN,
}
-## DecObject
-#
-# This class defined basic Dec object which is used by inheriting
-#
-# @param object: Inherited from object class
-#
-class DecObject(object):
- def __init__(self):
- object.__init__()
-
## Dec
#
# This class defined the structure used in Dec object
#
-# @param DecObject: Inherited from DecObject class
# @param Filename: Input value for Filename of Dec file, default is None
# @param IsMergeAllArches: Input value for IsMergeAllArches
# True is to merge all arches
@@ -82,7 +71,7 @@ class DecObject(object):
# @var Contents: To store value for Contents, it is a structure as DecContents
# @var KeyList: To store value for KeyList, a list for all Keys used in Dec
#
-class Dec(DecObject):
+class Dec(object):
def __init__(self, Filename=None, IsToDatabase=False, IsToPackage=False, WorkspaceDir=None, Database=None, SupArchList=DataType.ARCH_LIST):
self.Identification = Identification()
self.Package = PackageClass()
diff --git a/BaseTools/Source/Python/Common/DscClassObject.py b/BaseTools/Source/Python/Common/DscClassObject.py
index c2fa1c275a2d..d14b6a718522 100644
--- a/BaseTools/Source/Python/Common/DscClassObject.py
+++ b/BaseTools/Source/Python/Common/DscClassObject.py
@@ -54,21 +54,10 @@ Section = {TAB_UNKNOWN.upper() : MODEL_UNKNOWN,
TAB_USER_EXTENSIONS.upper() : MODEL_META_DATA_USER_EXTENSION
}
-## DscObject
-#
-# This class defined basic Dsc object which is used by inheriting
-#
-# @param object: Inherited from object class
-#
-class DscObject(object):
- def __init__(self):
- object.__init__()
-
## Dsc
#
# This class defined the structure used in Dsc object
#
-# @param DscObject: Inherited from InfObject class
# @param Ffilename: Input value for Ffilename of Inf file, default is None
# @param IsMergeAllArches: Input value for IsMergeAllArches
# True is to merge all arches
@@ -89,7 +78,7 @@ class DscObject(object):
# @var WorkspaceDir: To store value for WorkspaceDir
# @var KeyList: To store value for KeyList, a list for all Keys used in Dec
#
-class Dsc(DscObject):
+class Dsc(object):
_NullClassIndex = 0
def __init__(self, Filename=None, IsToDatabase=False, IsToPlatform=False, WorkspaceDir=None, Database=None):
diff --git a/BaseTools/Source/Python/Common/FdfClassObject.py b/BaseTools/Source/Python/Common/FdfClassObject.py
index 3e7d44954c88..b3b45f634ed8 100644
--- a/BaseTools/Source/Python/Common/FdfClassObject.py
+++ b/BaseTools/Source/Python/Common/FdfClassObject.py
@@ -19,25 +19,15 @@ from Table.TableFdf import TableFdf
from CommonDataClass.DataClass import MODEL_FILE_FDF, MODEL_PCD, MODEL_META_DATA_COMPONENT
from String import NormPath
-## FdfObject
-#
-# This class defined basic Fdf object which is used by inheriting
-#
-# @param object: Inherited from object class
-#
-class FdfObject(object):
- def __init__(self):
- object.__init__()
## Fdf
#
# This class defined the structure used in Fdf object
#
-# @param FdfObject: Inherited from FdfObject class
# @param Filename: Input value for Ffilename of Fdf file, default is None
# @param WorkspaceDir: Input value for current workspace directory, default is None
#
-class Fdf(FdfObject):
+class Fdf(object):
def __init__(self, Filename = None, IsToDatabase = False, WorkspaceDir = None, Database = None):
self.WorkspaceDir = WorkspaceDir
self.IsToDatabase = IsToDatabase
diff --git a/BaseTools/Source/Python/Common/InfClassObject.py b/BaseTools/Source/Python/Common/InfClassObject.py
index f24e4e41a0c1..89e110ea5e7a 100644
--- a/BaseTools/Source/Python/Common/InfClassObject.py
+++ b/BaseTools/Source/Python/Common/InfClassObject.py
@@ -131,21 +131,10 @@ class InfHeader(ModuleHeaderClass):
def __contains__(self, key):
return key in self._Mapping_
-## InfObject
-#
-# This class defined basic Inf object which is used by inheriting
-#
-# @param object: Inherited from object class
-#
-class InfObject(object):
- def __init__(self):
- object.__init__()
-
## Inf
#
# This class defined the structure used in Inf object
#
-# @param InfObject: Inherited from InfObject class
# @param Ffilename: Input value for Ffilename of Inf file, default is None
# @param IsMergeAllArches: Input value for IsMergeAllArches
# True is to merge all arches
@@ -163,7 +152,7 @@ class InfObject(object):
# @var WorkspaceDir: To store value for WorkspaceDir
# @var KeyList: To store value for KeyList, a list for all Keys used in Inf
#
-class Inf(InfObject):
+class Inf(object):
def __init__(self, Filename=None, IsToDatabase=False, IsToModule=False, WorkspaceDir=None, Database=None, SupArchList=DataType.ARCH_LIST):
self.Identification = Identification()
self.Module = ModuleClass()
diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
index ba478f9ecf10..b60e8f50e4f2 100644
--- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
@@ -1900,25 +1900,14 @@ class DecParser(MetaFileParser):
}
-## FdfObject
-#
-# This class defined basic Fdf object which is used by inheriting
-#
-# @param object: Inherited from object class
-#
-class FdfObject(object):
- def __init__(self):
- object.__init__()
-
## Fdf
#
# This class defined the structure used in Fdf object
#
-# @param FdfObject: Inherited from FdfObject class
# @param Filename: Input value for Ffilename of Fdf file, default is None
# @param WorkspaceDir: Input value for current workspace directory, default is None
#
-class Fdf(FdfObject):
+class Fdf(object):
def __init__(self, Filename = None, IsToDatabase = False, WorkspaceDir = None, Database = None):
self.WorkspaceDir = WorkspaceDir
self.IsToDatabase = IsToDatabase
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 0/4] BaseTools: eliminate some redundant code.
2018-03-29 0:02 [PATCH v1 0/4] BaseTools: eliminate some redundant code Jaben Carsey
` (3 preceding siblings ...)
2018-03-29 0:02 ` [PATCH v1 4/4] BaseTools: cleanup class heirarchy Jaben Carsey
@ 2018-03-30 1:12 ` Zhu, Yonghong
4 siblings, 0 replies; 6+ messages in thread
From: Zhu, Yonghong @ 2018-03-30 1:12 UTC (permalink / raw)
To: Carsey, Jaben, edk2-devel@lists.01.org
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Best Regards,
Zhu Yonghong
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Jaben Carsey
Sent: Thursday, March 29, 2018 8:02 AM
To: edk2-devel@lists.01.org
Subject: [edk2] [PATCH v1 0/4] BaseTools: eliminate some redundant code.
no external behavorial change, but remove some confusing and unneeded code.
Jaben Carsey (4):
BaseTools: no need to do int() API work for it
BaseTools: use in to compare single chars
BaseTools: remove loop and variables.
BaseTools: cleanup class heirarchy
BaseTools/Source/Python/AutoGen/GenC.py | 5 +----
BaseTools/Source/Python/Common/DecClassObject.py | 13 +------------
BaseTools/Source/Python/Common/DscClassObject.py | 13 +------------
BaseTools/Source/Python/Common/Expression.py | 6 +++---
BaseTools/Source/Python/Common/FdfClassObject.py | 12 +-----------
BaseTools/Source/Python/Common/InfClassObject.py | 13 +------------
BaseTools/Source/Python/Common/Misc.py | 13 -------------
BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py | 13 +------------
BaseTools/Source/Python/GenFds/FdfParser.py | 5 +----
BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py | 10 ++--------
10 files changed, 12 insertions(+), 91 deletions(-)
--
2.16.2.windows.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 6+ messages in thread