comp.lang.ada
 help / color / mirror / Atom feed
* Interfaces.C.Strings
@ 2002-06-01 12:34 Philippe Tarroux
  2002-06-03 16:22 ` Interfaces.C.Strings sk
  2002-06-03 19:09 ` Interfaces.C.Strings Jeffrey Carter
  0 siblings, 2 replies; 3+ messages in thread
From: Philippe Tarroux @ 2002-06-01 12:34 UTC (permalink / raw)


I got a problem in interfacing a TclTk function with Ada:

This function returns a Chars_Ptr (Char *) type which is a pointer to a
char_array supposed to be nul terminated. In the present case, this array
contains pixel values and probably several nul values. The array I get from
the Interfaces.C.Strings.Value procedure is truncated to the first nul and I
was unable to find a way to bypass this limitation.

I came to the conclusion that there is no way in Ada to get an array pointed
by a Chars_Ptr  and containing nul values?

Am I wrong?





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

* Re: Interfaces.C.Strings
  2002-06-01 12:34 Interfaces.C.Strings Philippe Tarroux
@ 2002-06-03 16:22 ` sk
  2002-06-03 19:09 ` Interfaces.C.Strings Jeffrey Carter
  1 sibling, 0 replies; 3+ messages in thread
From: sk @ 2002-06-03 16:22 UTC (permalink / raw)


Hi,

Firstly, have you looked at the GtkAda stuff ?

If this still doesn't meet your needs, you 
might try "re-modeling" the arrays of pixel
values and try using the techniques described
in the previous c.l.a thread,

"C lib returns char** - How in ADA?"

The "re-modeling" is that you are not really
pointing to an array of null terminated
strings, you are pointing to an array of
something else so don't try to pretend that
they are strings.

-- 
-------------------------------------
-- Merge vertically for real address
-------------------------------------
s n p @ t . o
 k i e k c c m
-------------------------------------



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

* Re: Interfaces.C.Strings
  2002-06-01 12:34 Interfaces.C.Strings Philippe Tarroux
  2002-06-03 16:22 ` Interfaces.C.Strings sk
@ 2002-06-03 19:09 ` Jeffrey Carter
  1 sibling, 0 replies; 3+ messages in thread
From: Jeffrey Carter @ 2002-06-03 19:09 UTC (permalink / raw)


Philippe Tarroux wrote:
> 
> This function returns a Chars_Ptr (Char *) type which is a pointer to a
> char_array supposed to be nul terminated. In the present case, this array
> contains pixel values and probably several nul values. The array I get from
> the Interfaces.C.Strings.Value procedure is truncated to the first nul and I
> was unable to find a way to bypass this limitation.

The main problem here is that "char*" means a lot of different things in
C, and some of them have nothing to do with characters or strings. This
function is an example of that. The return value is a pointer to an
array of what are referred to in Ada as Storage_Elements (type
System.Storage_Elements.Storage_Element), usually bytes, not to a
NUL-terminated string. Thus, using Value is probably inappropriate,
although a version of Value that takes a Length parameter may do what
you want.

In general, though, you might want to define a C-convention access type
designating System.Storage_Elements.Storage_Array (or even better a
suitably constrained subtype) and import a function returning that
access type.

-- 
Jeff Carter
"Nobody expects the Spanish Inquisition!"
Monty Python's Flying Circus



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

end of thread, other threads:[~2002-06-03 19:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-01 12:34 Interfaces.C.Strings Philippe Tarroux
2002-06-03 16:22 ` Interfaces.C.Strings sk
2002-06-03 19:09 ` Interfaces.C.Strings Jeffrey Carter

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