tag:blogger.com,1999:blog-10106032.post1795234792364465362..comments2024-03-14T09:24:53.310+00:00Comments on Entropy Overload: An ugly alternative to interface to object castingBarry Kellyhttp://www.blogger.com/profile/10559947643606684495noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-10106032.post-78421662739343444532013-01-24T08:03:32.710+00:002013-01-24T08:03:32.710+00:00I tried this code but it cannot was compiled in my...I tried this code but it cannot was compiled in my machine. <br /><br />Array type required error in the line below : <br />if L[i] <> R[i] then<br /><br />How do I fix it ?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-10106032.post-38852038827879608642013-01-24T08:02:54.420+00:002013-01-24T08:02:54.420+00:00I tried this code but it cannot was compiled in my...I tried this code but it cannot was compiled in my machine. <br /><br />Array type required error in the line below : <br />if L[i] <> R[i] then<br /><br />How do I fix it ?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-10106032.post-28858481115219470072011-05-17T22:12:10.305+01:002011-05-17T22:12:10.305+01:00Anonymous - I wouldn't fear, several EMBT peop...Anonymous - I wouldn't fear, several EMBT people follow DHB.Barry Kellyhttps://www.blogger.com/profile/10559947643606684495noreply@blogger.comtag:blogger.com,1999:blog-10106032.post-14393727836421577442011-05-17T21:51:54.362+01:002011-05-17T21:51:54.362+01:00How can I notify Embarcadero of a source code leak...How can I notify Embarcadero of a source code leak?<br /><br />http://delphihaters.blogspot.com/2011/05/tpc-source-code-leak.htmlAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-10106032.post-68300321274395888972011-03-02T21:26:54.352+00:002011-03-02T21:26:54.352+00:00In the component installer, which is now part of t...In the component installer, which is now part of the XE IDE, I did it this way (sorry for the lack of indentation, but I found no way to format source code in comments):<br /><br /><i><br /> TStub = packed record<br /> case Byte of<br /> 0: (LongAdd: Byte; // Must be $05<br /> LongOffset: Integer);<br /> 1: (ShortAdd: Word; // Must be $C083<br /> ShortOffset: Shortint);<br /> end;<br /> PStub = ^TStub;<br /> ...<br />var<br /> Stub: PStub;<br /> Configs: IOTAProjectOptionsConfigurations;<br /> ...<br />begin<br /> ...<br /> Stub := PPInterface(Configs)^^.Method;<br /> if Stub^.LongAdd = $05 then<br /> Offset := Stub^.LongOffset<br /> else if Stub^.ShortAdd = $C083 then<br /> Offset := Stub^.ShortOffset<br /> else<br /> begin<br /> MessageDlg(SProjectOptionsNotFound, mtError, [mbOK], 0);<br /> Exit;<br /> end;<br /><br /></i>Rudy Velthuishttp://rvelthuis.denoreply@blogger.comtag:blogger.com,1999:blog-10106032.post-56565801016759515702011-03-02T14:02:52.315+00:002011-03-02T14:02:52.315+00:00Don't you love the first hit on the http://www...Don't you love the first hit on the http://www.google.com/search?q=delphi+interface+to+object search ;-)<br /><br />The cool thing is that the research that Hallvard Vassbotn did in 2004 shows how stable the interface implementation has been over the years.<br /><br />But I do like the way that 'is' and 'as' now just 'work'.<br /><br />--jeroenAnonymoushttps://www.blogger.com/profile/04244706419710554421noreply@blogger.comtag:blogger.com,1999:blog-10106032.post-18850191159839274092011-03-02T06:32:56.078+00:002011-03-02T06:32:56.078+00:00Hi Barry,
So an other idea.
For ensuring safety ...Hi Barry,<br />So an other idea. <br /><br />For ensuring safety you may use a ability of yours :) (Delphi) Memory Manager. <br />Just check the interface reference for to be in MM allocated range. <br />So if in range the the first byte of allocated block is the the object instance. Of course this true for normally allocated objects via standart Newintance. <br /><br />:)<br /><br />As for other much rarely case for example in the case of overrided Newintance may be checking the stub signature is the best way.<br /><br />Sergey.Sergey Antonov aka oxffffhttps://www.blogger.com/profile/10045102019512764602noreply@blogger.comtag:blogger.com,1999:blog-10106032.post-70092853361654578622011-03-01T17:08:56.192+00:002011-03-01T17:08:56.192+00:00Yes.Yes.Barry Kellyhttps://www.blogger.com/profile/10559947643606684495noreply@blogger.comtag:blogger.com,1999:blog-10106032.post-49375253872121429282011-03-01T17:07:20.429+00:002011-03-01T17:07:20.429+00:00Barry, does the "is" operator also work ...Barry, does the "is" operator also work for this? i.e. can I do this?<br /><br />var iObj: IInterface;<br />...<br />if IObj is TObject then with IObj as TObjectAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-10106032.post-45682883207291454212011-03-01T15:33:24.571+00:002011-03-01T15:33:24.571+00:00Delphi 2010, I believe.Delphi 2010, I believe.Barry Kellyhttps://www.blogger.com/profile/10559947643606684495noreply@blogger.comtag:blogger.com,1999:blog-10106032.post-88655680043506839552011-03-01T15:28:36.221+00:002011-03-01T15:28:36.221+00:00Hi Barry,
Out of curiosity: which recent version...Hi Barry, <br /><br />Out of curiosity: which recent versions of Delphi enabled the cast behaviour with "as"?Jamie Inoreply@blogger.com