ANN: bindings-DSL 1.0.4 (Category: FFI)

Hi,
bindings-DSL is a mature and well documented preprocessor domain
specific language you can use to generate bindings to a C API.
It's based on functionality provided by hsc2hs. These are links to
Hackage page and documentation:
http://hackage.haskell.org/package/bindings-DSL
http://bitbucket.org/mauricio/bindings-dsl
New in this version:
* Support for C unions.
* Use of
let value = C'example 1 []
u'example'k value (2^10)
C'example {c'example'k = 1024, c'example'c = [0,4,0,0]}
u'example'c value [1,0,0,0]
C'example {c'example'k = 1, c'example'c = [1,0,0,0]}
u'example'c value [0,0,0,1]
C'example {c'example'k = 16777216, c'example'c = [0,0,0,1]} Peeking an uninitialized memory address:
v <- alloca $ \p -> peek p :: IO C'example v
C'example {c'example'k = 81842189, c'example'c = [13,-48,-32,4]} Hope it's useful to you. Best, Maurício

On Sat, Jan 23, 2010 at 01:02:07AM -0200, Maurício CA wrote:
bindings-DSL is a mature and well documented preprocessor domain specific language you can use to generate bindings to a C API. It's based on functionality provided by hsc2hs. These are links to Hackage page and documentation:
http://hackage.haskell.org/package/bindings-DSL http://bitbucket.org/mauricio/bindings-dsl
Much thanks for this lovely package. I'm currently using it to write a low-level Direct3D9 binding and thus far it's very friendly. The only thing I've missed for now is a #ccall equivalence for "stdcall" functions, I hacked one up myself and called it #stdcall, but it would be nice to have in the package proper if possible. Keep up the good work, -- Lars Viklund | zao@acc.umu.se

http://hackage.haskell.org/package/bindings-DSL http://bitbucket.org/mauricio/bindings-dsl
The only thing I've missed for now is a #ccall equivalence for "stdcall" functions, I hacked one up myself and called it #stdcall, but it would be nice to have in the package proper if possible.
Here is my attempt. I added #callconv macro, that accepts a calling convention parameter. The lines below are now equivalent. #ccall do_something , CString -> IO CInt #callconv do_something , ccall , CString -> IO CInt Would you mind give it some testing (and of course sugestions as you wish) before I upload it to Hackage? The link below gives you a few options for download format. Look for version 1.0.5. http://bitbucket.org/mauricio/bindings-dsl/downloads There are a few good C libraries that work well under Linux and Windows (libusb1.0 for Windows is in beta now, for instance). Do you think we should have a macro that defaults to 'ccall' in Linux and others and to 'stdcall' on Windows? If so, I would need some help to avoid portability issues (like a list of platforms and proper defaults). Thanks for your toughts, Maurício

On Thu, Jan 28, 2010 at 09:36:42PM -0200, Maurício CA wrote:
The only thing I've missed for now is a #ccall equivalence for "stdcall" functions, I hacked one up myself and called it #stdcall, but it would be nice to have in the package proper if possible. Here is my attempt. I added #callconv macro, that accepts a calling convention parameter. The lines below are now equivalent.
#ccall do_something , CString -> IO CInt #callconv do_something , ccall , CString -> IO CInt
Builds fine here and looks reasonably fine.
There are a few good C libraries that work well under Linux and Windows (libusb1.0 for Windows is in beta now, for instance). Do you think we should have a macro that defaults to 'ccall' in Linux and others and to 'stdcall' on Windows? If so, I would need some help to avoid portability issues (like a list of platforms and proper defaults).
I would guess that any libraries that are written to be portable will likely use the default (cdecl) as calling convention. I do not expect that one would see stdcall used outside inherently native headers like the Windows ones, DirectX, etc. -- Lars Viklund | zao@acc.umu.se
participants (2)
-
Lars Viklund
-
Maurício CA