* interfaces.C - Import struct
@ 2005-03-13 7:53 Jean-Baptiste CAMPESATO
2005-03-13 9:05 ` Martin Krischik
0 siblings, 1 reply; 5+ messages in thread
From: Jean-Baptiste CAMPESATO @ 2005-03-13 7:53 UTC (permalink / raw)
Hello;
In a C Header file i've got this struct :
typedef struct {
void (*driver_setpixel_func) (int, int, int);
int (*driver_getpixel_func) (int, int);
void (*driver_hline_func) (int, int, int, int);
void (*driver_fillbox_func) (int, int, int, int, int);
void (*driver_putbox_func) (int, int, int, int, void *, int);
void (*driver_getbox_func) (int, int, int, int, void *, int);
void (*driver_putboxmask_func) (int, int, int, int, void *);
void (*driver_putboxpart_func) (int, int, int, int, int, int, void *,
int, int);
void (*driver_getboxpart_func) (int, int, int, int, int, int, void *,
int, int);
void (*driver_copybox_func) (int, int, int, int, int, int);
} framebufferfunctions;
And with the package interfaces.C i wan't to import this structure as
"type framebufferfunctions is record" but i don't know the equivalent of a
pointer for a function in Ada, and if i must import all the possible
function.
And c2ada doesn't work under SlackwareLinux 10.1, Debian Sarge, Fedora2.
I've a lot of error when i compile.
Somebody can help please ? (use c2ada on vgagl.h or explicate me how
translat this struct)
Thanks
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: interfaces.C - Import struct
2005-03-13 7:53 interfaces.C - Import struct Jean-Baptiste CAMPESATO
@ 2005-03-13 9:05 ` Martin Krischik
2005-03-13 11:06 ` Jean-Baptiste CAMPESATO
2005-03-13 12:31 ` Simon Wright
0 siblings, 2 replies; 5+ messages in thread
From: Martin Krischik @ 2005-03-13 9:05 UTC (permalink / raw)
Jean-Baptiste CAMPESATO wrote:
> Hello;
> In a C Header file i've got this struct :
> typedef struct {
> void (*driver_setpixel_func) (int, int, int);
type driver_setpixel_type
is access procedure (
A : Interfaces.C.int;
B : Interfaces.C.int;
C : Interfaces.C.int);
pragma Convetion (C, driver_setpixel_type);
> int (*driver_getpixel_func) (int, int);
> void (*driver_hline_func) (int, int, int, int);
> void (*driver_fillbox_func) (int, int, int, int, int);
> void (*driver_putbox_func) (int, int, int, int, void *, int);
> void (*driver_getbox_func) (int, int, int, int, void *, int);
> void (*driver_putboxmask_func) (int, int, int, int, void *);
> void (*driver_putboxpart_func) (int, int, int, int, int, int, void
> *,
> int, int);
> void (*driver_getboxpart_func) (int, int, int, int, int, int, void
> *,
> int, int);
> void (*driver_copybox_func) (int, int, int, int, int, int);
> } framebufferfunctions;
>
> And with the package interfaces.C i wan't to import this structure as
> "type framebufferfunctions is record" but i don't know the equivalent of a
> pointer for a function in Ada, and if i must import all the possible
> function.
> And c2ada doesn't work under SlackwareLinux 10.1, Debian Sarge, Fedora2.
> I've a lot of error when i compile.
> Somebody can help please ? (use c2ada on vgagl.h or explicate me how
> translat this struct)
You will need to define access to procedure type for each produre - as shown
above. And you don't need to import the functions.
With Regards
Martin
BTW: do you know about:
typedef void driver_setpixel_type (int, int, int);
Looks much nicer then the (*xxxx) stuff - It is also easer to type: just
copy the original prototype and replace extern/static with typedef - done.
And the code would become symetic to the Ada code making maintance easier.
--
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: interfaces.C - Import struct
2005-03-13 9:05 ` Martin Krischik
@ 2005-03-13 11:06 ` Jean-Baptiste CAMPESATO
2005-03-13 12:31 ` Simon Wright
1 sibling, 0 replies; 5+ messages in thread
From: Jean-Baptiste CAMPESATO @ 2005-03-13 11:06 UTC (permalink / raw)
Le Sun, 13 Mar 2005 10:05:35 +0100, Martin Krischik a ᅵcritᅵ:
> Jean-Baptiste CAMPESATO wrote:
>
>> Hello;
>> In a C Header file i've got this struct :
>> typedef struct {
>> void (*driver_setpixel_func) (int, int, int);
>
> type driver_setpixel_type
> is access procedure (
> A : Interfaces.C.int;
> B : Interfaces.C.int;
> C : Interfaces.C.int);
>
> pragma Convetion (C, driver_setpixel_type);
>
>> int (*driver_getpixel_func) (int, int);
>> void (*driver_hline_func) (int, int, int, int);
>> void (*driver_fillbox_func) (int, int, int, int, int);
>> void (*driver_putbox_func) (int, int, int, int, void *, int);
>> void (*driver_getbox_func) (int, int, int, int, void *, int);
>> void (*driver_putboxmask_func) (int, int, int, int, void *);
>> void (*driver_putboxpart_func) (int, int, int, int, int, int, void
>> *,
>> int, int);
>> void (*driver_getboxpart_func) (int, int, int, int, int, int, void
>> *,
>> int, int);
>> void (*driver_copybox_func) (int, int, int, int, int, int);
>> } framebufferfunctions;
>>
>> And with the package interfaces.C i wan't to import this structure as
>> "type framebufferfunctions is record" but i don't know the equivalent of a
>> pointer for a function in Ada, and if i must import all the possible
>> function.
>> And c2ada doesn't work under SlackwareLinux 10.1, Debian Sarge, Fedora2.
>> I've a lot of error when i compile.
>> Somebody can help please ? (use c2ada on vgagl.h or explicate me how
>> translat this struct)
>
> You will need to define access to procedure type for each produre - as shown
> above. And you don't need to import the functions.
>
> With Regards
>
> Martin
>
> BTW: do you know about:
>
> typedef void driver_setpixel_type (int, int, int);
>
> Looks much nicer then the (*xxxx) stuff - It is also easer to type: just
> copy the original prototype and replace extern/static with typedef - done.
> And the code would become symetic to the Ada code making maintance easier.
Thanks a looot :)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: interfaces.C - Import struct
2005-03-13 9:05 ` Martin Krischik
2005-03-13 11:06 ` Jean-Baptiste CAMPESATO
@ 2005-03-13 12:31 ` Simon Wright
2005-03-13 17:27 ` Martin Krischik
1 sibling, 1 reply; 5+ messages in thread
From: Simon Wright @ 2005-03-13 12:31 UTC (permalink / raw)
Martin Krischik <martin@krischik.com> writes:
> BTW: do you know about:
>
> typedef void driver_setpixel_type (int, int, int);
>
> Looks much nicer then the (*xxxx) stuff - It is also easer to type:
> just copy the original prototype and replace extern/static with
> typedef - done. And the code would become symetic to the Ada code
> making maintance easier.
Thanks a lot for that!
Personally I would go for
typedef void driver_setpixel_type (int a, int b, int c);
being a believer in descriptive names for parameters ... of course I
would never actually use a, b, c, that's obviously silly.
--
Simon Wright 100% Ada, no bugs.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: interfaces.C - Import struct
2005-03-13 12:31 ` Simon Wright
@ 2005-03-13 17:27 ` Martin Krischik
0 siblings, 0 replies; 5+ messages in thread
From: Martin Krischik @ 2005-03-13 17:27 UTC (permalink / raw)
Simon Wright wrote:
> Martin Krischik <martin@krischik.com> writes:
>
>> BTW: do you know about:
>>
>> typedef void driver_setpixel_type (int, int, int);
>>
>> Looks much nicer then the (*xxxx) stuff - It is also easer to type:
>> just copy the original prototype and replace extern/static with
>> typedef - done. And the code would become symetic to the Ada code
>> making maintance easier.
>
> Thanks a lot for that!
>
> Personally I would go for
>
> typedef void driver_setpixel_type (int a, int b, int c);
>
> being a believer in descriptive names for parameters ... of course I
> would never actually use a, b, c, that's obviously silly.
Me too, in this case I just copied the example from the OP.
Martin
--
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-03-13 17:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-13 7:53 interfaces.C - Import struct Jean-Baptiste CAMPESATO
2005-03-13 9:05 ` Martin Krischik
2005-03-13 11:06 ` Jean-Baptiste CAMPESATO
2005-03-13 12:31 ` Simon Wright
2005-03-13 17:27 ` Martin Krischik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox