Skip to content

Commit

Permalink
BaseTools: replace long by int
Browse files Browse the repository at this point in the history
replace long by int
Because the long() was not exist in Python3

Cc: Bob Feng <[email protected]>
Cc: Liming Gao <[email protected]>
Cc: Yonghong Zhu <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <[email protected]>
Tested-by: Laszlo Ersek <[email protected]>
Tested-by: Ard Biesheuvel <[email protected]>
Reviewed-by: Liming Gao <[email protected]>
Reviewed-by: Bob Feng <[email protected]>
  • Loading branch information
yunhuafx authored and BobCF committed Feb 1, 2019
1 parent 1d2aa01 commit af881ab
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def dump(self, dest, Phase):
itemIndex += 1
realLength += 5
for v_data in item.data:
if type(v_data) in (int, long):
if isinstance(v_data, int):
realLength += item.StorageWidth
else:
realLength += item.StorageWidth
Expand Down Expand Up @@ -137,7 +137,7 @@ def dump(self, dest, Phase):
Buffer += b
realLength += 1
for v_data in item.data:
if type(v_data) in (int, long):
if isinstance(v_data, int):
b = pack(PACK_CODE_BY_SIZE[item.StorageWidth], v_data)
Buffer += b
realLength += item.StorageWidth
Expand Down
2 changes: 1 addition & 1 deletion BaseTools/Source/Python/Common/Misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ def CheckPcdDatum(Type, Value):
if Value and int(Value, 0) < 0:
return False, "PCD can't be set to negative value[%s] for datum type [%s]" % (Value, Type)
try:
Value = long(Value, 0)
Value = int(Value, 0)
if Value > MAX_VAL_TYPE[Type]:
return False, "Too large PCD value[%s] for datum type [%s]" % (Value, Type)
except:
Expand Down
2 changes: 1 addition & 1 deletion BaseTools/Source/Python/GenFds/AprioriSection.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def GenFfs (self, FvName, Dict = {}, IsMakefile = False):
% (InfFileName, GenFdsGlobalVariable.ArchList))

GuidPart = Guid.split('-')
Buffer.write(pack('I', long(GuidPart[0], 16)))
Buffer.write(pack('I', int(GuidPart[0], 16)))
Buffer.write(pack('H', int(GuidPart[1], 16)))
Buffer.write(pack('H', int(GuidPart[2], 16)))

Expand Down
18 changes: 9 additions & 9 deletions BaseTools/Source/Python/GenFds/FdfParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@ def _GetTokenStatements(self, Obj):
self.SetPcdLocalation(pcdPair)
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
self.Profile.PcdFileLineDict[pcdPair] = FileLineTuple
Obj.Size = long(Size, 0)
Obj.Size = int(Size, 0)
return True

if self._IsKeyword("ErasePolarity"):
Expand Down Expand Up @@ -1597,7 +1597,7 @@ def _GetAddressStatements(self, Obj):
if not self._GetNextDecimalNumber() and not self._GetNextHexNumber():
raise Warning.Expected("address", self.FileName, self.CurrentLineNumber)

BsAddress = long(self._Token, 0)
BsAddress = int(self._Token, 0)
Obj.BsBaseAddress = BsAddress

if self._IsKeyword("RtBaseAddress"):
Expand All @@ -1607,7 +1607,7 @@ def _GetAddressStatements(self, Obj):
if not self._GetNextDecimalNumber() and not self._GetNextHexNumber():
raise Warning.Expected("address", self.FileName, self.CurrentLineNumber)

RtAddress = long(self._Token, 0)
RtAddress = int(self._Token, 0)
Obj.RtBaseAddress = RtAddress

## _GetBlockStatements() method
Expand Down Expand Up @@ -1655,7 +1655,7 @@ def _GetBlockStatement(self, Obj):
self.SetPcdLocalation(PcdPair)
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
self.Profile.PcdFileLineDict[PcdPair] = FileLineTuple
BlockSize = long(BlockSize, 0)
BlockSize = int(BlockSize, 0)

BlockNumber = None
if self._IsKeyword("NumBlocks"):
Expand All @@ -1665,7 +1665,7 @@ def _GetBlockStatement(self, Obj):
if not self._GetNextDecimalNumber() and not self._GetNextHexNumber():
raise Warning.Expected("block numbers", self.FileName, self.CurrentLineNumber)

BlockNumber = long(self._Token, 0)
BlockNumber = int(self._Token, 0)

