----- Original Message -----
From: "Florian Klaempfl"
Show quoted text 7 lines
> For example "DECLARE_INTERFACE_(IClassFactory, IUnknown)" in C++ is expanded
> to "struct FAR IClassFactory : public IUnknown", so really public parts of
> VMT (with positive offset) are always [should be] compatible. Surely we can't
> talk about FULL compatibility of classes, but exposing "interfaces" to other
> languages should be possible.
Use raw interfaces for such a purpose.
Problem is here:
Show quoted text 7 lines
> Problem here is what I'm forced to use some these COM incompatibe
> "interfaces" exposed by MS programmers in DirectX API. These interfaces look
> like real COM interfaces but without IUnknown embedded. In Delphi I can use
> them just by creating abstract class just like in C++, but in FPC it's
> impossible to do so. And I've seen other reports when people were forced to
> use similiar cripped interfaces exposed by C++ programmers. So it's the real
> problem not just artificial one.
Delphi and FreePascal simplest interfaces already includes IUnknown. So using raw interfaces is incompatible here too.
Actually I have working solution and it's based as you hinted on interface feature of object pascal, but after quering interface a have to patch object instance so pointer to VMT start pointing above IUnknown part of it. Something like this:
var
AllocI: ID3DXAllocateHierarchy_Interface;
begin
AllocI:= pAlloc;
// Now patch interface VMT - so it will point to truncated interface (without
IUnknown)
Inc(PInteger(AllocI)^, $C);
// Call C++ function and pass to it our "special" interface
Result := D3DXLoadMeshHierarchyFromX_FPC_{$}(Filename, MeshOptions,
pD3DDevice, AllocI, pUserDataLoader, ppFrameHierarchy, ppAnimController);
Dec(PInteger(AllocI)^, $C); // Patch interface VMT - BACK
end;
But I really want FPC be compatible with Delphi in this situation.