Recent

Author Topic: Interfaces without CORBA, COM  (Read 1409 times)

XiJinping

  • New member
  • *
  • Posts: 9
Interfaces without CORBA, COM
« on: September 12, 2019, 07:30:32 am »
I tried interfaces in Free Pascal (delphi mode). And it seems that to compile a code with interfaces, I need to use directive
Code: Pascal  [Select][+][-]
  1. {$interfaces corba}
(or com, I suppose). As I understand, these interfaces add runtime support of CORBA (or COM) IInterface. But is there any way to use simple interface like in any other OOP language without CORBA, COM and similar which will be ordinal, existing at compile time only classical interface?

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Interfaces without CORBA, COM
« Reply #1 on: September 12, 2019, 09:11:58 am »
The naming of {$interfaces com} and {$interfaces corba} is a bit misleading. The main difference is that if {$interfaces com} is set then an interface inherits from IUnknown which provides the methods _AddRef, _Release and QueryInterface which in turn allows the compiler to provide automatic reference counting for such interfaces as well as support for the as and is operators. It's suggested to inherit from TInterfacedObject in such cases (though in no way required). "CORBA" interfaces on the other hand are raw interfaces. They don't inherit from anything and they don't provide reference counting, so you yourself are responsible that the class instance implementing the interfaces is freed at the end.

XiJinping

  • New member
  • *
  • Posts: 9
Re: Interfaces without CORBA, COM
« Reply #2 on: September 12, 2019, 09:52:03 am »
So is it a correct suggestion: CORBA interfaces are the same as plain usual interfaces in other languages and they have not any runtime overhead to support CORBA? I mean something like C++ "interfaces" (with pure virtual functions)...

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Interfaces without CORBA, COM
« Reply #3 on: September 12, 2019, 11:09:47 am »
Indeed. When interfaces were added, the COM IUnknown dependency was seen as a potential portability problem, so a more base interface type was added.

As Corba was seen as a potential substitute for COM on other targets it got that name, but there is no real connection.

XiJinping

  • New member
  • *
  • Posts: 9
Re: Interfaces without CORBA, COM
« Reply #4 on: September 14, 2019, 08:32:34 am »
Thanks a lot.

 

TinyPortal © 2005-2018