module Foreign.HacanonLight.DIS.Types where import Language.Haskell.TH type Func = (ExpQ -> ExpQ) {- A DIS is a representation of a C function argument. func :: IO (a,b) cFunc :: Ptr a -> IO b func :: a -> IO b cFunc :: a -> IO b func :: a -> IO (a,b) cFunc :: Ptr a -> IO b simpleCFunc :: Ptr Int -> IO CString simpleFunc :: Int -> IO (String,Int) simpleFunc = \arg1 -> (\action -> action arg1) -- No need to process Int since the FFI can handle it. (\marshalled action -> alloca (\ptr -> poke ptr marshalled >> action ptr)) -- Create a ptr and set it to arg1. (\marshalled -> do ret <- simpleCFunc marshalled peeked <- peek marshalled case (ret,peeked) of (t1,t2) -> do unmarshal1 <- peekCString t1 free t1 unmarshal2 <- return t2 return t2 return (unmarshal1,unmarshal2) -} data DISOperation = DISIn | DISOut | DISInOut | DISIgnore deriving (Eq,Show,Ord) data DIS = MkDIS { disOperation :: DISOperation, disType :: TypeQ, disFFIType :: TypeQ, disMarshal :: Func, disMarshalP :: Func, -- Persistent storage disUnMarshal :: Func, disFree :: Func }