From: tmoran@acm.org
Subject: Re: Binding to C
Date: Mon, 21 Jul 2003 21:07:52 GMT
Date: 2003-07-21T21:07:52+00:00 [thread overview]
Message-ID: <ICYSa.114135$N7.15266@sccrnsc03> (raw)
In-Reply-To: MxXSa.2290$l63.28380@newsfep4-glfd.server.ntli.net
>Also does anyone have any advice in general mapping to C.
Look at some of the Windows binding source code at www.adapower.com
>For the jpeg_error_mgr struct, I mapped ptrs to functions to System.Address
>and made the struct a record. Will this work, or will the corresponding
>type of the struct have to be a System.Address?
You almost never need a System.Address. Use access types.
> type Jpeg_Error_Mgr is record
> Error_Exit : System.Address; -- addr of a handler
> Emit_Message : System.Address;
> ...
Instead:
type Error_Exit_Ptr is access
procedure (cinfo : access Decompress_Cinfo_Type);
pragma Convention(C, Error_Exit_Ptr);
type Emit_Message_Ptr is access
procedure (cinfo : access Decompress_Cinfo_Type;
msg_level: Interfaces.C.Int);
pragma Convention(C, Emit_Message_Ptr);
...
procedure error_exit(cinfo : access Decompress_Cinfo_Type);
pragma Export(C, error_exit);
procedure emit_message(cinfo : access Decompress_Cinfo_Type;
msg_level: Interfaces.C.Int);
pragma Export(C, Emit_Message);
...
type Jpeg_Error_Mgr is record
P_Error_Exit: Error_Exit_Ptr; -- will be set := error_exit'access;
P_Emit_Message: Emit_Message_Ptr; -- will be set := emit_message'access;
etc.
next prev parent reply other threads:[~2003-07-21 21:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-21 18:59 Binding to C chris
2003-07-21 20:02 ` Martin Krischik
2003-07-22 17:12 ` chris
2003-07-23 13:47 ` Martin Krischik
2003-07-27 13:11 ` Matthew Heaney
2003-07-27 13:07 ` Matthew Heaney
2003-07-21 21:07 ` tmoran [this message]
2003-07-21 21:57 ` chris
2003-07-27 13:04 ` Matthew Heaney
2003-07-28 20:52 ` Freejack
2003-07-29 19:21 ` chris
2003-08-09 11:29 ` Patrice Freydiere
2003-08-09 13:09 ` Jeffrey Creem
2003-08-09 13:54 ` Patrice Freydiere
2003-08-11 23:49 ` chris
2003-08-12 6:40 ` Patrice Freydiere
2003-08-12 11:58 ` chris
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox