* Change return type of some functions, so -1 can actually be returned, patch by Zeljko Avramovic (issue 39268).

This commit is contained in:
Michaël Van Canneyt 2022-01-22 11:17:44 +01:00
parent 986a6feb95
commit 30b0d98636
2 changed files with 32 additions and 32 deletions

View File

@ -431,8 +431,8 @@ Type
Function ToggleBit(const Index: TByteBitIndex) : Byte; inline;
Function TestBit(const Index:TByteBitIndex):Boolean; inline;
procedure Clear; inline;
function HighestSetBitPos: cardinal; inline;
function LowestSetBitPos: cardinal; inline;
function HighestSetBitPos: int8; inline;
function LowestSetBitPos: int8; inline;
function SetBitsCount: byte; inline;
property Bits [aIndex: TByteBitIndex]: boolean read GetBit write PutBit;
property Nibbles [aIndex: TByteNibbleIndex]: nibble read GetNibble write PutNibble;
@ -476,8 +476,8 @@ Type
Function ToggleBit(const Index: TShortIntBitIndex): Shortint; inline;
Function TestBit(const Index:TShortIntBitIndex):Boolean;
procedure Clear; inline;
function HighestSetBitPos: cardinal; inline;
function LowestSetBitPos: cardinal; inline;
function HighestSetBitPos: int8; inline;
function LowestSetBitPos: int8; inline;
function SetBitsCount: byte; inline;
property Bits [aIndex: TShortIntBitIndex]: boolean read GetBit write PutBit;
property Nibbles [aIndex: TShortIntNibbleIndex]: nibble read GetNibble write PutNibble;
@ -532,8 +532,8 @@ Type
Function ToggleBit(const Index: TWordBitIndex) : Word; inline;
Function TestBit(const Index:TWordBitIndex):Boolean; inline;
procedure Clear; inline;
function HighestSetBitPos: cardinal; inline;
function LowestSetBitPos: cardinal; inline;
function HighestSetBitPos: int8; inline;
function LowestSetBitPos: int8; inline;
function SetBitsCount: byte; inline;
property Bits [aIndex: TWordBitIndex]: boolean read GetBit write PutBit;
property Nibbles [aIndex: TWordNibbleIndex]: nibble read GetNibble write PutNibble;
@ -582,8 +582,8 @@ Type
Function ToggleBit(const Index: TSmallIntBitIndex) : Smallint; inline;
Function TestBit(const Index:TSmallIntBitIndex):Boolean;
procedure Clear; inline;
function HighestSetBitPos: cardinal; inline;
function LowestSetBitPos: cardinal; inline;
function HighestSetBitPos: int8; inline;
function LowestSetBitPos: int8; inline;
function SetBitsCount: byte; inline;
property Bits [aIndex: TSmallIntBitIndex]: boolean read GetBit write PutBit;
property Nibbles [aIndex: TSmallIntNibbleIndex]: nibble read GetNibble write PutNibble;
@ -653,8 +653,8 @@ Type
Function ToggleBit(const Index: TCardinalBitIndex) : Cardinal; inline;
Function TestBit(const Index:TCardinalBitIndex):Boolean; inline;
procedure Clear; inline;
function HighestSetBitPos: cardinal; inline;
function LowestSetBitPos: cardinal; inline;
function HighestSetBitPos: int8; inline;
function LowestSetBitPos: int8; inline;
function SetBitsCount: byte; inline;
property Bits [aIndex: TCardinalBitIndex]: boolean read GetBit write PutBit;
property Nibbles[aIndex: TCardinalNibbleIndex]: nibble read GetNibble write PutNibble;
@ -722,8 +722,8 @@ Type
Function ToggleBit(const Index: TIntegerBitIndex) : Integer; inline;
Function TestBit(const Index:TIntegerBitIndex):Boolean; inline;
procedure Clear; inline;
function HighestSetBitPos: cardinal; inline;
function LowestSetBitPos: cardinal; inline;
function HighestSetBitPos: int8; inline;
function LowestSetBitPos: int8; inline;
function SetBitsCount: byte; inline;
property Bits [aIndex: TIntegerBitIndex]: boolean read GetBit write PutBit;
property Nibbles[aIndex: TIntegerNibbleIndex]: nibble read GetNibble write PutNibble;
@ -780,8 +780,8 @@ Type
Function ToggleBit(const Index: TLongIntBitIndex) : LongInt; inline;
Function TestBit(const Index:TLongIntBitIndex):Boolean; inline;
procedure Clear; inline;
function HighestSetBitPos: cardinal; inline;
function LowestSetBitPos: cardinal; inline;
function HighestSetBitPos: int8; inline;
function LowestSetBitPos: int8; inline;
function SetBitsCount: byte; inline;
property Bits [aIndex: TLongIntBitIndex]: boolean read GetBit write PutBit;
property Nibbles[aIndex: TLongIntNibbleIndex]: nibble read GetNibble write PutNibble;
@ -852,8 +852,8 @@ Type
Function ToggleBit(const Index: TQwordBitIndex): Qword; inline;
Function TestBit(const Index:TQwordBitIndex): Boolean; inline;
procedure Clear; inline;
function HighestSetBitPos: cardinal; inline;
function LowestSetBitPos: cardinal; inline;
function HighestSetBitPos: int8; inline;
function LowestSetBitPos: int8; inline;
function SetBitsCount: byte; inline;
property Bits [aIndex: TQwordBitIndex]: boolean read GetBit write PutBit;
property Nibbles[aIndex: TQwordNibbleIndex]: nibble read GetNibble write PutNibble;
@ -914,8 +914,8 @@ Type
Function ToggleBit(const Index: TInt64BitIndex) : Int64; inline;
Function TestBit(const Index: TInt64BitIndex): Boolean; inline;
procedure Clear; inline;
function HighestSetBitPos: cardinal; inline;
function LowestSetBitPos: cardinal; inline;
function HighestSetBitPos: int8; inline;
function LowestSetBitPos: int8; inline;
function SetBitsCount: byte; inline;
property Bits [aIndex: TInt64BitIndex]: boolean read GetBit write PutBit;
property Nibbles[aIndex: TInt64NibbleIndex]: nibble read GetNibble write PutNibble;
@ -998,8 +998,8 @@ Type
Function ToggleBit(const Index: TNativeIntBitIndex) : NativeInt; inline;
Function TestBit(const Index:TNativeIntBitIndex):Boolean; inline;
procedure Clear; inline;
function HighestSetBitPos: cardinal; inline;
function LowestSetBitPos: cardinal; inline;
function HighestSetBitPos: int8; inline;
function LowestSetBitPos: int8; inline;
function SetBitsCount: byte; inline;
property Bits [aIndex: TNativeIntBitIndex]: boolean read GetBit write PutBit;
property Nibbles [aIndex: TNativeIntNibbleIndex]: nibble read GetNibble write PutNibble;
@ -1087,8 +1087,8 @@ Type
Function ToggleBit(const Index: TNativeUIntBitIndex) : NativeUint; inline;
Function TestBit(const Index:TNativeUIntBitIndex) :Boolean; inline;
procedure Clear; inline;
function HighestSetBitPos: cardinal; inline;
function LowestSetBitPos: cardinal; inline;
function HighestSetBitPos: int8; inline;
function LowestSetBitPos: int8; inline;
function SetBitsCount: byte; inline;
property Bits [aIndex: TNativeUIntBitIndex]: boolean read GetBit write PutBit;
property Nibbles [aIndex: TNativeUIntNibbleIndex]: nibble read GetNibble write PutNibble;

