1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-30 12:52:16 -05:00

Lape Integration, TLPThread work

This commit is contained in:
John P (Dgby714) 2011-06-16 21:26:03 -04:00 committed by Merlijn Wajer
parent ecab4d5801
commit e5812a8000
8 changed files with 432 additions and 63 deletions

View File

@ -27,9 +27,9 @@
{$ENDIF} {$ENDIF}
//{$DEFINE USE_RUTIS} //{$DEFINE USE_RUTIS}
//{$DEFINE USE_LAPE}
//{$DEFINE USE_CPASCAL} // TODO //{$DEFINE USE_CPASCAL} // TODO
//{$DEFINE USE_LAPE} // TODO
//{$DEFINE USE_EXTENSIONS} // TODO //{$DEFINE USE_EXTENSIONS} // TODO
//{$DEFINE USE_CODECOMPLETION} // TODO //{$DEFINE USE_CODECOMPLETION} // TODO

View File

@ -5,7 +5,7 @@ object SimbaForm: TSimbaForm
Width = 660 Width = 660
AllowDropFiles = True AllowDropFiles = True
Caption = 'THA FUKING Simba' Caption = 'THA FUKING Simba'
ClientHeight = 598 ClientHeight = 603
ClientWidth = 660 ClientWidth = 660
KeyPreview = True KeyPreview = True
Menu = MainMenu Menu = MainMenu
@ -207,8 +207,8 @@ object SimbaForm: TSimbaForm
end end
object StatusBar: TStatusBar object StatusBar: TStatusBar
Left = 0 Left = 0
Height = 21 Height = 23
Top = 577 Top = 580
Width = 660 Width = 660
Panels = < Panels = <
item item
@ -230,7 +230,7 @@ object SimbaForm: TSimbaForm
object PanelMemo: TPanel object PanelMemo: TPanel
Left = 0 Left = 0
Height = 154 Height = 154
Top = 423 Top = 426
Width = 660 Width = 660
Align = alBottom Align = alBottom
ClientHeight = 154 ClientHeight = 154
@ -253,19 +253,19 @@ object SimbaForm: TSimbaForm
Cursor = crVSplit Cursor = crVSplit
Left = 0 Left = 0
Height = 5 Height = 5
Top = 418 Top = 421
Width = 660 Width = 660
Align = alBottom Align = alBottom
ResizeAnchor = akBottom ResizeAnchor = akBottom
end end
object ScriptPanel: TPanel object ScriptPanel: TPanel
Left = 0 Left = 0
Height = 394 Height = 397
Top = 24 Top = 24
Width = 660 Width = 660
Align = alClient Align = alClient
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 394 ClientHeight = 397
ClientWidth = 660 ClientWidth = 660
DockSite = True DockSite = True
TabOrder = 4 TabOrder = 4
@ -273,7 +273,7 @@ object SimbaForm: TSimbaForm
OnDockOver = ScriptPanelDockOver OnDockOver = ScriptPanelDockOver
object PageControl1: TPageControl object PageControl1: TPageControl
Left = 155 Left = 155
Height = 359 Height = 362
Top = 0 Top = 0
Width = 505 Width = 505
Align = alClient Align = alClient
@ -292,7 +292,7 @@ object SimbaForm: TSimbaForm
object SearchPanel: TPanel object SearchPanel: TPanel
Left = 0 Left = 0
Height = 35 Height = 35
Top = 359 Top = 362
Width = 660 Width = 660
Align = alBottom Align = alBottom
BevelOuter = bvSpace BevelOuter = bvSpace
@ -387,7 +387,7 @@ object SimbaForm: TSimbaForm
end end
object LabeledEditSearch: TLabeledEdit object LabeledEditSearch: TLabeledEdit
Left = 104 Left = 104
Height = 27 Height = 23
Top = 6 Top = 6
Width = 80 Width = 80
EditLabel.AnchorSideLeft.Control = LabeledEditSearch EditLabel.AnchorSideLeft.Control = LabeledEditSearch
@ -395,10 +395,10 @@ object SimbaForm: TSimbaForm
EditLabel.AnchorSideTop.Side = asrCenter EditLabel.AnchorSideTop.Side = asrCenter
EditLabel.AnchorSideRight.Control = LabeledEditSearch EditLabel.AnchorSideRight.Control = LabeledEditSearch
EditLabel.AnchorSideBottom.Control = LabeledEditSearch EditLabel.AnchorSideBottom.Control = LabeledEditSearch
EditLabel.Left = 66 EditLabel.Left = 71
EditLabel.Height = 18 EditLabel.Height = 16
EditLabel.Top = 10 EditLabel.Top = 9
EditLabel.Width = 35 EditLabel.Width = 30
EditLabel.Caption = 'Find: ' EditLabel.Caption = 'Find: '
EditLabel.ParentColor = False EditLabel.ParentColor = False
LabelPosition = lpLeft LabelPosition = lpLeft
@ -413,7 +413,7 @@ object SimbaForm: TSimbaForm
Left = 320 Left = 320
Height = 19 Height = 19
Top = 7 Top = 7
Width = 93 Width = 80
Caption = 'Match case' Caption = 'Match case'
OnClick = CheckBoxMatchCaseClick OnClick = CheckBoxMatchCaseClick
TabOrder = 1 TabOrder = 1
@ -421,38 +421,38 @@ object SimbaForm: TSimbaForm
end end
object SplitterFunctionList: TSplitter object SplitterFunctionList: TSplitter
Left = 150 Left = 150
Height = 359 Height = 362
Top = 0 Top = 0
Width = 5 Width = 5
OnCanResize = SplitterFunctionListCanResize OnCanResize = SplitterFunctionListCanResize
Visible = False Visible = False
end end
inline frmFunctionList: TFunctionListFrame inline frmFunctionList: TFunctionListFrame
Height = 359 Height = 362
Width = 150 Width = 150
ClientHeight = 359 ClientHeight = 362
ClientWidth = 150 ClientWidth = 150
OnEndDock = nil OnEndDock = nil
TabOrder = 3 TabOrder = 3
inherited FunctionList: TTreeView inherited FunctionList: TTreeView
Height = 310 Height = 319
Top = 22 Top = 20
Width = 150 Width = 150
DefaultItemHeight = 19 DefaultItemHeight = 17
OnChange = FunctionListChange OnChange = FunctionListChange
OnEnter = FunctionListEnter OnEnter = FunctionListEnter
OnExit = FunctionListExit OnExit = FunctionListExit
end end
inherited editSearchList: TEdit inherited editSearchList: TEdit
Height = 27 Height = 23
Top = 332 Top = 339
Width = 150 Width = 150
OnExit = editSearchListExit OnExit = editSearchListExit
OnKeyDown = editSearchListKeyDown OnKeyDown = editSearchListKeyDown
OnKeyPress = editSearchListKeyPress OnKeyPress = editSearchListKeyPress
end end
inherited FunctionListLabel: TLabel inherited FunctionListLabel: TLabel
Height = 18 Height = 16
Width = 146 Width = 146
end end
end end
@ -1263,12 +1263,18 @@ object SimbaForm: TSimbaForm
end end
object MenuItemRUTIS: TMenuItem object MenuItemRUTIS: TMenuItem
Action = ActionRUTIS Action = ActionRUTIS
Enabled = False
RadioItem = True RadioItem = True
end end
object MenuItemCPascal: TMenuItem object MenuItemCPascal: TMenuItem
Action = ActionCPascal Action = ActionCPascal
RadioItem = True RadioItem = True
end end
object MenuItemLape: TMenuItem
Action = ActionLape
Enabled = False
RadioItem = True
end
end end
end end
object MenuView: TMenuItem object MenuView: TMenuItem
@ -3025,6 +3031,10 @@ object SimbaForm: TSimbaForm
OnExecute = ActionGotoExecute OnExecute = ActionGotoExecute
ShortCut = 16455 ShortCut = 16455
end end
object ActionLape: TAction
Caption = 'Lape'
OnExecute = ActionLapeExecute
end
end end
object DebugTimer: TTimer object DebugTimer: TTimer
OnTimer = ProcessDebugStream OnTimer = ProcessDebugStream

