comp.lang.ada
 help / color / mirror / Atom feed
From: Lucretia <laguest9000@googlemail.com>
Subject: Re: How to bind this properly, C ** which is an array
Date: Fri, 1 Mar 2019 05:59:32 -0800 (PST)
Date: 2019-03-01T05:59:32-08:00	[thread overview]
Message-ID: <ebe7b3e8-6703-41e0-a0ac-777b81ed9e45@googlegroups.com> (raw)
In-Reply-To: <q5bdim$4iv$1@dont-email.me>

On Friday, 1 March 2019 13:54:32 UTC, björn lundin  wrote:
> On 2019-03-01 14:48, Lucretia wrote:
> > Hi,
> > 
> > I'm trying to bind the following struct:
> > 
> > typedef struct mpc_ast_t {
> >   char *tag;
> >   char *contents;
> >   mpc_state_t state;
> >   int children_num;
> >   struct mpc_ast_t** children;
> > } mpc_ast_t;
> > 
> > I have this:
> > 
> >    type ASTs is
> >    record
> >       Tag                : C.Strings.chars_ptr;
> >       Contents           : C.Strings.chars_ptr;
> >       State              : States;
> >       Number_Of_Children : C.int;
> >       Children           : System.Address; --  Pointer to a pointer to an array of ASTs.
> >    end record with
> >      Convention => C;
> > 
> > Children needs to be accessed in code as a pointer to a pointer to an array of ASTs.
> > 
> > How do I best bind this thing? It's likely going to have to be converted from Address to a particular type using Unchecked_Conversion most likely.
> > 
> > Thanks,
> > Luke.
> > 
> 
> naïvly I would have tried something like
> 
>  type Ptr_To_Chars_Ptr is access all C.Strings.chars_ptr;
> 
>     type ASTs is
>     record
>        Tag                : C.Strings.chars_ptr;
>        Contents           : C.Strings.chars_ptr;
>        State              : States;
>        Number_Of_Children : C.int;
>        Children           : Ptr_To_Chars_Ptr;
>     end record with
>       Convention => C;

But it's not a chars_ptr, it's an ASTs_Ptr_Ptr, effecitvely.


  reply	other threads:[~2019-03-01 13:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-01 13:48 How to bind this properly, C ** which is an array Lucretia
2019-03-01 13:54 ` Björn Lundin
2019-03-01 13:59   ` Lucretia [this message]
2019-03-01 14:02 ` Dmitry A. Kazakov
2019-03-01 14:20   ` Lucretia
2019-03-01 19:57 ` Per Sandberg
2019-03-01 20:25   ` Lucretia
2019-03-01 22:02     ` Per Sandberg
2019-03-01 23:42       ` Lucretia
replies disabled

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