Obj.BlockSizeList.append((BlockSize, BlockNumber, BlockSizePcd))
return True
Expand Down Expand Up @@ -1774,7 +1774,7 @@ def _CalcRegionExpr(self):
Expr += CurCh
self._GetOneChar()
try:
return long(
return int(
ValueExpression(Expr,
self._CollectMacroPcd()
)(True), 0)
Expand Down Expand Up @@ -1822,7 +1822,7 @@ def _GetRegionLayout(self, theFd):
RegionOffsetPcdPattern.match(self._CurrentLine()[self.CurrentOffsetWithinLine:]))
if IsRegionPcd:
RegionObj.PcdOffset = self._GetNextPcdSettings()
self.Profile.PcdDict[RegionObj.PcdOffset] = "0x%08X" % (RegionObj.Offset + long(theFd.BaseAddress, 0))
self.Profile.PcdDict[RegionObj.PcdOffset] = "0x%08X" % (RegionObj.Offset + int(theFd.BaseAddress, 0))
self.SetPcdLocalation(RegionObj.PcdOffset)
self._PcdDict['%s.%s' % (RegionObj.PcdOffset[1], RegionObj.PcdOffset[0])] = "0x%x" % RegionObj.Offset
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
Expand Down Expand Up @@ -3134,9 +3134,9 @@ def _GetFmp(self):
if FdfParser._Verify(Name, Value, 'UINT64'):
FmpData.MonotonicCount = Value
if FmpData.MonotonicCount.upper().startswith('0X'):
FmpData.MonotonicCount = (long)(FmpData.MonotonicCount, 16)
FmpData.MonotonicCount = int(FmpData.MonotonicCount, 16)
else:
FmpData.MonotonicCount = (long)(FmpData.MonotonicCount)
FmpData.MonotonicCount = int(FmpData.MonotonicCount)
if not self._GetNextToken():
break
else:
Expand Down
8 changes: 4 additions & 4 deletions BaseTools/Source/Python/GenFds/GenFds.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,9 @@ def DisplayFvSpaceInfo(FdfParserObject):
GenFdsGlobalVariable.InfLogger('\nFV Space Information')
for FvSpaceInfo in FvSpaceInfoList:
Name = FvSpaceInfo[0]
TotalSizeValue = long(FvSpaceInfo[1], 0)
UsedSizeValue = long(FvSpaceInfo[2], 0)
FreeSizeValue = long(FvSpaceInfo[3], 0)
TotalSizeValue = int(FvSpaceInfo[1], 0)
UsedSizeValue = int(FvSpaceInfo[2], 0)
FreeSizeValue = int(FvSpaceInfo[3], 0)
if UsedSizeValue == TotalSizeValue:
Percentage = '100'
else:
Expand All @@ -655,7 +655,7 @@ def PreprocessImage(BuildDb, DscFile):
if PcdValue == '':
return

Int64PcdValue = long(PcdValue, 0)
Int64PcdValue = int(PcdValue, 0)
if Int64PcdValue == 0 or Int64PcdValue < -1:
return

Expand Down
10 changes: 5 additions & 5 deletions BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@

try:
if args.MonotonicCountStr.upper().startswith('0X'):
args.MonotonicCountValue = (long)(args.MonotonicCountStr, 16)
args.MonotonicCountValue = int(args.MonotonicCountStr, 16)
else:
args.MonotonicCountValue = (long)(args.MonotonicCountStr)
args.MonotonicCountValue = int(args.MonotonicCountStr)
except:
args.MonotonicCountValue = (long)(0)
args.MonotonicCountValue = int(0)

if args.Encode:
#
Expand Down Expand Up @@ -251,9 +251,9 @@
sys.exit(1)
else:
if args.SignatureSizeStr.upper().startswith('0X'):
SignatureSize = (long)(args.SignatureSizeStr, 16)
SignatureSize = int(args.SignatureSizeStr, 16)
else:
SignatureSize = (long)(args.SignatureSizeStr)
SignatureSize = int(args.SignatureSizeStr)
if SignatureSize < 0:
print("ERROR: The value of option --signature-size can't be set to negative value!")
sys.exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@
if args.MonotonicCountStr:
try:
if args.MonotonicCountStr.upper().startswith('0X'):
args.MonotonicCountValue = (long)(args.MonotonicCountStr, 16)
args.MonotonicCountValue = int(args.MonotonicCountStr, 16)
else:
args.MonotonicCountValue = (long)(args.MonotonicCountStr)
args.MonotonicCountValue = int(args.MonotonicCountStr)
except:
pass

Expand Down
6 changes: 3 additions & 3 deletions BaseTools/Source/Python/UPT/Parser/DecParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,11 @@ def _ParseItem(self):
if not IsValidToken(PCD_TOKEN_PATTERN, Token):
self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN % Token)
elif not Token.startswith('0x') and not Token.startswith('0X'):
if long(Token) > 4294967295:
if int(Token) > 4294967295:
self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN_INT % Token)
Token = hex(long(Token))[:-1]
Token = hex(int(Token))[:-1]

IntToken = long(Token, 0)
IntToken = int(Token, 0)
if (Guid, IntToken) in self.TokenMap:
if self.TokenMap[Guid, IntToken] != CName:
self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN_UNIQUE%(Token))
Expand Down

0 comments on commit af881ab

Please sign in to comment.