[Haskell-cafe] Is hdirect just broken?

Vincenzo aka Nick Name vincenzo_mlRE.MOVE at yahoo.it
Thu May 6 17:10:34 EDT 2004


On Thursday 06 May 2004 13:36, Vincenzo aka Nick Name wrote:
> Can greencard support callbacks? If yes, can someone provide a simple
> example?

Ok, I finally found Alistair Reid's tutorial, which I forgot to read 
again, and well, I see that greencard does not support callbacks. My 
alternatives are plain FFI and hdirect. I just renounced to the 
[unique] tag and having optionally null fields in a record, but now I 
have another problem:

===
typedef int (*readlinkT)([in,string] const char *, 
[size_is(size),string,out] char * buf, [hide] unsigned int size);

ghc  -package hdirect -fglasgow-exts HSFuse.hs -c

HSFuse.hs:190: Variable not in scope: `buf'
===

The offending line is, in the following fragment of code, the one 
beginning with "let size =", of course there is no "buf", if the 
argument is called "out_buf"!

===
wrap_ReadlinkT readlinkT_meth anon1 out_buf size =
  do
    anon1 <- HDirect.unmarshallString anon1
    (res__buf, res__o_ReadlinkT) <- readlinkT_meth anon1 size
    let size = (Prelude.fromIntegral (Prelude.length buf) ::                      
                                             Data.Word.Word32)
    buf <- HDirect.marshallString buf
    HDirect.writePtr (Foreign.Ptr.castPtr out_buf) res__buf
    Prelude.return (res__buf, res__o_ReadlinkT)
===

Now, if I may ask the final question: is it me not understanding how I 
should do things, or is hdirect completely broken and I am the only one 
not knowing this? What tool should I use to write a libfuse binding? Is 
plain FFI my only hope?

Thanks

Vincenzo


More information about the Haskell-Cafe mailing list