hdr_export (ExportFun n cn ret args)
   = ctype ret ++ " " ++ cdesc cn ++
         "(VM* vm" ++ showArgs (zip argNames args) ++ ");\n"
  where showArgs [] = ""
        showArgs ((n, t) : ts) = ", " ++ ctype t ++ " " ++ n ++
                                 showArgs ts

        argNames = zipWith (++) (repeat "arg") (map show [0..])

------------------ Callback wrapper generation ----------------
-- Generate callback wrappers and a function to select the
-- correct wrapper function to pass.
-- TODO: This is limited to functions that are specified in
-- the foreign call. Otherwise we would have to generate wrappers for all
-- functions with correct arity or do flow analysis
-- to find all possible inputs to the foreign call.
hdr_export (ExportFun n cn ret args)
   = ctype ret ++ " " ++ cdesc cn ++
         "(VM* vm" ++ showArgs (zip argNames args) ++ ");\n"
  where showArgs [] = ""
        showArgs ((n, t) : ts) = ", " ++ ctype t ++ " " ++ n ++
                                 showArgs ts

        argNames = zipWith (++) (repeat "arg") (map show [0..])

------------------ Callback wrapper generation ----------------
-- Generate callback wrappers and a function to select the
-- correct wrapper function to pass.
-- TODO: This is limited to functions that are specified in
-- the foreign call. Otherwise we would have to generate wrappers for all
-- functions with correct arity or do flow analysis
-- to find all possible inputs to the foreign call.
hdr_export (ExportFun n cn ret args)
   = ctype ret ++ " " ++ cdesc cn ++
         "(VM* vm" ++ showArgs (zip argNames args) ++ ");\n"
  where showArgs [] = ""
        showArgs ((n, t) : ts) = ", " ++ ctype t ++ " " ++ n ++
                                 showArgs ts

        argNames = zipWith (++) (repeat "arg") (map show [0..])

------------------ Callback wrapper generation ----------------
-- Generate callback wrappers and a function to select the
-- correct wrapper function to pass.
-- TODO: This is limited to functions that are specified in
-- the foreign call. Otherwise we would have to generate wrappers for all
-- functions with correct arity or do flow analysis
-- to find all possible inputs to the foreign call.