View File

@ -112,35 +112,35 @@ begin
Self := 0;
end;
function TORDINALHELPER.HighestSetBitPos: cardinal;
function TORDINALHELPER.HighestSetBitPos: int8;
begin
{$ifdef TORDINALTYPESIZE1}
Result := BsrByte(byte(Self));
Result := int8(BsrByte(byte(Self)));
{$else}
{$ifdef TORDINALTYPESIZE2}
Result := BsrWord(word(Self));
Result := int8(BsrWord(word(Self)));
{$else}
{$ifdef TORDINALTYPESIZE4}
Result := BsrDWord(dword(Self));
Result := int8(BsrDWord(dword(Self)));
{$else} // TORDINALTYPESIZE8
Result := BsrQWord(qword(Self));
Result := int8(BsrQWord(qword(Self)));
{$endif}
{$endif}
{$endif}
end;
function TORDINALHELPER.LowestSetBitPos: cardinal;
function TORDINALHELPER.LowestSetBitPos: int8;
begin
{$ifdef TORDINALTYPESIZE1}
Result := BsfByte(byte(Self));
Result := int8(BsfByte(byte(Self)));
{$else}
{$ifdef TORDINALTYPESIZE2}
Result := BsfWord(word(Self));
Result := int8(BsfWord(word(Self)));
{$else}
{$ifdef TORDINALTYPESIZE4}
Result := BsfDWord(dword(Self));
Result := int8(BsfDWord(dword(Self)));
{$else} // TORDINALTYPESIZE8
Result := BsfQWord(qword(Self));
Result := int8(BsfQWord(qword(Self)));
{$endif}
{$endif}
{$endif}