Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Phyx-

By: a guest on Jul 12th, 2010  |  syntax: Haskell  |  size: 19.43 KB  |  views: 195  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. -- @@ Autogenerated from WinDll. Do NOT modify unless you know what you're doing.
  2. {-# LANGUAGE ForeignFunctionInterface #-}
  3. {-# LANGUAGE UndecidableInstances #-}
  4.  
  5. module HsParser where
  6.  
  7. import WinDll.Lib.NativeMapping
  8. import WinDll.Lib.Tuples
  9. import WinDll.Lib.InstancesTypes
  10. import Foreign
  11. import Foreign.C
  12. import Foreign.Ptr
  13. import Foreign.Marshal.Alloc
  14. import Foreign.Marshal.Utils
  15. import Foreign.ForeignPtr
  16. import Control.Monad
  17. import Control.Monad.Instances
  18. import VsxParser
  19. import GhcSession
  20. import Lexer
  21. import SrcLoc
  22. import FastString
  23. import GHC hiding (ModuleInfo, Type, Instance, Warning, ClassDecl, DataType)
  24. import OccName
  25. import Name
  26. import Var
  27. import DataCon
  28. import Type hiding (Type)
  29. import TyCon
  30. import Class
  31. import Foreign.StablePtr
  32. import HscTypes
  33. import Data.IORef
  34.  
  35. #let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
  36.  
  37. #include "HsParser.h"
  38.  
  39. #enum Int,,cApiResultsApiOk = cApiResultsApiOk,cApiResultsApiFail = cApiResultsApiFail
  40. #enum Int,,cMaybeNothing = cMaybeNothing,cMaybeJust = cMaybeJust
  41.  
  42. type ErrorMessagePtr = (Ptr ErrorMessage)
  43. type ModuleInfoPtr = (Ptr ModuleInfo)
  44. type InformationPtr = (Ptr Information)
  45. type ClassDeclPtr = (Ptr ClassDecl)
  46. type DataTypePtr = (Ptr DataType)
  47. type FunTypePtr = (Ptr FunType)
  48. type ImportPtr = (Ptr Import)
  49. type ConstructorPtr = (Ptr Constructor)
  50. type InstancePtr = (Ptr Instance)
  51. type TypePtr = (Ptr Type)
  52. type ForeignDclPtr = (Ptr ForeignDcl)
  53. type WarningPtr = (Ptr Warning)
  54. type ApiResultsPtr a= (Ptr ((ApiResults a)))
  55. type SrcSpanPtr = (Ptr (SrcSpan))
  56. type FastStringPtr = (Ptr (FastString))
  57. type IORefPtr a1= (Ptr ((IORef a1)))
  58. type HscEnvPtr = (Ptr (HscEnv))
  59.  
  60. foreign export stdcall "getModuleInfoByPath" getModInfoA :: StablePtr (IORef HscEnv) -> CInt -> CInt -> CWString -> CWString -> CWString -> IO ((ApiResultsPtr ModuleInfo))
  61. foreign export stdcall "createContext" createContextA :: IO (StablePtr (IORef HscEnv))
  62. foreign export stdcall "freeContext" freeContextA :: StablePtr (IORef HscEnv) -> IO (())
  63.  
  64. getModInfoA :: StablePtr (IORef HscEnv) -> CInt -> CInt -> CWString -> CWString -> CWString -> IO ((ApiResultsPtr ModuleInfo))
  65. getModInfoA a1 a2 a3 a4 a5 a6 = toFFI $ getModInfo (fromFFI a1) (fromFFI a2) (fromFFI a3) (fromFFI a4) (fromFFI a5) (fromFFI a6)
  66.  
  67. createContextA :: IO (StablePtr (IORef HscEnv))
  68. createContextA  = toFFI $ createContext
  69.  
  70. freeContextA :: StablePtr (IORef HscEnv) -> IO (())
  71. freeContextA a1 = toFFI $ freeContext (fromFFI a1)
  72.  
  73. instance Storable ErrorMessage where
  74.     sizeOf    _ = 12
  75.     alignment _ = #alignment ErrorMessage_t
  76.    
  77.     poke ptr (ErrorMessage a1 a2 a3) = do
  78.         (#poke ErrorMessage_t, msg_span) ptr (toFFI a1 :: SrcSpanPtr)
  79.         (#poke ErrorMessage_t, short_msg) ptr (toFFI a2 :: CWString)
  80.         (#poke ErrorMessage_t, long_msg) ptr (toFFI a3 :: CWString)
  81.  
  82.     peek ptr = do
  83.         a1' <- (#peek ErrorMessage_t, msg_span) ptr :: IO SrcSpanPtr
  84.         a2' <- (#peek ErrorMessage_t, short_msg) ptr :: IO CWString
  85.         a3' <- (#peek ErrorMessage_t, long_msg) ptr :: IO CWString
  86.         return $ ErrorMessage (fromFFI a1' :: SrcSpan) (fromFFI a2' :: String) (fromFFI a3' :: String)
  87.  
  88. instance Storable ModuleInfo where
  89.     sizeOf    _ = 44
  90.     alignment _ = #alignment ModuleInfo_t
  91.    
  92.     poke ptr (ModuleInfo a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11) = do
  93.         (#poke ModuleInfo_t, generalInfo) ptr (toFFI a1 :: ((MaybePtr Information)))
  94.         (#poke ModuleInfo_t, functions) ptr (toFFI a2 :: ((Tuple2Ptr CInt ((Ptr (FunTypePtr))))))
  95.         (#poke ModuleInfo_t, imports) ptr (toFFI a3 :: ((Tuple2Ptr CInt ((Ptr (ImportPtr))))))
  96.         (#poke ModuleInfo_t, constructors) ptr (toFFI a4 :: ((Tuple2Ptr CInt ((Ptr (ConstructorPtr))))))
  97.         (#poke ModuleInfo_t, instances) ptr (toFFI a5 :: ((Tuple2Ptr CInt ((Ptr (InstancePtr))))))
  98.         (#poke ModuleInfo_t, types) ptr (toFFI a6 :: ((Tuple2Ptr CInt ((Ptr (TypePtr))))))
  99.         (#poke ModuleInfo_t, classes) ptr (toFFI a7 :: ((Tuple2Ptr CInt ((Ptr (ClassDeclPtr))))))
  100.         (#poke ModuleInfo_t, datatypes) ptr (toFFI a8 :: ((Tuple2Ptr CInt ((Ptr (DataTypePtr))))))
  101.         (#poke ModuleInfo_t, foreigns) ptr (toFFI a9 :: ((Tuple2Ptr CInt ((Ptr (ForeignDclPtr))))))
  102.         (#poke ModuleInfo_t, warnings) ptr (toFFI a10 :: ((Tuple2Ptr CInt ((Ptr (WarningPtr))))))
  103.         (#poke ModuleInfo_t, srcWarnings) ptr (toFFI a11 :: ((Tuple2Ptr CInt ((Ptr (ErrorMessagePtr))))))
  104.  
  105.     peek ptr = do
  106.         a1' <- (#peek ModuleInfo_t, generalInfo) ptr :: IO ((MaybePtr Information))
  107.         a2' <- (#peek ModuleInfo_t, functions) ptr :: IO ((Tuple2Ptr CInt ((Ptr (FunTypePtr)))))
  108.         a3' <- (#peek ModuleInfo_t, imports) ptr :: IO ((Tuple2Ptr CInt ((Ptr (ImportPtr)))))
  109.         a4' <- (#peek ModuleInfo_t, constructors) ptr :: IO ((Tuple2Ptr CInt ((Ptr (ConstructorPtr)))))
  110.         a5' <- (#peek ModuleInfo_t, instances) ptr :: IO ((Tuple2Ptr CInt ((Ptr (InstancePtr)))))
  111.         a6' <- (#peek ModuleInfo_t, types) ptr :: IO ((Tuple2Ptr CInt ((Ptr (TypePtr)))))
  112.         a7' <- (#peek ModuleInfo_t, classes) ptr :: IO ((Tuple2Ptr CInt ((Ptr (ClassDeclPtr)))))
  113.         a8' <- (#peek ModuleInfo_t, datatypes) ptr :: IO ((Tuple2Ptr CInt ((Ptr (DataTypePtr)))))
  114.         a9' <- (#peek ModuleInfo_t, foreigns) ptr :: IO ((Tuple2Ptr CInt ((Ptr (ForeignDclPtr)))))
  115.         a10' <- (#peek ModuleInfo_t, warnings) ptr :: IO ((Tuple2Ptr CInt ((Ptr (WarningPtr)))))
  116.         a11' <- (#peek ModuleInfo_t, srcWarnings) ptr :: IO ((Tuple2Ptr CInt ((Ptr (ErrorMessagePtr)))))
  117.         return $ ModuleInfo (fromFFI a1' :: (Maybe Information)) (fromFFI a2' :: ((Int, [FunType]))) (fromFFI a3' :: ((Int, [Import]))) (fromFFI a4' :: ((Int, [Constructor]))) (fromFFI a5' :: ((Int, [Instance]))) (fromFFI a6' :: ((Int, [Type]))) (fromFFI a7' :: ((Int, [ClassDecl]))) (fromFFI a8' :: ((Int, [DataType]))) (fromFFI a9' :: ((Int, [ForeignDcl]))) (fromFFI a10' :: ((Int, [Warning]))) (fromFFI a11' :: ((Int, [ErrorMessage])))
  118.  
  119. instance Storable Information where
  120.     sizeOf    _ = 4
  121.     alignment _ = #alignment Information_t
  122.    
  123.     poke ptr (Information a1) = do
  124.         (#poke Information_t, _importSpan) ptr (toFFI a1 :: SrcSpanPtr)
  125.  
  126.     peek ptr = do
  127.         a1' <- (#peek Information_t, _importSpan) ptr :: IO SrcSpanPtr
  128.         return $ Information (fromFFI a1' :: SrcSpan)
  129.  
  130. instance Storable ClassDecl where
  131.     sizeOf    _ = 16
  132.     alignment _ = #alignment ClassDecl_t
  133.    
  134.     poke ptr (ClassDecl a1 a2 a3 a4) = do
  135.         (#poke ClassDecl_t, _CDSpan) ptr (toFFI a1 :: SrcSpanPtr)
  136.         (#poke ClassDecl_t, _CDname) ptr (toFFI a2 :: CWString)
  137.         (#poke ClassDecl_t, _context) ptr (toFFI a3 :: ((Tuple2Ptr CInt ((Ptr (CWString))))))
  138.         (#poke ClassDecl_t, _head) ptr (toFFI a4 :: ((Tuple2Ptr CInt ((Ptr (CWString))))))
  139.  
  140.     peek ptr = do
  141.         a1' <- (#peek ClassDecl_t, _CDSpan) ptr :: IO SrcSpanPtr
  142.         a2' <- (#peek ClassDecl_t, _CDname) ptr :: IO CWString
  143.         a3' <- (#peek ClassDecl_t, _context) ptr :: IO ((Tuple2Ptr CInt ((Ptr (CWString)))))
  144.         a4' <- (#peek ClassDecl_t, _head) ptr :: IO ((Tuple2Ptr CInt ((Ptr (CWString)))))
  145.         return $ ClassDecl (fromFFI a1' :: SrcSpan) (fromFFI a2' :: String) (fromFFI a3' :: ((Int, [String]))) (fromFFI a4' :: ((Int, [String])))
  146.  
  147. instance Storable DataType where
  148.     sizeOf    _ = 12
  149.     alignment _ = #alignment DataType_t
  150.    
  151.     poke ptr (DataType a1 a2 a3) = do
  152.         (#poke DataType_t, _Dspan) ptr (toFFI a1 :: SrcSpanPtr)
  153.         (#poke DataType_t, _Dname) ptr (toFFI a2 :: CWString)
  154.         (#poke DataType_t, _isNewtype) ptr (toFFI a3 :: CInt)
  155.  
  156.     peek ptr = do
  157.         a1' <- (#peek DataType_t, _Dspan) ptr :: IO SrcSpanPtr
  158.         a2' <- (#peek DataType_t, _Dname) ptr :: IO CWString
  159.         a3' <- (#peek DataType_t, _isNewtype) ptr :: IO CInt
  160.         return $ DataType (fromFFI a1' :: SrcSpan) (fromFFI a2' :: String) (fromFFI a3' :: Bool)
  161.  
  162. instance Storable FunType where
  163.     sizeOf    _ = 28
  164.     alignment _ = #alignment FunType_t
  165.    
  166.     poke ptr (FunType a1 a2 a3 a4 a5 a6 a7) = do
  167.         (#poke FunType_t, _Tspan) ptr (toFFI a1 :: SrcSpanPtr)
  168.         (#poke FunType_t, _Tname) ptr (toFFI a2 :: CWString)
  169.         (#poke FunType_t, _type) ptr (toFFI a3 :: ((MaybePtr String)))
  170.         (#poke FunType_t, _body) ptr (toFFI a4 :: ((MaybePtr SrcSpan)))
  171.         (#poke FunType_t, _isMethod) ptr (toFFI a5 :: CInt)
  172.         (#poke FunType_t, _isExplicit) ptr (toFFI a6 :: CInt)
  173.         (#poke FunType_t, _inline) ptr (toFFI a7 :: (Tuple2Ptr CInt ((Ptr (FunTypePtr)))))
  174.  
  175.     peek ptr = do
  176.         a1' <- (#peek FunType_t, _Tspan) ptr :: IO SrcSpanPtr
  177.         a2' <- (#peek FunType_t, _Tname) ptr :: IO CWString
  178.         a3' <- (#peek FunType_t, _type) ptr :: IO ((MaybePtr String))
  179.         a4' <- (#peek FunType_t, _body) ptr :: IO ((MaybePtr SrcSpan))
  180.         a5' <- (#peek FunType_t, _isMethod) ptr :: IO CInt
  181.         a6' <- (#peek FunType_t, _isExplicit) ptr :: IO CInt
  182.         a7' <- (#peek FunType_t, _inline) ptr :: IO (Tuple2Ptr CInt ((Ptr (FunTypePtr))))
  183.         return $ FunType (fromFFI a1' :: SrcSpan) (fromFFI a2' :: String) (fromFFI a3' :: (Maybe String)) (fromFFI a4' :: (Maybe SrcSpan)) (fromFFI a5' :: Bool) (fromFFI a6' :: Bool) (fromFFI a7' :: (Int, [FunType]))
  184.  
  185. instance Storable Import where
  186.     sizeOf    _ = 28
  187.     alignment _ = #alignment Import_t
  188.    
  189.     poke ptr (Import a1 a2 a3 a4 a5 a6 a7) = do
  190.         (#poke Import_t, _Ispan) ptr (toFFI a1 :: SrcSpanPtr)
  191.         (#poke Import_t, _Iname) ptr (toFFI a2 :: CWString)
  192.         (#poke Import_t, _pkg) ptr (toFFI a3 :: ((MaybePtr String)))
  193.         (#poke Import_t, _source) ptr (toFFI a4 :: CInt)
  194.         (#poke Import_t, _qual) ptr (toFFI a5 :: CInt)
  195.         (#poke Import_t, _as) ptr (toFFI a6 :: ((MaybePtr String)))
  196.         (#poke Import_t, _hiding) ptr (toFFI a7 :: ((MaybePtr ((Int, [String])))))
  197.  
  198.     peek ptr = do
  199.         a1' <- (#peek Import_t, _Ispan) ptr :: IO SrcSpanPtr
  200.         a2' <- (#peek Import_t, _Iname) ptr :: IO CWString
  201.         a3' <- (#peek Import_t, _pkg) ptr :: IO ((MaybePtr String))
  202.         a4' <- (#peek Import_t, _source) ptr :: IO CInt
  203.         a5' <- (#peek Import_t, _qual) ptr :: IO CInt
  204.         a6' <- (#peek Import_t, _as) ptr :: IO ((MaybePtr String))
  205.         a7' <- (#peek Import_t, _hiding) ptr :: IO ((MaybePtr ((Int, [String]))))
  206.         return $ Import (fromFFI a1' :: SrcSpan) (fromFFI a2' :: String) (fromFFI a3' :: (Maybe String)) (fromFFI a4' :: Bool) (fromFFI a5' :: Bool) (fromFFI a6' :: (Maybe String)) (fromFFI a7' :: (Maybe ((Int, [String]))))
  207.  
  208. instance Storable Constructor where
  209.     sizeOf    _ = 12
  210.     alignment _ = #alignment Constructor_t
  211.    
  212.     poke ptr (Constructor a1 a2 a3) = do
  213.         (#poke Constructor_t, _Cspan) ptr (toFFI a1 :: SrcSpanPtr)
  214.         (#poke Constructor_t, _Cname) ptr (toFFI a2 :: CWString)
  215.         (#poke Constructor_t, _Ctype) ptr (toFFI a3 :: CWString)
  216.  
  217.     peek ptr = do
  218.         a1' <- (#peek Constructor_t, _Cspan) ptr :: IO SrcSpanPtr
  219.         a2' <- (#peek Constructor_t, _Cname) ptr :: IO CWString
  220.         a3' <- (#peek Constructor_t, _Ctype) ptr :: IO CWString
  221.         return $ Constructor (fromFFI a1' :: SrcSpan) (fromFFI a2' :: String) (fromFFI a3' :: String)
  222.  
  223. instance Storable Instance where
  224.     sizeOf    _ = 8
  225.     alignment _ = #alignment Instance_t
  226.    
  227.     poke ptr (Instance a1 a2) = do
  228.         (#poke Instance_t, _Ixspan) ptr (toFFI a1 :: SrcSpanPtr)
  229.         (#poke Instance_t, _Ixname) ptr (toFFI a2 :: CWString)
  230.  
  231.     peek ptr = do
  232.         a1' <- (#peek Instance_t, _Ixspan) ptr :: IO SrcSpanPtr
  233.         a2' <- (#peek Instance_t, _Ixname) ptr :: IO CWString
  234.         return $ Instance (fromFFI a1' :: SrcSpan) (fromFFI a2' :: String)
  235.  
  236. instance Storable Type where
  237.     sizeOf    _ = 8
  238.     alignment _ = #alignment Type_t
  239.    
  240.     poke ptr (Type a1 a2) = do
  241.         (#poke Type_t, _Txspan) ptr (toFFI a1 :: SrcSpanPtr)
  242.         (#poke Type_t, _Txname) ptr (toFFI a2 :: CWString)
  243.  
  244.     peek ptr = do
  245.         a1' <- (#peek Type_t, _Txspan) ptr :: IO SrcSpanPtr
  246.         a2' <- (#peek Type_t, _Txname) ptr :: IO CWString
  247.         return $ Type (fromFFI a1' :: SrcSpan) (fromFFI a2' :: String)
  248.  
  249. instance Storable ForeignDcl where
  250.     sizeOf    _ = 16
  251.     alignment _ = #alignment ForeignDcl_t
  252.    
  253.     poke ptr (ForeignDcl a1 a2 a3 a4) = do
  254.         (#poke ForeignDcl_t, _Fspan) ptr (toFFI a1 :: SrcSpanPtr)
  255.         (#poke ForeignDcl_t, _import) ptr (toFFI a2 :: CInt)
  256.         (#poke ForeignDcl_t, _Fname) ptr (toFFI a3 :: CWString)
  257.         (#poke ForeignDcl_t, _Ftype) ptr (toFFI a4 :: CWString)
  258.  
  259.     peek ptr = do
  260.         a1' <- (#peek ForeignDcl_t, _Fspan) ptr :: IO SrcSpanPtr
  261.         a2' <- (#peek ForeignDcl_t, _import) ptr :: IO CInt
  262.         a3' <- (#peek ForeignDcl_t, _Fname) ptr :: IO CWString
  263.         a4' <- (#peek ForeignDcl_t, _Ftype) ptr :: IO CWString
  264.         return $ ForeignDcl (fromFFI a1' :: SrcSpan) (fromFFI a2' :: Bool) (fromFFI a3' :: String) (fromFFI a4' :: String)
  265.  
  266. instance Storable Warning where
  267.     sizeOf    _ = 12
  268.     alignment _ = #alignment Warning_t
  269.    
  270.     poke ptr (Warning a1 a2 a3) = do
  271.         (#poke Warning_t, _Wspan) ptr (toFFI a1 :: SrcSpanPtr)
  272.         (#poke Warning_t, _Wname) ptr (toFFI a2 :: CWString)
  273.         (#poke Warning_t, _msg) ptr (toFFI a3 :: ((Tuple2Ptr CInt ((Ptr (CWString))))))
  274.  
  275.     peek ptr = do
  276.         a1' <- (#peek Warning_t, _Wspan) ptr :: IO SrcSpanPtr
  277.         a2' <- (#peek Warning_t, _Wname) ptr :: IO CWString
  278.         a3' <- (#peek Warning_t, _msg) ptr :: IO ((Tuple2Ptr CInt ((Ptr (CWString)))))
  279.         return $ Warning (fromFFI a1' :: SrcSpan) (fromFFI a2' :: String) (fromFFI a3' :: ((Int, [FastString])))
  280.  
  281. instance Storable ModuleInfo => Storable (ApiResults ModuleInfo) where
  282.     sizeOf    _ = 20
  283.     alignment _ = #alignment ApiResults_t
  284.    
  285.     poke ptr (ApiOk a1) = do
  286.         (#poke ApiResults_t, tag) ptr cApiResultsApiOk
  287.         newptr659112 <- malloc :: IO (Ptr (ApiResults ModuleInfo))
  288.         (#poke ApiOk_t, apiresults_apiok_var1) newptr659112 (toFFI a1 :: ModuleInfoPtr)
  289.         (#poke ApiResults_t, elt) ptr newptr659112
  290.  
  291.     poke ptr (ApiFail a1 a2 a3) = do
  292.         (#poke ApiResults_t, tag) ptr cApiResultsApiFail
  293.         newptr659112 <- malloc :: IO (Ptr (ApiResults ModuleInfo))
  294.         (#poke ApiFail_t, apiresults_apifail_var1) newptr659112 (toFFI a1 :: CInt)
  295.         (#poke ApiFail_t, apiresults_apifail_var2) newptr659112 (toFFI a2 :: (Ptr (ErrorMessagePtr)))
  296.         (#poke ApiFail_t, apiresults_apifail_var3) newptr659112 (toFFI a3 :: ((MaybePtr ModuleInfo)))
  297.         (#poke ApiResults_t, elt) ptr newptr659112
  298.  
  299.     peek ptr = do
  300.         tag' <- (#peek ApiResults_t, tag) ptr :: IO CInt
  301.         case tag' of
  302.           0 -> do
  303.             a1' <- (#peek ApiOk_t, apiresults_apiok_var1) ptr :: IO ModuleInfoPtr
  304.             return $ ApiOk (fromFFI a1' :: ModuleInfo)
  305.           1 -> do
  306.             a1' <- (#peek ApiFail_t, apiresults_apifail_var1) ptr :: IO CInt
  307.             a2' <- (#peek ApiFail_t, apiresults_apifail_var2) ptr :: IO (Ptr (ErrorMessagePtr))
  308.             a3' <- (#peek ApiFail_t, apiresults_apifail_var3) ptr :: IO ((MaybePtr ModuleInfo))
  309.             return $ ApiFail (fromFFI a1' :: Int) (fromFFI a2' :: [ErrorMessage]) (fromFFI a3' :: (Maybe ModuleInfo))
  310.  
  311. instance Storable ModuleInfo => Storable (Maybe ModuleInfo) where
  312.     sizeOf    _ = 12
  313.     alignment _ = #alignment Maybe_t
  314.    
  315.     poke ptr Nothing = do
  316.         (#poke Maybe_t, tag) ptr cMaybeNothing
  317.         newptr659112 <- malloc :: IO (Ptr (Maybe ModuleInfo))
  318.         (#poke Maybe_t, elt) ptr newptr659112
  319.  
  320.     poke ptr (Just a1) = do
  321.         (#poke Maybe_t, tag) ptr cMaybeJust
  322.         newptr659112 <- malloc :: IO (Ptr (Maybe ModuleInfo))
  323.         (#poke Just_t, maybe_just_var1) newptr659112 (toFFI a1 :: ModuleInfoPtr)
  324.         (#poke Maybe_t, elt) ptr newptr659112
  325.  
  326.     peek ptr = do
  327.         tag' <- (#peek Maybe_t, tag) ptr :: IO CInt
  328.         case tag' of
  329.           0 -> do
  330.             return $ Nothing
  331.           1 -> do
  332.             a1' <- (#peek Just_t, maybe_just_var1) ptr :: IO ModuleInfoPtr
  333.             return $ Just (fromFFI a1' :: ModuleInfo)
  334.  
  335. instance Storable Information => Storable (Maybe Information) where
  336.     sizeOf    _ = 12
  337.     alignment _ = #alignment Maybe_t
  338.    
  339.     poke ptr Nothing = do
  340.         (#poke Maybe_t, tag) ptr cMaybeNothing
  341.         newptr659112 <- malloc :: IO (Ptr (Maybe Information))
  342.         (#poke Maybe_t, elt) ptr newptr659112
  343.  
  344.     poke ptr (Just a1) = do
  345.         (#poke Maybe_t, tag) ptr cMaybeJust
  346.         newptr659112 <- malloc :: IO (Ptr (Maybe Information))
  347.         (#poke Just_t, maybe_just_var1) newptr659112 (toFFI a1 :: InformationPtr)
  348.         (#poke Maybe_t, elt) ptr newptr659112
  349.  
  350.     peek ptr = do
  351.         tag' <- (#peek Maybe_t, tag) ptr :: IO CInt
  352.         case tag' of
  353.           0 -> do
  354.             return $ Nothing
  355.           1 -> do
  356.             a1' <- (#peek Just_t, maybe_just_var1) ptr :: IO InformationPtr
  357.             return $ Just (fromFFI a1' :: Information)
  358.  
  359. instance Storable CWString => Storable (Maybe String) where
  360.     sizeOf    _ = 12
  361.     alignment _ = #alignment Maybe_t
  362.    
  363.     poke ptr Nothing = do
  364.         (#poke Maybe_t, tag) ptr cMaybeNothing
  365.         newptr659112 <- malloc :: IO (Ptr (Maybe String))
  366.         (#poke Maybe_t, elt) ptr newptr659112
  367.  
  368.     poke ptr (Just a1) = do
  369.         (#poke Maybe_t, tag) ptr cMaybeJust
  370.         newptr659112 <- malloc :: IO (Ptr (Maybe String))
  371.         (#poke Just_t, maybe_just_var1) newptr659112 (toFFI a1 :: CWString)
  372.         (#poke Maybe_t, elt) ptr newptr659112
  373.  
  374.     peek ptr = do
  375.         tag' <- (#peek Maybe_t, tag) ptr :: IO CInt
  376.         case tag' of
  377.           0 -> do
  378.             return $ Nothing
  379.           1 -> do
  380.             a1' <- (#peek Just_t, maybe_just_var1) ptr :: IO CWString
  381.             return $ Just (fromFFI a1' :: String)
  382.  
  383. instance Storable SrcSpan => Storable (Maybe SrcSpan) where
  384.     sizeOf    _ = 12
  385.     alignment _ = #alignment Maybe_t
  386.    
  387.     poke ptr Nothing = do
  388.         (#poke Maybe_t, tag) ptr cMaybeNothing
  389.         newptr659112 <- malloc :: IO (Ptr (Maybe SrcSpan))
  390.         (#poke Maybe_t, elt) ptr newptr659112
  391.  
  392.     poke ptr (Just a1) = do
  393.         (#poke Maybe_t, tag) ptr cMaybeJust
  394.         newptr659112 <- malloc :: IO (Ptr (Maybe SrcSpan))
  395.         (#poke Just_t, maybe_just_var1) newptr659112 (toFFI a1 :: SrcSpanPtr)
  396.         (#poke Maybe_t, elt) ptr newptr659112
  397.  
  398.     peek ptr = do
  399.         tag' <- (#peek Maybe_t, tag) ptr :: IO CInt
  400.         case tag' of
  401.           0 -> do
  402.             return $ Nothing
  403.           1 -> do
  404.             a1' <- (#peek Just_t, maybe_just_var1) ptr :: IO SrcSpanPtr
  405.             return $ Just (fromFFI a1' :: SrcSpan)
  406.  
  407. instance Storable ((CInt, [CWString])) => Storable (Maybe ((Int, [String]))) where
  408.     sizeOf    _ = 12
  409.     alignment _ = #alignment Maybe_t
  410.    
  411.     poke ptr Nothing = do
  412.         (#poke Maybe_t, tag) ptr cMaybeNothing
  413.         newptr659112 <- malloc :: IO (Ptr (Maybe ((Int, [String]))))
  414.         (#poke Maybe_t, elt) ptr newptr659112
  415.  
  416.     poke ptr (Just a1) = do
  417.         (#poke Maybe_t, tag) ptr cMaybeJust
  418.         newptr659112 <- malloc :: IO (Ptr (Maybe ((Int, [String]))))
  419.         (#poke Just_t, maybe_just_var1) newptr659112 (toFFI a1 :: ((Tuple2Ptr CInt ((Ptr (CWString))))))
  420.         (#poke Maybe_t, elt) ptr newptr659112
  421.  
  422.     peek ptr = do
  423.         tag' <- (#peek Maybe_t, tag) ptr :: IO CInt
  424.         case tag' of
  425.           0 -> do
  426.             return $ Nothing
  427.           1 -> do
  428.             a1' <- (#peek Just_t, maybe_just_var1) ptr :: IO ((Tuple2Ptr CInt ((Ptr (CWString)))))
  429.             return $ Just (fromFFI a1' :: ((Int, [String])))
clone this paste RAW Paste Data