packages feed

ngx-export 0.1.0.0 → 0.1.1.0

raw patch · 2 files changed

+33/−40 lines, 2 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- NgxExport: instance GHC.Enum.Enum NgxExport.NgxExport

Files

NgxExport.hs view
@@ -26,16 +26,35 @@ import qualified Data.ByteString.Unsafe as B import qualified Data.ByteString.Lazy as L +data NgxExport = SS            (String -> String)+               | SSS           (String -> String -> String)+               | SLS           ([String] -> String)+               | BS            (String -> Bool)+               | BSS           (String -> String -> Bool)+               | BLS           ([String] -> Bool)+               | YY            (B.ByteString -> L.ByteString)+               | BY            (B.ByteString -> Bool)+               | Handler       (B.ByteString -> (L.ByteString, String, Int))+               | UnsafeHandler (B.ByteString ->+                                    (B.ByteString, B.ByteString, Int))++let name = mkName "exportType" in sequence+    [sigD name [t|NgxExport -> IO CInt|],+     funD name $+         map (\(c, i) -> clause [conP c [wildP]] (normalB [|return i|]) [])+             (zip ['SS, 'SSS, 'SLS, 'BS, 'BSS, 'BLS, 'YY, 'BY,+                   'Handler, 'UnsafeHandler] [1 ..] :: [(Name, Int)])+    ]+ ngxExport :: Name -> Name -> Q Type -> Name -> Q [Dec] ngxExport e h t f = sequence-    [funD nameFt $ body [|exportType $ $eVar $fVar|],-     fmap (ForeignD . ExportF CCall ftName nameFt) [t|IO CInt|],-     funD nameF $ body [|$hVar $ $eVar $fVar|],-     fmap (ForeignD . ExportF CCall fName nameF) t+    [funD nameFt $ body [|exportType $efVar|],+     ForeignD . ExportF CCall ftName nameFt <$> [t|IO CInt|],+     funD nameF $ body [|$hVar $efVar|],+     ForeignD . ExportF CCall fName nameF <$> t     ]-    where eVar   = conE e-          hVar   = varE h-          fVar   = varE f+    where hVar   = varE h+          efVar  = conE e `appE` varE f           fName  = "ngx_hs_" ++ nameBase f           nameF  = mkName fName           ftName = "type_" ++ fName@@ -78,34 +97,6 @@     [t|CString -> CInt ->        Ptr CString -> Ptr CSize -> Ptr CString -> Ptr CSize -> IO CInt|] -data NgxExport = SS (String -> String)-               | SSS (String -> String -> String)-               | SLS ([String] -> String)-               | BS (String -> Bool)-               | BSS (String -> String -> Bool)-               | BLS ([String] -> Bool)-               | YY (B.ByteString -> L.ByteString)-               | BY (B.ByteString -> Bool)-               | Handler (B.ByteString -> (L.ByteString, String, Int))-               | UnsafeHandler (B.ByteString ->-                                    (B.ByteString, B.ByteString, Int))--instance Enum NgxExport where-    toEnum _ = SS id    -- not used-    fromEnum (SS _)            = 1-    fromEnum (SSS _)           = 2-    fromEnum (SLS _)           = 3-    fromEnum (BS _)            = 4-    fromEnum (BSS _)           = 5-    fromEnum (BLS _)           = 6-    fromEnum (YY _)            = 7-    fromEnum (BY _)            = 8-    fromEnum (Handler _)       = 9-    fromEnum (UnsafeHandler _) = 10--exportType :: NgxExport -> IO CInt-exportType = return . fromIntegral . fromEnum- data NgxStrType = NgxStrType CSize CString  instance Storable NgxStrType where@@ -117,9 +108,9 @@         n <- peekByteOff p 0         s <- peekByteOff p $ alignment (undefined :: NgxStrType)         return $ NgxStrType n s-    poke p a@(NgxStrType n s) = do+    poke p x@(NgxStrType n s) = do         poke (castPtr p) n-        poke (plusPtr p $ alignment a) s+        poke (plusPtr p $ alignment x) s  catchAlloc :: IO (Ptr a) -> IO (Ptr a) catchAlloc = (`catchIOError` const (return nullPtr))@@ -254,3 +245,4 @@     (smt, fromIntegral -> lmt) <- B.unsafeUseAsCStringLen mt return     pokeCStringLen smt lmt pt plt     return st+
ngx-export.cabal view
@@ -1,7 +1,8 @@ name:                ngx-export-version:             0.1.0.0-synopsis:            Export custom haskell functions into nginx configuration-description:         Please see README.md+version:             0.1.1.0+synopsis:            Helper module for Nginx haskell module+description:         Helper module for+        <http://github.com/lyokha/nginx-haskell-module Nginx haskell module> homepage:            http://github.com/lyokha/nginx-haskell-module license:             BSD3 license-file:        LICENSE