- Timestamp:
- May 9, 2014, 12:37:10 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 52 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 3 3 LinuxBuilder.lps 4 4 LinuxBuilder.res 5 backup
-
- Property svn:ignore
-
trunk/LinuxBuilder.lpi
r11 r13 28 28 </local> 29 29 </RunParams> 30 <RequiredPackages Count=" 2">30 <RequiredPackages Count="4"> 31 31 <Item1> 32 <PackageName Value="reg"/> 33 <DefaultFilename Value="Packages/fcl-registry/reg.lpk" Prefer="True"/> 34 </Item1> 35 <Item2> 36 <PackageName Value="TemplateGenerics"/> 37 <DefaultFilename Value="Packages/TemplateGenerics/TemplateGenerics.lpk" Prefer="True"/> 38 </Item2> 39 <Item3> 32 40 <PackageName Value="Common"/> 33 41 <DefaultFilename Value="Packages/Common/Common.lpk" Prefer="True"/> 34 </Item 1>35 <Item 2>42 </Item3> 43 <Item4> 36 44 <PackageName Value="LCL"/> 37 </Item 2>45 </Item4> 38 46 </RequiredPackages> 39 47 <Units Count="7"> -
trunk/LinuxBuilder.lpr
r11 r13 9 9 Interfaces, // this includes the LCL widgetset 10 10 Forms, UFormMain, UKConfig, UFormList, UFormLog, UFormCompare, UFormSearch, 11 Common 11 Common, TemplateGenerics 12 12 { you can add units after this }; 13 13 -
trunk/Packages/Common/Common.lpk
r11 r13 112 112 </i18n> 113 113 <Type Value="RunAndDesignTime"/> 114 <RequiredPkgs Count=" 2">114 <RequiredPkgs Count="3"> 115 115 <Item1> 116 <PackageName Value=" TemplateGenerics"/>116 <PackageName Value="reg"/> 117 117 </Item1> 118 118 <Item2> 119 <PackageName Value="TemplateGenerics"/> 120 </Item2> 121 <Item3> 119 122 <PackageName Value="FCL"/> 120 123 <MinVersion Major="1" Valid="True"/> 121 </Item 2>124 </Item3> 122 125 </RequiredPkgs> 123 126 <UsageOptions> -
trunk/Packages/Common/UApplicationInfo.pas
r11 r13 6 6 7 7 uses 8 SysUtils, Registry , Classes, Forms, URegistry;8 SysUtils, Registry2, Classes, Forms, URegistry; 9 9 10 10 type -
trunk/Packages/Common/ULastOpenedList.pas
r11 r13 6 6 7 7 uses 8 Classes, SysUtils, Registry, URegistry, Menus;8 Classes, SysUtils, myregistry, URegistry, Menus, Dialogs; 9 9 10 10 type -
trunk/Packages/Common/UPersistentForm.pas
r11 r13 8 8 9 9 uses 10 Classes, SysUtils, Forms, URegistry, LCLIntf, Registry ;10 Classes, SysUtils, Forms, URegistry, LCLIntf, Registry2; 11 11 12 12 type -
trunk/Packages/Common/URegistry.pas
r11 r13 6 6 7 7 uses 8 Classes, Registry;8 Classes, MyRegistry; 9 9 10 10 type -
trunk/UFormMain.lfm
r12 r13 145 145 object MenuItemOpenRecent: TMenuItem 146 146 Caption = 'Open recent' 147 OnClick = MenuItemOpenRecentClick148 147 end 149 148 object MenuItem7: TMenuItem -
trunk/UFormMain.pas
r12 r13 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus, 9 ActnList, ComCtrls, StdCtrls, UKConfig, ULastOpenedList, URegistry, Registry ;9 ActnList, ComCtrls, StdCtrls, UKConfig, ULastOpenedList, URegistry, Registry2; 10 10 11 11 const … … 67 67 procedure LastOpenedListCompareChange(Sender: TObject); 68 68 procedure LastOpenedListOpenChange(Sender: TObject); 69 procedure MenuItemOpenRecentClick(Sender: TObject);70 69 procedure TreeView1SelectionChanged(Sender: TObject); 71 70 private … … 95 94 begin 96 95 AutoOpen := True; 97 LastOpenedListOpen.LoadFromRegistry(RegContext(RootKey, RootPath + ' /OpenRecent'));98 LastOpenedListCompare.LoadFromRegistry(RegContext(RootKey, RootPath + ' /CompareRecent'));96 LastOpenedListOpen.LoadFromRegistry(RegContext(RootKey, RootPath + '\OpenRecent')); 97 LastOpenedListCompare.LoadFromRegistry(RegContext(RootKey, RootPath + '\CompareRecent')); 99 98 if AutoOpen and (LastOpenedListOpen.Items.Count > 0) then 100 99 OpenDir(LastOpenedListOpen.Items[0]) … … 112 111 LastOpenedListOpen.LoadToMenuItem(MenuItemOpenRecent, AOpenDirExecute); 113 112 LastOpenedListOpen.LoadToMenuItem(PopupMenuOpenRecent.Items, AOpenDirExecute); 114 end;115 116 procedure TFormMain.MenuItemOpenRecentClick(Sender: TObject);117 begin118 119 113 end; 120 114 … … 254 248 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction); 255 249 begin 256 LastOpenedListOpen.SaveToRegistry(RegContext(RootKey, RootPath + ' /OpenRecent'));257 LastOpenedListCompare.SaveToRegistry(RegContext(RootKey, RootPath + ' /CompareRecent'));250 LastOpenedListOpen.SaveToRegistry(RegContext(RootKey, RootPath + '\OpenRecent')); 251 LastOpenedListCompare.SaveToRegistry(RegContext(RootKey, RootPath + '\CompareRecent')); 258 252 end; 259 253 -
trunk/UFormSearch.pas
r6 r13 50 50 FormMain.Config.TopNode.Search(EditText.Text, List); 51 51 ListView1.Items.Clear; 52 ListView1.Items.BeginUpdate; 52 53 for I := 0 to List.Count - 1 do 53 54 with TMenuNode(List[I]) do begin … … 59 60 end; 60 61 finally 62 ListView1.Items.EndUpdate; 61 63 List.Free; 62 64 end; -
trunk/UKConfig.pas
r11 r13 15 15 vtComment); 16 16 17 TMenuNode = class; 17 18 TLoadTreeOption = (toShowSystem); 18 19 TLoadTreeOptions = set of TLoadTreeOption; … … 30 31 ExpOperator: TExpOperator; 31 32 Items: TObjectList; // TList<TExpression> 32 constructor Create; 33 Parent: TExpression; 34 function Show: String; virtual; 35 procedure GetList(List: TStringList); virtual; 36 constructor Create; virtual; 33 37 destructor Destroy; override; 34 38 end; 35 39 36 TExpressionVar = class 40 TCompareType = (ctNone, ctEqual, ctNotEqual); 41 42 { TExpressionVar } 43 44 TExpressionVar = class(TExpression) 37 45 Name: string; 46 Node: TMenuNode; 38 47 Negative: Boolean; 48 Compare: TCompareType; 49 Value: string; 50 constructor Create; override; 51 procedure GetList(List: TStringList); override; 52 function Show: String; override; 39 53 end; 40 54 … … 42 56 43 57 TMenuNode = class 58 private 59 function GetVisible: Boolean; 60 public 44 61 ID: string; 45 62 Name: string; 46 Depends : TStringList;63 DependsOn: TExpression; 47 64 Selects: TStringList; 48 65 Description: TStringList; … … 70 87 function GetTopNode: TMenuNode; virtual; 71 88 function FindNode(ID: string): TMenuNode; virtual; 89 property Visible: Boolean read GetVisible; 72 90 end; 73 91 … … 82 100 Arch: string; 83 101 FOnLog: TOnLogEvent; 102 ParseFileName: string; 103 LineNumber: Integer; 84 104 function GetTopCondition: string; 85 105 procedure Log(Text: string); 86 106 function IsWhiteSpace(Character: Char): Boolean; 107 function IsAlpha(Character: Char): Boolean; 108 function IsAlphaNumeric(Character: Char): Boolean; 109 function IsNumeric(Character: Char): Boolean; 110 function IsIdentifier(Name: string): Boolean; 111 function IsSpecialSymbol(Character: Char): Boolean; 112 procedure Expect(var Text: string; Token: string); 87 113 function GetNextToken(var Text: string): string; 114 procedure ParseExpression(Node: TMenuNode; Line: string); 88 115 procedure ParseFile(FileName: string); 89 116 procedure ParseConfig; 90 117 procedure ParseMakeFile; 118 function GetLog: string; 91 119 public 92 120 TopNode: TMenuNode; … … 105 133 implementation 106 134 135 { TExpressionVar } 136 137 constructor TExpressionVar.Create; 138 begin 139 inherited; 140 Compare := ctNone; 141 Value := ''; 142 Negative := False; 143 Name := ''; 144 end; 145 146 procedure TExpressionVar.GetList(List: TStringList); 147 begin 148 inherited GetList(List); 149 List.Add(Name); 150 end; 151 152 function TExpressionVar.Show: String; 153 begin 154 Result := Name; 155 if Negative then Result := '!' + Result; 156 if Compare = ctEqual then Result := Result + ' = ' + Value; 157 if Compare = ctNotEqual then Result := Result + ' != ' + Value; 158 end; 159 107 160 { TExpression } 108 161 162 function TExpression.Show: String; 163 var 164 Operand: string; 165 I: Integer; 166 begin 167 Result := ''; 168 if ExpOperator = eoAnd then Operand := '&&'; 169 if ExpOperator = eoOr then Operand := '||'; 170 for I := 0 to Items.Count - 1 do begin 171 Result := Result + TExpression(Items[I]).Show; 172 if I < (Items.Count - 1) then Result := Result + ' ' + Operand + ' '; 173 end; 174 if Assigned(Parent) then Result := '(' + Result + ')'; 175 end; 176 177 procedure TExpression.GetList(List: TStringList); 178 var 179 I: Integer; 180 begin 181 for I := 0 to Items.Count - 1 do 182 TExpression(Items[I]).GetList(List); 183 end; 184 109 185 constructor TExpression.Create; 110 186 begin 111 187 Items := TObjectList.Create; 188 Parent := nil; 189 ExpOperator := eoAnd; 112 190 end; 113 191 … … 119 197 120 198 { TMenuNode } 199 200 function TMenuNode.GetVisible: Boolean; 201 var 202 I: Integer; 203 begin 204 Result := True; 205 //for I := 0 to Depends.Count - 1 do 206 //if Depends[I] 207 end; 121 208 122 209 constructor TMenuNode.Create; … … 125 212 ID := ''; 126 213 Parent := nil; 127 Depends := TStringList.Create;214 DependsOn := TExpression.Create; 128 215 Description := TStringList.Create; 129 216 Selects := TStringList.Create; … … 134 221 destructor TMenuNode.Destroy; 135 222 begin 223 DependsOn.Free; 136 224 Items.Free; 137 Depends.Free;138 225 Description.Free; 139 226 Selects.Free; … … 197 284 Add('ID: ' + ID); 198 285 Add('Name: ' + Name); 199 Add('Depends on: ' + Depends .Text);286 Add('Depends on: ' + DependsOn.Show); 200 287 Add('Selects: ' + Selects.Text); 201 288 Add('Description: ' + Description.Text); … … 245 332 LatestNode: TMenuNode; 246 333 CheckList: TObjectList; 334 DepList: TStringList; 247 335 begin 248 336 Result := False; … … 250 338 CheckList := TObjectList.Create; 251 339 CheckList.OwnsObjects := False; 340 DepList := TStringList.Create; 252 341 if Assigned(Parent) then begin 253 342 Index := Parent.Items.IndexOf(Self); 254 343 if Index = -1 then raise Exception.Create('Node not found in parent'); 255 344 if Index >= 1 then TMenuNode(Parent.Items[Index - 1]).AddLastToList(CheckList); 345 DepList.Clear; 346 DependsOn.GetList(DepList); 256 347 for I := CheckList.Count - 1 downto 0 do begin 257 for J := 0 to Dep ends.Count - 1 do258 if Trim(Dep ends[J]) <> '' then begin259 if (Dep ends[J] = TMenuNode(CheckList[I]).ID) and (TMenuNode(CheckList[I]).ValueType <> vtChoice) then begin348 for J := 0 to DepList.Count - 1 do 349 if Trim(DepList[J]) <> '' then begin 350 if (DepList[J] = TMenuNode(CheckList[I]).ID) and (TMenuNode(CheckList[I]).ValueType <> vtChoice) then begin 260 351 ChangeParent(TMenuNode(CheckList[I])); 261 352 Result := True; … … 267 358 end; 268 359 finally 360 DepList.Free; 269 361 CheckList.Free; 270 362 end; … … 329 421 end; 330 422 423 function TConfigMenu.IsAlpha(Character: Char): Boolean; 424 begin 425 Result := ((Character >= 'a') and (Character <= 'z')) 426 or ((Character >= 'A') and (Character <= 'Z')); 427 end; 428 429 function TConfigMenu.IsAlphaNumeric(Character: Char): Boolean; 430 begin 431 Result := IsAlpha(Character) or IsNumeric(Character); 432 end; 433 434 function TConfigMenu.IsNumeric(Character: Char): Boolean; 435 begin 436 Result := (Character >= '0') and (Character <= '9'); 437 end; 438 439 function TConfigMenu.IsIdentifier(Name: string): Boolean; 440 var 441 I: Integer; 442 begin 443 Result := True; 444 for I := 1 to Length(Name) do 445 if not (IsAlphaNumeric(Name[I]) or (Name[I] = '_')) then begin 446 Result := False; 447 Break; 448 end; 449 end; 450 451 function TConfigMenu.IsSpecialSymbol(Character: Char): Boolean; 452 begin 453 Result := (Character = '!') or (Character = '=') or (Character = '(') or 454 (Character = ')') or (Character = '-') or (Character = '|') or (Character = '&'); 455 end; 456 457 procedure TConfigMenu.Expect(var Text: string; Token: string); 458 begin 459 if GetNextToken(Text) <> Token then 460 raise Exception.Create('Expected "' + Token + '"'); 461 end; 462 331 463 function TConfigMenu.GetNextToken(var Text: string): string; 332 464 var 333 465 I: Integer; 334 466 Terminate: Boolean; 335 State: (stNormal, stWhiteSpace, stString); 467 State: (stNormal, stWhiteSpace, stString, stSpecialSymbol, stIdent, 468 stString2); 336 469 begin 337 470 I := 1; … … 350 483 State := stNormal; 351 484 Terminate := True; 485 Inc(I); 486 end else Result := Result + Text[I]; 487 end else 488 if State = stString2 then begin 489 if Text[I] = '''' then begin 490 State := stNormal; 491 Terminate := True; 492 Inc(I); 493 end else Result := Result + Text[I]; 494 end else 495 if State = stSpecialSymbol then begin 496 if not IsSpecialSymbol(Text[I]) or (Result = '(') or (Result = ')') or 497 ((Result = '!') and (Text[I] <> '=')) or (Result = '||') or 498 (Result = '&&') then begin 499 State := stNormal; 500 Terminate := True; 501 end else Result := Result + Text[I]; 502 end else 503 if State = stIdent then begin 504 if not (IsAlphanumeric(Text[I]) or (Text[I] = '_')) then begin 505 State := stNormal; 506 Terminate := True; 352 507 end else Result := Result + Text[I]; 353 508 end else begin 354 509 if IsWhiteSpace(Text[I]) then State := stWhiteSpace 355 510 else if Text[I] = '"' then State := stString 511 else if Text[I] = '''' then State := stString2 512 else if Text[I] = '#' then begin 513 // Comment 514 Text := ''; 515 Terminate := True; 516 end 517 else if IsSpecialSymbol(Text[I]) then begin 518 State := stSpecialSymbol; 519 Result := Result + Text[I]; 520 end 521 else if IsAlphaNumeric(Text[I]) then begin 522 State := stIdent; 523 Result := Result + Text[I]; 524 end 356 525 else Result := Result + Text[I]; 357 526 end; … … 359 528 end; 360 529 Delete(Text, 1, I - 1); 530 end; 531 532 procedure TConfigMenu.ParseExpression(Node: TMenuNode; Line: string); 533 var 534 Token: string; 535 Exp: TExpression; 536 ExpVar: TExpressionVar; 537 ExpNew: TExpression; 538 Neg: Boolean; 539 Compare: TCompareType; 540 begin 541 Line := Trim(Line); 542 Exp := Node.DependsOn; 543 Neg := False; 544 while Line <> '' do begin 545 Token := GetNextToken(Line); 546 if Token = '||' then begin 547 Exp.ExpOperator := eoOr; 548 end else 549 if Token = '&&' then begin 550 Exp.ExpOperator := eoAnd; 551 end else 552 if Token = '!' then begin 553 Neg := True; 554 Continue; 555 end else 556 if Token = '(' then begin 557 ExpNew := TExpression.Create; 558 ExpNew.Parent := Exp; 559 Exp.Items.Add(ExpNew); 560 Exp := ExpNew; 561 Neg := False; 562 end else 563 if Token = ')' then begin 564 if Assigned(Exp.Parent) then Exp := Exp.Parent 565 else raise Exception.Create('Cannot go to expression parent.' + GetLog); 566 Neg := False; 567 end else 568 if Token = '' then begin 569 // White space 570 end else 571 if Token = '=' then begin 572 ExpVar.Compare := ctEqual; 573 Token := GetNextToken(Line); 574 ExpVar.Value := Token; 575 Continue; 576 end else 577 if Token = '!=' then begin 578 ExpVar.Compare := ctNotEqual; 579 Token := GetNextToken(Line); 580 ExpVar.Value := Token; 581 Continue; 582 end else 583 if IsIdentifier(Token) then begin 584 ExpVar := TExpressionVar.Create; 585 ExpVar.Negative := Neg; 586 ExpVar.Name := Token; 587 ExpVar.Compare := Compare; 588 Exp.Items.Add(ExpVar); 589 Neg := False; 590 end else 591 raise Exception.Create('Unknown token "' + Token + '".' + GetLog); 592 end; 593 594 {// Just try to load symbol list. Do not parse expression 595 while Trim(Line) <> '' do begin 596 Parameter := GetNextToken(Line); 597 if Copy(Parameter, 1, 1) = '!' then Delete(Parameter, 1, 1); 598 if Copy(Parameter, 1, 1) = '(' then Delete(Parameter, 1, 1); 599 if Copy(Parameter, Length(Parameter), 1) = ')' then Delete(Parameter, Length(Parameter), 1); 600 Parameter := Trim(Parameter); 601 if (Parameter <> '&&') and (Parameter <> '||') then 602 Node.Depends.Add(Parameter); 603 end; 604 } 605 606 end; 607 608 function TConfigMenu.GetLog: string; 609 begin 610 Result := ' ' + ParseFileName + ':' + IntToStr(LineNumber); 361 611 end; 362 612 … … 375 625 HelpIndent: Integer; 376 626 LineIndent: Integer; 377 378 function GetLog: string; 379 begin 380 Result := FileName + ':' + IntToStr(I + 1) + ' ' + Content[I]; 381 end; 382 627 NewExp: TExpressionVar; 383 628 const 384 629 TabSize = 8; 385 386 begin 630 begin 631 ParseFileName := FileName; 387 632 Log('FILE ' + FileName); 388 633 try … … 394 639 HelpIndent := 0; 395 640 for I := 0 to Content.Count - 1 do begin 641 LineNumber := I + 1; 396 642 Line := MergedLines + Content[I]; 397 643 MergedLines := ''; … … 408 654 HelpIndent := LineIndent; 409 655 if (State = stHelpStart) and (HelpIndent = 0) then 410 raise Exception.Create('Error during help parsing ');656 raise Exception.Create('Error during help parsing.' + GetLog); 411 657 end; 412 658 if (State = stHelpStart) and (Trim(Line) <> '') and (LineIndent < HelpIndent) then … … 434 680 end else 435 681 if (Command = 'bool') or (Command = 'boolean') then begin 436 Parameter := GetNextToken(Line); 437 if not Assigned(NewItem) then raise Exception.Create('Item not defined. ' + GetLog); 682 Expect(Line, ''); 683 Parameter := GetNextToken(Line); 684 if not Assigned(NewItem) then raise Exception.Create('Item not defined.' + GetLog); 438 685 NewItem.ValueType := vtBool; 439 686 NewItem.Name := Parameter; 440 687 end else 441 688 if Command = 'def_bool' then begin 442 Parameter := GetNextToken(Line); 443 if not Assigned(NewItem) then raise Exception.Create('Item not defined. ' + GetLog); 689 Expect(Line, ''); 690 Parameter := GetNextToken(Line); 691 if not Assigned(NewItem) then raise Exception.Create('Item not defined.' + GetLog); 444 692 NewItem.DefaultValue := Parameter; 445 693 NewItem.ValueType := vtBool; 446 694 end else 447 695 if Command = 'tristate' then begin 448 Parameter := GetNextToken(Line); 449 if not Assigned(NewItem) then raise Exception.Create('Item not defined. ' + GetLog); 696 Expect(Line, ''); 697 Parameter := GetNextToken(Line); 698 if not Assigned(NewItem) then raise Exception.Create('Item not defined.' + GetLog); 450 699 NewItem.Name := Parameter; 451 700 NewItem.ValueType := vtTristate; 452 701 end else 453 702 if Command = 'def_tristate' then begin 454 Parameter := GetNextToken(Line); 455 if not Assigned(NewItem) then raise Exception.Create('Item not defined. ' + GetLog); 703 Expect(Line, ''); 704 Parameter := GetNextToken(Line); 705 if not Assigned(NewItem) then raise Exception.Create('Item not defined.' + GetLog); 456 706 NewItem.Name := Parameter; 457 707 end else 458 708 if Command = 'string' then begin 459 Parameter := GetNextToken(Line); 460 if not Assigned(NewItem) then raise Exception.Create('Item not defined. ' + GetLog); 709 Expect(Line, ''); 710 Parameter := GetNextToken(Line); 711 if not Assigned(NewItem) then raise Exception.Create('Item not defined.' + GetLog); 461 712 NewItem.Name := Parameter; 462 713 NewItem.ValueType := vtString; 463 714 end else 464 715 if Command = 'int' then begin 465 Parameter := GetNextToken(Line); 466 if not Assigned(NewItem) then raise Exception.Create('Item not defined. ' + GetLog); 716 Expect(Line, ''); 717 Parameter := GetNextToken(Line); 718 if not Assigned(NewItem) then raise Exception.Create('Item not defined.' + GetLog); 467 719 NewItem.Name := Parameter; 468 720 NewItem.ValueType := vtInt; 469 721 end else 470 722 if Command = 'hex' then begin 471 Parameter := GetNextToken(Line); 472 if not Assigned(NewItem) then raise Exception.Create('Item not defined. ' + GetLog); 723 Expect(Line, ''); 724 Parameter := GetNextToken(Line); 725 if not Assigned(NewItem) then raise Exception.Create('Item not defined.' + GetLog); 473 726 NewItem.Name := Parameter; 474 727 NewItem.ValueType := vtHex; 475 728 end else 476 729 if Command = 'range' then begin 477 Parameter := GetNextToken(Line); 478 if not Assigned(NewItem) then raise Exception.Create('Item not defined. ' + GetLog); 730 Expect(Line, ''); 731 Parameter := GetNextToken(Line); 732 if not Assigned(NewItem) then raise Exception.Create('Item not defined.' + GetLog); 479 733 NewItem.RangeMin := Parameter; 480 734 Parameter := GetNextToken(Line); … … 482 736 end else 483 737 if Command = 'prompt' then begin 484 Parameter := GetNextToken(Line); 485 if not Assigned(NewItem) then raise Exception.Create('Item not defined. ' + GetLog); 738 Expect(Line, ''); 739 Parameter := GetNextToken(Line); 740 if not Assigned(NewItem) then raise Exception.Create('Item not defined.' + GetLog); 486 741 NewItem.Name := Parameter; 487 742 end else 488 743 if Command = 'default' then begin 489 Parameter := GetNextToken(Line); 490 if not Assigned(NewItem) then raise Exception.Create('Item not defined. ' + GetLog); 744 Expect(Line, ''); 745 Parameter := GetNextToken(Line); 746 if not Assigned(NewItem) then raise Exception.Create('Item not defined.' + GetLog); 491 747 NewItem.DefaultValue := Parameter; 492 748 end else 493 749 if Command = 'depends' then begin 750 Expect(Line, ''); 494 751 Parameter := GetNextToken(Line); 495 752 if Parameter = 'on' then begin 496 if not Assigned(NewItem) then raise Exception.Create('Item not defined. ' + GetLog); 497 // Just try to load symbol list. Do not parse expression 498 while Trim(Line) <> '' do begin 499 Parameter := GetNextToken(Line); 500 if Copy(Parameter, 1, 1) = '!' then Delete(Parameter, 1, 1); 501 if Copy(Parameter, 1, 1) = '(' then Delete(Parameter, 1, 1); 502 if Copy(Parameter, Length(Parameter), 1) = ')' then Delete(Parameter, Length(Parameter), 1); 503 Parameter := Trim(Parameter); 504 if (Parameter <> '&&') and (Parameter <> '||') then 505 NewItem.Depends.Add(Parameter); 506 end; 753 if not Assigned(NewItem) then raise Exception.Create('Item not defined.' + GetLog); 754 ParseExpression(NewItem, Line); 507 755 end; 508 756 end else 509 757 if Command = 'select' then begin 510 Parameter := GetNextToken(Line); 511 if not Assigned(NewItem) then raise Exception.Create('Item not defined. ' + GetLog); 758 Expect(Line, ''); 759 Parameter := GetNextToken(Line); 760 if not Assigned(NewItem) then raise Exception.Create('Item not defined.' + GetLog); 512 761 NewItem.Selects.Add(Parameter); 513 762 end else … … 524 773 end else 525 774 if Command = 'option' then begin 775 Expect(Line, ''); 526 776 Parameter := GetNextToken(Line); 527 777 end else 528 778 if (Command = 'config') or (Command = 'menuconfig') then begin 779 Expect(Line, ''); 529 780 Parameter := GetNextToken(Line); 530 781 State := stConfig; … … 532 783 NewItem.Parent := CurrentMenu; 533 784 NewItem.ID := Parameter; 534 NewItem.Depends.AddStrings(ConditionStack); 785 for J := 0 to ConditionStack.Count - 1 do 786 if ConditionStack[J] <> '' then 787 begin 788 NewExp := TExpressionVar.Create; 789 NewExp.Name := ConditionStack[J]; 790 NewItem.DependsOn.Items.Add(NewExp); 791 end; 535 792 CurrentMenu.Items.Add(NewItem); 536 793 if Command = 'menuconfig' then NewItem.MenuConfig := True; 537 794 end else 538 795 if (Command = 'comment') then begin 796 Expect(Line, ''); 539 797 Parameter := GetNextToken(Line); 540 798 NewItem := TMenuNode.Create; 541 799 NewItem.Parent := CurrentMenu; 542 800 NewItem.Name := Parameter; 543 NewItem.Depends.AddStrings(ConditionStack); 801 for J := 0 to ConditionStack.Count - 1 do 802 if ConditionStack[J] <> '' then begin 803 NewExp := TExpressionVar.Create; 804 NewExp.Name := ConditionStack[J]; 805 NewItem.DependsOn.Items.Add(NewExp); 806 end; 544 807 NewItem.ValueType := vtComment; 545 808 CurrentMenu.Items.Add(NewItem); 546 809 end else 547 810 if Command = 'source' then begin 811 Expect(Line, ''); 548 812 Parameter := GetNextToken(Line); 549 813 if Pos('$SRCARCH', Parameter) > 0 then … … 552 816 if FileExistsUTF8(Parameter) then 553 817 ParseFile(Parameter) 554 else raise Exception.Create('Source file "' + Parameter + '" not found. 818 else raise Exception.Create('Source file "' + Parameter + '" not found.' + GetLog); 555 819 end else 556 820 if Command = 'choice' then begin 821 Expect(Line, ''); 557 822 Parameter := GetNextToken(Line); 558 823 NewMenu := TMenuNode.Create; … … 560 825 NewMenu.Name := Parameter; 561 826 NewMenu.Parent := CurrentMenu; 562 NewMenu.Depends.AddStrings(ConditionStack); 827 for J := 0 to ConditionStack.Count - 1 do 828 if ConditionStack[J] <> '' then begin 829 NewExp := TExpressionVar.Create; 830 NewExp.Name := ConditionStack[J]; 831 NewMenu.DependsOn.Items.Add(NewExp); 832 end; 563 833 ConditionStack.AddObject('', nil); 564 834 NewItem := NewMenu; … … 570 840 ConditionStack.Delete(ConditionStack.Count - 1); 571 841 CurrentMenu := CurrentMenu.Parent; 572 end else raise Exception.Create('Can''t change menu level up. 842 end else raise Exception.Create('Can''t change menu level up.' + GetLog); 573 843 end else 574 844 if Command = 'mainmenu' then begin 845 Expect(Line, ''); 575 846 Parameter := GetNextToken(Line); 576 847 Parameter := StringReplace(Parameter, '$ARCH', Arch, [rfReplaceAll]); … … 579 850 end else 580 851 if Command = 'menu' then begin 852 Expect(Line, ''); 581 853 Parameter := GetNextToken(Line); 582 854 Log('MENU ' + Parameter + ' IN ' + CurrentMenu.GetAbsoluteName); … … 584 856 NewMenu.Name := Parameter; 585 857 NewMenu.Parent := CurrentMenu; 586 NewMenu.Depends.AddStrings(ConditionStack); 858 for J := 0 to ConditionStack.Count - 1 do 859 if ConditionStack[J] <> '' then begin 860 NewExp := TExpressionVar.Create; 861 NewExp.Name := ConditionStack[J]; 862 NewMenu.DependsOn.Items.Add(NewExp); 863 end; 587 864 ConditionStack.AddObject('', nil); 588 865 NewItem := NewMenu; … … 595 872 ConditionStack.Delete(ConditionStack.Count - 1); 596 873 CurrentMenu := CurrentMenu.Parent; 597 end else raise Exception.Create('Can''t change menu level up. 874 end else raise Exception.Create('Can''t change menu level up.' + GetLog); 598 875 end else 599 876 if Command = 'if' then begin 877 Expect(Line, ''); 600 878 ConditionStack.AddObject(GetNextToken(Line), NewItem); 601 879 end else … … 606 884 ConditionStack.Delete(ConditionStack.Count - 1); 607 885 end else 608 raise Exception.Create('Unknown command "' + Command + '". 886 raise Exception.Create('Unknown command "' + Command + '".' + GetLog); 609 887 end; 610 888 finally
Note:
See TracChangeset
for help on using the changeset viewer.