From: Olivier S. <ob...@us...> - 2004-02-20 13:53:00
|
Update of /cvsroot/jvcl/dev/JVCL3/devtools/PackagesGenerator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16360/dev/JVCL3/devtools/PackagesGenerator Modified Files: GenerateUtils.pas Log Message: Added binary cache Index: GenerateUtils.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/devtools/PackagesGenerator/GenerateUtils.pas,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** GenerateUtils.pas 14 Feb 2004 09:16:24 -0000 1.41 --- GenerateUtils.pas 20 Feb 2004 13:41:52 -0000 1.42 *************** *** 128,132 **** public constructor Create(incfile : TStringList); overload; ! function IsDefined(const Condition, Target : string): Boolean; property Items[index : integer] : TDefine read GetItems write SetItems; default; --- 128,132 ---- public constructor Create(incfile : TStringList); overload; ! function IsDefined(const Condition, Target : string; DefineLimit : Integer = -1): Boolean; property Items[index : integer] : TDefine read GetItems write SetItems; default; *************** *** 142,145 **** --- 142,146 ---- AliasList : TAliasList; DefinesList : TDefinesList; + IsBinaryCache : TStringList; function PackagesLocation : string; *************** *** 849,853 **** repeatSectionUsed := True; repeatLines := ''; ! while(Trim(template[i]) <> '<%%% END REQUIRES %%%>') do begin repeatLines := repeatLines + template[i] + #13#10; --- 850,855 ---- repeatSectionUsed := True; repeatLines := ''; ! while (i < template.count) and ! (Trim(template[i]) <> '<%%% END REQUIRES %%%>') do begin repeatLines := repeatLines + template[i] + #13#10; *************** *** 882,886 **** repeatSectionUsed := True; repeatLines := ''; ! while(Trim(template[i]) <> '<%%% END FILES %%%>') do begin repeatLines := repeatLines + template[i] + #13#10; --- 884,889 ---- repeatSectionUsed := True; repeatLines := ''; ! while (i < template.count) and ! (Trim(template[i]) <> '<%%% END FILES %%%>') do begin repeatLines := repeatLines + template[i] + #13#10; *************** *** 916,920 **** repeatSectionUsed := True; repeatLines := ''; ! while(Trim(template[i]) <> '<%%% END FORMS %%%>') do begin repeatLines := repeatLines + template[i] + #13#10; --- 919,924 ---- repeatSectionUsed := True; repeatLines := ''; ! while (i < template.count) and ! (Trim(template[i]) <> '<%%% END FORMS %%%>') do begin repeatLines := repeatLines + template[i] + #13#10; *************** *** 951,955 **** Inc(i); repeatLines := ''; ! while(Trim(template[i]) <> '<%%% END LIBS %%%>') do begin repeatLines := repeatLines + template[i] + #13#10; --- 955,960 ---- Inc(i); repeatLines := ''; ! while (i < template.count) and ! (Trim(template[i]) <> '<%%% END LIBS %%%>') do begin repeatLines := repeatLines + template[i] + #13#10; *************** *** 1094,1097 **** --- 1099,1110 ---- begin Result := False; + // If the cache contains information on that file, get the result + // from it and skip the real test + if IsBinaryCache.IndexOf(FileName) > -1 then + begin + Result := Boolean(IsBinaryCache.Objects[IsBinaryCache.IndexOf(FileName)]); + Exit; + end; + // Read the first characters of the file and if enough of them // are not text characters, then consider the file to be binary *************** *** 1111,1114 **** --- 1124,1130 ---- end; end; + + // save the result in the cache + IsBinaryCache.AddObject(FileName, TObject(Result)); end; *************** *** 1148,1151 **** --- 1164,1170 ---- end; + // Empty the binary file cache + IsBinaryCache.Clear; + FreeAndNil(DefinesList); if incFileName = '' then *************** *** 1534,1546 **** end; ! function TDefinesList.IsDefined(const Condition, Target : string): Boolean; var I : Integer; Define : TDefine; begin Result := False; Define := nil; I := 0; ! while not Result and (I < Count) do begin Define := Items[I]; --- 1553,1568 ---- end; ! function TDefinesList.IsDefined(const Condition, Target : string; DefineLimit : Integer = -1): Boolean; var I : Integer; Define : TDefine; begin + if DefineLimit = -1 then + DefineLimit := Count; + Result := False; Define := nil; I := 0; ! while (I < Count) and (I < DefineLimit) and not Result do begin Define := Items[I]; *************** *** 1557,1568 **** // If the condition is defined, then all the IfDefs in which ! // it is enclosed must also be defined if Result and Assigned(Define) then for I := 0 to Define.IfDefs.Count - 1 do begin if Boolean(Define.IfDefs.Objects[I]) then ! Result := Result and IsDefined(Define.IfDefs[I], Target) else ! Result := Result and not IsDefined(Define.IfDefs[I], Target); end end; --- 1579,1591 ---- // If the condition is defined, then all the IfDefs in which ! // it is enclosed must also be defined but only before the ! // current define if Result and Assigned(Define) then for I := 0 to Define.IfDefs.Count - 1 do begin if Boolean(Define.IfDefs.Objects[I]) then ! Result := Result and IsDefined(Define.IfDefs[I], Target, IndexOf(Define)) else ! Result := Result and not IsDefined(Define.IfDefs[I], Target, IndexOf(Define)); end end; *************** *** 1576,1579 **** --- 1599,1604 ---- StartupDir := GetCurrentDir; + IsBinaryCache := TStringList.Create; + // ensure the lists are not assigned TargetList := nil; *************** *** 1585,1588 **** --- 1610,1614 ---- AliasList.Free; DefinesList.Free; + IsBinaryCache.Free; end. |