[fpc-pascal]Mapping Object Pascal Classes to C++ Classes
memsom at interalpha.co.uk
memsom at interalpha.co.uk
Thu Nov 14 14:34:34 CET 2002
> >I think it's the way Delphi is implemented. It also works when the DLL is
> >compiled with MinGW, which certainly isn't Borland compatible in the same way
> >as BC++ is. I just tested it. Further, the C++ class doesn't have to be
> >abstract as Rudy suggests, because I altered it to return the 'TestClass'
> >in my example, and it still works.
You can actually do what you like to the Delphi side, and Delphi doesn't seem
to worry. If you alter the order of the virtual methods on C++, the Delphi side
will call the wrong method. It's not doing anything clever, it is litterally
mapping the VMT directly on to the C++ VMT. I think the FPC problem is possibly
because FPC either doesn't do the Delphi 'hack' Rudy mentions - moving all
virtual methods from TObject into a negative offset when compared to the start
of the VMT as the instance sees it, or maybe the VMT just isn't compatible.
Remember this is just in Delphi 5... I'm wondering if Delphi 4 or 6 will have
such a success.
> Hmmm, if I find time I'll look into it :/
If you could generate Delphi compatible VMT, would that enable FPC classes to
be compiled and used by Delphi, if there was a common Object format. Okay, I
know DCU is a bit of a non standard, but supporting some kind of DLL based
solution could be cool.
If you could get the direct VMT mapping working, extending the ObjFPC mode to
include a CPPClass as well as Class would be cool. The compiler does the
gruntwork, so long as the special C++ format is followed...
> BeOS support for the LCL :) ?
Yeah. That is what I want. The others, Olivier especially, are mapping Pascal
Classes to C++ Classes of the BeAPI. Whilst this helps people who program in
BeOS already, it is a bit of a non starter for those who want to use a VCL
alike. I think there is room for both approaches though, which is why we joined
together in the first place.
> >Anyway, with the new GCC3.x 'universal' ABI, shouldn't it all become a bit
> >easier soon? :-)
>
> Yepp, but when we implement this, the GCC3 must be stabilized first.
See you sometime in 2010 then ;-)
Matt
---------------------------------------------
This message was sent using Mistral WebMail.
http://www.mistral.co.uk/
More information about the fpc-pascal
mailing list