EditorMacroSript: Fix compilation with different defines, reduce compiler warnings.

git-svn-id: trunk@51064 -
This commit is contained in:
juha 2015-12-28 13:32:21 +00:00
parent 060d956ee0
commit c2f0586120
6 changed files with 44 additions and 46 deletions

View File

@ -3,6 +3,7 @@
<Package Version="4"> <Package Version="4">
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Name Value="EditorMacroScript"/> <Name Value="EditorMacroScript"/>
<Type Value="RunAndDesignTime"/>
<Author Value="M Friebe"/> <Author Value="M Friebe"/>
<CompilerOptions> <CompilerOptions>
<Version Value="11"/> <Version Value="11"/>
@ -12,7 +13,6 @@
</SearchPaths> </SearchPaths>
<Other> <Other>
<CustomOptions Value="$(IDEBuildOptions)"/> <CustomOptions Value="$(IDEBuildOptions)"/>
<CompilerPath Value="$(CompPath)"/>
</Other> </Other>
</CompilerOptions> </CompilerOptions>
<Description Value="IDE-Extension: Adds PascalScript to editor-macros. <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> </Item3>
<Item4> <Item4>
<Filename Value="emsselftest.pas"/> <Filename Value="emsselftest.pas"/>
<UnitName Value="emsselftest"/> <UnitName Value="EMSSelfTest"/>
</Item4> </Item4>
<Item5> <Item5>
<Filename Value="emsideoptions.pas"/> <Filename Value="emsideoptions.pas"/>
<UnitName Value="emsideoptions"/> <UnitName Value="EMSIdeOptions"/>
</Item5> </Item5>
<Item6> <Item6>
<Filename Value="emsstrings.pas"/> <Filename Value="emsstrings.pas"/>
<UnitName Value="emsstrings"/> <UnitName Value="EMSStrings"/>
</Item6> </Item6>
</Files> </Files>
<i18n> <i18n>
<EnableI18N Value="True"/> <EnableI18N Value="True"/>
<OutDir Value="languages"/> <OutDir Value="languages"/>
</i18n> </i18n>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="4"> <RequiredPkgs Count="4">
<Item1> <Item1>
<PackageName Value="synedit"/> <PackageName Value="synedit"/>

View File

@ -130,7 +130,7 @@ end;
function HandleEcCommandFoo({%H-}Caller: TPSExec; p: TPSExternalProcRec; {%H-}Global, Stack: TPSStack): Boolean; function HandleEcCommandFoo({%H-}Caller: TPSExec; p: TPSExternalProcRec; {%H-}Global, Stack: TPSStack): Boolean;
var var
i: integer; i: PtrUInt;
pt: TPoint; pt: TPoint;
e: TEMSTPSExec; e: TEMSTPSExec;
begin begin
@ -173,7 +173,7 @@ var
begin begin
i := 0; i := 0;
if not IdentToEditorCommand(s, i) then exit; if not IdentToEditorCommand(s, i) then exit;
RegisterFunctionName(UpperCase(s), @HandleEcCommandFoo, self, Pointer(PtrUInt(i))); RegisterFunctionName(UpperCase(s), @HandleEcCommandFoo, self, Pointer(PtrInt(i)));
end; end;
procedure TEMSTPSExec.AddFuncToExec; procedure TEMSTPSExec.AddFuncToExec;
@ -232,6 +232,7 @@ const
DeclInputBox = 'Function InputBox(ACaption, APrompt, ADefault: string): string'; DeclInputBox = 'Function InputBox(ACaption, APrompt, ADefault: string): string';
DeclInputQuery = 'Function InputQuery(ACaption, APrompt: string; var Value: string): Boolean'; 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; 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; 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; 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; FuncShowMessagePos: procedure(Msg: string; X, Y: Integer) = @EMS_ShowMessagePos;
FuncInputBox: function(ACaption, APrompt, ADefault: string): string = @EMS_InputBox; FuncInputBox: function(ACaption, APrompt, ADefault: string): string = @EMS_InputBox;
FuncInputQuery: function(ACaption, APrompt: string; var Value : string): Boolean = @EMS_InputQuery; 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; 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 CompRegisterBasics(AComp: TPSPascalCompiler);
procedure AddConst(const Name, FType: TbtString; I: Integer); procedure AddConst(const Name, FType: TbtString; I: Integer);
@ -305,7 +306,6 @@ end;
function GetVarPointFromStack(Stack: TPSStack; Idx: Integer): PPoint; function GetVarPointFromStack(Stack: TPSStack; Idx: Integer): PPoint;
var var
res: PPSVariant; res: PPSVariant;
data: Pointer;
typerec: TPSTypeRec; typerec: TPSTypeRec;
begin begin
if Idx < 0 then Idx := Idx + Stack.Count; if Idx < 0 then Idx := Idx + Stack.Count;
@ -347,14 +347,12 @@ end;
function ExecBasicHandler({%H-}Caller: TPSExec; p: TPSExternalProcRec; function ExecBasicHandler({%H-}Caller: TPSExec; p: TPSExternalProcRec;
{%H-}Global, Stack: TPSStack): Boolean; {%H-}Global, Stack: TPSStack): Boolean;
var var
res: PPSVariant;
data: Pointer; data: Pointer;
temp: TPSVariantIFC; temp: TPSVariantIFC;
s: String; s: String;
typerec: TPSTypeRec;
begin begin
Result := True; Result := True;
case Longint(p.Ext1) of case PtrUInt(p.Ext1) of
0: begin // POINT() 0: begin // POINT()
if Stack.Count < 3 then raise TEMScriptBadParamException.Create('Invalid param count for "Point"');; if Stack.Count < 3 then raise TEMScriptBadParamException.Create('Invalid param count for "Point"');;
data := GetVarPointFromStack(Stack, -1); data := GetVarPointFromStack(Stack, -1);

