-- |
-- 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"]
    [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
"size_t", String
"ptrdiff_t", String
"intptr_t", String
"uintpyt_t", String
"void"]
    [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ (String -> [String]) -> [String] -> [String]
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"]
    [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
"image2d_t", String
"image3d_t", String
"sampler_t", String
"event_t"]
    -- OpenCL 1.2
    [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String
"double"]
    [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ (String -> [String]) -> [String] -> [String]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap String -> [String]
typeN [String
"double"]
    [String] -> [String] -> [String]
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 String -> String -> String
forall a. [a] -> [a] -> [a]
++ Integer -> String
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    = [Extensions] -> [String] -> P InitGroup -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P InitGroup
P.parseDecl
cedecl :: QuasiQuoter
cedecl   = [Extensions] -> [String] -> P Definition -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P Definition
P.parseEdecl
cenum :: QuasiQuoter
cenum    = [Extensions] -> [String] -> P CEnum -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P CEnum
P.parseEnum
cexp :: QuasiQuoter
cexp     = [Extensions] -> [String] -> P Exp -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P Exp
P.parseExp
cfun :: QuasiQuoter
cfun     = [Extensions] -> [String] -> P Func -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P Func
P.parseFunc
cinit :: QuasiQuoter
cinit    = [Extensions] -> [String] -> P Initializer -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P Initializer
P.parseInit
cparam :: QuasiQuoter
cparam   = [Extensions] -> [String] -> P Param -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P Param
P.parseParam
cparams :: QuasiQuoter
cparams  = [Extensions] -> [String] -> P [Param] -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P [Param]
P.parseParams
csdecl :: QuasiQuoter
csdecl   = [Extensions] -> [String] -> P FieldGroup -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P FieldGroup
P.parseStructDecl
cstm :: QuasiQuoter
cstm     = [Extensions] -> [String] -> P Stm -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P Stm
P.parseStm
cstms :: QuasiQuoter
cstms    = [Extensions] -> [String] -> P [Stm] -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P [Stm]
P.parseStms
citem :: QuasiQuoter
citem    = [Extensions] -> [String] -> P BlockItem -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P BlockItem
P.parseBlockItem
citems :: QuasiQuoter
citems   = [Extensions] -> [String] -> P [BlockItem] -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P [BlockItem]
P.parseBlockItems
ctyquals :: QuasiQuoter
ctyquals = [Extensions] -> [String] -> P [TypeQual] -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P [TypeQual]
P.parseTypeQuals
cty :: QuasiQuoter
cty      = [Extensions] -> [String] -> P Type -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P Type
P.parseType
cunit :: QuasiQuoter
cunit    = [Extensions] -> [String] -> P [Definition] -> QuasiQuoter
forall a. Data a => [Extensions] -> [String] -> P a -> QuasiQuoter
quasiquote [Extensions]
exts [String]
typenames P [Definition]
P.parseUnit