Problem in generated HPP file with Delphi interfaces inheriting from eachother


2004-09-09 02:47:17 AM
cppbuilder68
Hi
I'm the coordinator of the JVCL and in the course of writing some
components for Delphi and BCB, we used interfaces that inherit from each
other. We are having a problem with interfaces that have two levels of
interfaces: the generated hpp file is not even compiling, it is missing
a declaration. I managed to get down to a simple test case, here is the
Delphi code:
-------------------------------------------------
uses
Controls;
type
IA = interface
end;
IB = interface(IA)
end;
IC = interface(IB)
end;
TABCControl = class(TControl, IC, IB, IA)
end;
-------------------------------------------------
The generated HPP file contains this for the TABCControl class (extract):
-------------------------------------------------
private:
void *__IC; /* TestInterfaces::IC */
public:
operator IA*(void) { return (IA*)&__IB; }
operator IB*(void) { return (IB*)&__IC; }
operator IC*(void) { return (IC*)&__IC; }
-------------------------------------------------
And as you can see, the declaration of __IB is missing. This is clearly
wrong and I can't explain why it is doing this.
After experimenting a bit, I found a workaround that consists in making
IC inherit from IA instead of IB ( IC = interface(IA) ). Then the
generated HPP file contains this:
-------------------------------------------------
private:
void *__IC; /* TestInterfaces::IC */
void *__IB; /* TestInterfaces::IB */
public:
operator IA*(void) { return (IA*)&__IB; }
operator IB*(void) { return (IB*)&__IB; }
operator IC*(void) { return (IC*)&__IC; }
-------------------------------------------------
The header is usable, but there is a problem: The interface inheritance
is lost, and this can be a potential problem.
Does anyone have an idea as to why the generator is doing this? And best
of all, a solution to this?
If not, I'll add a new QC issue, even if I doubt it'll ever get fixed :-(
Thanks for your help
Olivier Sannier
JVCL Coordinator