1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-24 18:22:25 -05:00

Simba/PS: Added extra directive ``FIXME''.

Not totally done yet. I also want to add ERROR.
Also modified the Pascalscript preprocessor a bit more, it never passed a
filename to the custom define functions. I'm open for more elegant solutions!
This commit is contained in:
Merlijn Wajer 2011-02-21 14:36:55 +01:00
parent aac852c18c
commit 8558ae66d5
3 changed files with 66 additions and 40 deletions

View File

@ -139,7 +139,9 @@ type
procedure FormCallBackEx(cmd : integer; var data : pointer); procedure FormCallBackEx(cmd : integer; var data : pointer);
procedure FormCallBack(cmd : integer; data : pointer); procedure FormCallBack(cmd : integer; data : pointer);
procedure HandleError(ErrorRow,ErrorCol,ErrorPosition : integer; ErrorStr : string; ErrorType : TErrorType; ErrorModule : string); procedure HandleError(ErrorRow,ErrorCol,ErrorPosition : integer; ErrorStr : string; ErrorType : TErrorType; ErrorModule : string);
function ProcessDirective(DirectiveName, DirectiveArgs: string): boolean; function ProcessDirective(Sender: TPSPreProcessor;
Parser: TPSPascalPreProcessorParser;
DirectiveName, DirectiveArgs: string; Filename:String): boolean;
function LoadFile(ParentFile : string; var filename, contents: string): boolean; function LoadFile(ParentFile : string; var filename, contents: string): boolean;
procedure AddMethod(meth: TExpMethod); virtual; procedure AddMethod(meth: TExpMethod); virtual;
@ -168,12 +170,14 @@ type
public public
procedure OnProcessDirective(Sender: TPSPreProcessor; procedure OnProcessDirective(Sender: TPSPreProcessor;
Parser: TPSPascalPreProcessorParser; const Active: Boolean; Parser: TPSPascalPreProcessorParser; const Active: Boolean;
const DirectiveName, DirectiveParam: string; var Continue: Boolean); const DirectiveName, DirectiveParam: string; var Continue: Boolean;
Filename: String);
function PSScriptFindUnknownFile(Sender: TObject; function PSScriptFindUnknownFile(Sender: TObject;
const OrginFileName: string; var FileName, Output: string): Boolean; const OrginFileName: string; var FileName, Output: string): Boolean;
procedure PSScriptProcessUnknowDirective(Sender: TPSPreProcessor; procedure PSScriptProcessUnknownDirective(Sender: TPSPreProcessor;
Parser: TPSPascalPreProcessorParser; const Active: Boolean; Parser: TPSPascalPreProcessorParser; const Active: Boolean;
const DirectiveName, DirectiveParam: string; var Continue: Boolean); const DirectiveName, DirectiveParam: string; var Continue: Boolean;
Filename: string);
protected protected
PluginsToload : array of integer; PluginsToload : array of integer;
procedure LoadPlugin(plugidx: integer); override; procedure LoadPlugin(plugidx: integer); override;
@ -435,12 +439,16 @@ begin
end; end;
end; end;
function TMThread.ProcessDirective(DirectiveName, DirectiveArgs: string): boolean; function TMThread.ProcessDirective(Sender: TPSPreProcessor;
Parser: TPSPascalPreProcessorParser;
DirectiveName, DirectiveArgs: string; FileName: string): boolean;
var var
plugin_idx, i: integer; plugin_idx, i: integer;
path : string; path : string;
begin begin
Result := False; Result := False;
writeln('ProcessDirective called');
if CompareText(DirectiveName,'LOADLIB') = 0 then if CompareText(DirectiveName,'LOADLIB') = 0 then
begin begin
if DirectiveArgs <> '' then if DirectiveArgs <> '' then
@ -457,21 +465,25 @@ begin
else else
psWriteln('Your LoadLib directive has no params, thus cannot find the plugin'); psWriteln('Your LoadLib directive has no params, thus cannot find the plugin');
end end
else if CompareText(DirectiveName,'INCLUDE_ONCE') = 0 then else if CompareText(DirectiveName,'FIXME') = 0 then
begin begin
Result := True; //Lets to the actual file checking later on in the preprocessor ;-) if (sender = nil) or (parser = nil) then
begin
psWriteln('ERROR: FIXME directive not supported for this interpreter');
exit(False);
end;
if (DirectiveArgs <> '') then if (DirectiveArgs <> '') then
begin begin
path := FindFile(DirectiveArgs,[ScriptPath,IncludePath]); Result := True;
if (path <> '') then HandleError(Parser.Row, Parser.Col, Parser.Pos, 'FIXME AT ' + DirectiveArgs, errCompile, 'test');
if Includes.Find(path,i) then psWriteln(format('FIXME: In file %s: at row: %d, col: %d, pos %d: %s',
begin [FileName, Parser.row, Parser.col,
Writeln('include_once: File already included.'); // debug message Parser.pos, DirectiveArgs]));
Result := False;
end
end; end;
end else end else
Result := True; Result := True; // If we do not know the directive; return true so Continue
// will be false.
end; end;
procedure TMThread.SetDebug(writelnProc: TWritelnProc); procedure TMThread.SetDebug(writelnProc: TWritelnProc);
@ -580,7 +592,7 @@ begin
PSScript.OnNeedFile := @RequireFile; PSScript.OnNeedFile := @RequireFile;
PSScript.OnFileAlreadyIncluded := @FileAlreadyIncluded; PSScript.OnFileAlreadyIncluded := @FileAlreadyIncluded;
PSScript.OnProcessDirective:=@OnProcessDirective; PSScript.OnProcessDirective:=@OnProcessDirective;
PSScript.OnProcessUnknowDirective:=@PSScriptProcessUnknowDirective; PSScript.OnProcessUnknowDirective:=@PSScriptProcessUnknownDirective;
PSScript.OnCompile:= @OnCompile; PSScript.OnCompile:= @OnCompile;
PSScript.OnCompImport:= @OnCompImport; PSScript.OnCompImport:= @OnCompImport;
PSScript.OnExecImport:= @OnExecImport; PSScript.OnExecImport:= @OnExecImport;
@ -609,10 +621,11 @@ end;
procedure TPSThread.OnProcessDirective(Sender: TPSPreProcessor; procedure TPSThread.OnProcessDirective(Sender: TPSPreProcessor;
Parser: TPSPascalPreProcessorParser; const Active: Boolean; Parser: TPSPascalPreProcessorParser; const Active: Boolean;
const DirectiveName, DirectiveParam: string; var Continue: Boolean); const DirectiveName, DirectiveParam: string; var Continue: Boolean; Filename: String);
begin begin
if CompareText(DirectiveName, 'LOADLIB') = 0 then if (CompareText(DirectiveName, 'LOADLIB') = 0) or (CompareText(DirectiveName, 'FIXME') = 0) then
Continue := not ProcessDirective(DirectiveName,DirectiveParam); Continue := not ProcessDirective(Sender, Parser, DirectiveName,DirectiveParam,
FileName);
end; end;
function TPSThread.PSScriptFindUnknownFile(Sender: TObject; function TPSThread.PSScriptFindUnknownFile(Sender: TObject;
@ -622,11 +635,14 @@ begin
Result := false; Result := false;
end; end;
procedure TPSThread.PSScriptProcessUnknowDirective(Sender: TPSPreProcessor; procedure TPSThread.PSScriptProcessUnknownDirective(Sender: TPSPreProcessor;
Parser: TPSPascalPreProcessorParser; const Active: Boolean; Parser: TPSPascalPreProcessorParser; const Active: Boolean;
const DirectiveName, DirectiveParam: string; var Continue: Boolean); const DirectiveName, DirectiveParam: string; var Continue: Boolean;
Filename: string);
begin begin
Continue:= not ProcessDirective(DirectiveName, DirectiveParam); writeln('PSScriptProcessUnknownDirective called');
Continue:= not ProcessDirective(Sender, Parser, DirectiveName, DirectiveParam,
FileName);
end; end;
function Muf_Conv_to_PS_Conv( conv : integer) : TDelphiCallingConvention; function Muf_Conv_to_PS_Conv( conv : integer) : TDelphiCallingConvention;
@ -773,11 +789,16 @@ begin
end; end;
function TMufasaBitmapCreate : TMufasaBitmap; function TMufasaBitmapCreate : TMufasaBitmap;
begin; begin
result := TMufasaBitmap.Create; result := TMufasaBitmap.Create;
CurrThread.Client.MBitmaps.AddBMP(result); CurrThread.Client.MBitmaps.AddBMP(result);
end; end;
procedure TMufasaBitmapFree(Self : TMufasaBitmap);begin; CurrThread.Client.MBitmaps.FreeBMP(Self.Index); end;
procedure TMufasaBitmapFree(Self : TMufasaBitmap);
begin
CurrThread.Client.MBitmaps.FreeBMP(Self.Index);
end;
function TMufasaBitmapCopy(Self : TMufasaBitmap;const xs,ys,xe,ye : integer) : TMufasaBitmap; function TMufasaBitmapCopy(Self : TMufasaBitmap;const xs,ys,xe,ye : integer) : TMufasaBitmap;
begin begin
result := Self.Copy(xs,ys,xe,ye); result := Self.Copy(xs,ys,xe,ye);
@ -928,7 +949,7 @@ end;
function Interpreter_Precompiler(name, args: PChar): boolean; stdcall; function Interpreter_Precompiler(name, args: PChar): boolean; stdcall;
begin begin
result:= CurrThread.ProcessDirective(name, args); result:= CurrThread.ProcessDirective(nil, nil, name, args, '');
end; end;
procedure Interpreter_ErrorHandler(line, pos: integer; err: PChar; runtime: boolean); stdcall; procedure Interpreter_ErrorHandler(line, pos: integer; err: PChar; runtime: boolean); stdcall;

View File

@ -102,7 +102,8 @@ type
Parser: TPSPascalPreProcessorParser; Parser: TPSPascalPreProcessorParser;
const Active: Boolean; const Active: Boolean;
const DirectiveName, DirectiveParam: tbtstring; const DirectiveName, DirectiveParam: tbtstring;
Var Continue: Boolean) of Object; // jgv Var Continue: Boolean;
Filename: tbtString) of Object; // jgv
TPSScript = class(TComponent) TPSScript = class(TComponent)
private private
@ -177,12 +178,14 @@ type
Parser: TPSPascalPreProcessorParser; Parser: TPSPascalPreProcessorParser;
const Active: Boolean; const Active: Boolean;
const DirectiveName, DirectiveParam: tbtstring; const DirectiveName, DirectiveParam: tbtstring;
Var Continue: Boolean); virtual; Var Continue: Boolean;
Filename: tbtString); virtual;
procedure DoOnProcessUnknowDirective (Sender: TPSPreProcessor; procedure DoOnProcessUnknowDirective (Sender: TPSPreProcessor;
Parser: TPSPascalPreProcessorParser; Parser: TPSPascalPreProcessorParser;
const Active: Boolean; const Active: Boolean;
const DirectiveName, DirectiveParam: tbtstring; const DirectiveName, DirectiveParam: tbtstring;
Var Continue: Boolean); virtual; Var Continue: Boolean;
Filename: tbtString); virtual;
public public
property RuntimeImporter: TPSRuntimeClassImporter read RI; property RuntimeImporter: TPSRuntimeClassImporter read RI;
@ -459,9 +462,9 @@ procedure callObjectOnProcessDirective (
Parser: TPSPascalPreProcessorParser; Parser: TPSPascalPreProcessorParser;
const Active: Boolean; const Active: Boolean;
const DirectiveName, DirectiveParam: tbtstring; const DirectiveName, DirectiveParam: tbtstring;
Var Continue: Boolean); Var Continue: Boolean; Filename: tbtstring);
begin begin
TPSScript (Sender.ID).DoOnProcessDirective(Sender, Parser, Active, DirectiveName, DirectiveParam, Continue); TPSScript (Sender.ID).DoOnProcessDirective(Sender, Parser, Active, DirectiveName, DirectiveParam, Continue, Filename);
end; end;
procedure callObjectOnProcessUnknowDirective ( procedure callObjectOnProcessUnknowDirective (
@ -469,9 +472,9 @@ procedure callObjectOnProcessUnknowDirective (
Parser: TPSPascalPreProcessorParser; Parser: TPSPascalPreProcessorParser;
const Active: Boolean; const Active: Boolean;
const DirectiveName, DirectiveParam: tbtstring; const DirectiveName, DirectiveParam: tbtstring;
Var Continue: Boolean); Var Continue: Boolean; Filename: tbtString);
begin begin
TPSScript (Sender.ID).DoOnProcessUnknowDirective(Sender, Parser, Active, DirectiveName, DirectiveParam, Continue); TPSScript (Sender.ID).DoOnProcessUnknowDirective(Sender, Parser, Active, DirectiveName, DirectiveParam, Continue, Filename);
end; end;
@ -1051,18 +1054,20 @@ end;
procedure TPSScript.DoOnProcessDirective(Sender: TPSPreProcessor; procedure TPSScript.DoOnProcessDirective(Sender: TPSPreProcessor;
Parser: TPSPascalPreProcessorParser; const Active: Boolean; Parser: TPSPascalPreProcessorParser; const Active: Boolean;
const DirectiveName, DirectiveParam: tbtstring; var Continue: Boolean); const DirectiveName, DirectiveParam: tbtstring; var Continue: Boolean;
Filename: tbtString);
begin begin
If Assigned (OnProcessDirective) then If Assigned (OnProcessDirective) then
OnProcessDirective (Sender, Parser, Active, DirectiveName, DirectiveParam, Continue); OnProcessDirective (Sender, Parser, Active, DirectiveName, DirectiveParam, Continue, Filename);
end; end;
procedure TPSScript.DoOnProcessUnknowDirective(Sender: TPSPreProcessor; procedure TPSScript.DoOnProcessUnknowDirective(Sender: TPSPreProcessor;
Parser: TPSPascalPreProcessorParser; const Active: Boolean; Parser: TPSPascalPreProcessorParser; const Active: Boolean;
const DirectiveName, DirectiveParam: tbtstring; var Continue: Boolean); const DirectiveName, DirectiveParam: tbtstring; var Continue: Boolean;
FileName: tbtString);
begin begin
If Assigned (OnProcessUnknowDirective) then If Assigned (OnProcessUnknowDirective) then
OnProcessUnknowDirective (Sender, Parser, Active, DirectiveName, DirectiveParam, Continue); OnProcessUnknowDirective (Sender, Parser, Active, DirectiveName, DirectiveParam, Continue,Filename);
end; end;
function TPSScript.DoOnNeedFile(Sender: TObject; function TPSScript.DoOnNeedFile(Sender: TObject;

View File

@ -24,7 +24,8 @@ type
Parser: TPSPascalPreProcessorParser; Parser: TPSPascalPreProcessorParser;
const Active: Boolean; const Active: Boolean;
const DirectiveName, DirectiveParam: tbtString; const DirectiveName, DirectiveParam: tbtString;
Var Continue: Boolean); //- jgv - application set continue to false to stop the normal directive processing Var Continue: Boolean;
FileName: tbtString); //- jgv - application set continue to false to stop the normal directive processing
TPSLineInfo = class(TObject) TPSLineInfo = class(TObject)
private private
@ -625,10 +626,9 @@ begin
//-- 20050707_jgv - ask the application //-- 20050707_jgv - ask the application
AppContinue := True; AppContinue := True;
If @OnProcessDirective <> Nil then OnProcessDirective (Self, Parser, FDefineState.DoWrite, name, s, AppContinue); If @OnProcessDirective <> Nil then OnProcessDirective (Self, Parser, FDefineState.DoWrite, name, s, AppContinue, Filename);
If AppContinue then If AppContinue then
//-- end jgv //-- end jgv
if (Name = 'I') or (Name = 'INCLUDE') then if (Name = 'I') or (Name = 'INCLUDE') then
begin begin
if FDefineState.DoWrite then if FDefineState.DoWrite then
@ -710,7 +710,7 @@ begin
//-- 20050710_jgv custom application error process //-- 20050710_jgv custom application error process
else if Parser.Token[2] <> '.' then begin else if Parser.Token[2] <> '.' then begin
If @OnProcessUnknowDirective <> Nil then begin If @OnProcessUnknowDirective <> Nil then begin
OnProcessUnknowDirective (Self, Parser, FDefineState.DoWrite, name, s, AppContinue); OnProcessUnknowDirective (Self, Parser, FDefineState.DoWrite, name, s, AppContinue, Filename);
end; end;
If AppContinue then If AppContinue then
//-- end jgv //-- end jgv