Navid Madani
Members-
Content Count
41 -
Joined
-
Last visited
Everything posted by Navid Madani
-
Delphi 12 Athens Refactoring Broken
Navid Madani replied to Navid Madani's topic in Delphi IDE and APIs
Thank you, but mine is a different problem (P.S. modelling was selected during installation). Refactoring options are available, but they do not work. -
Delphi 12 Athens Refactoring Broken
Navid Madani replied to Navid Madani's topic in Delphi IDE and APIs
Agree. Unfortunately, version 12's installation made my previous versions unusable. -
Delphi 12 Athens Refactoring Broken
Navid Madani replied to Navid Madani's topic in Delphi IDE and APIs
So, whatβs new in Athens boils down to multiline strings at the expense of: - No more refactoring. - Range-check errors with bitwise operations. Ranting aside, using GREP and RegEx would work, but would be error-prone. Years ago, before Uwe took over ModelMaker Tools, it wreaked havoc while trying to refactor one of my medium-sized projects. So I did not use its refactoring capabilities again. I am curious what options people are using. -
Since you are calling your function from C, try declaring ShowForm as cdecl instead of stdcall.
-
macOS process spawning: Exception class 6 when calling addObserver
Navid Madani posted a topic in Cross-platform
unit uMacOSSpawn; interface uses System.SysUtils , System.Classes , Macapi.Foundation , Macapi.ObjectiveC , Macapi.ObjCRuntime , Macapi.Helpers ; type TProcessSpawn = class(TOCLocal) private fTask: NSTask; fInputPipe: NSPipe; fOutputPipe: NSPipe; fErrorPipe: NSPipe; fNotify: TNotifyEvent; fOutput: string; function GetNotify: TNotifyEvent; procedure SetNotify(const Value: TNotifyEvent); function GetOutput: string; public constructor Create(FileName: PWideChar); destructor Destroy; override; procedure NotificationReceived(notification: NSNotification); cdecl; procedure Input(const aText: string); property Output: string read GetOutput; property Notify: TNotifyEvent read GetNotify write SetNotify; end; implementation { TProcessSpawn } constructor TProcessSpawn.Create(FileName: PWideChar); var FileHandleLocObj: ILocalObject; InputLocObj: ILocalObject; OutputLocObj: ILocalObject; ErrorLocObj: ILocalObject; begin inherited Create; fInputPipe := TNSPipe.Create; fOutputPipe := TNSPipe.Create; fErrorPipe := TNSPipe.Create; fTask := TNSTask.Wrap(TNSTask.Wrap(TNSTask.OCClass.alloc).init); fTask.setLaunchPath(StrToNSStr(FileName)); if Supports(fInputPipe, ILocalObject, InputLocObj) and Supports(fOutputPipe, ILocalObject, OutputLocObj) and Supports(fErrorPipe, ILocalObject, ErrorLocObj) and Supports(fOutputPipe.fileHandleForReading, ILocalObject, FileHandleLocObj) then begin fTask.setStandardInput(InputLocObj.GetObjectID); fTask.setStandardOutput(OutputLocObj.GetObjectID); fTask.setStandardError(ErrorLocObj.GetObjectID); fOutputPipe.fileHandleForReading.acceptConnectionInBackgroundAndNotify; fOutputPipe.fileHandleForReading.readInBackgroundAndNotify; TNSNotificationCenter.Wrap(TNSNotificationCenter.OCClass.defaultCenter).addObserver( Self.GetObjectID, sel_getUid('NotificationReceived:'), NSFileHandleReadCompletionNotification, FileHandleLocObj.GetObjectID ); fTask.launch; // fNSTask.waitUntilExit; end else raise Exception.Create('ILocalObject interface not supported.'); end; destructor TProcessSpawn.Destroy; begin fTask.release; fInputPipe.release; fOutputPipe.release; fErrorPipe.release; inherited; end; function TProcessSpawn.GetNotify: TNotifyEvent; begin Result := fNotify; end; function TProcessSpawn.GetOutput: string; begin Result := fOutput; end; procedure TProcessSpawn.NotificationReceived(notification: NSNotification); var data: NSData; str: NSString; notifHandle: NSFileHandle; begin notifHandle := TNSFileHandle.Wrap(notification.&object); if notifHandle = fOutputPipe.fileHandleForReading then begin data := fOutputPipe.fileHandleForReading.availableData; str := TNSString.Wrap(TNSString.Alloc.initWithData(data, NSUTF8StringEncoding)); try fOutput := NSStrToStr(str); if Assigned(fNotify) then fNotify(Self); finally str.release; end; end; end; procedure TProcessSpawn.Input(const aText: string); var data: NSData; str: NSString; begin str := StrToNSStr(aText + #10); data := str.dataUsingEncoding(NSUTF8StringEncoding); fInputPipe.fileHandleForWriting.writeData(data); end; procedure TProcessSpawn.SetNotify(const Value: TNotifyEvent); begin fNotify := Value; end; end. I am trying to create a unit that spawns a console process on macOS that receives text input through stdin, and returns the result through stdout. I am not an iOS programmer, but I think I managed to get things done correctly based on documentation I consulted, and the unit below compiles without errors or warnings. However, the .addObserver call in the constructor (line 67) causes a runtime exception: First chance exception at $00000001823C976C. Exception class 6. Process Project1 (2540). Is this my fault, or could this be a bug in Delphi's Objective-C bridge? Thanks to everyone in advance. P.S.: I should also mention that debugging the RTL using Delphi 12 Athens on my Apple Silicon device running macOS Sonoma and Windows 11 Pro for ARM virtualized with Parallels, hangs the IDE π- 3 replies
-
- macos
- spawning processes
-
(and 1 more)
Tagged with:
-
macOS process spawning: Exception class 6 when calling addObserver
Navid Madani replied to Navid Madani's topic in Cross-platform
unit uMacOSSpawn; interface uses System.SysUtils , System.Classes , System.Threading , Macapi.Foundation , Macapi.ObjectiveC , Macapi.ObjCRuntime , Macapi.Helpers ; type TStringCallback = procedure(const aText: string) of object; IProcessSpawn = interface ['{606A5174-5921-431C-AD57-DD037472CEF5}'] function GetNotify: TStringCallback; procedure SetNotify(const Value: TStringCallback); function GetOutput: string; procedure Input(const aText: string); property Output: string read GetOutput; property OutputNotify: TStringCallback read GetNotify write SetNotify; end; TProcessSpawn = class(TInterfacedObject, IProcessSpawn) strict private fNSTask: NSTask; fInputPipe: NSPipe; fOutputPipe: NSPipe; fOutputNotify: TStringCallback; fOutput: string; fOutputTask: ITask; function GetNotify: TStringCallback; procedure SetNotify(const Value: TStringCallback); function GetOutput: string; procedure SendNotification(const aToNotify: TStringCallback; const aOutput: string); function WaitForOutput: ITask; procedure Input(const aText: string); public constructor Create(const FileName: string; const aCallback: TStringCallback); destructor Destroy; override; end; implementation { TProcessSpawn } constructor TProcessSpawn.Create(const FileName: string; const aCallback: TStringCallback); var InputLocObj: ILocalObject; OutputLocObj: ILocalObject; begin inherited Create; fOutputNotify := aCallback; fInputPipe := TNSPipe.Create; fOutputPipe := TNSPipe.Create; fNSTask := TNSTask.Wrap(TNSTask.Wrap(TNSTask.OCClass.alloc).init); fNSTask.setLaunchPath(StrToNSStr(FileName)); if Supports(fInputPipe, ILocalObject, InputLocObj) and Supports(fOutputPipe, ILocalObject, OutputLocObj) then begin fNSTask.setStandardInput(InputLocObj.GetObjectID); fNSTask.setStandardOutput(OutputLocObj.GetObjectID); fNSTask.setStandardError(OutputLocObj.GetObjectID); fNSTask.launch; end else raise Exception.Create('ILocalObject interface not supported.'); end; destructor TProcessSpawn.Destroy; begin if fNSTask.isRunning then fNSTask.terminate; fNSTask.release; fInputPipe.release; fOutputPipe.release; fOutputNotify := nil; fOutputTask.Cancel; fOutputTask := nil; inherited; end; function TProcessSpawn.GetNotify: TStringCallback; begin Result := fOutputNotify; end; function TProcessSpawn.GetOutput: string; begin Result := fOutput; end; procedure TProcessSpawn.Input(const aText: string); var data: NSData; str: NSString; begin if not fNSTask.isRunning then raise Exception.Create('No running process!'); str := StrToNSStr(aText + #10); data := str.dataUsingEncoding(NSUTF8StringEncoding); fInputPipe.fileHandleForWriting.writeData(data); if fOutputTask = nil then fOutputTask := WaitForOutput; end; procedure TProcessSpawn.SendNotification(const aToNotify: TStringCallback; const aOutput: string); begin fOutputTask := nil; if Assigned(aToNotify) then begin TThread.Synchronize(nil, procedure begin aToNotify(aOutput); end); end; fOutputTask := WaitForOutput; end; procedure TProcessSpawn.SetNotify(const Value: TStringCallback); begin fOutputNotify := Value; end; function TProcessSpawn.WaitForOutput: ITask; begin Result := TTask.Create( procedure var data: NSData; str: NSString; begin data := fOutputPipe.fileHandleForReading.availableData; str := TNSString.Wrap(TNSString.Alloc.initWithData(data, NSUTF8StringEncoding)); try fOutput := NSStrToStr(str); SendNotification(fOutputNotify, fOutput); finally str.release; end; end); Result.Start; end; end. In case anyone would run into this issue, I simplified things by calling .dataAvailable which is a blocking call in a separate thread. The unit below (at least for now) is working for my purposes.- 3 replies
-
- macos
- spawning processes
-
(and 1 more)
Tagged with:
-
macOS process spawning: Exception class 6 when calling addObserver
Navid Madani replied to Navid Madani's topic in Cross-platform
Thanks, David. That was indeed what caused the exception. I noticed that pattern at least once in the docs I read and forgot. The pattern above was based on Objective-C code samples I studied. However, mine does not work as intended because the notification handler is not called back. I did not know about Kastri until now. I'll pursue the Kastri solution if tinkering with my own implementation remains fruitless. In any case, I just became a Kastri sponsor on GitHub. Thanks again.- 3 replies
-
- macos
- spawning processes
-
(and 1 more)
Tagged with:
-
Based on my own results and consistent with what I read on https://quality.embarcadero.com/browse/RSP-42424, The Correct order is: begin GlobalUseMetal := True; // <-- should appear before Application.Iniialize; Application.Initialize; HTH, Navid
-
Hi: I noticed that using Delphi/VCL (Alexandria 11.3) under Windows ARM via Parallels on macOS Ventura, I cannot get menu or action list accelerator keys to show or function (defined using ampersand, e.g. "&Open...", the underscore does not show even when pressing the alt key, and pressing alt-O sounds an error bell). Can anyone else confirm this behavior? Thanks in advance, Navid
-
Accelerator keys not working with Windows ARM macOS Parallels
Navid Madani replied to Navid Madani's topic in VCL
OK - silly me - it was somehow being blocked by Dragon Speech ... -
Adding macOS directory path crashing IDE (RAD Studio 11.3, Windows 11 ARM, Apple Silicon, Parallels)
Navid Madani posted a topic in Delphi IDE and APIs
Hi: I am using RAD Studio 11.3 on Windows ARM running on Apple Silicon/macOS Ventura via Parallels. I am trying to set up my custom packages (mostly written by myself) that under Windows are in the Documents/Embarcadero/Studio/ subdirectory. Parallels conveniently shares the home directory between Windows and macOS that makes sharing common files (Lisp, C, Python, Delphi) easier. Can anyone confirm that with a setup like mine, adding a library path to Tools β Options... β Language β Delphi β Library β Browsing Path such as: \\Mac\Home\Documents\Embarcadero\Studio\Virtual-TreeView causes the IDE to choke and need to be shut down via task manager? Many thanks to everyone in this great community! -
Adding macOS directory path crashing IDE (RAD Studio 11.3, Windows 11 ARM, Apple Silicon, Parallels)
Navid Madani replied to Navid Madani's topic in Delphi IDE and APIs
Thank you for your post. The problem does not appear to be related to performance when scanning a shared Parallels directory. The performance when building large projects saved on the shared home directory is comparable to native Windows machines with i-9 processors and SSD drives. I think the problem lies in that the IDE does not recognize the shared directory browsing path at all. -
Looks like the issue has been resolved: Apple resolved M1 Mac SSD wear reporting issue in macOS 11.4
-
Hello: Using Alexandria 11.1, installing TSynEdit via GetIt will not allow compilation due to a missing SynHighlighterMulti.pas file. Replacing the file with what I could find online caused additional problems (seems it was suited for Lazarus/FPC). I then cloned the sources from the GitHub repository, but I can still not compile following the readme file's directions due to the errors below. Any help/directions would be hugely appreciated. Thank you for reading! Navid description:"TurboPack SynEdit Delphi designtime package" -JL -NB..\cpp\Win32\Release -NH..\cpp\Win32\Release -NO..\cpp\Win32\Release SynEditDD.dpk [dcc32 Error] SynEditReg.pas(190): E2003 Undeclared identifier: 'TSynSpellCheckFile' [dcc32 Error] SynEditReg.pas(190): E2003 Undeclared identifier: 'TSynSpellCheckLine' [dcc32 Error] SynEditReg.pas(190): E2003 Undeclared identifier: 'TSynSpellCheckSelection' [dcc32 Error] SynEditReg.pas(191): E2003 Undeclared identifier: 'TSynSpellCheckWord' [dcc32 Error] SynEditReg.pas(191): E2003 Undeclared identifier: 'TSynSpellClearErrors' [dcc32 Error] SynEditReg.pas(191): E2003 Undeclared identifier: 'TSynSpellCheckAsYouType' [dcc32 Error] SynEditReg.pas(192): E2003 Undeclared identifier: 'TSynSpellErrorAdd' [dcc32 Error] SynEditReg.pas(192): E2003 Undeclared identifier: 'TSynSpellErrorIgnoreOnce' [dcc32 Error] SynEditReg.pas(193): E2003 Undeclared identifier: 'TSynSpellErrorIgnore' [dcc32 Error] SynEditReg.pas(193): E2003 Undeclared identifier: 'TSynSpellErrorDelete' [dcc32 Fatal Error] SynEditDD.dpk(39): F2063 Could not compile used unit 'SynEditReg.pas' Failed Elapsed time: 00:00:00.7
-
Problems using/building TSynEdit with Alexandria
Navid Madani replied to Navid Madani's topic in General Help
Yes -
I allowed the ISO installer to uninstall 11.1. The 11.2 installation process went smoothly. However, I got all manner of access errors trying to start 11.2. Uninstalled and the ISO installer switched to web install (which I have never used for any version). Uninstalled and removed everything manually, now I'm three hours into another "web install" that I worry might again not work...