comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Passing a String to a C/C++ Subprogram (Special Case)
Date: Tue, 15 Oct 2013 15:19:47 -0700 (PDT)
Date: 2013-10-15T15:19:47-07:00	[thread overview]
Message-ID: <6d603161-46a4-4d3a-a5b9-0babb9887619@googlegroups.com> (raw)
In-Reply-To: <9ee842b6-b053-4f4e-94df-66459ec1fb7c@googlegroups.com>

On Tuesday, October 15, 2013 3:13:09 PM UTC-6, Eryndlia Mavourneen wrote:
> On Tuesday, October 15, 2013 3:59:21 PM UTC-5, Jeffrey Carter wrote:
> 
> > On 10/15/2013 12:54 PM, Eryndlia Mavourneen wrote:
> 
> > 
> 
> > >  . . .
> 
> > 
> 
> > If I were doing this, I would wrap each in an Ada subprogram that ensures the 
> 
> > String will be passed correctly to C. Ultimately it will be less effort.
> 
> > 
> 
> 
> 
> Thanks, Jeff.  This could be a good way to manage things.  Unfortunately, I can not guarantee that I can perform a trim operation or that the last character is indeed not being used (for the placement of a nul).  I suppose I could create the wrapper, as you said, and copy the String (1 .. size) to a String (1 .. size + 1) and place a nul in the last character of the target string.  Of course, this does not add a lot of overhead for short strings, but it is a hard real-time system.
> 
> 
> 
> It sounds as if I need to get with my people and get a further, clear consensus about how this stuff is going to be used, in reality.
> 
> 
> 
> -- Eryndlia Mavourneen (KK1T)

Could you use an Ada 2012 subtype predicate? something like:

    Type Transport_String is array (1..31) of Character
        with Default_Component_Value => ASCII.NUL,
        Dynamic_Predicate => Transport_String(Transport_String'Last) = ASCII.NUL;

Actually I'm rather disappointed that there aren't static_predicates available for Arrays. I had hoped to, in my OpenGL binding, have something like the following available for the vector operations:

    Type RGBA is (Red, Blue, Green, Alpha); 
    Subtype RGB is RGBA range Red..Blue;
    
    --  Declare the general Vector-type for OprnGL which has vectors
    --  of three or four components of RGBA [A being optional], always
    --  starting with R.
    Type Float_Vector is array(RGBA range <>) of Float
        with Static_Predicate => Float_Vector'First = Red;



  reply	other threads:[~2013-10-15 22:19 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-15 19:54 Passing a String to a C/C++ Subprogram (Special Case) Eryndlia Mavourneen
2013-10-15 20:11 ` Adam Beneschan
2013-10-15 21:02   ` Eryndlia Mavourneen
2013-10-16  7:17     ` Dmitry A. Kazakov
2013-10-16 15:14       ` Jeffrey Carter
2013-10-16 17:32     ` Martin
2013-10-16 17:42       ` Eryndlia Mavourneen
2013-10-16 17:54         ` Martin
2013-10-16 18:13           ` Eryndlia Mavourneen
2013-10-16 19:40             ` Simon Wright
2013-10-16 20:02               ` Eryndlia Mavourneen
2013-10-19  2:11           ` Randy Brukardt
2013-10-16 19:11       ` Adam Beneschan
2013-10-16 21:31         ` Martin
2013-10-16 21:41           ` Adam Beneschan
2013-10-16 23:15             ` Martin
2013-10-15 20:59 ` Jeffrey Carter
2013-10-15 21:13   ` Eryndlia Mavourneen
2013-10-15 22:19     ` Shark8 [this message]
2013-10-16  0:00     ` Jeffrey Carter
2013-10-17  9:55     ` Georg Bauhaus
2013-10-16 20:17 ` sbelmont700
2013-10-16 20:48   ` Adam Beneschan
2013-10-17 13:05     ` Eryndlia Mavourneen
2013-10-17 13:58       ` sbelmont700
2013-10-17 16:28         ` Eryndlia Mavourneen
replies disabled

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