comp.lang.ada
 help / color / mirror / Atom feed
* SGI inheriting C++ classes ...
@ 1994-11-17 21:46 Bennett, Chip (KTR) ~U
  1994-11-18  2:47 ` David Weller
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Bennett, Chip (KTR) ~U @ 1994-11-17 21:46 UTC (permalink / raw)


Recently, in info-ada, David Weller made a reference to "... SGI's cool
demonstration of inheriting from C++ classes ...", that from the context, I
assume means inherited by Ada 9X.

What is that all about.  Did SGI demo the ability to fully inherit C++
classes by Ada 9X at TRI-Ada?

Thanks,
*****************************************************************
* Chip Bennett, GDE Systems Inc | BennettC@j64.stratcom.af.mil  *
* USSTRATCOM/J64213             | Voice (402)294-7360           *
* 901 SAC Blvd, Suite 2B24      | FAX   (402)294-7912           *
* Offutt AFB, NE 68113-6600     | Proud member of Team Ada      *
* Opinions expressed here are my own _so_,  TTFWTW              *
*****************************************************************



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

* Re: SGI inheriting C++ classes ...
  1994-11-17 21:46 SGI inheriting C++ classes Bennett, Chip (KTR) ~U
@ 1994-11-18  2:47 ` David Weller
  1994-11-18 23:09 ` Tom Quiggle
  1994-11-19  7:12 ` Robert Dewar
  2 siblings, 0 replies; 8+ messages in thread
From: David Weller @ 1994-11-18  2:47 UTC (permalink / raw)


In article <2ECBCF25@SMTPGATE2.STRATCOM.AF.MIL>,
Bennett, Chip (KTR) ~U <BennettC@J64.STRATCOM.AF.MIL> wrote:
>Recently, in info-ada, David Weller made a reference to "... SGI's cool
>demonstration of inheriting from C++ classes ...", that from the context, I
>assume means inherited by Ada 9X.
>
>What is that all about.  Did SGI demo the ability to fully inherit C++
>classes by Ada 9X at TRI-Ada?
>

Yes!  YOu must have missed that demo :-)  That was The Big Brag in
the SGI booth (with words backed up by deeds, in the traditional SGI
fashion :-)
.


-- 
Proud (and vocal) member of Team Ada! (and Team OS/2)        ||This is not your
   	      Ada -- Very Cool.  Doesn't Suck.               ||  father's Ada 
For all sorts of interesting Ada tidbits, run the command:   ||________________
"finger dweller@starbase.neosoft.com | more" (or e-mail with "finger" as subj.)
      Just another dull, stodgy, non-creative developer who uses Ada.



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

* Re: SGI inheriting C++ classes ...
  1994-11-17 21:46 SGI inheriting C++ classes Bennett, Chip (KTR) ~U
  1994-11-18  2:47 ` David Weller
@ 1994-11-18 23:09 ` Tom Quiggle
  1994-11-19  5:13   ` Cyrille Comar
  1994-11-19  7:12 ` Robert Dewar
  2 siblings, 1 reply; 8+ messages in thread
From: Tom Quiggle @ 1994-11-18 23:09 UTC (permalink / raw)



In article <2ECBCF25@SMTPGATE2.STRATCOM.AF.MIL>, "Bennett, Chip writes:
> Recently, in info-ada, David Weller made a reference to "... SGI's cool
> demonstration of inheriting from C++ classes ...", that from the context, I
> assume means inherited by Ada 9X.

Your assumption is basically correct.

> What is that all about.  Did SGI demo the ability to fully inherit C++
> classes by Ada 9X at TRI-Ada?

Let me first respond to the general issue of Ada9x interfacing to C++ classes,
then describe the specifics of the demo we were showing at TriAda.

-------------------

As has been widely publicized, SGI's Ada9x product strategy is based on
a commercially supported version of the GNAT, integrated with SGI's
multilinguial software development environment.  Following detailed
design discussions with SGI, the GNAT team (and specifically Cyrille
Comar) has added several implementation-defined pragmas to the GNAT to
facilitate interfacing to C++ classes from Ada.

C++ classes with virtual member functions are represented as Ada9x
tagged types.  With pragma advice, the GNAT will layout the tagged type to 
exactly correspond to the layout of the C++ class (including the C++ virtual
function table).  The C++ member functions,virtual and non-virtual, are
imported in the usual manner with Pragma Import.  For virtual member functions,
there is an additional pragma to specify which vtable pointer and index to
use in generating dispatching calls (I say which vtable pointer because in
the case of a C++ class with multiple base classes, you may have more than
one vtable pointer to dispatch off of).

