From: Adriano d. S. F. <adr...@gm...> - 2011-03-30 17:33:43
|
On 30-03-2011 14:16, Daniel Rail wrote: > 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 is a "interface" with three methods. This interface is understood by the Delphi compiler and makes RAII works. > "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). > And IInterface is incompatible with our Interface class, cause our don't have QueryInterface. So our Interface must be declared as: Interface = interface ... end; and not: Interface = interface(IInterface) ... end; Hence you can't make the Firebird objects uses Delphi's RAII. Adriano |