Chris Rolliston
-
Content Count
5 -
Joined
-
Last visited
Posts posted by Chris Rolliston
-
-
13 hours ago, Marcelo Jaloto said:Hello
I discovered the bug and the solution.
A pointer is 4 bytes in 32 bits and 8 bytes in 64 bits.See more at :
http://docwiki.embarcadero.com/RADStudio/Rio/en/Converting_32-bit_Delphi_Applications_to_64-bit_WindowsThe IcsWireFmtToStrList method of the OverbyteIcsUtils unit had a problem moving characters with Move without regard to the number of bytes.
Wrong:
Move (Buffer [offset], AStr [1], mylen);
Correct:
Move (Buffer [offset], AStr [1], mylen * SizeOf (TBytes));
The Len parameter comes with the value 12.
This correction cannot be correct. TBytes is a reference type (i.e. thinly-veiled pointer) to an array of byte values; Move copies actual data (i.e. the stuff that a reference type references), against units of the actual data. In addition, this code uses Move to copy into an AnsiString, which is also a reference type to an array of byte-sized elements. Ergo, an element size of 1 is correct, being what both SizeOf(Byte) (i.e. the element type for a TBytes) and SizeOf(AnsiChar) (the element type for an AnsiString) both are.
-
Hmm, beyond DataGridView (pretty nice for a default grid control), I think I'd personally take pretty much any VCL control over its WinForms equivalent.
Given you have the plumbing, have you considered wrapping a newer .NET UI tech, or even UWP...?
-
By the by, this historical piece is quite an amusing read:
https://web.archive.org/web/20120627043929/http://java.sun.com/docs/white/delegates.html
Sun's reply to Microsoft adding delegate types to its Windows-centric version of Java (Visual J++ being Anders Hejlsberg's main project in between Delphi and C# I think...?).
- 1
-
10 minutes ago, Rudy Velthuis said:That's cool. ISTM that for Delphi, it would mean quite a few changes in the compiler.
And well, I still don't see why it should be done.
C# event types were the equivalent of method reference types in Delphi in the first place (in fact, even more heavyweight given the multicasting support), so a Delphi-style problem of how to shoehorn anonymous methods to events, when anonymous methods were added in C# 2.0, didn't arise.
IMO (and I think this is in agreement with you?), the only way to do this truly cleanly in Delphi would be to switch the event type from method pointers to method references (the latter already support at a syntax level assignments of regular methods and standalone routines). However, that would be a complete no-no for VCL backwards compatibility.
Record / Class
in Algorithms, Data Structures and Class Design
Posted
What are you aiming to achieve...? Returning a pointer to Self doesn't give any obvious benefit - if the rTxt instance is statically defined, the validity of a pointer to it will remain restricted to the scope of the instance variable. In other words, this sort of code is invalid -
Conversely if rTxt is dynamically allocated (New and Dispose standard procedures), then by definition you lose the 'lazy' benefit you hoped to achieve. If your intent was that WriteValue should return a new instance, then (as David said) the method needs to be a class static method (or a constructor), and return the instance type (not a pointer):