Leaderboard
Popular Content
Showing content with the highest reputation on 10/28/20 in Posts
-
How do I enumerate all properties of a Variant?
FPiette replied to Phil Brinkle's topic in General Help
Yes, you can. Basically, you have to call GetTypeInfoCount(), GetTypeInfo(), GetTypeAttr() and other functions (All documented by Microsoft). Here is a function to list all method names including property getter/setter. Similar code can enumerate argument list, argument data types and return value data type. procedure DisplayMethodNames( const DispIntf : IDispatch; const IntfName : String; Strings : TStrings); var Count : Integer; TypeInfo : ITypeInfo; TypeAttr : PTypeAttr; FuncDesc : PFuncDesc; HR : HRESULT; I : Integer; FuncName : WideString; begin if IntfName <> '' then Strings.Add(IntfName); Count := 0; HR := DispIntf.GetTypeInfoCount(Count); if Failed(HR) or (Count = 0) then Exit; HR := DispIntf.GetTypeInfo(0, 0, TypeInfo); if Succeeded(HR) and (TypeInfo <> nil) then begin TypeAttr := nil; HR := TypeInfo.GetTypeAttr(TypeAttr); if Succeeded(HR) and (TypeAttr <> nil) then begin for I := 0 to TypeAttr.cFuncs - 1 do begin FuncDesc := nil; HR := TypeInfo.GetFuncDesc(I, FuncDesc); if Succeeded(HR) and (FuncDesc <> nil) then begin TypeInfo.GetDocumentation(FuncDesc.memid, @FuncName, nil, // DocString, nil, // HelpContext nil); // HelpFile if Length(FuncName) <> 0 then Strings.Add(Format(' %-3d %s', [I, FuncName])); TypeInfo.ReleaseFuncDesc(FuncDesc); end; end; TypeInfo.ReleaseTypeAttr(TypeAttr); end; end; end; -
function reference feature for Delphi source code
Stefan Glienke replied to Nasreddine's topic in GExperts
This feature is called CodeLens - if you fancy you can look on GitHub how its implemented in VSCode. -
What counts is that in x86_64 asm, MUL and DIV are 128-bit. https://www.felixcloutier.com/x86/mul states: REX.W + F7 /4 MUL r/m64 M Valid N.E. Unsigned multiply (RDX:RAX ← RAX ∗ r/m64). and https://www.felixcloutier.com/x86/div reports: REX.W + F7 /6 DIV r/m64 M Valid N.E. Unsigned divide RDX:RAX by r/m64, with result stored in RAX ← Quotient, RDX ← Remainder So my guess is that this code is correct, and the fastest possible on the target. Only if m is known in advance (as a constant), you may be able to make the division faster by using a reciprocal multiplication or a bits shift. From https://www.agner.org/optimize/instruction_tables.pdf on a modern CPU, 64-bit MUL takes around 3 cycles, and 64-bit DIV 10 cycles. Difficult to make it faster with any other algorithm. As a small optimization, you can omit the stack frame: function MulModASM(a, b, m: UInt64): UInt64; {$ifdef FPC}nostackframe; assembler; asm {$else} asm .noframe {$endif FPC} MOV rax, a MOV rcx, m MUL b DIV rcx MOV rax, RDX end; https://ideone.com/KUsgMi About register conventions, for windows/posix: rcx/rdi=a rdx/rsi=b r8/rdx=m so it should be fine. Just to be tested with a lot of values and high 64-bit limits.
-
Having fun with Delphi
Marat1961 replied to Attila Kovacs's topic in Algorithms, Data Structures and Class Design
unit Uri; interface uses System.SysUtils; type PxUri = ^TxUri; TxUri = record private FScheme: string; FPort: Cardinal; FHost: string; FUserName: string; FPassword: string; FPath: string; FQuery: string; FFragment: string; public function Init(const Scheme, Path: string; Port: Cardinal = 0): PxUri; function Host(const Value: string): PxUri; function UserName(const Value: string): PxUri; function Password(const Value: string): PxUri; function Path(const Value: string): PxUri; function Query(const Value: string): PxUri; function Fragment(const Value: string): PxUri; function ToString: string; end; implementation function TxUri.Init(const Scheme, Path: string; Port: Cardinal): PxUri; begin Result := @Self; Self := Default(TxUri); FScheme := Scheme; FPath := '/' + Path; FPort := Port; end; function TxUri.Host(const Value: string): PxUri; begin Result := @Self; FHost := Value; end; function TxUri.UserName(const Value: string): PxUri; begin Result := @Self; FUserName := Value; end; function TxUri.Password(const Value: string): PxUri; begin Result := @Self; FPassword := Value; end; function TxUri.Path(const Value: string): PxUri; begin Result := @Self; FPath := FPath + Format('/%s', [Value]); end; function TxUri.Query(const Value: string): PxUri; begin Result := @Self; if FQuery = '' then FQuery := Format('?%s', [Value]) else FQuery := FQuery + Format('&%s', [Value]); end; function TxUri.Fragment(const Value: string): PxUri; begin Result := @Self; FFragment := Format('#%s', [Value]); end; function TxUri.ToString: string; var sb: TStringBuilder; begin sb := TStringBuilder.Create; try sb.Append(FScheme); sb.Append(':'); if FHost <> '' then begin sb.Append('//'); if FUserName <> '' then sb.AppendFormat('%s:%s@', [FUserName, FPassword]); sb.Append(FHost); if FPort <> 0 then sb.AppendFormat(':%d', [FPort]); end; sb.Append(FPath); if FQuery <> '' then sb.Append(FQuery); if FFragment <> '' then sb.Append(FFragment); Result := sb.ToString; finally sb.Free; end; end; end. procedure TForm2.Button1Click(Sender: TObject); var uri: TxUri; begin uri.Init('http', 'Mammalia', 8080) .UserName('yourname') .Password('TopSecret') .Host('www.website.com') .Path('Theria') .Path('Carnivora') .Path('Felidae') .Path('Lynx_pardinus') .Query('showall') .Query('yearstart=1990') .Fragment('StartReadingHere'); Label1.Caption := uri.ToString; end; http://yourname:TopSecret@www.website.com:8080/Mammalia/Theria/Carnivora/Felidae/Lynx_pardinus?showall&yearstart=1990#StartReadingHere 005FD859 68901F0000 push $00001f90 005FD85E 8D45D8 lea eax,[ebp-$28] 005FD861 B92CD95F00 mov ecx,$005fd92c 005FD866 BA4CD95F00 mov edx,$005fd94c 005FD86B E8C8F8FFFF call TxUri.Init 005FD870 BA64D95F00 mov edx,$005fd964 005FD875 E856F9FFFF call TxUri.UserName 005FD87A BA84D95F00 mov edx,$005fd984 005FD87F E874F9FFFF call TxUri.Password 005FD884 BAA4D95F00 mov edx,$005fd9a4 005FD889 E81AF9FFFF call TxUri.Host 005FD88E BAD0D95F00 mov edx,$005fd9d0 005FD893 E888F9FFFF call TxUri.Path 005FD898 BAECD95F00 mov edx,$005fd9ec 005FD89D E87EF9FFFF call TxUri.Path 005FD8A2 BA0CDA5F00 mov edx,$005fda0c 005FD8A7 E874F9FFFF call TxUri.Path 005FD8AC BA28DA5F00 mov edx,$005fda28 005FD8B1 E86AF9FFFF call TxUri.Path 005FD8B6 BA50DA5F00 mov edx,$005fda50 005FD8BB E8ECF9FFFF call TxUri.Query 005FD8C0 BA6CDA5F00 mov edx,$005fda6c 005FD8C5 E8E2F9FFFF call TxUri.Query 005FD8CA BA98DA5F00 mov edx,$005fda98 005FD8CF E8B8FAFFFF call TxUri.Fragment TestUri.pas.42: Label1.Caption := uri.ToString; 005FD8D4 8D55D4 lea edx,[ebp-$2c] 005FD8D7 8D45D8 lea eax,[ebp-$28] 005FD8DA E835FBFFFF call TxUri.ToString 005FD8DF 8B55D4 mov edx,[ebp-$2c] 005FD8E2 8B45FC mov eax,[ebp-$04] 005FD8E5 8B80D4030000 mov eax,[eax+$000003d4] 005FD8EB E8F446F4FF call TControl.SetText -
Hello, this is the notice that DEC (Delphi Encryption Compendium) has a new home. The GitHub repository has been transferred to me by the previous maintainer as he no longer found the time to work on it and I was the main developer since a few years already anyway. The new URL is: https://github.com/MHumm/DelphiEncryptionCompendium This transfer also makes it a bit more likely that the V6.0 which is still in the works will be released in the near future. Best regards TurboMagic
-
Why is it hard? TTask has constructors that take a TThreadPool as input. Create a single TThreadPool, configure it as needed, such as MaxWorkerThreads, and then pass that pool to each TTask you create.
-
Connect the TTask objects to a shared TThreadPool that limits how many threads can run at a time. Or, use a shared Win32 semaphore to limit how many TTask threads can send HTTP requests at a time.
-
Showing secondary form from the main form OnShow event
Remy Lebeau replied to Mowafaq's topic in Cross-platform
No, I meant what I posted. An anonymous procedure is not necessary. TThread.ForceQueue() accepts both standard method closures and anonymous procedures as input, same as TThread.Synchronize() and TThread.Queue() do: type TThreadMethod = procedure of object; TThreadProcedure = reference to procedure class procedure ForceQueue(const AThread: TThread; const AMethod: TThreadMethod; ADelay: Integer = 0); overload; static; class procedure ForceQueue(const AThread: TThread; const AThreadProc: TThreadProcedure; ADelay: Integer = 0); overload; static; What I had left off by accident in my example was just the nil TThread parameter: TThread.ForceQueue(nil, SignForm.Show); -
The android app doesn't start at specific devices
Dave Nottage replied to Juan Martinez's topic in FMX
..and its name is? It may help in finding what the problem is from the logs. Better still, what is the package identifier? Is the app on the Google Play, and if so, is it available in all regions? -
How secure is your WordPress installation?
dummzeuch replied to dummzeuch's topic in Tips / Blogs / Tutorials / Videos
No, it doesn't. -
Common callback functions, or not?
FPiette replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Where is the "thanks" button? As I said: hover the "like" button and you'll see it. The like button is the heart icon on the bottom right corner of a message. -
CrystalNet - .Net Runtime Library for Delphi
CrystalNet replied to Lars Fosdal's topic in Delphi Third-Party
Hello, I am a member of the support team at CrystalNet Technologies LTD. Let me address the issues and questions raised in this forum. First and foremost, the .Net Runtime Library for Delphi is our flagship product and the most comprehensive library for bridging Delphi and .Net which is used by over 1000 companies and individuals worldwide. The product eliminates much of the complexity of developing Delphi applications with .Net libraries or components, by providing easy-to-use programmable components that facilitate tasks such as hosting .Net CLR in Delphi, access .Net Framework libraries, Load .Net 3rd party DLLs, and many more. The .Net Runtime Library for Delphi contains .Net DLL/WSDL Import Utility for Delphi which helps eliminates the need to manually convert your .Net 3rd-party libraries to Delphi. Competitive Advantages Full access to .Net Framework Class Library (Including new and emerging .NET technologies). No extra dll is required when deployed. No COM registration of .Net Libraries is required when deployed. There are tools to generate your .Net Libraries into Delphi pas files. Allows Delphi to consume .Net libraries as if they were native code. Easy to use. We are currently working on new a product .Net Core Library for Delphi which will fully support .Net Core. At the moment the .Net Runtime Library for Delphi supports only .Net Standard 2.1. For source code examples, go to https://www.crystalnet-tech.com/RuntimeLibrary/ViewRTLExamples https://www.crystalnet-tech.com/DevCodeSamples/Default I understand the confusion surrounding the licenses. The Professional license is interchanged with the Enterprise license. This discrepancy happened way back in 2015 and there are so many clients using the Pro and Enterprise license such that changing it will cause massive problems for them. We know about the issues and we are working on ways to resolve this to ensure smooth transition between Pro and Enterprise licenses for all our clients. If you have further questions, you can send them to us using the link below: https://www.crystalnet-tech.com/contactform.aspx -
For your information: WebView2 is now out of preview: Announcing Microsoft Edge WebView2 General Availability - Microsoft Edge Blog (windows.com) Instead of using the runtime (or an installed beta version), it can now also leverage a new "fixed version" (previously called "bring-your-own") which is new and in preview.
-
tbh not having IDEFixPack being available is good in the long run - with the existence of it nobody (or very few) actually cared to report issues and put some pressure on Embarcadero to address these things. Now that there is no solution available the pressure on Embarcadero has raised and I can confirm that they are working on it - will they suddenly implement all fixes and optimizations from Andreas? No, but better they do slowly than relying on the third party no matter how incredible.