From: Volkert Barr <barr@cs.tu-berlin.de>
Subject: Re: GNAT/Interfacing C++/Dispatching
Date: Wed, 14 Nov 2001 08:47:56 +0100
Date: 2001-11-14T07:47:56+00:00 [thread overview]
Message-ID: <3BF221AC.C6E2EC54@cs.tu-berlin.de> (raw)
In-Reply-To: u1yj2fpe4.fsf@gsfc.nasa.gov
Stephen Leake wrote:
>
> Volkert.Barr@freenet.de (Volkert) writes:
>
> > Hello c.l.a.
> >
> > Is this true, that dispatching works not across
> > languages boundaries when interfacing Ada 95 with C++
> > (using C++ Interface mechanisms of GNAT 3.13p.)?
>
> I have not done it, and I did not read your code in detail, but
> GNAT/g++ is supposed to allow full inter-operation between Ada tagged
> types and C++ classes. So keep trying!
Yes! Simple interfacing to C++ Classes seems to work well. But when is
comes to polymophism i run into trouble. Polymophism on Ada side works.
But,
dispatching calls starting at the c++ side do not propagate into the Ada
work.
I think, a C++ class does not know the dispatching table, which i have
to add to an
Ada tagged type. The c++ work does not know about overriden features
from
the Ada side.
Expample:
class A {
void f() {
this->g();
};
virtual void g() {
// do something
}
}
package A_Type is
-- corresponds to C++ Class A
type A is tagged
record
...
Vptr : Interfacing.CPP.Vtable_Ptr;
end record;
pragma CPP_Class ...
pragma CPP_Vtable ...
procedure f (Self : in A'Class);
pragma Import(CPP, f, ...);
procedure g (Self: in A);
pragma CPP_Virtual (g);
pragma Import(CPP, ...)
end A_Type;
-- extends A
package B_Type is
type B is new A with ...
procedure g (Self : in B); -- redefines g of A.
...
end B_Type;
If i override g() on the Ada side (with a new tagged type B_Type) and
i call f() on an object of Type T_type in the Ada world, i would expect
the call of the overridden g() method (primitive operation of tagged
type B_Type)
BTW: For all C++ virtual declared mothods i follow the gnat convention
to add a prama CPP_Virtual.
With regards,
Volkert
> > <snip>
>
> --
> -- Stephe
--
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Volkert Barr Institut fuer Softwaretechnik und
Theoretische Informatik
Fachgruppe Softwaretechnik * TU Berlin
email: barr@cs.tu-berlin.de
web: www.cs.tu-berlin.de/~barr
- - - - - - - - - - - - - - - - - - - - - - - - - - -
* macrosolutions to megaproblems *
prev parent reply other threads:[~2001-11-14 7:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-11 18:48 GNAT/Interfacing C++/Dispatching Volkert
2001-11-13 19:21 ` Stephen Leake
2001-11-13 22:09 ` Jerry van Dijk
2001-11-14 7:47 ` Volkert Barr [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox