[fpc-pascal] Mozilla XPCOM

José Mejuto joshyfun at gmail.com
Mon Jun 7 20:04:21 CEST 2010


Hello FPC-Pascal,

Monday, June 7, 2010, 6:41:21 PM, you wrote:

>> Yes, but removing the "const" still passes the parameter as 16 bytes,
>> and defining it as "var" creates problems when passing an interface to
>> extract the GUID instead passing the interface reference. Anyway most
>> of this problems are quite easy to be bypassed with some source
>> changes which still remain compatible between windows and linux.
JM> In such cases, the parameter should be a pointer. It's
JM> probably "const" for Delphi compatibility (which probably
JM> guarantees passing const records by reference for safecall, and
JM> hence FPC probably also does on platforms that support it).

The interfaces has a TGUID special handling when passing an interface
definition as parameter:

interface MyInterfaceDefinition
  procedure Something(const X: TGUID);

when calling this method:

var
  MyIntf: MyInterfaceDefinition;
begin
  MyInft.Something(MyIntf);
end;

This code is replaced by the MyInterfaceDefinition GUID, so in this
case PGUID is not valid because @MyInft does not point to the same
PGUID information. I think it is an "on the fly" compiler trick to
simplify GUID operations, which are "easy" to solve using the consts
with TGUID values usually present in headers, but as they are not a
must some problems when porting could happend.

>> That looks as a hard job :( I can only help testing XPCOM in both
>> windows and linux, but I doubt that I can help in the compiler side :(
JM> You should file a bug report.

I'll file one ASAP. Thank you.

-- 
Best regards,
 José




More information about the fpc-pascal mailing list