comp.lang.ada
 help / color / mirror / Atom feed
* Problems with the GNAT/C++ Interface.
@ 2001-11-02  3:13 Volkert
  2001-11-03  9:53 ` Volkert Barr
  0 siblings, 1 reply; 4+ messages in thread
From: Volkert @ 2001-11-02  3:13 UTC (permalink / raw)


Hello c.l.a!

Problem: I want an Ada Binding to the following recursive C++ 
class declaration:

class Chainable {

public:
       
  Chainable *next, *prev;
  
  Chainable();
  void reset();

};

The following Ada package Chainable_Type seams for me an 
obvious corresponding Ada type declaration:

package Chainable_Type is

   type Chainable;
   type Chainable_Access is access all Chainable'Class;

   type Chainable is tagged limited
      record
         next        : Chainable_Access;
         prev        : Chainable_Access;
      end record;

    ...

end Chainable_Type;

So far so good. Now i say the GNAT Compiler that the tagged type 
Chainable has to be mapped to the corresponding C++ class:

package Chainable_Type is

   type Chainable;
   type Chainable_Access is access all Chainable'Class; -- (*)

   type Chainable is tagged limited
      record
         next        : Chainable_Access;
         prev        : Chainable_Access;

         Vptr : Interfaces.CPP.Vtable_Ptr; -- new
      end record;

   pragma CPP_Class (Entity => Chainable); -- new

   ...

end Chainable_Type;

compiling this package gnat says: 
  
  error : pragma "Cpp_Class" applicable to a record, tagged record or
  record extension.

Ok, the problem seems the incomplete type declararion 
in line (*). Do is miss something?

Volkert



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problems with the GNAT/C++ Interface.
  2001-11-02  3:13 Problems with the GNAT/C++ Interface Volkert
@ 2001-11-03  9:53 ` Volkert Barr
  2001-11-03 20:39   ` Jerry van Dijk
  0 siblings, 1 reply; 4+ messages in thread
From: Volkert Barr @ 2001-11-03  9:53 UTC (permalink / raw)


I forgot to mention: We are using the GNAT 3.13p 
running on a Linux-Box.

With regards,
Volkert 

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - -
 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
- - - - - - - - - - - - - - - - - - - - - - - - - - -



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problems with the GNAT/C++ Interface.
  2001-11-03  9:53 ` Volkert Barr
@ 2001-11-03 20:39   ` Jerry van Dijk
  2001-11-05 15:24     ` Volkert Barr
  0 siblings, 1 reply; 4+ messages in thread
From: Jerry van Dijk @ 2001-11-03 20:39 UTC (permalink / raw)



The problem is that the compiler refuses the tagged declaration after the 
forwarding declaration. I'm no language lawyer, but normally I would expect
this to work here. Maybe it's a CPP interface limitation.

with Interfaces.CPP;

package Chainable_Type is

--   type Chainable;
--   type Chainable_Class_Access is access all Chainable'Class;

   type Chainable is tagged
      record
--           next   : Chainable_Class_Access;
--           prev   : Chainable_Class_Access;
         Vtable : Interfaces.CPP.Vtable_Ptr;
      end record;

   function Constructor return Chainable'Class;  -- default constructor
   procedure reset;

   pragma CPP_Class (Chainable);

   pragma Import (CPP, Constructor, "chainable");
   pragma CPP_Constructor (Constructor);

   pragma Import (CPP, reset);

end Chainable_Type;

-- 
--  Jerry van Dijk   | email: jvandyk@attglobal.net
--  Leiden, Holland  | web:   home.trouwweb.nl/Jerry



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problems with the GNAT/C++ Interface.
  2001-11-03 20:39   ` Jerry van Dijk
@ 2001-11-05 15:24     ` Volkert Barr
  0 siblings, 0 replies; 4+ messages in thread
From: Volkert Barr @ 2001-11-05 15:24 UTC (permalink / raw)


Jerry van Dijk wrote:
> 
> The problem is that the compiler refuses the tagged declaration after the
> forwarding declaration. I'm no language lawyer, but normally I would expect
> this to work here. Maybe it's a CPP interface limitation.
The GNAT Reference Manual says nothing about this 
kind of limitation. It looks like a GNAT bug to me.

With regards,
Volkert


-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - -
 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 *



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-11-05 15:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-02  3:13 Problems with the GNAT/C++ Interface Volkert
2001-11-03  9:53 ` Volkert Barr
2001-11-03 20:39   ` Jerry van Dijk
2001-11-05 15:24     ` Volkert Barr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox