[fpc-pascal] Passing a CORBA interface as parameter

Zamrony P. Juhara zamronypj at yahoo.com
Sat Dec 21 02:16:51 CET 2019

If you need to know if an instance implement certain interface, you can use is operator
if anInstance is IInterface1 thenbegin     end;

Zamrony P. Juhara 
  On Sat, Dec 21, 2019 at 0:25, Adriaan van Os<fpc at microbizz.nl> wrote:   
I would like to pass a CORBA interface-type as parameter and test for equality, So, for example, I have

{$mode objfpc}
{$interfaces corba}

    IMyInterface = Interface
        [  '{34aad6d0-5884-4143-97c2-b6e330305ae3}']

        Function MyFunc : Integer;

Now I can pass IMyInterface to TObject.GetInterface as the first parameter, which is of type TGuid 
in the declaration.

However, if I use the same TGuid parameter type in my own procedure

    procedure TestInterfaceParameter
          ( const theInterface            : TGuid);
          if IsEqualGUID
          ( theInterface, ITestInterface1)
            then writeln
              ( 'theInterface = ITestInterface1')

then I run into the problem that IMyInterface is accepted as actual parameter of 
TestInterfaceParameter and of IsEqualGUID only if IMyInterface inherits from IUnknown (which I 
certainly don't want, as it is reference counted). Strangely, TObject.GetInterface does accept 
IMyInterface as a parameter. So where is the difference ? Is there some compiler magic involved in 
TObject.GetInterface ?


Adriaan van Os

fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20191221/7c18f0b7/attachment.html>

More information about the fpc-pascal mailing list