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

c2hs cvs-ghc at haskell.org
Mon Oct 8 04:23:33 CEST 2012


#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
 @@ -894,8 +894,8 @@
        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



More information about the C2hs mailing list