-- |
-- Module      :  Language.C.Quote.OpenCL
-- Copyright   :  (c) 2006-2011 Harvard University
--                (c) 2011-2013 Geoffrey Mainland
--             :  (c) 2013-2015 Drexel University
-- License     :  BSD-style
-- Maintainer  :  mainland@drexel.edu

module Language.C.Quote.OpenCL (
    ToIdent(..),
    ToConst(..),
    ToExp(..),
    cexp,
    cedecl,
    cdecl,
    csdecl,
    cenum,
    ctyquals,
    cty,
    cparam,
    cparams,
    cinit,
    cstm,
    cstms,
    citem,
    citems,
    cunit,
    cfun
  ) where

import qualified Language.C.Parser as P
import qualified Language.C.Syntax as C
import Language.C.Quote.Base (ToIdent(..), ToConst(..), ToExp(..), quasiquote)
import Language.Haskell.TH.Quote (QuasiQuoter)

exts :: [C.Extensions]
exts :: [Extensions]
exts = [Extensions
C.OpenCL]

typenames :: [String]
typenames :: [String]
typenames =
    [String
"bool", String
"char", String
"uchar", String
"short", String
"ushort", String
"int", String
"uint",
     String
"long" , String
"ulong", String
"float", String
"half"]
    forall a. [a] -> [a] -> [a]
++ [String
"size_t", String
"ptrdiff_t", String
"intptr_t", String
"uintpyt_t", String
"void"]
    forall a. [a] -> [a] -> [a]
++ forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap String -> [String]
typeN [String
"char", String
"uchar", String
"short", String
"ushort",
                        String
"int", String
"uint", String
"long", String
"ulong", String
"float"]
    forall a. [a] -> [a] -> [a]
++ [String
"image2d_t", String
"image3d_t", String
"sampler_t", String
"event_t"]
    -- OpenCL 1.2
    forall a. [a] -> [a] -> [a]
++ [String
"double"]
    forall a. [a] -> [a] -> [a]
++ forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap String -> [String]
typeN [String
"double"]
    forall a. [a] -> [a] -> [a]
++ [String
"image2d_array_t", String
"image1d_t", String
"image1d_buffer_t", String
"image1d_array_t"]

typeN :: String -> [String]
typeN :: String -> [String]
typeN String
typename = [String
typename forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Integer
n | Integer
n <- [Integer
2, Integer
3, Integer
4, Integer
8, Integer
16 :: Integer]]

cdecl, cedecl, cenum, cexp, cfun, cinit, cparam, cparams, csdecl, cstm, cstms :: QuasiQuoter
citem, citems, ctyquals, cty, cunit :: QuasiQuoter
cdecl :: QuasiQuoter
cdecl    = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P InitGroup
P.parseDecl
cedecl :: QuasiQuoter
cedecl   = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P Definition
P.parseEdecl
cenum :: QuasiQuoter
cenum    = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P CEnum
P.parseEnum
cexp :: QuasiQuoter
cexp     = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P Exp
P.parseExp
cfun :: QuasiQuoter
cfun     = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P Func
P.parseFunc
cinit :: QuasiQuoter
cinit    = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P Initializer
P.parseInit
cparam :: QuasiQuoter
cparam   = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P Param
P.parseParam
cparams :: QuasiQuoter
cparams  = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P [Param]
P.parseParams
csdecl :: QuasiQuoter
csdecl   = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P FieldGroup
P.parseStructDecl
cstm :: QuasiQuoter
cstm     = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P Stm
P.parseStm
cstms :: QuasiQuoter
cstms    = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P [Stm]
P.parseStms
citem :: QuasiQuoter
citem    = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P BlockItem
P.parseBlockItem
citems :: QuasiQuoter
citems   = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P [BlockItem]
P.parseBlockItems
ctyquals :: QuasiQuoter
ctyquals = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P [TypeQual]
P.parseTypeQuals
cty :: QuasiQuoter
cty      = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P Type
P.parseType
cunit :: QuasiQuoter
cunit    = forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P [Definition]
P.parseUnit