mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 00:02:03 +02:00
EditorMacroSript: Fix compilation with different defines, reduce compiler warnings.
git-svn-id: trunk@51064 -
This commit is contained in:
parent
060d956ee0
commit
c2f0586120
@ -3,6 +3,7 @@
|
||||
<Package Version="4">
|
||||
<PathDelim Value="\"/>
|
||||
<Name Value="EditorMacroScript"/>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<Author Value="M Friebe"/>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
@ -12,7 +13,6 @@
|
||||
</SearchPaths>
|
||||
<Other>
|
||||
<CustomOptions Value="$(IDEBuildOptions)"/>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Description Value="IDE-Extension: Adds PascalScript to editor-macros.
|
||||
@ -37,22 +37,21 @@ Extends the Editors macro recorder and player. Macros can be written in pascal s
|
||||
</Item3>
|
||||
<Item4>
|
||||
<Filename Value="emsselftest.pas"/>
|
||||
<UnitName Value="emsselftest"/>
|
||||
<UnitName Value="EMSSelfTest"/>
|
||||
</Item4>
|
||||
<Item5>
|
||||
<Filename Value="emsideoptions.pas"/>
|
||||
<UnitName Value="emsideoptions"/>
|
||||
<UnitName Value="EMSIdeOptions"/>
|
||||
</Item5>
|
||||
<Item6>
|
||||
<Filename Value="emsstrings.pas"/>
|
||||
<UnitName Value="emsstrings"/>
|
||||
<UnitName Value="EMSStrings"/>
|
||||
</Item6>
|
||||
</Files>
|
||||
<i18n>
|
||||
<EnableI18N Value="True"/>
|
||||
<OutDir Value="languages"/>
|
||||
</i18n>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<RequiredPkgs Count="4">
|
||||
<Item1>
|
||||
<PackageName Value="synedit"/>
|
||||
|
@ -130,7 +130,7 @@ end;
|
||||
|
||||
function HandleEcCommandFoo({%H-}Caller: TPSExec; p: TPSExternalProcRec; {%H-}Global, Stack: TPSStack): Boolean;
|
||||
var
|
||||
i: integer;
|
||||
i: PtrUInt;
|
||||
pt: TPoint;
|
||||
e: TEMSTPSExec;
|
||||
begin
|
||||
@ -173,7 +173,7 @@ var
|
||||
begin
|
||||
i := 0;
|
||||
if not IdentToEditorCommand(s, i) then exit;
|
||||
RegisterFunctionName(UpperCase(s), @HandleEcCommandFoo, self, Pointer(PtrUInt(i)));
|
||||
RegisterFunctionName(UpperCase(s), @HandleEcCommandFoo, self, Pointer(PtrInt(i)));
|
||||
end;
|
||||
|
||||
procedure TEMSTPSExec.AddFuncToExec;
|
||||
@ -232,6 +232,7 @@ const
|
||||
DeclInputBox = 'Function InputBox(ACaption, APrompt, ADefault: string): string';
|
||||
DeclInputQuery = 'Function InputQuery(ACaption, APrompt: string; var Value: string): Boolean';
|
||||
|
||||
{$IFnDEF PasMacroNoNativeCalls}
|
||||
FuncMessageDlg: function(Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer = @EMS_MessageDlg;
|
||||
FuncMessageDlgPos: function(Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint; X, Y: Integer): Integer = @EMS_MessageDlgPos;
|
||||
FuncMessageDlgPosHelp: function(Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint; X, Y: Integer; HelpFileName: string): Integer = @EMS_MessageDlgPosHelp;
|
||||
@ -239,9 +240,9 @@ const
|
||||
FuncShowMessagePos: procedure(Msg: string; X, Y: Integer) = @EMS_ShowMessagePos;
|
||||
FuncInputBox: function(ACaption, APrompt, ADefault: string): string = @EMS_InputBox;
|
||||
FuncInputQuery: function(ACaption, APrompt: string; var Value : string): Boolean = @EMS_InputQuery;
|
||||
|
||||
DeclPoint = 'function Point(AX, AY: Integer): TPoint;';
|
||||
FuncPoint: function(AX, AY: Integer): {$IFDEF NeedTPointFix}TPoint2{$ELSE}TPoint{$ENDIF} = @EMS_Point; // @Classes.Point;
|
||||
{$ENDIF}
|
||||
DeclPoint = 'function Point(AX, AY: Integer): TPoint;';
|
||||
|
||||
procedure CompRegisterBasics(AComp: TPSPascalCompiler);
|
||||
procedure AddConst(const Name, FType: TbtString; I: Integer);
|
||||
@ -305,7 +306,6 @@ end;
|
||||
function GetVarPointFromStack(Stack: TPSStack; Idx: Integer): PPoint;
|
||||
var
|
||||
res: PPSVariant;
|
||||
data: Pointer;
|
||||
typerec: TPSTypeRec;
|
||||
begin
|
||||
if Idx < 0 then Idx := Idx + Stack.Count;
|
||||
@ -347,14 +347,12 @@ end;
|
||||
function ExecBasicHandler({%H-}Caller: TPSExec; p: TPSExternalProcRec;
|
||||
{%H-}Global, Stack: TPSStack): Boolean;
|
||||
var
|
||||
res: PPSVariant;
|
||||
data: Pointer;
|
||||
temp: TPSVariantIFC;
|
||||
s: String;
|
||||
typerec: TPSTypeRec;
|
||||
begin
|
||||
Result := True;
|
||||
case Longint(p.Ext1) of
|
||||
case PtrUInt(p.Ext1) of
|
||||
0: begin // POINT()
|
||||
if Stack.Count < 3 then raise TEMScriptBadParamException.Create('Invalid param count for "Point"');;
|
||||
data := GetVarPointFromStack(Stack, -1);
|
||||
|
@ -16,9 +16,6 @@ uses
|
||||
{$ifend}
|
||||
{$if defined(cpusparc) } {$DEFINE PasScriptNotAvail } {$ifend}
|
||||
|
||||
const
|
||||
EMSSupported = {$IFDEF PasScriptNotAvail} False {$ELSE} True {$ENDIF} ;
|
||||
|
||||
type
|
||||
|
||||
{ TEMSEditorMacro }
|
||||
|
@ -6,7 +6,10 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, StdCtrls, IDEOptionsIntf,
|
||||
SrcEditorIntf, EMScriptMacro, EMSStrings;
|
||||
{$IFnDEF PasScriptNotAvail}
|
||||
SrcEditorIntf,
|
||||
{$ENDIF}
|
||||
EMScriptMacro, EMSStrings;
|
||||
|
||||
type
|
||||
|
||||
@ -17,13 +20,12 @@ type
|
||||
lblStatus: TLabel;
|
||||
procedure btnActivateClick(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
|
||||
public
|
||||
{ public declarations }
|
||||
function GetTitle: String; override;
|
||||
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
|
||||
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
|
||||
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
|
||||
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
|
||||
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
|
||||
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
|
||||
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
|
||||
end;
|
||||
|
||||
@ -55,34 +57,31 @@ begin
|
||||
end;
|
||||
|
||||
procedure TEMSIdeOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
|
||||
{$IFnDEF PasScriptNotAvail}
|
||||
var
|
||||
cfg: TEMSConfig;
|
||||
{$ENDIF}
|
||||
begin
|
||||
if not EMSSupported then begin
|
||||
lblStatus.Caption := EMSNotSupported;
|
||||
btnActivate.Enabled := True;
|
||||
exit;
|
||||
end;
|
||||
|
||||
{$IFDEF PasScriptNotAvail}
|
||||
lblStatus.Caption := EMSNotSupported;
|
||||
btnActivate.Enabled := True;
|
||||
{$ELSE}
|
||||
cfg := GetEMSConf;
|
||||
|
||||
if cfg.SelfTestFailed >= EMSVersion then begin
|
||||
lblStatus.Caption := EMSNotActive;
|
||||
btnActivate.Enabled := True;
|
||||
end
|
||||
else
|
||||
|
||||
if EditorMacroPlayerClass = TEMSEditorMacro then begin
|
||||
lblStatus.Caption := EMSActive;
|
||||
btnActivate.Enabled := False;
|
||||
end
|
||||
|
||||
else
|
||||
begin
|
||||
lblStatus.Caption := EMSPending;
|
||||
btnActivate.Enabled := False;
|
||||
end;
|
||||
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TEMSIdeOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
|
||||
|
@ -9,9 +9,9 @@ interface
|
||||
{$ENDIF}
|
||||
|
||||
uses
|
||||
Classes, SysUtils, SynEdit, SynEditTypes, SynEditKeyCmds, LazLoggerBase,
|
||||
Classes, SysUtils, SynEdit, SynEditKeyCmds, LazLoggerBase,
|
||||
IDECommands, EMScriptClasses, EMScriptMacro, Clipbrd, Dialogs, Controls,
|
||||
uPSCompiler, uPSRuntime, uPSUtils, uPSDebugger, uPSR_std, uPSC_std;
|
||||
uPSCompiler, uPSRuntime, uPSUtils;
|
||||
|
||||
type
|
||||
|
||||
@ -56,7 +56,7 @@ type TPoint2 = record x,y,a,b,c: Longint; end;
|
||||
{%region RegisterSelfTests}
|
||||
|
||||
var
|
||||
TestResultA: integer;
|
||||
//TestResultA: integer;
|
||||
TestResultInt1, TestResultInt2: integer;
|
||||
TestInputInt1, TestInputInt2: integer;
|
||||
TestResultBool1, TestResultBool2: boolean;
|
||||
@ -67,13 +67,13 @@ var
|
||||
function test_ord_mt(AType: TMsgDlgType): Integer;
|
||||
begin
|
||||
Result := ord(AType);
|
||||
TestResultA := Result;
|
||||
//TestResultA := Result;
|
||||
end;
|
||||
|
||||
function test_ord_mb(ABtn: TMsgDlgBtn): Integer;
|
||||
begin
|
||||
Result := ord(ABtn);
|
||||
TestResultA := Result;
|
||||
//TestResultA := Result;
|
||||
end;
|
||||
|
||||
procedure test_int1(AValue: Integer);
|
||||
@ -188,6 +188,8 @@ const
|
||||
Decltest_getstr1 = 'function test_getstr1: String;';
|
||||
Decltest_getstr2 = 'function test_getstr2: String;';
|
||||
Decltest_varstr1 = 'procedure test_varstr1(var AValue: String);';
|
||||
|
||||
{$IFnDEF PasMacroNoNativeCalls}
|
||||
Functest_ord_mt: function(AType: TMsgDlgType): Integer = @test_ord_mt;
|
||||
Functest_ord_mb: function(ABtn: TMsgDlgBtn): Integer = @test_ord_mb;
|
||||
Proctest_int1: procedure (AValue: Integer) = @test_int1;
|
||||
@ -207,9 +209,7 @@ const
|
||||
Proctest_getstr1: function: String = @test_getstr1;
|
||||
Proctest_getstr2: function: String = @test_getstr2;
|
||||
Proctest_varstr1: procedure (var AValue: String) = @test_varstr1;
|
||||
|
||||
{$IFDEF PasMacroNoNativeCalls}
|
||||
const
|
||||
{$ELSE}
|
||||
Id_test_ord_mb = 901;
|
||||
Id_test_ord_mt = 902;
|
||||
Id_test_int1 = 910;
|
||||
@ -238,7 +238,7 @@ var
|
||||
s: TbtString;
|
||||
begin
|
||||
Result := True;
|
||||
case Longint(p.Ext1) of
|
||||
case PtrUInt(p.Ext1) of
|
||||
Id_test_ord_mb: begin // test_ord_mb(ABtn: TMsgDlgBtn): Integer;
|
||||
if Stack.Count < 2 then raise TEMScriptBadParamException.Create('Invalid param count for "test_ord_mb"');
|
||||
Stack.SetInt(-1, test_ord_mb(TMsgDlgBtn(Stack.GetUInt(-2))) );
|
||||
|
@ -5,8 +5,11 @@ unit RegisterEMS;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, SrcEditorIntf, IDEOptionsIntf, EMScriptMacro, EMSSelfTest,
|
||||
EMSIdeOptions, EMSStrings, Dialogs;
|
||||
Classes, SysUtils, Dialogs, IDEOptionsIntf,
|
||||
{$IFDEF PasScriptNotAvail}
|
||||
SrcEditorIntf, EMSStrings,
|
||||
{$ENDIF}
|
||||
EMScriptMacro, EMSSelfTest, EMSIdeOptions;
|
||||
|
||||
procedure Register;
|
||||
|
||||
@ -14,16 +17,17 @@ implementation
|
||||
|
||||
procedure Register;
|
||||
var
|
||||
OptionsGroup: Integer;
|
||||
{$IFDEF PasScriptNotAvail}
|
||||
conf: TEMSConfig;
|
||||
ok: Boolean;
|
||||
OptionsGroup: Integer;
|
||||
{$ENDIF}
|
||||
begin
|
||||
OptionsGroup := GetFreeIDEOptionsGroupIndex(GroupEditor);
|
||||
RegisterIDEOptionsGroup(OptionsGroup, TEMSConfig);
|
||||
RegisterIDEOptionsEditor(OptionsGroup, TEMSIdeOptionsFrame, 1);
|
||||
|
||||
if not EMSSupported then exit;
|
||||
|
||||
{$IFDEF PasScriptNotAvail}
|
||||
conf := GetEMSConf;
|
||||
try
|
||||
conf.Load;
|
||||
@ -79,6 +83,7 @@ begin
|
||||
conf.Save;
|
||||
|
||||
EditorMacroPlayerClass := TEMSEditorMacro;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user