View File

@ -16,9 +16,6 @@ uses
{$ifend} {$ifend}
{$if defined(cpusparc) } {$DEFINE PasScriptNotAvail } {$ifend} {$if defined(cpusparc) } {$DEFINE PasScriptNotAvail } {$ifend}
const
EMSSupported = {$IFDEF PasScriptNotAvail} False {$ELSE} True {$ENDIF} ;
type type
{ TEMSEditorMacro } { TEMSEditorMacro }

View File

@ -6,7 +6,10 @@ interface
uses uses
Classes, SysUtils, FileUtil, Forms, Controls, StdCtrls, IDEOptionsIntf, Classes, SysUtils, FileUtil, Forms, Controls, StdCtrls, IDEOptionsIntf,
SrcEditorIntf, EMScriptMacro, EMSStrings; {$IFnDEF PasScriptNotAvail}
SrcEditorIntf,
{$ENDIF}
EMScriptMacro, EMSStrings;
type type
@ -17,13 +20,12 @@ type
lblStatus: TLabel; lblStatus: TLabel;
procedure btnActivateClick(Sender: TObject); procedure btnActivateClick(Sender: TObject);
private private
{ private declarations }
public public
{ public declarations }
function GetTitle: String; override; function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override; procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override; procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override; procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override; class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end; end;
@ -55,34 +57,31 @@ begin
end; end;
procedure TEMSIdeOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions); procedure TEMSIdeOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
{$IFnDEF PasScriptNotAvail}
var var
cfg: TEMSConfig; cfg: TEMSConfig;
{$ENDIF}
begin begin
if not EMSSupported then begin {$IFDEF PasScriptNotAvail}
lblStatus.Caption := EMSNotSupported; lblStatus.Caption := EMSNotSupported;
btnActivate.Enabled := True; btnActivate.Enabled := True;
exit; {$ELSE}
end;
cfg := GetEMSConf; cfg := GetEMSConf;
if cfg.SelfTestFailed >= EMSVersion then begin if cfg.SelfTestFailed >= EMSVersion then begin
lblStatus.Caption := EMSNotActive; lblStatus.Caption := EMSNotActive;
btnActivate.Enabled := True; btnActivate.Enabled := True;
end end
else else
if EditorMacroPlayerClass = TEMSEditorMacro then begin if EditorMacroPlayerClass = TEMSEditorMacro then begin
lblStatus.Caption := EMSActive; lblStatus.Caption := EMSActive;
btnActivate.Enabled := False; btnActivate.Enabled := False;
end end
else else
begin begin
lblStatus.Caption := EMSPending; lblStatus.Caption := EMSPending;
btnActivate.Enabled := False; btnActivate.Enabled := False;
end; end;
{$ENDIF}
end; end;
procedure TEMSIdeOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions); procedure TEMSIdeOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);

View File

