Philipp Balzarek | 2 May 2013 22:09

add addrof directive (was: ptrto)

{#addrof <path> #} retrieves the address of a field of a c
structure, following <path>. It behaves much like get or set, but
instead of marshalling the target it returns a pointer to it.
This is useful e.g. when the associated Haskell type doesn't
have a Storable instance, for example SockAddr.

See also: http://www.haskell.org/pipermail/c2hs/2013-March/001113.html
Attachment (addrof.patch): text/x-patch, 10 KiB
{#addrof <path> #} retrieves the address of a field of a c
structure, following <path>. It behaves much like get or set, but
instead of marshalling the target it returns a pointer to it.
This is useful e.g. when the associated Haskell type doesn't
have a Storable instance, for example SockAddr.

See also: http://www.haskell.org/pipermail/c2hs/2013-March/001113.html
c2hs | 10 Apr 2013 20:21
Favicon

[c2hs] #55: `strip: unable to rename 'c2hs.exe'; reason: File exists`

#55: `strip: unable to rename 'c2hs.exe'; reason: File exists`
--------------------+-------------------------------------------------------
 Reporter:  guest   |        Type:  defect                                         
   Status:  new     |    Priority:  normal                                         
Milestone:          |   Component:  general                                        
  Version:  0.16.2  |    Keywords:  strip rename file configure setup mingw windows
--------------------+-------------------------------------------------------
 I'm currently trying to build c2hs (v 0.16.4) from the cabal source
 package from HackageDB on a Win64 system.

 == TERMINAL LOG ==

 PS .> cabal install
 Resolving dependencies...
 Configuring c2hs-0.16.4...
 Preprocessing executables for c2hs-0.16.4...
 Building c2hs-0.16.4...
 Linking dist\build\c2hs\c2hs.exe ...
 Installing executable(s) in C:\Users\##\AppData\Roaming\cabal\bin
 C:\prog-x86\MinGW\bin\strip.exe: unable to rename
 'C:\Users\##\AppData\Roaming\cabal\bin\c2hs.exe'; r
 eason: File exists
 cabal.exe: Error: some packages failed to install:
 c2hs-0.16.4 failed during the final install step. The exception was:
 ExitFailure 1

 == SETUP CONFIG - CONCERNING STRIP ==
 ("strip", ConfiguredProgram {programId = "strip", programVersion =
 Nothing, programDefaultArgs = [], programOverrideArgs = [],
 programLocation = FoundOnSystem {locationPath =
(Continue reading)

General Failure | 30 Mar 2013 15:59

darcs patch: add ptrto directive

1 patch for repository http://code.haskell.org/c2hs:

Sun Mar 24 16:21:29 CET 2013  p.balzarek <at> googlemail.com
  * add ptrto directive

{#ptrto <path> #} creates a pointer into a c structure, following
<path>. It behaves much like get or set, but instead of marshalling the
target it returns a pointer to it.
This is useful e.g. when the associated Haskell type doesn't
have a Storable instance, for example SockAddr.

Attachment (ptrto.patch): application/octet-stream, 9 KiB
<div><p>1 patch for repository <a href="http://code.haskell.org/c2hs">http://code.haskell.org/c2hs</a>:<br><br>Sun Mar 24 16:21:29 CET 2013&nbsp; <a href="mailto:p.balzarek <at> googlemail.com">p.balzarek <at> googlemail.com</a><br>&nbsp; * add ptrto directive<br><br>{#ptrto &lt;path&gt; #} creates a pointer into a c structure, following<br>&lt;path&gt;. It behaves much like get or set, but instead of marshalling the<br>target it returns a pointer to it. <br>This is useful e.g. when the associated Haskell type doesn't<br>
have a Storable instance, for example SockAddr.<br></p></div>
c2hs | 9 Feb 2013 04:41
Favicon

Re: [c2hs] #7: compile gtk2hs failed under locale zh_CN.utf8

#7: compile gtk2hs failed under locale zh_CN.utf8
---------------------+------------------------------------------------------
 Reporter:  duncan   |       Owner:        
     Type:  defect   |      Status:  new   
 Priority:  normal   |   Milestone:        
Component:  general  |     Version:  0.15.1
 Keywords:           |  
---------------------+------------------------------------------------------

Comment(by duncan):

 The latest darcs version may fix this. It uses the latest language-c which
 when built with alex 3 may handle the unicode correctly. Worth someone
 trying and confirming.

--

-- 
Ticket URL: <http://hackage.haskell.org/trac/c2hs/ticket/7#comment:2>
c2hs <http://www.cse.unsw.edu.au/~chak/haskell/c2hs/>
C->Haskell, An Interface Generator for Haskell

c2hs | 18 Oct 2012 00:59
Favicon

[c2hs] #54: Allow referring to 'struct foo' identifiers from {#sizeof} {#get} and friends

#54: Allow referring to 'struct foo' identifiers from {#sizeof} {#get} and
friends
--------------------+-------------------------------------------------------
 Reporter:  guest   |        Type:  defect 
   Status:  new     |    Priority:  normal 
Milestone:          |   Component:  general
  Version:  0.16.0  |    Keywords:         
--------------------+-------------------------------------------------------
 C maintains separate namespaces for 'struct foo' and 'typedef ... foo',
 and at present c2hs only references the latter namespace.  This is
 annoying if a library author didn't add typedefs to allow eliding the
 'struct' keyword from type definitions; we have to re-typedef everything
 we want to use from c2hs. It would be convenient if we could write {#get
 struct foo->bar #} or similar.  Note that pointer appears to look in both
 namespaces, so I don't know what's going on there. -- ezyang

--

-- 
Ticket URL: <http://hackage.haskell.org/trac/c2hs/ticket/54>
c2hs <http://www.cse.unsw.edu.au/~chak/haskell/c2hs/>
C->Haskell, An Interface Generator for Haskell

c2hs | 9 Oct 2012 14:33
Favicon

[c2hs] #53: Cabal Install failed with ghc 7.6.1

#53: Cabal Install failed with ghc 7.6.1
--------------------+-------------------------------------------------------
 Reporter:  guest   |        Type:  defect 
   Status:  new     |    Priority:  normal 
Milestone:          |   Component:  general
  Version:  0.16.2  |    Keywords:         
--------------------+-------------------------------------------------------
 Fail to install using ghc 7.6.1.
 Two changes are needed, but I don't know if backward compatible.

 Émeric

 diff -r c2hs-0.16.3_bu/src/C2HS/Config.hs c2hs-0.16.3/src/C2HS/Config.hs
 40c40
 < import Foreign.C (CInt)
 ---
 > import Foreign.C (CInt(..))
 diff -r c2hs-0.16.3_bu/src/Control/StateTrans.hs
 c2hs-0.16.3/src/Control/StateTrans.hs
 75a76
 > import System.IO.Error(catchIOError)
 299c300
 <             `catch` (\err -> let
 ---
 >             `catchIOError` (\err -> let

--

-- 
Ticket URL: <http://hackage.haskell.org/trac/c2hs/ticket/53>
c2hs <http://www.cse.unsw.edu.au/~chak/haskell/c2hs/>
C->Haskell, An Interface Generator for Haskell

_______________________________________________
C2hs mailing list
C2hs <at> haskell.org
http://www.haskell.org/mailman/listinfo/c2hs
c2hs | 8 Oct 2012 05:55
Favicon

[c2hs] #52: Parenthesize types in bindings, to allow function types without parentheses

#52: Parenthesize types in bindings, to allow function types without parentheses
--------------------+-------------------------------------------------------
 Reporter:  guest   |        Type:  defect 
   Status:  new     |    Priority:  normal 
Milestone:          |   Component:  general
  Version:  0.16.0  |    Keywords:         
--------------------+-------------------------------------------------------
 c2hs allows arbitrary types in function bindings.  However, a function
 type such as {{{T1 -> T2}}} will cause the generated code to parse
 incorrectly; since c2hs does not parenthesize each argument type, the
 argument and return types of the function type will parse as multiple
 arguments of the binding type, rather than as a single argument of
 function type.  The binding can work around this by explicitly
 parenthesizing the function type, but since c2hs already requires quoting
 the entire type, the need for parentheses does not become apparent without
 reading the generated code (or encountering a compile error).

 Add parentheses around the types in bindings, so that unparenthesized
 function types as arguments will parse correctly.

 {{{
 diff -rN -u old-c2hs/src/C2HS/Gen/Bind.hs new-c2hs/src/C2HS/Gen/Bind.hs
 --- old-c2hs/src/C2HS/Gen/Bind.hs       2012-10-07 20:49:16.773294894
 -0700
 +++ new-c2hs/src/C2HS/Gen/Bind.hs       2012-10-07 20:49:16.789294705
 -0700
  <at>  <at>  -913,8 +913,8  <at>  <at> 
          ctxt   = case octxt of
                     Nothing      -> ""
                     Just ctxtStr -> ctxtStr ++ " => "
 -        argTys = [ty | CHSParm im ty _ _  _ <- parms'      , notVoid im]
 -        resTys = [ty | CHSParm _  ty _ om _ <- parm':parms', notVoid om]
 +        argTys = ["(" ++ ty ++ ")" | CHSParm im ty _ _  _ <- parms'
 , notVoid im]
 +        resTys = ["(" ++ ty ++ ")" | CHSParm _  ty _ om _ <-
 parm':parms', notVoid om]
          resTup = let
                     (lp, rp) = if isPure && length resTys == 1
                                then ("", "")
 }}}

--

-- 
Ticket URL: <http://hackage.haskell.org/trac/c2hs/ticket/52>
c2hs <http://www.cse.unsw.edu.au/~chak/haskell/c2hs/>
C->Haskell, An Interface Generator for Haskell

c2hs | 8 Oct 2012 04:33
Favicon

[c2hs] #51: Should not define preprocessor symbols for GCC

#51: Should not define preprocessor symbols for GCC
--------------------+-------------------------------------------------------
 Reporter:  guest   |        Type:  defect 
   Status:  new     |    Priority:  normal 
Milestone:          |   Component:  general
  Version:  0.16.0  |    Keywords:         
--------------------+-------------------------------------------------------
 c2hs uses GCC's preprocessor, and as a result it parses C code with GCC's
 default preprocessor symbols defined.  Many projects rely on those
 preprocessor symbols to decide whether to use GCC-specific extensions,
 such as {{{__attribute__}}} declarations.  Since c2hs does not support
 those extensions, it should not define those preprocessor symbols.  Please
 consider invoking the preprocessor with {{{-U__GNUC__ -U__GNUC_MINOR__
 -U__GNUC_PATCHLEVEL__}}} .

--

-- 
Ticket URL: <http://hackage.haskell.org/trac/c2hs/ticket/51>
c2hs <http://www.cse.unsw.edu.au/~chak/haskell/c2hs/>
C->Haskell, An Interface Generator for Haskell

c2hs | 8 Oct 2012 04:26
Favicon

[c2hs] #50: Parenthesize marshallers, to preserve Haskell expressions

#50: Parenthesize marshallers, to preserve Haskell expressions
--------------------+-------------------------------------------------------
 Reporter:  guest   |        Type:  defect 
   Status:  new     |    Priority:  normal 
Milestone:          |   Component:  general
  Version:  0.16.0  |    Keywords:         
--------------------+-------------------------------------------------------
 Marshallers can contain Haskell expressions; however, c2hs substitutes
 those expressions into Haskell code as function calls and adds arguments
 to the end, which limits these Haskell expressions to simple function
 calls with one or more arguments.  Add parentheses to these expressions,
 allowing them to contain arbitrary Haskell expressions with lower
 precedence than function calls, such as operators.

 {{{
 diff -rN -u old-c2hs/src/C2HS/Gen/Bind.hs new-c2hs/src/C2HS/Gen/Bind.hs
 --- old-c2hs/src/C2HS/Gen/Bind.hs       2012-10-07 19:24:21.493527302
 -0700
 +++ new-c2hs/src/C2HS/Gen/Bind.hs       2012-10-07 19:24:21.521526937
 -0700
  <at>  <at>  -884,7 +884,7  <at>  <at> 
                        interr "GenBind.funDef: marshRes: no default?"

        marshBody (Left ide) = identToString ide
 -      marshBody (Right str) = str
 +      marshBody (Right str) = "(" ++ str ++ ")"

        retArgs'  = case parm' of
                      CHSParm _ _ _ (Just (_, CHSVoidArg))   _ ->
 retArgs
  <at>  <at>  -962,7 +962,7  <at>  <at> 
          retArg   = if omArgKind == CHSVoidArg || omArgKind ==
 CHSIOVoidArg then "" else outBndr

          marshBody (Left ide) = identToString ide
 -        marshBody (Right str) = str
 +        marshBody (Right str) = "(" ++ str ++ ")"
        in
        (funArg, marshIn, callArgs, marshOut, retArg)
      marshArg _ _ = interr "GenBind.funDef: Missing default?"
 }}}

--

-- 
Ticket URL: <http://hackage.haskell.org/trac/c2hs/ticket/50>
c2hs <http://www.cse.unsw.edu.au/~chak/haskell/c2hs/>
C->Haskell, An Interface Generator for Haskell

c2hs | 8 Oct 2012 04:23
Favicon

[c2hs] #49: Run return value marshaller before output parameter marshallers

#49: Run return value marshaller before output parameter marshallers
--------------------+-------------------------------------------------------
 Reporter:  guest   |        Type:  defect 
   Status:  new     |    Priority:  normal 
Milestone:          |   Component:  general
  Version:  0.16.0  |    Keywords:         
--------------------+-------------------------------------------------------
 Many C functions provide an error code as a return value, and have output
 parameters that they do not set unless the return value indicates success.
 Handling such functions requires checking the return value before running
 any output marshallers.  The reverse situation (an error code as an output
 parameter that needs checking before the return value) almost never
 occurs.  Thus, run the return value marshaller before the output parameter
 marshallers, so that the return value marshaller can generate an exception
 that will prevent the output marshallers from running.

 {{{
 diff -rN -u old-c2hs/src/C2HS/Gen/Bind.hs new-c2hs/src/C2HS/Gen/Bind.hs
 --- old-c2hs/src/C2HS/Gen/Bind.hs       2012-10-07 19:22:14.515183247
 -0700
 +++ new-c2hs/src/C2HS/Gen/Bind.hs       2012-10-07 19:22:14.515183247
 -0700
  <at>  <at>  -894,8 +894,8  <at>  <at> 
        funBody   = joinLines marshIns  ++
                    mkMarsh2            ++
                    call                ++
 -                  joinLines marshOuts ++
                    marshRes            ++
 +                  joinLines marshOuts ++
                    "  " ++
                    (if isImpure || not isPure then "return " else "") ++
 ret
      return $ sig ++ funHead ++ funBody
 }}}

--

-- 
Ticket URL: <http://hackage.haskell.org/trac/c2hs/ticket/49>
c2hs <http://www.cse.unsw.edu.au/~chak/haskell/c2hs/>
C->Haskell, An Interface Generator for Haskell

c2hs | 8 Oct 2012 01:34
Favicon

Re: [c2hs] #5: support for enum define hooks

#5: support for enum define hooks
--------------------+-------------------------------------------------------
 Reporter:  guest   |        Type:  enhancement
   Status:  new     |    Priority:  normal     
Milestone:          |   Component:  general    
  Version:  0.15.1  |    Keywords:             
--------------------+-------------------------------------------------------

Comment(by guest):

 c2hs has had enum define for a while now.

--

-- 
Ticket URL: <http://hackage.haskell.org/trac/c2hs/ticket/5#comment:1>
c2hs <http://www.cse.unsw.edu.au/~chak/haskell/c2hs/>
C->Haskell, An Interface Generator for Haskell


Gmane