[fpc-pascal] Passing a CORBA interface as parameter
Sven Barth
pascaldragon at googlemail.com
Sat Dec 21 22:26:28 CET 2019
Am 21.12.2019 um 16:12 schrieb Adriaan van Os:
> Sven Barth via fpc-pascal wrote:
>>
>> The important difference in this regard between COM and CORBA
>> interfaces is that for CORBA interfaces the "guid" is a ShortString,
>> not a TGUID. Thus the compiler allows to convert a CORBA interface to
>> a ShortString. For TObject.GetInterface this works, because it has a
>> overload for ShortString. ;) (this is document here:
>> https://www.freepascal.org/docs-html/current/ref/refse47.html#x100-1220007.6
>
>
> Thanks, I hadn't seen that. Yes, this solves the problem. And this
> clarifies that the CORBA interface-identifying string doesn't need to
> be in GUID form, it can be something as simple as [ 'IMyInterface' ].
>
> I will note that the interface-identifier comparison below (in
> procedure TestInterfaceParameter) doesn't work without the explicit
> typecast from interface-identifier to "shortstring". Apparently, that
> typecast is implicit when passing an interface-identifier as actual
> parameter to a "shortstring" formal parameter.
>
> type
> InterfaceType = string[ 255];
>
> procedure TestInterfaceParameter
> ( const theInterface : InterfaceType);
> begin
> if theInterface = InterfaceType( ITestInterface1)
> then writeln
> ( 'theInterface = ITestInterface1')
> end;
>
> begin
> TestInterfaceParameter
> ( ITestInterface1)
> end.
That is because the compiler only implements the *assignment* of an
interface to a ShortString (or TGUID for COM interfaces), not the
comparison.
Regards,
Sven
More information about the fpc-pascal
mailing list