-
Content Count
267 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Jacek Laskowski
-
Named pipe failure, multithreading and asynchronous I/O
Jacek Laskowski replied to FPiette's topic in Windows API
I try download from your site, but I get error: Access denied The requested URL cannot be provided http://www.overbyte.eu/cgi-bin/redirect1<...> Blocked by Web Anti-Virus Reason: threat of data loss Detection method: cloud protection -
Named pipe failure, multithreading and asynchronous I/O
Jacek Laskowski replied to FPiette's topic in Windows API
Will this project be publicly available in a repository? -
Is it possible to register a generic class implementing the delphi IEqualityComparer<T> in the Spring container? This interface does not have a GUID and RegisterType generates an error. How to do it?
-
Spring4D and IEqualityComparer<T>
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
Ok, I paste more code with real example: program s4dgic; uses System.Generics.Defaults, Spring.Collections, Spring.Container, System.SysUtils; {$APPTYPE CONSOLE} {$R *.res} type TBaseClass<T, V> = class(TInterfacedObject) private fDict: IDictionary<T, V>; public constructor Create(const aComparer: IEqualityComparer<T>); virtual; end; constructor TBaseClass<T, V>.Create(const aComparer: IEqualityComparer<T>); begin inherited Create; fDict := TCollections.CreateDictionary<T, V>(aComparer); end; type RKey = record FieldA: Integer; FieldB: String; end; TMyEqualityComparer = class(TEqualityComparer<RKey>) public function Equals(const Left, Right: RKey): Boolean; override; end; function TMyEqualityComparer.Equals(const Left, Right: RKey): Boolean; begin Result := (Left.FieldA = Right.FieldA) and (Left.FieldB = Right.FieldB); end; type IMyIntf = interface ['{874B15D9-675E-428B-906A-D526FCC3AE0D}'] end; TMainClass = class(TBaseClass<RKey, TObject>, IMyIntf) public constructor Create(const aComparer: IEqualityComparer<RKey>); override; end; constructor TMainClass.Create(const aComparer: IEqualityComparer<RKey>); begin inherited Create(aComparer); end; var C: TContainer; I : IMyIntf; begin try C := TContainer.Create; >>>>> how to register required types? <<<< C.RegisterType<TMainClass>.Implements<IMyIntf>; C.Build; I := C.Resolve<IMyIntf>; C.Free; Readln; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end. -
Spring4D and IEqualityComparer<T>
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
Yes, I have class with IEqualityComparer<T> in constructor, so I need the container to be able to resolve this interface... but this is impossible? TMyClass<T> = class(TInterfacedObject, IMyInterface) constructor Create(const aKeyComparer : IEqualityComparer<T>); end; -
I knew that you're sticking to it ... 🙂 I try to eliminate warnings from my own code, but I have warnings from external libraries, eg Synapse, DCPCrypt and others.
-
Check for override
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
the temptation to optimize is sometimes so great... 😉 -
New feature suggestion for MMX: implementation marking in Find Identifier window
Jacek Laskowski replied to PeterPanettone's topic in MMX Code Explorer
Maybe green and gray circle would be enough? Without plus or minus sign? Green for interface, gray for implementation (gray as in shadow, hidden). -
Check for override
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
The class design is rather good, the override detection I need in order to optimize performance (class implements cache in the REST server). The ancestor (in base class) method returns always False, the descendant method can change this behavior, but if it does not change, I prefer to check the boolean flag rather than call the method (just because it's faster). -
Check for override
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
Thanks for both solutions, I use Spring4D, but "seek" way is worth attention too (and probably faster). -
CNPack has similar or in some cases better solution, see:
-
from Microsft site: " [Network DDE is no longer supported. Nddeapi.dll is present on Windows Vista, but all function calls return NDDE_NOT_IMPLEMENTED.] "
-
https://github.com/ahausladen/JsonDataObjects by Andreas Hausladen
-
Discussion: JSON and templates
Jacek Laskowski replied to Mahdi Safsafi's topic in Algorithms, Data Structures and Class Design
Maybe instead of thinking up a language, use TypeScript? In JS (and TS), JSON automatically becomes an object (Java Script Object Notation). -
Caching with class variables
Jacek Laskowski replied to Primož Gabrijelčič's topic in Tips / Blogs / Tutorials / Videos
what about thread safety? -
The code is correct, compiles, but the editor highlights errors 😞
-
Strange thing in System.Generics.Defaults.pas
Jacek Laskowski posted a topic in RTL and Delphi Object Pascal
Quote: unit System.Generics.Defaults; [...] function GetHashCode_Class(Inst: PSimpleInstance; const Value: TObject): Integer; begin if Value = nil then Result := 42 else Result := Value.GetHashCode; end; What is this? Why 42? 🙂 ps. Delphi Tokyo, maybe other too -
Yes, quality lies and cries. Recently, I have been working a little in VSCode and the node.js ecosystem. Environmental quality is ahead of Delphi for ages. In addition, it works steadily and quickly, although behind the scenes everything is based on slow JS! I have serious doubts that Delphi will ever catch up with the world in this area.
-
Node modules with Delphi and Free Pascal
Jacek Laskowski replied to a topic in Tips / Blogs / Tutorials / Videos
great!- 6 replies
-
- delphi
- freepascal
-
(and 3 more)
Tagged with:
-
GExperts?
-
WebAssembly with Delphi and ChakraCore
Jacek Laskowski replied to a topic in Tips / Blogs / Tutorials / Videos
Chakra is open source, under the liberal MIT license, it doesn't have to die with Edge. -
Then try to debug the GZIP usage or place of parsing response headers. IMHO Rio has many errors in HTTPClient classes, see:
-
try to debug HTTPClient after exit from this event
-
Such a curiosity Code insight caused an exception in Delphi Tokyo, I pay attention to the path in the call stack. See screen:
-
Strange thing in System.Generics.Defaults.pas
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
"The number 42 is, in The Hitchhiker's Guide to the Galaxy by Douglas Adams, the "Answer to the Ultimate Question of Life, the Universe, and Everything", calculated by an enormous supercomputer named Deep Thought over a period of 7.5 million years. " Yes, I was looking for that! 🙂