module Language.C.Inline.Cpp
( module Language.C.Inline
, cppCtx
, cppTypePairs
, using
) where
import Data.Monoid ((<>), mempty)
import qualified Language.Haskell.TH as TH
import qualified Language.Haskell.TH.Syntax as TH
import Language.C.Inline
import Language.C.Inline.Context
import qualified Language.C.Types as CT
import qualified Data.Map as Map
cppCtx :: Context
cppCtx = baseCtx <> mempty
{ ctxForeignSrcLang = Just TH.LangCxx
, ctxOutput = Just $ \s -> "extern \"C\" {\n" ++ s ++ "\n}"
, ctxEnableCpp = True
}
using :: String -> TH.DecsQ
using s = verbatim $ "using " ++ s ++ ";"
cppTypePairs :: [(CT.CIdentifier, TH.TypeQ)] -> Context
cppTypePairs typePairs = mempty {
ctxTypesTable = Map.fromList $ map (\(cpp_sym, haskell_sym) -> (CT.TypeName cpp_sym, haskell_sym)) typePairs
}