Re: HDirect (CVS version) - some bugs

2001-11-16 Thread Sigbjorn Finne

Thanks for the bug report. I've checked in a fix for 1), but
for 2), I suggest instead of doing

  void pj_set_finder( const char *(*)(const char *) );

you express this as

  typedef [string]char* (*StringTrans) ([in,string]char* arg1);
  void pj_set_finder([in]StringTrans arg);

as HDirect doesn't currently handle 'const' qualifiers as well as it
could.

--sigbjorn

- Original Message -
From: "Mike Thomas" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "Sigbjorn Finne" <[EMAIL PROTECTED]>
Sent: Wednesday, November 07, 2001 15:42
Subject: HDirect (CVS version) - some bugs


> Hi there.
>
> Attached is a small zip file containing some idl and header files which
are
> meant to define an interface to Frank Warmerdam's map projection library.
>
> The problems can be reproduced by unzipping, going to the top level
> directory and running "make".  I am using Windows NT GHC 5.02 and CVS
> version of HDirect.
>
> 1. The C stub code ("Proj.c") generated for structures defined in the idl
> with lower-case leading characters has upper case leading characters eg:
> projXY in the IDL is converted to ProjXY.  I have worked around this by
> including a header file ("nameconvert.h") with macros which change the
names
> back to those used in the library headers, but this is messy.
>
> 2. The Haskell code ("Proj.hs") contains some strange definitions to do
with
> a datatype "IHC_TAG_0", which causes the errors below when compiled.   The
> datatype is associated with a function which takes another function as an
> argument:
>
> void pj_set_finder( const char *(*)(const char *) );
>
> Cheers
>
> Mike Thomas
>
> --- IHC_TAG_0 error messages 
>
> ghc -c -package lang -package com -fglasgow-exts -fvia-C Proj.hs -o
> proj_hs.o
>
> Proj.hs:338:
> Couldn't match
> `PrelMaybe.Maybe (PrelBase.Char -> PrelIOBase.IO PrelBase.Char)'
> against
> `IHC_TAG_0'
> Expected type: PrelMaybe.Maybe
>(PrelBase.Char -> PrelIOBase.IO PrelBase.Char)
> Inferred type: IHC_TAG_0
> In the third argument of `HDirect.marshallref', namely `arg10'
> In a 'do' expression pattern binding:
> arg10 <- HDirect.marshallref (HDirect.allocBytes (PrelReal.toInt
> sizeofI
> HC_TAG_0))
>  (HDirect.writeunique
> (HDirect.allocBytes (P
> relReal.toInt sizeofIHC_TAG_0))
>   writeIHC_TAG_0)
>  arg10
> make: *** [proj_hs.o] Error 1
>


___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



Re: AbsCStixGen.gencode panic

2001-11-16 Thread Sigbjorn Finne

The native code generator only handles 'foreign import's with a
static target, which is why you're seeing this (HEAD handles
this situation a little bit more gracefully).

Use -fvia-C (or -O, which implicitly does the same thing).

--sigbjorn

- Original Message -
From: "Volker Stolz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 16, 2001 10:18
Subject: AbsCStixGen.gencode panic


> Beware, to reproduce you need c2hs & gtk+hs!
> Luckily, I can use the "-O" switch (does that option mean "turn errors
OFF"?)
> to get a perfectly working binary!
>
> ghc -c Get.lhs -o Get.o `c2hs-config --cflags`  -fglasgow-exts -package
lang
>
> ghc-5.02.1: panic! (the `impossible' happened, GHC version 5.02.1):
> AbsCStixGen.gencode
> typedef void ( *_ccall_fun_tys1Cc) (StgAddr, I_);
>
> \begin{code}
>
> module Main where
>
> import IO
> import Maybe
> import Monad
> import Foreign
> import CString
> import GModule
>
> type Fun = CString -> Int -> IO ()
> foreign import dynamic unsafe iterator__ :: FunPtr Fun -> Fun
>
> main :: IO ()
> main = do
>   withModule (Just ".") "simple" ModuleBindOnLoad $ \ mod -> do
> funptr <- moduleSymbol mod "simple"
> when (isNothing funptr) $ error "fo!"
> let res = iterator__ (castPtrToFunPtr (fromJust funptr))
> withCString "hello" $ \ str -> res str 1
>   return ()
>
> \end{code}
> --
> Volker Stolz * [EMAIL PROTECTED] * PGP + S/MIME
>
> ___
> Glasgow-haskell-bugs mailing list
> [EMAIL PROTECTED]
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



AbsCStixGen.gencode panic

2001-11-16 Thread Volker Stolz

Beware, to reproduce you need c2hs & gtk+hs!
Luckily, I can use the "-O" switch (does that option mean "turn errors OFF"?)
to get a perfectly working binary!

ghc -c Get.lhs -o Get.o `c2hs-config --cflags`  -fglasgow-exts -package lang

ghc-5.02.1: panic! (the `impossible' happened, GHC version 5.02.1):
AbsCStixGen.gencode
typedef void ( *_ccall_fun_tys1Cc) (StgAddr, I_);

\begin{code}

module Main where

import IO
import Maybe
import Monad
import Foreign
import CString
import GModule

type Fun = CString -> Int -> IO ()
foreign import dynamic unsafe iterator__ :: FunPtr Fun -> Fun

main :: IO ()
main = do
  withModule (Just ".") "simple" ModuleBindOnLoad $ \ mod -> do
funptr <- moduleSymbol mod "simple"
when (isNothing funptr) $ error "fo!"
let res = iterator__ (castPtrToFunPtr (fromJust funptr))
withCString "hello" $ \ str -> res str 1
  return ()

\end{code}
-- 
Volker Stolz * [EMAIL PROTECTED] * PGP + S/MIME

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs