From: Daniel R. <da...@ac...> - 2011-03-30 17:20:12
|
X-UCS- Spam Mail 2 Hi, Just to clarify a few things with relations to Delphi. At March-30-11, 12:33 PM, Adriano dos Santos Fernandes wrote: > On 30-03-2011 08:04, Vlad Khorsun wrote: >> >> With Delphi you will just use IAttachment, without SmartPtr, as Delphi's "interface" have >> built-in compiler magic to work with reference counts. >> > AFAIK, this is not how it works. > Delphi "interface" has nothing directly related with refcount. Actually, Vlad is correct. Here's what is written in Delphi's help for IInterface: "IInterface introduces the QueryInterface method, which is useful for discovering and using other interfaces implemented by the same object. IInterface also introduces the reference counting methods, _AddRef and _Release. The Delphi compiler automatically provides calls to these methods when interfaces are used. The TInterfacedObject class is provided as a base class for objects that implement interfaces. Use of TInterfacedObject is not mandatory, but will often be easier than designing an implementer class from scratch." > Refcount comes on when IInterface is used, but IInterface is about COM > (has queryInterface). I don't think you can make our interfaces to work > with IInterface, so you won't get RAII with Delphi and our interfaces. You are correct when you say "Refcount comes on when IInterface is used". But, Delphi's IInterface has nothing to do with COM, as I can use IInterface in an application, without ever using COM. And, there are some that was able to implement RAII in Delphi, with the use of IInterface (I did a search on Google). -- Best regards, Daniel Rail Senior Software Developer ACCRA Solutions Inc. (www.accra.ca) ACCRA Med Software Inc. (www.filopto.com) |