"Manuel M. T. Chakravarty" wrote:
> [...] So, how about providing functions that advance the `mem'
> pointer for you or even have `writeXXXOffAddr' return the
> next address after the datum just written?
> [...] This is, however, maybe not so helpful because of alignment
> constraints that are harder to satisfy manually than in
> generated code. [...]
How about a new class subsuming the plethora of functions in Addr:
class NoGoodIdeaForANameYet a where
sizeOf :: a -> Int
alignment :: a -> Int
indexOffAddr :: Addr -> Int -> a
readOffAddr :: Addr -> Int -> IO a
writeOffAddr :: Addr -> Int -> a -> IO ()
sizeOf returns the size of the corresponding C-type in bytes, alignment
returns the alignment constraint for the given type and the underlying
architecture, indexOffAddr/readOffAddr/writeOffAddr behave like the
similarly named functions in Addr, but the second argument is a *byte*
offset. The first two methods would make FFI stuff more portable
without resorting to autoconf or other hacks.
Cheers,
Sven
--
Sven Panne Tel.: +49/89/2178-2235
LMU, Institut fuer Informatik FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen Oettingenstr. 67
mailto:[EMAIL PROTECTED] D-80538 Muenchen
http://www.informatik.uni-muenchen.de/~Sven.Panne