.include now quite working..

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@144 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Raymond 2009-10-20 20:30:11 +00:00
parent dd3d202b44
commit f3dae9ae78
3 changed files with 44 additions and 4 deletions

7
Includes/test.mufa Normal file
View File

@ -0,0 +1,7 @@
const
TestStr = 'Hai, seems like you got includes working!';
function Multiply(a,b : integer) : integer;
begin;
result := a*b;
end;

View File

@ -140,9 +140,9 @@ begin
MMLPSThread.SetPSScript(Self.SynEdit1.Lines.Text);
MMLPSThread.SetDebug(Self.Memo1);
if ScriptFile <> '' then
MMLPSThread.SetPaths( ExtractFileDir(ScriptFile) + DS,MainDir +DS)
MMLPSThread.SetPaths( ExtractFileDir(ScriptFile) + DS,IncludeTrailingPathDelimiter(ExpandFileName(MainDir +DS + '..' + DS + '..' + ds)))
else
MMLPSThread.SetPaths('',MainDir + DS);
MMLPSThread.SetPaths('', IncludeTrailingPathDelimiter(ExpandFileName(MainDir +DS + '..' + DS + '..' + ds)));
// This doesn't actually set the Client's MWindow to the passed window, it
// only copies the current set window handle.

View File

@ -44,6 +44,9 @@ type
PSyncInfo = ^TSyncInfo;
TMMLPSThread = class(TThread)
procedure OnProcessDirective(Sender: TPSPreProcessor;
Parser: TPSPascalPreProcessorParser; const Active: Boolean;
const DirectiveName, DirectiveParam: string; var Continue: Boolean);
procedure PSScriptProcessUnknowDirective(Sender: TPSPreProcessor;
Parser: TPSPascalPreProcessorParser; const Active: Boolean;
const DirectiveName, DirectiveParam: string; var Continue: Boolean);
@ -150,6 +153,7 @@ begin
PSScript := TPSScript.Create(nil);
PSScript.UsePreProcessor:= True;
PSScript.OnNeedFile := @RequireFile;
PSScript.OnProcessDirective:=@OnProcessDirective;
PSScript.OnProcessUnknowDirective:=@PSScriptProcessUnknowDirective;
PSScript.OnCompile:= @OnCompile;
PSScript.OnCompImport:= @OnCompImport;
@ -187,6 +191,11 @@ end;
{$I PSInc/Wrappers/mouse.inc}
{$I PSInc/Wrappers/dtm.inc}
procedure TMMLPSThread.OnProcessDirective(Sender: TPSPreProcessor;
Parser: TPSPascalPreProcessorParser; const Active: Boolean;
const DirectiveName, DirectiveParam: string; var Continue: Boolean);
begin
end;
procedure TMMLPSThread.PSScriptProcessUnknowDirective(Sender: TPSPreProcessor;
Parser: TPSPascalPreProcessorParser; const Active: Boolean;
@ -233,9 +242,33 @@ end;
function TMMLPSThread.RequireFile(Sender: TObject;
const OriginFileName: String; var FileName, OutPut: string): Boolean;
var
path: string;
f: TFileStream;
begin
Result := False;
if FileExists(FileName) then
Path := FileName
else
Path := AppPath+ 'Includes' + DS + Filename;
if not FileExists(Path) then
begin;
Writeln(Path + ' doesn''t exist');
Result := false;
Exit;
end;
try
F := TFileStream.Create(Path, fmOpenRead or fmShareDenyWrite);
except
Result := false;
exit;
end;
try
SetLength(Output, f.Size);
f.Read(Output[1], Length(Output));
finally
f.Free;
end;
Result := True;
end;
procedure TMMLPSThread.OnCompImport(Sender: TObject; x: TPSPascalCompiler);