comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: type Foo_ptr in new void*;
Date: Sun, 29 Jul 2001 05:56:03 GMT
Date: 2001-07-29T05:56:03+00:00	[thread overview]
Message-ID: <TzN87.10780$Kd7.6085799@news1.rdc1.sfba.home.com> (raw)
In-Reply-To: 9k03jc$2me$2@news.tpi.pl

> Foo *foo_new(some args);
> void foo_delete(Foo*);
> void foo_some_operation(Foo*,some args);
> xyz foo_some_function(Foo*,some args);
>
> How should I typedef Foo* ?

  Presumably you "typedef Foo" in the C code in normal C style.
If you are wondering how to describe these C functions in Ada,
from the implementation advice in ARM B.3(67 .. 70), as given
at www.adapower.com:

4.An Ada in parameter of an access-to-object type with designated type
  T is passed as a t* argument to a C function, where t is the C type
  corresponding to the Ada type T.
5.An Ada access T parameter, or an Ada out or in out parameter of an
  elementary type T, is passed as a t* argument to a C function, where t
  is the C type corresponding to the Ada type T. In the case of an
  elementary out or in out parameter, a pointer to a temporary copy is
  used to preserve by-copy semantics.
6.An Ada parameter of a record type T, of any mode, is passed as a t*
  argument to a C function, where t is the C struct corresponding to the
  Ada type T.
7.An Ada parameter of an array type with component type T, of any
  mode, is passed as a t* argument to a C function, where t is the C
  type corresponding to the Ada type T.

So given
  type Foo is record ...
  type Foo_Pointer is access Foo;

> Foo *foo_new(some args);
    function foo_new(someargs : sometype) return Foo_Pointer;
> void foo_delete(Foo*);
    procedure foo_delete(Param : in out Foo);
> void foo_some_operation(Foo*,some args);
    procedure foo_some_operation(Param : in out Foo; someargs : in sometype);
> xyz foo_some_function(Foo*,some args);
    function foo_some_function(P : Foo_Pointer; someargs : sometype)
      return xyz;

There are other ways, for instance
    procedure foo_delete(Param : access Foo);



  reply	other threads:[~2001-07-29  5:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-29  4:31 type Foo_ptr in new void*; Tomasz Wegrzanowski
2001-07-29  5:56 ` tmoran [this message]
2001-07-29  8:57   ` Tomasz Wegrzanowski
2001-07-29 12:26     ` Marc A. Criley
2001-07-30  1:05       ` Tomasz Wegrzanowski
2001-07-30  1:20         ` tmoran
2001-07-30  2:09         ` James Rogers
2001-07-30  2:36           ` Warren W. Gay VE3WWG
2001-07-30  3:10             ` James Rogers
2001-07-31  2:14               ` Warren W. Gay VE3WWG
2001-07-31  1:21           ` Tomasz Wegrzanowski
2001-07-31  3:06             ` James Rogers
2001-07-31  5:02               ` Warren W. Gay VE3WWG
2001-07-31  7:22               ` Florian Weimer
2001-07-31  4:56           ` Darren New
2001-08-04  6:05             ` David Thompson
2001-08-05  2:27               ` Warren W. Gay VE3WWG
2001-07-29 13:40     ` Dale Stanbrough
2001-07-29 14:12 ` Florian Weimer
replies disabled

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