From 467ee875c5cf9a7610c9eda808731f132eafe83d Mon Sep 17 00:00:00 2001 From: Olly Date: Fri, 15 Sep 2023 14:57:01 +0100 Subject: [PATCH] Fixes --- Source/codetools/simba.ide_codetools_parser.pas | 7 +++++-- Source/codetools/simba.ide_codetools_plugins.pas | 2 +- Source/editor/simba.editor_autocomplete.pas | 1 + Source/simba.ide_showdeclaration.pas | 4 +--- Source/simba.target.pas | 2 ++ Source/targets/simba.target_plugin.pas | 9 ++++++--- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Source/codetools/simba.ide_codetools_parser.pas b/Source/codetools/simba.ide_codetools_parser.pas index c2e3f5725..f6a3dbc70 100644 --- a/Source/codetools/simba.ide_codetools_parser.pas +++ b/Source/codetools/simba.ide_codetools_parser.pas @@ -111,6 +111,7 @@ TDeclaration = class({$IFDEF PARSER_LEAK_CHECKS}TLeakChecker{$ELSE}TObject{$EN function IsName(const Value: String): Boolean; inline; + property Parser: TCodeParser read FParser; property Lexer: TmwPasLex read FLexer; property Owner: TDeclaration read FOwner; @@ -335,8 +336,6 @@ TDeclaration_Parameter = class(TDeclaration_Var) TFindPluginEvent = function(Sender: TmwBasePasLex; var FileName: string): Boolean of object; TCodeParser = class(TmwSimplePasPar) - private - function GetFileName: String; protected FManagedItems: TDeclarationList; @@ -357,6 +356,8 @@ TCodeParser = class(TmwSimplePasPar) procedure FindLocals; procedure FindGlobals; + function GetFileName: String; + // Hashes lexers filenames, fileage and defines. function GetHash: String; virtual; @@ -461,6 +462,8 @@ TCodeParser = class(TmwSimplePasPar) constructor Create; override; destructor Destroy; override; end; + TPluginParser = class(TCodeParser); + TCodeParserArray = array of TCodeParser; TCodeParserList = specialize TSimbaObjectList; diff --git a/Source/codetools/simba.ide_codetools_plugins.pas b/Source/codetools/simba.ide_codetools_plugins.pas index fca742d2c..f8bd6b25f 100644 --- a/Source/codetools/simba.ide_codetools_plugins.pas +++ b/Source/codetools/simba.ide_codetools_plugins.pas @@ -42,7 +42,7 @@ implementation simba.ide_initialization, simba.ide_codetools_utils; type - TCachedPlugin = class(TCodeParser) + TCachedPlugin = class(TPluginParser) public RefCount: Integer; LastUsed: Integer; diff --git a/Source/editor/simba.editor_autocomplete.pas b/Source/editor/simba.editor_autocomplete.pas index 5947681ab..027cab902 100644 --- a/Source/editor/simba.editor_autocomplete.pas +++ b/Source/editor/simba.editor_autocomplete.pas @@ -697,6 +697,7 @@ TColumnFormat = record if Decl.isProcedure then Column := COLUMN_PROC else if Decl.isType then Column := COLUMN_TYPE else if Decl.isVar then Column := COLUMN_VAR else + if Decl.isField then Column := COLUMN_VAR else if Decl.isConst then Column := COLUMN_CONST else if Decl.isEnumElement then Column := COLUMN_ENUM else if Decl.isKeyword then Column := COLUMN_KEYWORD else diff --git a/Source/simba.ide_showdeclaration.pas b/Source/simba.ide_showdeclaration.pas index 9936e06fb..0c3bf89fa 100644 --- a/Source/simba.ide_showdeclaration.pas +++ b/Source/simba.ide_showdeclaration.pas @@ -66,8 +66,7 @@ procedure ShowDeclaration(StartPos, EndPos, Line: Integer; FileName: String); procedure ShowDeclaration(Declaration: TDeclaration); begin - { - if Declaration.Lexer.IsLibrary then + if (Declaration.Parser is TPluginParser) then begin if (Declaration is TDeclaration_Method) then SimbaDebugLn([EDebugLn.FOCUS], ['Declared internally in plugin: ' + Declaration.Lexer.FileName, TDeclaration_Method(Declaration).HeaderString]) @@ -75,7 +74,6 @@ procedure ShowDeclaration(Declaration: TDeclaration); SimbaDebugLn([EDebugLn.FOCUS], ['Declared internally in plugin: ' + Declaration.Lexer.FileName, Declaration.Text]) end else - } if (Declaration.Lexer.FileName = '') or FileExists(Declaration.Lexer.FileName) then begin if FileExists(Declaration.Lexer.FileName) then diff --git a/Source/simba.target.pas b/Source/simba.target.pas index 4e4d1176e..5d7219e88 100644 --- a/Source/simba.target.pas +++ b/Source/simba.target.pas @@ -540,6 +540,8 @@ function TSimbaTarget.ToString: String; Result := 'ETargetType.WINDOW: Handle=%d, Valid: %s'.Format([FTargetWindow, BoolToStr(IsValid(), True)]); ETargetType.EIOS: Result := 'ETargetType.EIOS: Target=%P'.Format([FTargetEIOS.Target]); + ETargetType.PLUGIN: + Result := 'ETargetType.PLUGIN: Filename="%s" Target=%P'.Format([FTargetPlugin.FileName, FTargetPlugin.Target]); end; end; diff --git a/Source/targets/simba.target_plugin.pas b/Source/targets/simba.target_plugin.pas index 0f6f0da26..c4d4e05b5 100644 --- a/Source/targets/simba.target_plugin.pas +++ b/Source/targets/simba.target_plugin.pas @@ -12,6 +12,7 @@ interface PSimbaPluginTarget = ^TSimbaPluginTarget; TSimbaPluginTarget = record Lib: TLibHandle; + FileName: String; Target: Pointer; Request: function(Args: PChar): Pointer; cdecl; @@ -55,21 +56,23 @@ function PluginTarget_KeyPressed(Target: Pointer; Key: EKeyCode): Boolean; implementation uses - simba.script_pluginloader; + simba.env, simba.files, simba.script_pluginloader; -function Load(FileName: String): TSimbaPluginTarget; +function Load(AFileName: String): TSimbaPluginTarget; begin Result := Default(TSimbaPluginTarget); with Result do begin try - Lib := LoadPlugin(FileName); + Lib := LoadPlugin(AFileName); except on E: Exception do raise Exception.Create('LoadPluginTarget: ' + E.Message); end; + FileName := TSimbaPath.PathExtractRelative(SimbaEnv.SimbaPath, AFileName); + Pointer(Request) := GetProcedureAddress(Lib, 'SimbaPluginTarget_Request'); Pointer(RequestWithDebugImage) := GetProcedureAddress(Lib, 'SimbaPluginTarget_RequestWithDebugImage'); Pointer(Release) := GetProcedureAddress(Lib, 'SimbaPluginTarget_Release');