Changeset 434 for Common


Ignore:
Timestamp:
Nov 19, 2012, 2:31:00 PM (12 years ago)
Author:
chronos
Message:
  • Modified: Confused TRegistryEx property Context with Context parameter in some methods.
  • Fixed: TURI path was not properly handled in case of file in root directory.
Location:
Common
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Common/UCommon.pas

    r404 r434  
    4848function LoggedOnUserNameEx(Format: TUserNameFormat): string;
    4949function SplitString(var Text: string; Count: Word): string;
     50function GetBitCount(Variable: QWord; MaxIndex: Integer): Integer;
    5051function GetBit(Variable: QWord; Index: Byte): Boolean;
     52procedure SetBit(var Variable: Int64; Index: Byte; State: Boolean); overload;
    5153procedure SetBit(var Variable: QWord; Index: Byte; State: Boolean); overload;
    5254procedure SetBit(var Variable: Cardinal; Index: Byte; State: Boolean); overload;
     
    336338end;
    337339
     340function GetBitCount(Variable: QWord; MaxIndex: Integer): Integer;
     341var
     342  I: Integer;
     343begin
     344  Result := 0;
     345  for I := 0 to MaxIndex - 1 do
     346    if ((Variable shr I) and 1) = 1 then Inc(Result);
     347end;
     348
    338349function GetBit(Variable:QWord;Index:Byte):Boolean;
    339350begin
     
    341352end;
    342353
     354procedure SetBit(var Variable: Int64; Index: Byte; State: Boolean);
     355begin
     356  Variable := (Variable and ((1 shl Index) xor High(QWord))) or (Int64(State) shl Index);
     357end;
     358
    343359procedure SetBit(var Variable:QWord;Index:Byte;State:Boolean); overload;
    344360begin
    345   Variable := (Variable and ((1 shl Index) xor QWord($ffffffffffffffff))) or (QWord(State) shl Index);
     361  Variable := (Variable and ((1 shl Index) xor High(QWord))) or (QWord(State) shl Index);
    346362end;
    347363
    348364procedure SetBit(var Variable:Cardinal;Index:Byte;State:Boolean); overload;
    349365begin
    350   Variable := (Variable and ((1 shl Index) xor Cardinal($ffffffff))) or (Cardinal(State) shl Index);
     366  Variable := (Variable and ((1 shl Index) xor High(Cardinal))) or (Cardinal(State) shl Index);
    351367end;
    352368
    353369procedure SetBit(var Variable:Word;Index:Byte;State:Boolean); overload;
    354370begin
    355   Variable := (Variable and ((1 shl Index) xor Word($ffff))) or (Word(State) shl Index);
     371  Variable := (Variable and ((1 shl Index) xor High(Word))) or (Word(State) shl Index);
    356372end;
    357373
  • Common/URegistry.pas

    r432 r434  
    2626  TRegistryEx = class(TRegistry)
    2727  private
    28     function GetContext: TRegistryContext;
    29     procedure SetContext(AValue: TRegistryContext);
     28    function GetCurrentContext: TRegistryContext;
     29    procedure SetCurrentContext(AValue: TRegistryContext);
    3030  public
    3131    function ReadBoolWithDefault(const Name: string;
     
    3737    function DeleteKeyRecursive(const Key: string): Boolean;
    3838    function OpenKey(const Key: string; CanCreate: Boolean): Boolean;
    39     property Context: TRegistryContext read GetContext write SetContext;
     39    property CurrentContext: TRegistryContext read GetCurrentContext write SetCurrentContext;
    4040  end;
    4141
     
    109109end;
    110110
    111 function TRegistryEx.GetContext: TRegistryContext;
     111function TRegistryEx.GetCurrentContext: TRegistryContext;
    112112begin
    113113  Result.Key := CurrentPath;
     
    115115end;
    116116
    117 procedure TRegistryEx.SetContext(AValue: TRegistryContext);
     117procedure TRegistryEx.SetCurrentContext(AValue: TRegistryContext);
    118118begin
    119119  RootKey := AValue.RootKey;
  • Common/USyncCounter.pas

    r432 r434  
    2323    constructor Create;
    2424    destructor Destroy; override;
     25    procedure Assign(Source: TSyncCounter);
    2526  end;
    2627
     
    7172end;
    7273
     74procedure TSyncCounter.Assign(Source: TSyncCounter);
     75begin
     76  Current := Source.Current;
     77  Top := Source.Top;
     78end;
     79
    7380end.
    7481
  • Common/UURI.pas

    r230 r434  
    326326    Drive := Drive + DriveSeparator;
    327327  end else Drive := '';
    328   Directory.AsString := AValue;
     328  if (Drive <> '') and (AValue = '') then
     329    Directory.AsString := Directory.DirSeparator
     330    else Directory.AsString := AValue;
    329331end;
    330332
Note: See TracChangeset for help on using the changeset viewer.