View File

@ -66,6 +66,7 @@ const
interp_PS = 0; //PascalScript interp_PS = 0; //PascalScript
interp_RT = 1; //RUTIS interp_RT = 1; //RUTIS
interp_CP = 2; //CPascal interp_CP = 2; //CPascal
interp_LP = 3; //Lape
{ Place the shortcuts here } { Place the shortcuts here }
{$IFDEF LINUX} {$IFDEF LINUX}
@ -100,6 +101,7 @@ type
{ TSimbaForm } { TSimbaForm }
TSimbaForm = class(TForm) TSimbaForm = class(TForm)
ActionLape: TAction;
ActionGoto: TAction; ActionGoto: TAction;
ActionCPascal: TAction; ActionCPascal: TAction;
ActionRUTIS: TAction; ActionRUTIS: TAction;
@ -145,6 +147,7 @@ type
MenuHelp: TMenuItem; MenuHelp: TMenuItem;
MenuDivider7: TMenuItem; MenuDivider7: TMenuItem;
MenuInterpreters: TMenuItem; MenuInterpreters: TMenuItem;
MenuItemLape: TMenuItem;
MenuItemReadOnlyTab: TMenuItem; MenuItemReadOnlyTab: TMenuItem;
MenuItemGoto: TMenuItem; MenuItemGoto: TMenuItem;
MenuItemDivider50: TMenuItem; MenuItemDivider50: TMenuItem;
@ -285,6 +288,7 @@ type
procedure ActionFindNextExecute(Sender: TObject); procedure ActionFindNextExecute(Sender: TObject);
procedure ActionFindstartExecute(Sender: TObject); procedure ActionFindstartExecute(Sender: TObject);
procedure ActionGotoExecute(Sender: TObject); procedure ActionGotoExecute(Sender: TObject);
procedure ActionLapeExecute(Sender: TObject);
procedure ActionNewExecute(Sender: TObject); procedure ActionNewExecute(Sender: TObject);
procedure ActionNewTabExecute(Sender: TObject); procedure ActionNewTabExecute(Sender: TObject);
procedure ActionNormalSizeExecute(Sender: TObject); procedure ActionNormalSizeExecute(Sender: TObject);
@ -733,13 +737,15 @@ end;
procedure TSimbaForm.UpdateInterpreter; procedure TSimbaForm.UpdateInterpreter;
begin begin
ActionPascalScript.Checked:= false; ActionPascalScript.Checked := False;
ActionRUTIS.Checked:= false; ActionRUTIS.Checked := False;
ActionCPascal.Checked:= false; ActionCPascal.Checked := False;
ActionLape.Checked := False;
case Interpreter of case Interpreter of
interp_PS: ActionPascalScript.Checked:= True; interp_PS: ActionPascalScript.Checked:= True;
interp_CP: ActionCPascal.Checked:= True; interp_CP: ActionCPascal.Checked:= True;
interp_RT: ActionRUTIS.Checked:= true; interp_RT: ActionRUTIS.Checked := True;
interp_LP: ActionLape.Checked := True;
end; end;
end; end;
@ -762,11 +768,11 @@ end;
function TSimbaForm.GetInterpreter: Integer; function TSimbaForm.GetInterpreter: Integer;
begin begin
result := StrToIntDef(LoadSettingDef('Settings/Interpreter/Type','0'),0); Result := StrToIntDef(LoadSettingDef('Settings/Interpreter/Type', '0'), 0);
if (result < 0) or (result > 2) then if ((Result < 0) or (Result > 3)) then
begin begin
SetInterpreter(0); SetInterpreter(0);
result := 0; Result := 0;
end; end;
end; end;
@ -972,7 +978,7 @@ var
time:integer; time:integer;
LatestVersion : integer; LatestVersion : integer;
begin begin
UpdateTimer.Interval:= MaxInt; UpdateTimer.Interval := MaxInt;
FontUpdate; FontUpdate;
chk := LowerCase(LoadSettingDef('Settings/Updater/CheckForUpdates','True')); chk := LowerCase(LoadSettingDef('Settings/Updater/CheckForUpdates','True'));
@ -991,7 +997,7 @@ begin
mDebugLn('Latest Simba Version: ' + IntToStr(LatestVersion)); mDebugLn('Latest Simba Version: ' + IntToStr(LatestVersion));
end; end;
time := StrToIntDef(LoadSettingDef('Settings/Updater/CheckEveryXMinutes','30'),30); time := StrToIntDef(LoadSettingDef('Settings/Updater/CheckEveryXMinutes','30'),30);
UpdateTimer.Interval:= time {mins} * 60 {secs} * 1000 {ms};//Every half hour UpdateTimer.Interval := time {mins} * 60 {secs} * 1000 {ms};//Every half hour
end; end;
procedure TSimbaForm.UpdateMenuButtonClick(Sender: TObject); procedure TSimbaForm.UpdateMenuButtonClick(Sender: TObject);
@ -1396,7 +1402,7 @@ begin
SettingsForm.SettingsTreeView.Items.GetFirstNode.Expand(false); SettingsForm.SettingsTreeView.Items.GetFirstNode.Expand(false);
SettingsForm.SaveCurrent; SettingsForm.SaveCurrent;
LoadFormSettings; LoadFormSettings;
UpdateTimer.Interval:=25; UpdateTimer.Interval :=25;
end; end;
{ Load settings } { Load settings }
@ -1608,19 +1614,21 @@ begin
AppPath:= MainDir + DS; AppPath:= MainDir + DS;
CurrScript.ScriptErrorLine:= -1; CurrScript.ScriptErrorLine:= -1;
CurrentSyncInfo.SyncMethod:= @Self.SafeCallThread; CurrentSyncInfo.SyncMethod:= @Self.SafeCallThread;
try try
case Interpreter of case Interpreter of
interp_PS : Thread := TPSThread.Create(true,@CurrentSyncInfo,PluginPath); interp_PS: Thread := TPSThread.Create(True, @CurrentSyncInfo, PluginPath);
{$IFDEF USE_RUTIS}interp_RT: Thread := TRTThread.Create(True, @CurrentSyncInfo, PluginPath);{$ENDIF}
// XXX: Rutis needs to be completely removed from Simba if it's not defined. interp_CP: Thread := TCPThread.Create(True,@CurrentSyncInfo,PluginPath);
// XXX: Not just print a message that it's not supported now. {$IFDEF USE_LAPE}interp_LP: Thread := TLPThread.Create(True, @CurrentSyncInfo, PluginPath);{$ENDIF}
interp_RT : {$IFDEF USE_RUTIS}Thread := TRTThread.Create(true,@CurrentSyncInfo,PluginPath){$ELSE}formWriteln('RUTIS NOT SUPPORTED') {$ENDIF}; else
interp_CP : Thread := TCPThread.Create(true,@CurrentSyncInfo,PluginPath); raise Exception.CreateFmt('Unknown Interpreter %d!', [Interpreter]);
end; end;
except except
mDebugLn('Failed to initialise the interpreter'); mDebugLn('Failed to initialise the interpreter');
Exit; Exit;
end; end;
{$IFNDEF TERMINALWRITELN} {$IFNDEF TERMINALWRITELN}
Thread.SetDebug(@formWriteln); Thread.SetDebug(@formWriteln);
{$ENDIF} {$ENDIF}
@ -1729,26 +1737,29 @@ begin
end; end;
function TSimbaForm.DefaultScript: string; function TSimbaForm.DefaultScript: string;
var
x : TStringList;
begin begin
result := ''; Result := '';
case Interpreter of case Interpreter of
interp_PS : begin interp_PS, interp_LP: begin
Result := 'program new;' + LineEnding + 'begin' + LineEnding + 'end.' + LineEnding;
if FileExistsUTF8(SimbaForm.DefScriptPath) then if FileExistsUTF8(SimbaForm.DefScriptPath) then
begin begin
x := TStringList.Create;
try try
x.LoadFromFile(SimbaForm.DefScriptPath); with TStringList.Create do
try
LoadFromFile(SimbaForm.DefScriptPath);
Result := Text;
finally
Free;
end;
except except
mDebugLn('Couldn''t load default script file.'); mDebugLn('Couldn''t load default script file.');
end; end;
Result := x.Text; end;
end else
result := 'program new;'+LineEnding + 'begin'+LineEnding+'end.' + LineEnding;
end; end;
interp_RT : result := 'program untitled;' + LineEnding + lineEnding + 'interface' + LineEnding + LineEnding + interp_RT: Result := 'program untitled;' + LineEnding + lineEnding + 'interface' + LineEnding + LineEnding +
'implementation' + LineEnding + LineEnding + 'begin' + LineEnding + 'end.' + LineEnding; 'implementation' + LineEnding + LineEnding + 'begin' + LineEnding + 'end.' + LineEnding;
end; end;
end; end;
@ -1804,7 +1815,7 @@ end;
procedure TSimbaForm.ActionCPascalExecute(Sender: TObject); procedure TSimbaForm.ActionCPascalExecute(Sender: TObject);
begin begin
Interpreter:= interp_CP; Interpreter := interp_CP;
end; end;
procedure TSimbaForm.ActionCutExecute(Sender: TObject); procedure TSimbaForm.ActionCutExecute(Sender: TObject);
@ -1876,6 +1887,11 @@ begin
end; end;
end; end;
procedure TSimbaForm.ActionLapeExecute(Sender: TObject);
begin
{$IFDEF USE_LAPE}Interpreter := interp_LP;{$ENDIF}
end;
procedure TSimbaForm.ActionClearDebugExecute(Sender: TObject); procedure TSimbaForm.ActionClearDebugExecute(Sender: TObject);
begin begin
Memo1.Clear; Memo1.Clear;
@ -1917,7 +1933,7 @@ end;
procedure TSimbaForm.ActionPascalScriptExecute(Sender: TObject); procedure TSimbaForm.ActionPascalScriptExecute(Sender: TObject);
begin begin
Interpreter:= interp_PS; Interpreter := interp_PS;
end; end;
procedure TSimbaForm.ActionPasteExecute(Sender: TObject); procedure TSimbaForm.ActionPasteExecute(Sender: TObject);
@ -2468,9 +2484,8 @@ begin
UpdateTitle; UpdateTitle;
{$IFNDEF USE_RUTIS} {$IFDEF USE_RUTIS}MenuItemRUTIS.Enabled := True;{$ENDIF}
MenuItemRUTIS.Enabled:=False; {$IFDEF USE_LAPE}MenuItemLape.Enabled := True;{$ENDIF}
{$ENDIF}
self.EndFormUpdate; self.EndFormUpdate;
if SettingsForm.Oops then if SettingsForm.Oops then
@ -3005,9 +3020,11 @@ begin
if (CurrScript <> nil) then if (CurrScript <> nil) then
with CurrScript.Synedit do with CurrScript.Synedit do
if (Lines.text = DefaultScript) and not(CanUndo or CanRedo) then if (Lines.text = DefaultScript) and not(CanUndo or CanRedo) then
UpdateCurrScript := true; UpdateCurrScript := True;
SetSetting('Settings/Interpreter/Type',Inttostr(AValue),true);
SetSetting('Settings/Interpreter/Type', IntToStr(AValue), True);
UpdateInterpreter; UpdateInterpreter;
if UpdateCurrScript then if UpdateCurrScript then
CurrScript.SynEdit.Lines.text := DefaultScript; CurrScript.SynEdit.Lines.text := DefaultScript;
end; end;

