tag:blogger.com,1999:blog-2428374771421713311.post70285194078484222..comments2024-03-10T12:04:17.661-07:00Comments on The Oracle at Delphi: The “Nitty Gritty” details on Casting an Interface Reference in Delphi
2010Anonymoushttp://www.blogger.com/profile/10119008505905401707noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-2428374771421713311.post-75986014458156312322009-08-22T03:03:24.000-07:002009-08-22T03:03:24.000-07:00[...] CR Getting down to the actual implementati...[...] CR Getting down to the actual implementation of interface-to-object casts in D2010, Allen Bauer reports that the solution was actually quite simple. Basically, given interface casting already used [...]Querying for the implementing object from an interface (2) « Delphi Havenhttp://delphihaven.wordpress.com/2009/08/22/querying-for-the-implementing-object-from-an-interface-2/noreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-76443941939937064232009-08-21T21:01:37.000-07:002009-08-21T21:01:37.000-07:00Very elegant, I like it!"Another caveat, is i...Very elegant, I like it!<br><br>"Another caveat, is if you’re doing cross-process marshaling of interfaces where both sides are Delphi 2010, you should not attempt to use this technique."<br><br>Just a thought, but if the internal GUID were changeable at runtime, couldn't this danger be averted? In fact, why not generate the GUID at application start up (a BPL would query its EXE for the right one)? While this would make casting across EXE and plain jane DLL boundaries not work by default, passing objects in that way is a dubious practice anyway of course.Chrisnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-74406099230199110012009-08-23T05:45:31.000-07:002009-08-23T05:45:31.000-07:00@Chris: A neat idea, but my first thought is that ...@Chris: A neat idea, but my first thought is that without a bit of finesse that would break the mechanism for both cross-process *and* in-process interfaces.<br><br>The finesse required would be to find some way for in-process DLL's to share the special IID with the "container" process.<br><br>At least currently the mechanism works and can be used for all those situations where the application developer know's it is safe to do so. It's entirely up to them if they want to shoot themselves in the foot with it.<br><br>:)Jolyon Smithhttp://www.deltics.co.nz/blognoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-57140770670011136372009-08-24T02:26:47.000-07:002009-08-24T02:26:47.000-07:00That's ingenious. Very cool.That's ingenious. Very cool.Joe Whitehttp://blog.excastle.com/noreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-25225544167265909132009-08-26T21:36:28.000-07:002009-08-26T21:36:28.000-07:00Nice solution. I had mentioned the "special G...Nice solution. <br><br>I had mentioned the "special GUID" approach in a C++Builder article a few months ago (http://www.audacia-software.de/en/bcb/dynamic-cast-on-interfaces.htm#workaround). Of course, when implemented language integration in Delphi, it's way more elegant to use.<br><br>(I miss an equivalent "interface_cast" in the C++Builder RTL though.)<br><br>> Granted, this technique does have a couple of potential issues. If, for some reason, the user decides to manually implement QueryInterface and never calls TObject.GetInterface, then none of the above casting and “is” testing will work.<br><br>The same happens when using the Supports(TClass,TGUID) overload, which just calls TObject.GetInterface(), so it's not uncommon in the Delphi world.<br><br>(FWIW, I think class references and all their implications - virtual constructors, virtual class methods, the ability to determine the interfaces supported by a class without having an actual object etc. - are the greatest assets of the Delphi language.)Moritz Beutelnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-48698172736592640502010-09-01T06:12:03.000-07:002010-09-01T06:12:03.000-07:00[...] set this up to load itself into my class RTT...[...] set this up to load itself into my class RTTI inspector tool, and used Delphi 2010′s trick of casting an interface to an object, and it worked! And here’s what the object looks [...]TURBU Tech » Blog Archive » Under the hood of an anonymous methodhttp://tech.turbu-rpg.com/30/under-the-hood-of-an-anonymous-methodnoreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-44075541836411500572009-08-22T16:29:30.000-07:002009-08-22T16:29:30.000-07:00Nice to see this as part of the language.It is pos...Nice to see this as part of the language.<br><br>It is possible to achieve the same functionality in older Delphi versions as well, as I blogged about in 2004:<br><br>http://hallvards.blogspot.com/2004/07/hack-7-interface-to-object-in-delphi.html<br><br>My solution is a bit more hacky, though. ;)Hallvard Vassbotnhttp://hallvards.blogspot.com/noreply@blogger.comtag:blogger.com,1999:blog-2428374771421713311.post-92024483348172418032009-08-21T21:11:02.000-07:002009-08-21T21:11:02.000-07:00[...] — will be removed in Delphi 2010, a thought ...[...] — will be removed in Delphi 2010, a thought strengthened when I read Allen Bauer’s subsequent post on the not particularly gory details. The one quibble I have, though, is how the new feature is [...]Querying for the implementing object from an interface (1) « Delphi Havenhttp://delphihaven.wordpress.com/2009/08/22/querying-for-the-implementing-object-from-an-interface-1/noreply@blogger.com