Einzelnen Beitrag anzeigen

Benutzerbild von geskill
geskill

Registriert seit: 17. Feb 2007
Ort: NRW
420 Beiträge
 
Delphi 2010 Professional
 
#9

Re: FastScript - dem Script ein Interface hinzufügen

  Alt 31. Dez 2009, 14:58
ups, da hatte ich mir wohl ein Eigentor geschossen, ein paar Zeilen später im Code hatte ich ein clear Befehl, der alle hinzugefügten Objekte wieder gelöscht hat.
Somit geht es soweit. Habe mir die Komponenten jetzt gekauft.


Falls irgendwann jemand einen Lösungsansatz braucht:
Delphi-Quellcode:
function TTemplateParser.GetProp(Instance: TObject; ClassType: TClass; const PropName: String): Variant;
begin
  Result := 0;
  if PropName = 'MIRRORCOUNTthen
    Result := IMirrorController(Instance as TMirrorController).MirrorCount
  else if PropName = 'DIRECTLINKSMIRRORCOUNTthen
    Result := IMirrorControl(Instance as TMirrorControl).DirectlinksMirrorCount
  else if PropName = 'CRYPTERCOUNTthen
    Result := IMirrorControl(Instance as TMirrorControl).CrypterCount
  else if PropName = 'NAMEthen
    Result := ICrypterPanel(Instance as TCrypterPanel).Name
  else if PropName = 'LINKthen
    Result := ICrypterPanel(Instance as TCrypterPanel).Link;
end;

function TTemplateParser.CallMethod(Instance: TObject; ClassType: TClass; const MethodName: String;
  var Params: Variant): Variant;
begin
  Result := 0;
  if MethodName = 'MIRROR.GETthen
    Result := Integer(IMirrorController(Instance as TMirrorController).Mirror[Params[0]] as TMirrorControl)
  else if MethodName = 'DIRECTLINKSMIRROR.GETthen
    Result := IMirrorControl(Instance as TMirrorControl).DirectlinksMirror[Params[0]]
  else if MethodName = 'CRYPTER.GETthen
    Result := Integer(IMirrorControl(Instance as TMirrorControl).Crypter[Params[0]] as TCrypterPanel)
end;

function TTemplateParser.Exec(s: string): string;
var
  I: Integer;
begin
  Result := '';

  with FfsScript do
  begin
    Clear;
    Lines.Text := s;
    Parent := fsGlobalUnit;

    with AddClass(TCrypterPanel, 'TCrypterPanel') do
    begin
      AddProperty('Name', 'string', GetProp, nil);
      AddProperty('Link', 'string', GetProp, nil);
    end;

    with AddClass(TMirrorControl, 'TMirrorControl') do
    begin
      AddIndexProperty('DirectlinksMirror', 'Integer', 'string', CallMethod);
      AddProperty('DirectlinksMirrorCount', 'Integer', GetProp, nil);

      AddIndexProperty('Crypter', 'Integer', 'TCrypterPanel', CallMethod);
      AddProperty('CrypterCount', 'Integer', GetProp, nil);
    end;

    with AddClass(TMirrorController, 'TMirrorController') do
    begin
      AddIndexProperty('Mirror', 'Integer', 'TMirrorControl', CallMethod);
      AddProperty('MirrorCount', 'Integer', GetProp, nil);
    end;
    AddObject('IMirrorController', FITabSheetController.MirrorController as TMirrorController);

    if Compile then
      Execute;
    else
      Error(ErrorMsg);

  end;
end;
Sebastian
  Mit Zitat antworten Zitat