@ -9,9 +9,9 @@ interface
{$ENDIF} {$ENDIF}
uses uses
Classes, SysUtils, SynEdit, SynEditTypes, SynEditKeyCmds, LazLoggerBase, Classes, SysUtils, SynEdit, SynEditKeyCmds, LazLoggerBase,
IDECommands, EMScriptClasses, EMScriptMacro, Clipbrd, Dialogs, Controls, IDECommands, EMScriptClasses, EMScriptMacro, Clipbrd, Dialogs, Controls,
uPSCompiler, uPSRuntime, uPSUtils, uPSDebugger, uPSR_std, uPSC_std; uPSCompiler, uPSRuntime, uPSUtils;
type type
@ -56,7 +56,7 @@ type TPoint2 = record x,y,a,b,c: Longint; end;
{%region RegisterSelfTests} {%region RegisterSelfTests}
var var
TestResultA: integer; //TestResultA: integer;
TestResultInt1, TestResultInt2: integer; TestResultInt1, TestResultInt2: integer;
TestInputInt1, TestInputInt2: integer; TestInputInt1, TestInputInt2: integer;
TestResultBool1, TestResultBool2: boolean; TestResultBool1, TestResultBool2: boolean;
@ -67,13 +67,13 @@ var
function test_ord_mt(AType: TMsgDlgType): Integer; function test_ord_mt(AType: TMsgDlgType): Integer;
begin begin
Result := ord(AType); Result := ord(AType);
TestResultA := Result; //TestResultA := Result;
end; end;
function test_ord_mb(ABtn: TMsgDlgBtn): Integer; function test_ord_mb(ABtn: TMsgDlgBtn): Integer;
begin begin
Result := ord(ABtn); Result := ord(ABtn);
TestResultA := Result; //TestResultA := Result;
end; end;
procedure test_int1(AValue: Integer); procedure test_int1(AValue: Integer);
@ -188,6 +188,8 @@ const
Decltest_getstr1 = 'function test_getstr1: String;'; Decltest_getstr1 = 'function test_getstr1: String;';
Decltest_getstr2 = 'function test_getstr2: String;'; Decltest_getstr2 = 'function test_getstr2: String;';
Decltest_varstr1 = 'procedure test_varstr1(var AValue: String);'; Decltest_varstr1 = 'procedure test_varstr1(var AValue: String);';
{$IFnDEF PasMacroNoNativeCalls}
Functest_ord_mt: function(AType: TMsgDlgType): Integer = @test_ord_mt; Functest_ord_mt: function(AType: TMsgDlgType): Integer = @test_ord_mt;
Functest_ord_mb: function(ABtn: TMsgDlgBtn): Integer = @test_ord_mb; Functest_ord_mb: function(ABtn: TMsgDlgBtn): Integer = @test_ord_mb;
Proctest_int1: procedure (AValue: Integer) = @test_int1; Proctest_int1: procedure (AValue: Integer) = @test_int1;
@ -207,9 +209,7 @@ const
Proctest_getstr1: function: String = @test_getstr1; Proctest_getstr1: function: String = @test_getstr1;
Proctest_getstr2: function: String = @test_getstr2; Proctest_getstr2: function: String = @test_getstr2;
Proctest_varstr1: procedure (var AValue: String) = @test_varstr1; Proctest_varstr1: procedure (var AValue: String) = @test_varstr1;
{$ELSE}
{$IFDEF PasMacroNoNativeCalls}
const
Id_test_ord_mb = 901; Id_test_ord_mb = 901;
Id_test_ord_mt = 902; Id_test_ord_mt = 902;
Id_test_int1 = 910; Id_test_int1 = 910;
@ -238,7 +238,7 @@ var
s: TbtString; s: TbtString;
begin begin
Result := True; Result := True;
case Longint(p.Ext1) of case PtrUInt(p.Ext1) of
Id_test_ord_mb: begin // test_ord_mb(ABtn: TMsgDlgBtn): Integer; 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"'); 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))) ); Stack.SetInt(-1, test_ord_mb(TMsgDlgBtn(Stack.GetUInt(-2))) );

View File

@ -5,8 +5,11 @@ unit RegisterEMS;
interface interface
uses uses
Classes, SysUtils, SrcEditorIntf, IDEOptionsIntf, EMScriptMacro, EMSSelfTest, Classes, SysUtils, Dialogs, IDEOptionsIntf,
EMSIdeOptions, EMSStrings, Dialogs; {$IFDEF PasScriptNotAvail}
SrcEditorIntf, EMSStrings,
{$ENDIF}
EMScriptMacro, EMSSelfTest, EMSIdeOptions;
procedure Register; procedure Register;
@ -14,16 +17,17 @@ implementation
procedure Register; procedure Register;
var var
OptionsGroup: Integer;
{$IFDEF PasScriptNotAvail}
conf: TEMSConfig; conf: TEMSConfig;
ok: Boolean; ok: Boolean;
OptionsGroup: Integer; {$ENDIF}
begin begin
OptionsGroup := GetFreeIDEOptionsGroupIndex(GroupEditor); OptionsGroup := GetFreeIDEOptionsGroupIndex(GroupEditor);
RegisterIDEOptionsGroup(OptionsGroup, TEMSConfig); RegisterIDEOptionsGroup(OptionsGroup, TEMSConfig);
RegisterIDEOptionsEditor(OptionsGroup, TEMSIdeOptionsFrame, 1); RegisterIDEOptionsEditor(OptionsGroup, TEMSIdeOptionsFrame, 1);
if not EMSSupported then exit; {$IFDEF PasScriptNotAvail}
conf := GetEMSConf; conf := GetEMSConf;
try try
conf.Load; conf.Load;
@ -79,6 +83,7 @@ begin
conf.Save; conf.Save;
EditorMacroPlayerClass := TEMSEditorMacro; EditorMacroPlayerClass := TEMSEditorMacro;
{$ENDIF}
end; end;
end. end.