The c2hs documentation at
http://www.cse.unsw.edu.au/~chak/haskell/c2hs/docu/implementing.html#id314947
 gives me an example to follow for this case:

{#fun notebook_query_tab_label_packing as ^
  `(NotebookClass nb, WidgetClass cld)' =>
  {notebook `nb'                ,
   widget   `cld'               ,
   alloca-  `Bool'     peekBool*,
   alloca-  `Bool'     peekBool*,
   alloca-  `PackType' peekEnum*} -> `()'#}

so I took the original C binding:

   void SHPGetInfo(SHPHandle, int*, int*, double*, double*)

And wrote a c2hs binding:

{#fun SHPGetInfo as getInfo
    { fromSHPHandle `SHPHandle'
    , alloca- `Int'
    , alloca- `Int'
    , alloca- `Double'
    , alloca- `Double'
    } -> `()' #}

The error I get:

Internal.chs:85:2:
    Couldn't match expected type `Int'
           against inferred type `(Ptr b -> IO c) -> IO c'
      Expected type: IO (Int, Int, Double, Double)
      Inferred type: IO
                       ((Ptr b -> IO c) -> IO c,
                        (Ptr b1 -> IO c1) -> IO c1,
                        (Ptr b2 -> IO c2) -> IO c2,
                        (Ptr b3 -> IO c3) -> IO c3)
    In the expression:
          alloca $ \ a2' -> alloca $ \ a3' -> alloca $ \ a4' -> ...
    In the expression:
        let a1' = fromSHPHandle a1
        in alloca $ \ a2' -> alloca $ \ a3' -> alloca $ ...

I've tried ending it with withCIntConv and withCFloatConv to no avail.
 The original c2hs file is attached.  I'm sure there are many more
problems, but this is the one I'm working on at the moemnt...

-- Jeff

Attachment: Internal.chs
Description: Binary data

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to