The net result is that C++ classes and objects may be directly imported
into Ada9x programs.  In addition to directly using a C++ class, an Ada
application can derive off of a C++ class and:

   - add a record extension part  (i.e. add new member data)
   - add new primitive oparations (i.e. add new member functions)
   - override C++ virtual functions with Ada implementations

Objects of a C++ class type (or type derived from such a type) may be declared
in Ada and operated on by either Ada subprograms or C++ member functions.  Since
such objects share a common virtual-function/dispatch table, either language can
dispatch calls to operations defined in the other language.  All of this has
been demonstrated with both SGI's C++ compiler and the GNU C++ compiler (G++).

To aid in building Ada interfaces to C and C++ libraries, SGI is
developing a tool capable of reading C/C++ header files and generating
corresponding Ada package specifications.  The binding generator
produces the appropriate implementation defined pragmas for specifying
the layout of C++ classes, as well as the necessary mangled linknames
for C++ member functions.  The tool will also drop out-of-line bodies for
in-line member functions (which have no callable body in a the compiled C++
object code), and perform other minor miracles.     :-)

--------------

All of which leads me to Puck...

SGI offers OpenInventor, an object-oriented, interactive, 3D modeling and
rendering library consisting of ~200 classes in as many header files.  The
inventor team produced a superb C++ example program in the form of an
interactive game resembling ice hocky.

In the week preceding TriAda (actually in just over 4 days), I
translated the main program of Puck to Ada9x, and generated slightly
more than 38000 lines of Ada bindings to (a subset) of the OpenInventor
header files needed by Puck.  The result was a mixed language
application in which the highest level objects in the system were
declared in Ada, and implemented in C++.  In this specific example, no
derivation (subclassing) was performed on the Ada side.  As time
permits, and I rewrite more of the Puck application code in Ada, this
will change.

> Thanks,

No problem.  If you have further questions, feel free to contact me
directly.

> *****************************************************************
> * Chip Bennett, GDE Systems Inc | BennettC@j64.stratcom.af.mil  *
> * USSTRATCOM/J64213             | Voice (402)294-7360           *
> * 901 SAC Blvd, Suite 2B24      | FAX   (402)294-7912           *
> * Offutt AFB, NE 68113-6600     | Proud member of Team Ada      *
> * Opinions expressed here are my own _so_,  TTFWTW              *
> *****************************************************************

------
Tom Quiggle                                                quiggle@sgi.com
Silicon Graphics					   (415) 390 - 2884



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

* Re: SGI inheriting C++ classes ...
  1994-11-18 23:09 ` Tom Quiggle
@ 1994-11-19  5:13   ` Cyrille Comar
  0 siblings, 0 replies; 8+ messages in thread
From: Cyrille Comar @ 1994-11-19  5:13 UTC (permalink / raw)


quiggle@lovelace.wpd.sgi.com (Tom Quiggle) writes:
: 
: As has been widely publicized, SGI's Ada9x product strategy is based on
: a commercially supported version of the GNAT, integrated with SGI's
: multilinguial software development environment.  Following detailed
: design discussions with SGI, the GNAT team (and specifically Cyrille
: Comar) has added several implementation-defined pragmas to the GNAT to
: facilitate interfacing to C++ classes from Ada.

Thank's Tom for the reference.  I wrote a tiny document explaining the basic
syntax and semantic of those implementation-defined pragmas. This document is
ftp-available along with the slides of my presentation about the implementation
of tagged types in GNAT at Tri-Ada'94 Fell free to pick them up in 
   pub/gnat/docs (cs.nyu.edu)
-- 
------------------------------------------------------------------------
Cyrille Comar,                                  E-mail: comar@cs.nyu.edu
Gnat Project                                    US phone: (212) 998-3489




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

* Re: SGI inheriting C++ classes ...
  1994-11-17 21:46 SGI inheriting C++ classes Bennett, Chip (KTR) ~U
  1994-11-18  2:47 ` David Weller
  1994-11-18 23:09 ` Tom Quiggle
@ 1994-11-19  7:12 ` Robert Dewar
  1994-11-21 15:09   ` R. William Beckwith
  2 siblings, 1 reply; 8+ messages in thread
From: Robert Dewar @ 1994-11-19  7:12 UTC (permalink / raw)


"Did SGI demonstrate ..."

GNAT supports fully interoperable dispatching and inheritance between GNAT
Ada and C++. FOr example, you can import a C++ class, then extend it on
the Ada side, using dynamic dispatching with it, and then reexport the
extended version back to C++. THe interface is procedurable allowing
customization for all C++ compilers we know about.