View File

@ -0,0 +1,89 @@
{
This file is part of the Mufasa Macro Library (MML)
Copyright (c) 2009 by Raymond van Venetië and Merlijn Wajer
MML is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MML is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MML. If not, see <http://www.gnu.org/licenses/>.
See the file COPYING, included in this distribution,
for details about the copyright.
lpcompile.inc for the Mufasa Macro Library
}
addGlobalVar(AppPath, 'AppPath');
addGlobalVar(ScriptPath, 'ScriptPath');
addGlobalVar(IncludePath, 'IncludePath');
addGlobalVar(PluginPath, 'PluginPath');
addGlobalVar(FontPath, 'FontPath');
addGlobalVar(maxLongint, 'MaxLongInt');
addGlobalVar(maxLongint, 'MaxInt');
addGlobalVar(ps_mouse_right, 'mouse_Right');//0
addGlobalVar(ps_mouse_left, 'mouse_Left');//1
addGlobalVar(ps_mouse_middle, 'mouse_Middle');//2
addGlobalType('UInt8', 'Byte');
addGlobalType('Int8', 'ShortInt');
addGlobalType('UInt16', 'Word');
addGlobalType('Int16', 'SmallInt');
addGlobalType('UInt32', 'LongWord');
addGlobalType('Int32', 'LongInt');
addGlobalType('UInt64', 'QWord');
addGlobalType('LongInt', 'Integer');
addGlobalType('Integer', 'TColor');
addGlobalType('Double', 'TDateTime');
addGlobalType('(rfReplaceAll, rfIgnoreCase)', 'TReplaceFlag');
addGlobalType('set of TReplaceFlag', 'TReplaceFlags');
addGlobalType('(Numbers, Letters, Others)', 'StrExtr');
addGlobalType('(MirrorWidth, MirrorHeight, MirrorLine)', 'TBmpMirrorStyle');
addGlobalType('(mouse_Down, mouse_Up)', 'TMousePress');
addGlobalType('(SP_WriteTimeStamp, SP_OnTerminate)', 'TSP_Property');
addGlobalType('array of string', 'TStringArray');
addGlobalType('array of Integer', 'TIntegerArray');
addGlobalType('array of TIntegerArray', 'T2DIntegerArray');
addGlobalType('array of T2DIntegerArray', 'T3DIntegerArray');
addGlobalType('array of byte', 'TByteArray');
addGlobalType('array of extended', 'TExtendedArray');
addGlobalType('array of TExtendedArray', 'T2DExtendedArray');
addGlobalType('array of T2DExtendedArray', 'T3DExtendedArray');
addGlobalType('array of boolean', 'TBoolArray');
addGlobalType('array of variant', 'TVariantArray');
addGlobalType('record X1, Y1, X2, Y2: integer; end', 'TBox');
addGlobalType('array of TBox', 'TBoxArray');
addGlobalType('record X, Y: integer; end', 'TPoint');
addGlobalType('array of TPoint', 'TPointArray');
addGlobalType('array of TPointArray', 'T2DPointArray');
addGlobalType('T2DPointArray', 'TPointArrayArray');
addGlobalType('record White, Black: TPointarray; WhiteHi, BlackHi: integer; W, H: integer; end', 'TMask');
addGlobalType('record R, T: extended; end', 'PPoint');
addGlobalType('record int1,int2,int3,int4,int5,int6,int7,int8,int9,int10,int11,int12,int13,int14,int15,int16: integer; end', 'TTarget_Exported');
addGlobalType('record x, y, Color, Tolerance, AreaSize, AreaShape: integer; end', 'TSDTMPointDef');
addGlobalType('array of TSDTMPointDef', 'TSDTMPointDefArray');
addGlobalType('record MainPoint: TSDTMPointDef; SubPoints: TSDTMPointDefarray; end', 'TSDTM');
addGlobalType('record x, y, c, t, asz: integer; bp: boolean; end', 'TMDTMPoint');
addGlobalType('array of TMDTMPoint', 'TMDTMPointArray');
addGlobalType('record Title: string; Handle: integer; Pid: integer; Width, Height: integer; end', 'TSysProc');
addGlobalType('array of TSysProc', 'TSysProcArr');

View File

@ -0,0 +1,39 @@
{
This file is part of the Mufasa Macro Library (MML)
Copyright (c) 2009 by Raymond van Venetië and Merlijn Wajer
MML is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MML is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MML. If not, see <http://www.gnu.org/licenses/>.
See the file COPYING, included in this distribution,
for details about the copyright.
lpdefines.inc for the Mufasa Macro Library
}
BaseDefines.Add('LAPE');
{$IFDEF CPU386 }
BaseDefines.Add('CPU386');
{$ENDIF }
BaseDefines.Add('MUFASA');
BaseDefines.Add('COGAT');
BaseDefines.Add('SIMBA');
BaseDefines.Add('DGROCKS');
{$IFDEF MSWINDOWS }
BaseDefines.Add('MSWINDOWS');
BaseDefines.Add('WIN32');
BaseDefines.Add('WINDOWS');
{$ENDIF }
{$IFDEF LINUX }
BaseDefines.Add('LINUX');
{$ENDIF }

View File

@ -0,0 +1,24 @@
{
This file is part of the Mufasa Macro Library (MML)
Copyright (c) 2009 by Raymond van Venetië and Merlijn Wajer
MML is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MML is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MML. If not, see <http://www.gnu.org/licenses/>.
See the file COPYING, included in this distribution,
for details about the copyright.
lpexportedmethods.inc for the Mufasa Macro Library
}
//These will be added from Generator...

View File

@ -23,8 +23,9 @@
unit mmlpsthread; unit mmlpsthread;
{$Define PS_USESSUPPORT} {$define PS_USESSUPPORT}
//{$define USE_RUTIS} //{$define USE_RUTIS}
//{$define USE_LAPE}
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
interface interface
@ -35,9 +36,12 @@ uses
bitmaps, plugins, dynlibs,internets,scriptproperties, bitmaps, plugins, dynlibs,internets,scriptproperties,
settings,settingssandbox, lcltype, dialogs settings,settingssandbox, lcltype, dialogs
{$IFDEF USE_RUTIS} {$IFDEF USE_RUTIS}
,Rutis_Engine,Rutis_Defs , Rutis_Engine, Rutis_Defs
{$ENDIF} {$ENDIF}
; {$IFDEF USE_LAPE}
, lpparser, lpcompiler, lptypes, lpvartypes,
lpeval, lpinterpreter, lpdisassembler
{$ENDIF};
const const
m_Status = 0; //Data = PChar to new status m_Status = 0; //Data = PChar to new status
@ -232,6 +236,24 @@ type
end; end;
{$ENDIF} {$ENDIF}
{$IFDEF USE_LAPE}
{ TLPThread }
TLPThread = class(TMThread)
protected
procedure LoadPlugin(plugidx: integer); override;
public
Parser: TLapeTokenizerString;
Compiler: TLapeCompiler;
constructor Create(CreateSuspended: Boolean; TheSyncInfo : PSyncInfo; plugin_dir: string);
destructor Destroy; override;
procedure SetScript(Script: string); override;
procedure Execute; override;
procedure Terminate; override;
function OnFindFile(Sender: TLapeCompiler; var FileName: lpString): TLapeTokenizerBase;
function OnHandleDirective(Sender: TLapeCompiler; Directive, Argument: lpString; InPeek: Boolean): Boolean;
end;
{$ENDIF}
threadvar threadvar
CurrThread : TMThread; CurrThread : TMThread;
@ -681,7 +703,6 @@ begin
end; end;
end; end;
procedure TPSThread.LoadPlugin(plugidx: integer); procedure TPSThread.LoadPlugin(plugidx: integer);
var var
i: integer; i: integer;
@ -1188,6 +1209,175 @@ begin
end; end;
{$ENDIF} {$ENDIF}
{$IFDEF USE_LAPE}
{ TLPThread }
type
PBoolean = ^Boolean;
PStringArray = ^TStringArray;
PBmpMirrorStyle = ^TBmpMirrorStyle;
PPointArray = ^TPointArray;
P2DIntArray = ^T2DIntArray;
PCanvas = ^TCanvas;
P2DPointArray = ^T2DPointArray;
PMask = ^TMask;
PBox = ^TBox;
PTarget_Exported = ^TTarget_Exported;
PIntegerArray = ^TIntegerArray;
PExtendedArray = ^TExtendedArray;
PFont = ^TFont;
// PStrExtr = ^TStrExtr;
PReplaceFlags = ^TReplaceFlags;
PClickType = ^TClickType;
P2DExtendedArray = ^T2DExtendedArray;
PMDTM = ^TMDTM;
PMDTMPoint = ^TMDTMPoint;
PSDTM = ^TSDTM;
//Generate these wrappers with a script -Dg
//{$I LPInc/Wrappers/other.inc}
//{$I LPInc/Wrappers/settings.inc}
//{$I LPInc/Wrappers/bitmap.inc}
//{$I LPInc/Wrappers/window.inc}
//{$I LPInc/Wrappers/tpa.inc}
//{$I LPInc/Wrappers/strings.inc}
//{$I LPInc/Wrappers/colour.inc}
//{$I LPInc/Wrappers/colourconv.inc}
//{$I LPInc/Wrappers/crypto.inc}
//{$I LPInc/Wrappers/math.inc}
//{$I LPInc/Wrappers/mouse.inc}
//{$I LPInc/Wrappers/file.inc}
//{$I LPInc/Wrappers/keyboard.inc}
//{$I LPInc/Wrappers/dtm.inc}
//{$I LPInc/Wrappers/ocr.inc}
//{$I LPInc/Wrappers/internets.inc}
constructor TLPThread.Create(CreateSuspended: Boolean; TheSyncInfo: PSyncInfo; plugin_dir: string);
var
I: integer;
Fonts: TMFonts;
begin
inherited Create(CreateSuspended, TheSyncInfo, plugin_dir);
Parser := TLapeTokenizerString.Create('');
Compiler := TLapeCompiler.Create(Parser);
Compiler.OnFindFile := @OnFindFile;
Compiler.OnHandleDirective := @OnHandleDirective;
Fonts := Client.MOCR.Fonts;
with Compiler do
begin
for I := Fonts.Count - 1 downto 0 do
addGlobalVar(Fonts[I].Name, Fonts[I].Name);
for I := 0 to High(VirtualKeys) do
addGlobalVar(VirtualKeys[I].Key, Format('VK_%S', [VirtualKeys[i].Str]));
{$I LPInc/lpdefines.inc}
{$I LPInc/lpcompile.inc}
{$I LPInc/lpexportedmethods.inc}
end;
end;
destructor TLPThread.Destroy;
begin
try
{if (Compiler <> nil) then
Compiler.Free;}
if (Parser <> nil) then
Parser.Free;
except
on E: Exception do
psWriteln('Exception TLPThread.Destroy: ' + e.message);
end;
inherited Destroy;
end;
procedure TLPThread.SetScript(Script: string);
begin
Parser.Doc := Script;
end;
function TLPThread.OnFindFile(Sender: TLapeCompiler; var FileName: lpString): TLapeTokenizerBase;
begin
Result := nil;
FileName := IncludePath + FileName;
end;
function TLPThread.OnHandleDirective(Sender: TLapeCompiler; Directive, Argument: lpString; InPeek: Boolean): Boolean;
var
plugin_idx: integer;
begin
if (Directive = 'loadlib') then
begin
if (Argument <> '') then
begin
plugin_idx := PluginsGlob.LoadPlugin(Argument);
if (plugin_idx >= 0) then
begin
LoadPlugin(plugin_idx);
Result := True;
end else
psWriteln(Format('Your DLL %s has not been found', [Argument]))
end else
psWriteln('Your LoadLib directive has no params, thus cannot find the plugin');
end;
end;
procedure TLPThread.LoadPlugin(plugidx: integer);
var
I: integer;
begin
with PluginsGlob.MPlugins[plugidx] do
begin
for i := 0 to TypesLen -1 do
with Types[I] do
Compiler.addGlobalType(TypeDef, TypeName);
for i := 0 to MethodLen - 1 do
with Methods[i] do
Compiler.addGlobalFunc(FuncStr, FuncPtr);
end;
end;
procedure TLPThread.Execute;
function CombineDeclArray(a, b: TLapeDeclArray): TLapeDeclArray;
var
i, l: Integer;
begin
Result := a;
l := Length(a);
SetLength(Result, l + Length(b));
for i := High(b) downto 0 do
Result[l + i] := b[i];
end;
begin
CurrThread := self;
try
Starttime := lclintf.GetTickCount;
if Compiler.Compile() then
begin
DisassembleCode(Compiler.Emitter.Code, CombineDeclArray(Compiler.ManagedDeclarations.getByClass(TLapeGlobalVar), Compiler.GlobalDeclarations.getByClass(TLapeGlobalVar)));
psWriteln('Compiled succesfully in ' + IntToStr(GetTickCount - Starttime) + ' ms.');
if CompileOnly then
Exit;
RunCode(Compiler.Emitter.Code);
psWriteln('Successfully executed.');
end else
psWriteln('Compiling failed.');
except
on E : Exception do
psWriteln('Exception in Script: ' + e.message);
end;
end;
procedure TLPThread.Terminate;
begin
end;
{$ENDIF}
initialization initialization
PluginsGlob := TMPlugins.Create; PluginsGlob := TMPlugins.Create;
libcpascal:= 0; libcpascal:= 0;