mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 06:29:38 +02:00
* remove resourcestring tables
git-svn-id: trunk@2835 -
This commit is contained in:
parent
314e1672b7
commit
9d96f32bdc
@ -71,11 +71,12 @@ unit objpas;
|
|||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
|
|
||||||
type
|
type
|
||||||
TResourceIterator = Function (Name,Value : AnsiString; Hash : Longint) : AnsiString;
|
TResourceIterator = Function (Name,Value : AnsiString; Hash : Longint; arg:pointer) : AnsiString;
|
||||||
|
|
||||||
Function Hash(S : AnsiString) : longint;
|
Function Hash(S : AnsiString) : LongWord;
|
||||||
Procedure ResetResourceTables;
|
Procedure ResetResourceTables;
|
||||||
Procedure SetResourceStrings (SetFunction : TResourceIterator);
|
Procedure SetResourceStrings (SetFunction : TResourceIterator;arg:pointer);
|
||||||
|
{$ifndef RESSTRSECTIONS}
|
||||||
Function ResourceStringTableCount : Longint;
|
Function ResourceStringTableCount : Longint;
|
||||||
Function ResourceStringCount(TableIndex : longint) : longint;
|
Function ResourceStringCount(TableIndex : longint) : longint;
|
||||||
Function GetResourceStringName(TableIndex,StringIndex : Longint) : Ansistring;
|
Function GetResourceStringName(TableIndex,StringIndex : Longint) : Ansistring;
|
||||||
@ -83,6 +84,7 @@ unit objpas;
|
|||||||
Function GetResourceStringDefaultValue(TableIndex,StringIndex : Longint) : AnsiString;
|
Function GetResourceStringDefaultValue(TableIndex,StringIndex : Longint) : AnsiString;
|
||||||
Function GetResourceStringCurrentValue(TableIndex,StringIndex : Longint) : AnsiString;
|
Function GetResourceStringCurrentValue(TableIndex,StringIndex : Longint) : AnsiString;
|
||||||
Function SetResourceStringValue(TableIndex,StringIndex : longint; Value : Ansistring) : Boolean;
|
Function SetResourceStringValue(TableIndex,StringIndex : longint; Value : Ansistring) : Boolean;
|
||||||
|
{$endif RESSTRSECTIONS}
|
||||||
|
|
||||||
{ Delphi compatibility }
|
{ Delphi compatibility }
|
||||||
type
|
type
|
||||||
@ -208,14 +210,88 @@ end;
|
|||||||
{ ---------------------------------------------------------------------
|
{ ---------------------------------------------------------------------
|
||||||
ResourceString support
|
ResourceString support
|
||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
Type
|
Function Hash(S : AnsiString) : LongWord;
|
||||||
|
Var
|
||||||
|
thehash,g,I : LongWord;
|
||||||
|
begin
|
||||||
|
thehash:=0;
|
||||||
|
For I:=1 to Length(S) do { 0 terminated }
|
||||||
|
begin
|
||||||
|
thehash:=thehash shl 4;
|
||||||
|
inc(theHash,Ord(S[i]));
|
||||||
|
g:=thehash and LongWord($f shl 28);
|
||||||
|
if g<>0 then
|
||||||
|
begin
|
||||||
|
thehash:=thehash xor (g shr 24);
|
||||||
|
thehash:=thehash xor g;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
If theHash=0 then
|
||||||
|
Hash:=$ffffffff
|
||||||
|
else
|
||||||
|
Hash:=TheHash;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{$ifdef RESSTRSECTIONS}
|
||||||
|
Type
|
||||||
|
PResourceStringRecord = ^TResourceStringRecord;
|
||||||
|
TResourceStringRecord = Packed Record
|
||||||
|
Name,
|
||||||
|
CurrentValue,
|
||||||
|
DefaultValue : AnsiString;
|
||||||
|
HashValue : LongWord;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Var
|
||||||
|
ResourceStrings : TResourceStringRecord; External Name 'FPC_RESOURCESTRINGS';
|
||||||
|
|
||||||
|
Procedure SetResourceStrings (SetFunction : TResourceIterator;arg:pointer);
|
||||||
|
Var
|
||||||
|
ResStr : PResourceStringRecord;
|
||||||
|
begin
|
||||||
|
ResStr:=@ResourceStrings;
|
||||||
|
while ResStr^.Name<>'' do
|
||||||
|
begin
|
||||||
|
ResStr^.CurrentValue:=SetFunction(ResStr^.Name,ResStr^.DefaultValue,ResStr^.HashValue,arg);
|
||||||
|
inc(ResStr);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Procedure ResetResourceTables;
|
||||||
|
Var
|
||||||
|
ResStr : PResourceStringRecord;
|
||||||
|
begin
|
||||||
|
ResStr:=@ResourceStrings;
|
||||||
|
while ResStr^.Name<>'' do
|
||||||
|
begin
|
||||||
|
ResStr^.CurrentValue:=ResStr^.DefaultValue;
|
||||||
|
inc(ResStr);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Procedure FinalizeResourceTables;
|
||||||
|
Var
|
||||||
|
ResStr : PResourceStringRecord;
|
||||||
|
begin
|
||||||
|
ResStr:=@ResourceStrings;
|
||||||
|
while ResStr^.Name<>'' do
|
||||||
|
begin
|
||||||
|
ResStr^.CurrentValue:='';
|
||||||
|
inc(ResStr);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{$else RESSTRSECTIONS}
|
||||||
|
|
||||||
|
Type
|
||||||
PResourceStringRecord = ^TResourceStringRecord;
|
PResourceStringRecord = ^TResourceStringRecord;
|
||||||
TResourceStringRecord = Packed Record
|
TResourceStringRecord = Packed Record
|
||||||
DefaultValue,
|
DefaultValue,
|
||||||
CurrentValue : AnsiString;
|
CurrentValue : AnsiString;
|
||||||
HashValue : longint;
|
HashValue : LongWord;
|
||||||
Name : AnsiString;
|
Name : AnsiString;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TResourceStringTable = Packed Record
|
TResourceStringTable = Packed Record
|
||||||
@ -229,34 +305,9 @@ Type
|
|||||||
Tables : Array[Word] of PResourceStringTable;
|
Tables : Array[Word] of PResourceStringTable;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Var
|
Var
|
||||||
ResourceStringTable : TResourceTablelist; External Name 'FPC_RESOURCESTRINGTABLES';
|
ResourceStringTable : TResourceTablelist; External Name 'FPC_RESOURCESTRINGTABLES';
|
||||||
|
|
||||||
Function Hash(S : AnsiString) : longint;
|
|
||||||
|
|
||||||
Var thehash,g,I : longint;
|
|
||||||
|
|
||||||
begin
|
|
||||||
thehash:=0;
|
|
||||||
For I:=1 to Length(S) do { 0 terminated }
|
|
||||||
begin
|
|
||||||
thehash:=thehash shl 4;
|
|
||||||
inc(theHash,Ord(S[i]));
|
|
||||||
g:=thehash and longint($f shl 28);
|
|
||||||
if g<>0 then
|
|
||||||
begin
|
|
||||||
thehash:=thehash xor (g shr 24);
|
|
||||||
thehash:=thehash xor g;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
If theHash=0 then
|
|
||||||
Hash:=Not(0)
|
|
||||||
else
|
|
||||||
Hash:=TheHash;
|
|
||||||
end;
|
|
||||||
|
|
||||||
Function GetResourceString(Const TheTable: TResourceStringTable;Index : longint) : AnsiString;[Public,Alias : 'FPC_GETRESOURCESTRING'];
|
Function GetResourceString(Const TheTable: TResourceStringTable;Index : longint) : AnsiString;[Public,Alias : 'FPC_GETRESOURCESTRING'];
|
||||||
begin
|
begin
|
||||||
If (Index>=0) and (Index<TheTAble.Count) then
|
If (Index>=0) and (Index<TheTAble.Count) then
|
||||||
@ -265,18 +316,8 @@ begin
|
|||||||
Result:='';
|
Result:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(*
|
|
||||||
Function SetResourceString(Hash : Longint;Const Name : ShortString; Const Value : AnsiString) : Boolean;
|
|
||||||
|
|
||||||
begin
|
Procedure SetResourceStrings (SetFunction : TResourceIterator;arg:pointer);
|
||||||
Hash:=FindIndex(Hash,Name);
|
|
||||||
Result:=Hash<>-1;
|
|
||||||
If Result then
|
|
||||||
ResourceStringTable.ResRec[Hash].CurrentValue:=Value;
|
|
||||||
end;
|
|
||||||
*)
|
|
||||||
|
|
||||||
Procedure SetResourceStrings (SetFunction : TResourceIterator);
|
|
||||||
|
|
||||||
Var I,J : longint;
|
Var I,J : longint;
|
||||||
|
|
||||||
@ -286,7 +327,7 @@ begin
|
|||||||
With Tables[I]^ do
|
With Tables[I]^ do
|
||||||
For J:=0 to Count-1 do
|
For J:=0 to Count-1 do
|
||||||
With ResRec[J] do
|
With ResRec[J] do
|
||||||
CurrentValue:=SetFunction(Name,DefaultValue,HashValue);
|
CurrentValue:=SetFunction(Name,DefaultValue,HashValue,arg);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -315,6 +356,7 @@ begin
|
|||||||
With ResRec[J] do
|
With ResRec[J] do
|
||||||
CurrentValue:='';
|
CurrentValue:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function ResourceStringTableCount : Longint;
|
Function ResourceStringTableCount : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -385,8 +427,9 @@ begin
|
|||||||
ResourceStringTable.Tables[TableIndex]^.ResRec[StringIndex].CurrentValue:=Value;
|
ResourceStringTable.Tables[TableIndex]^.ResRec[StringIndex].CurrentValue:=Value;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function LoadResString(p:PResStringRec):AnsiString;
|
{$endif RESSTRSECTIONS}
|
||||||
|
|
||||||
|
Function LoadResString(p:PResStringRec):AnsiString;
|
||||||
begin
|
begin
|
||||||
Result:=p^;
|
Result:=p^;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user