Hs2lib-0.4.8: WinDll/Structs/Folds/CSharp.hs
-----------------------------------------------------------------------------
-- |
-- Module : Windll
-- Copyright : (c) Tamar Christina 2009 - 2010
-- License : BSD3
--
-- Maintainer : tamar@zhox.com
-- Stability : experimental
-- Portability : portable
--
-- General Folds for the CSharp datatypes
--
-----------------------------------------------------------------------------
module WinDll.Structs.Folds.CSharp
(module WinDll.Structs.Folds.CSharp) where
import WinDll.Structs.CSharp
import WinDll.Structs.C
import WinDll.Structs.Structures
import WinDll.Structs.Types
import WinDll.Session
-- import WinDll.Structs.Folds.C hiding (foldDataEnum)
-- * Type Algebras for the current ADTs in the C# file
-- | Type Algebra for the CAttr ADT
type AttrAlgebra a = (AttrType -> Key -> Values -> a)
-- | Type Algebra for Argument ADT
type ArgumentAlgebra a = ([Attr] -> CsType -> Name -> a)
-- | Type Algebra for Exporting of functions
type CsExportAlgebra a = ([Comment] -> [Attr] -> Name -> CsType -> [Argument] -> a)
-- | Type Algebra for C# structures
type CsStructAlgebra a = (CsStructType -> [Attr] -> Name -> [Argument] -> a)
-- | Type Algebra for the C# ADT
type CSharpAlgebra a = (String -> String -> String -> CallConvention ->
[CsCallback] -> [CsInclude] -> [TypeDecL] -> [CsExport] ->
[CsExport] -> [CsExport] -> [CsStruct] -> [CsDataEnum] -> a)
-- * The general folds used with the ADTs defined in the C file
-- | General fold for the Attr ADT
foldAttr :: AttrAlgebra a -> Attr -> a
foldAttr attr = fold
where fold (Attr b k v) = attr b k v
-- | General fold for the Argument ADT
foldArgument :: ArgumentAlgebra a -> Argument -> a
foldArgument arg = fold
where fold (Argument a c n) = arg a c n
-- | General fold for the CsExport ADT
foldCsExport :: CsExportAlgebra a -> CsExport -> a
foldCsExport csexport = fold
where fold (CsExport c t n r a) = csexport c t n r a
-- | General fold for the CsStruct ADT
foldCsStruct :: CsStructAlgebra a -> CsStruct -> a
foldCsStruct csstruct = fold
where fold (CsStruct ty to n e) = csstruct ty to n e
-- | General fold for the CSharp ADT
foldCSharp :: CSharpAlgebra a -> CSharp -> a
foldCSharp csalg = fold
where fold (CSharp a b c d e f g h i j k l) = csalg a b c d e f g h i j k l