{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}

module Cachix.Client.Store.Context where

import qualified Data.Map as M
import qualified Language.C.Inline.Context as C
import qualified Language.C.Inline.Cpp as C
import qualified Language.C.Types as C
import Protolude hiding (Set)

-- | A Nix @ref@
data Ref a

-- | A Nix @PathSet@ aka @std::set<Path>@ aka @std::set<std::string>>@
type PathSet = Set CxxString

data NixStore

data ValidPathInfo

-- | An STL @set@
data Set a

-- | An STL @::iterator@
data Iterator a

-- | An @std::string@
data CxxString

context :: C.Context
context :: Context
context =
  Context
C.cppCtx Context -> Context -> Context
forall a. Semigroup a => a -> a -> a
<> Context
C.fptrCtx Context -> Context -> Context
forall a. Semigroup a => a -> a -> a
<> Context
C.bsCtx
    Context -> Context -> Context
forall a. Semigroup a => a -> a -> a
<> Context
forall a. Monoid a => a
mempty
      { ctxTypesTable :: TypesTable
C.ctxTypesTable =
          TypeSpecifier -> TypeQ -> TypesTable
forall k a. k -> a -> Map k a
M.singleton (CIdentifier -> TypeSpecifier
C.TypeName "refStore") [t|Ref NixStore|]
            TypesTable -> TypesTable -> TypesTable
forall a. Semigroup a => a -> a -> a
<> TypeSpecifier -> TypeQ -> TypesTable
forall k a. k -> a -> Map k a
M.singleton
              (CIdentifier -> TypeSpecifier
C.TypeName "refValidPathInfo")
              [t|Ref ValidPathInfo|]
            TypesTable -> TypesTable -> TypesTable
forall a. Semigroup a => a -> a -> a
<> TypeSpecifier -> TypeQ -> TypesTable
forall k a. k -> a -> Map k a
M.singleton (CIdentifier -> TypeSpecifier
C.TypeName "PathSet") [t|PathSet|]
            TypesTable -> TypesTable -> TypesTable
forall a. Semigroup a => a -> a -> a
<> TypeSpecifier -> TypeQ -> TypesTable
forall k a. k -> a -> Map k a
M.singleton (CIdentifier -> TypeSpecifier
C.TypeName "PathSetIterator") [t|Iterator PathSet|]
      }