@@ -87,7 +87,7 @@ literals = mkPattern' match'
87 , prettyPrintCpp' target
87 , prettyPrintCpp' target
88 , return $ emit "]"
88 , return $ emit "]"
89 , return $ emit "("
89 , return $ emit "("
90− , return $ emit $ intercalate ", " (("const boxed& " <>) <$> args)
90+ , return $ emit $ intercalate ", " (renderArg <$> args)
91 , return $ emit ") -> boxed "
91 , return $ emit ") -> boxed "
92 , prettyPrintCpp' body
92 , prettyPrintCpp' body
@@ -169,7 +169,7 @@ literals = mkPattern' match'
169 match (Function _ name args ret) = mconcat <$> sequence
169 match (Function _ name args ret) = mconcat <$> sequence
170 [ return $ emit $ if name == (Just tcoLoop) then "[&]" else "[=]"
170 [ return $ emit $ if name == (Just tcoLoop) then "[&]" else "[=]"
171 , return $ emit "("
171 , return $ emit "("
172− , return $ emit $ intercalate ", " (("const boxed& " <>) <$> args)
172+ , return $ emit $ intercalate ", " (renderArg <$> args)
173 , return $ emit ") -> boxed "
173 , return $ emit ") -> boxed "
174 , prettyPrintCpp' ret
174 , prettyPrintCpp' ret
@@ -454,7 +454,7 @@ interfaceSource mn exports foreigns =
454 (if null foreigns then "" else ("// Foreign values\n\nauto " <> foreignDict <> "() -> " <> dictType <> "&;\n\n")) <>
454 (if null foreigns then "" else ("// Foreign values\n\nauto " <> foreignDict <> "() -> " <> dictType <> "&;\n\n")) <>
455 (T.concat $ (\foreign' -> "inline auto " <>
455 (T.concat $ (\foreign' -> "inline auto " <>
456 identToCpp foreign' <>
456 identToCpp foreign' <>
457− "() -> const boxed& { " <>
457+ "() -> " <> varDecl <> " { " <>
458 dispatchOnceBegin <>
458 dispatchOnceBegin <>
459 foreignDict <> "().at(" <>
459 foreignDict <> "().at(" <>
460 (stringLiteral . mkString $ runIdent foreign') <> "); " <>
460 (stringLiteral . mkString $ runIdent foreign') <> "); " <>
@@ -475,8 +475,8 @@ implFooterSource :: Text -> [Ident] -> Text
475implFooterSource mn foreigns =
475implFooterSource mn foreigns =
476 "\n\n" <>
476 "\n\n" <>
477 (if null foreigns then "" else ("auto " <> foreignDict <> "() -> " <> dictType <> "& {\n" <>
477 (if null foreigns then "" else ("auto " <> foreignDict <> "() -> " <> dictType <> "& {\n" <>
478− " static " <> dictType <> " _dict_;\n" <>
478+ " static " <> dictType <> " $dict$;\n" <>
479− " return _dict_;\n" <>
479+ " return $dict$;\n" <>
480 "}\n\n")) <>
480 "}\n\n")) <>
481 "} // end namespace " <> mn <>
481 "} // end namespace " <> mn <>
482 "\n\n" <>
482 "\n\n" <>
@@ -485,7 +485,7 @@ implFooterSource mn foreigns =
485 mainSource :: Text
485 mainSource :: Text
486 mainSource = "\
486 mainSource = "\
487 \int main(int argc, const char * argv[]) {\n\
487 \int main(int argc, const char * argv[]) {\n\
488− \ Main::main()(nullptr);\n\
488+ \ Main::main()();\n\
489 \ return 0;\n\
489 \ return 0;\n\
@@ -508,11 +508,19 @@ bool = "bool"
508string :: Text
508string :: Text
509string = "string"
509string = "string"
512+varDecl = "const boxed&"
514+renderArg :: Text -> Text
516+ | arg == unusedName = varDecl
517+ | otherwise = varDecl <> " " <> arg
511foreignDict :: Text
519foreignDict :: Text
512foreignDict = "foreign"
520foreignDict = "foreign"
514dispatchOnceBegin :: Text
522dispatchOnceBegin :: Text
515−dispatchOnceBegin = "static const boxed _value_ = "
523+dispatchOnceBegin = "static const boxed $value$ = "
517dispatchOnceEnd :: Text
525dispatchOnceEnd :: Text
518−dispatchOnceEnd = "return _value_;"
526+dispatchOnceEnd = "return $value$;"