SGI has written an automatic binding generator that uses the GNAT features
(consisting of a set of specialized pragmas) to generate Ada bindings from
C++.

The demo at Tri-Ada involved the semi-automatic translation of some 40,000
lines of C++ headers from the inventor toolset. The actual demo was a 200
line main program, driving, via about 30,000 lines of generated CAda
bindings, an existing C++ code to implement the Puck game.

It's all in a quite preliminary stage, and this was definitely a demo, but
GI fully intends to develop this capabality.

P.S. the invenrot demo was completed in a period of 4 days.




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

* Re: SGI inheriting C++ classes ...
  1994-11-19  7:12 ` Robert Dewar
@ 1994-11-21 15:09   ` R. William Beckwith
  1994-11-22 14:24     ` Robert Dewar
  0 siblings, 1 reply; 8+ messages in thread
From: R. William Beckwith @ 1994-11-21 15:09 UTC (permalink / raw)


Robert Dewar (dewar@cs.nyu.edu) wrote:

: The demo at Tri-Ada involved the semi-automatic translation of some 40,000
: lines of C++ headers from the inventor toolset. The actual demo was a 200
: line main program, driving, via about 30,000 lines of generated CAda
: bindings, an existing C++ code to implement the Puck game.

Not to take anything away from a very cool demo, but ...

A 200 line main program can't `drive' 30,000 lines of bindings since it
can make no more that 200 calls to the binding.

... Bill



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

* Re: SGI inheriting C++ classes ...
  1994-11-21 15:09   ` R. William Beckwith
@ 1994-11-22 14:24     ` Robert Dewar
  1994-11-23 17:42       ` Tom Quiggle
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Dewar @ 1994-11-22 14:24 UTC (permalink / raw)


Bill, regarding your "no more than 200 calls". You have a very peculiar
idea of what is going on. The bindings are not just a bunch of procedure
calls that are independent and may or may not be used.

For each C++ class that is duplicated exactly on the Ada side, there is
a large body of C++, and hence Ada 9X binding, code that describes the
structure of the class. When you use such a class in Ada 9X, you may not
explicitly be calling all the member functions, but they all have to be
properly declared and understood by the 9X binding, so that the data
structures, including dispatching tables, are layed out right.

Thus a single call, or declaration of an object, in the 9X code, can
very well involve hundreds of lines of interface code, which must be
exactly right for the single call to work right.




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

* Re: SGI inheriting C++ classes ...
  1994-11-22 14:24     ` Robert Dewar
@ 1994-11-23 17:42       ` Tom Quiggle
  0 siblings, 0 replies; 8+ messages in thread
From: Tom Quiggle @ 1994-11-23 17:42 UTC (permalink / raw)



In article <3asuuv$blb@gnat.cs.nyu.edu>, dewar@cs.nyu.edu writes:
> Bill, regarding your "no more than 200 calls". You have a very peculiar
> idea of what is going on. The bindings are not just a bunch of procedure
> calls that are independent and may or may not be used.
> 
> For each C++ class that is duplicated exactly on the Ada side, there is
> a large body of C++, and hence Ada 9X binding, code that describes the
> structure of the class. When you use such a class in Ada 9X, you may not
> explicitly be calling all the member functions, but they all have to be
> properly declared and understood by the 9X binding, so that the data
> structures, including dispatching tables, are layed out right.
> 
> Thus a single call, or declaration of an object, in the 9X code, can
> very well involve hundreds of lines of interface code, which must be
> exactly right for the single call to work right.

Robert is exactly correct.  For example, the single 'Player' class that
implements each of the two players in the game is defined in terms of 18
other classes, and '#include's 20 header files (each of which includes
several other header files).  In order to use the Player class, we need
to correctly represent it in Ada.  When you look at the transitive closure
of all the dependent declarations, you wind up with a large number of Ada
specifications.

------
Tom Quiggle                                                quiggle@sgi.com
Silicon Graphics					   (415) 390 - 2884



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

end of thread, other threads:[~1994-11-23 17:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1994-11-17 21:46 SGI inheriting C++ classes Bennett, Chip (KTR) ~U
1994-11-18  2:47 ` David Weller
1994-11-18 23:09 ` Tom Quiggle
1994-11-19  5:13   ` Cyrille Comar
1994-11-19  7:12 ` Robert Dewar
1994-11-21 15:09   ` R. William Beckwith
1994-11-22 14:24     ` Robert Dewar
1994-11-23 17:42       ` Tom Quiggle

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