packages feed

hoppy-generator 0.3.1 → 0.3.2

raw patch · 4 files changed

+41/−26 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Foreign.Hoppy.Generator.Main: defaultMain :: Either String Interface -> IO ()

Files

hoppy-generator.cabal view
@@ -1,5 +1,5 @@ name: hoppy-generator-version: 0.3.1+version: 0.3.2 synopsis: C++ FFI generator - Code generator homepage: http://khumba.net/projects/hoppy license: AGPL-3
src/Foreign/Hoppy/Generator/Main.hs view
@@ -19,28 +19,21 @@  -- | A driver for a command-line interface to a generator. ----- A simple @Main.hs@ for a generator can be:+-- A simple @Main.hs@ for a generator can simply be: ----- > import Foreign.Hoppy.Generator.Main (run)--- > import Foreign.Hoppy.Generator.Spec (ErrorMsg, Interface, interface, interfaceResult)--- > import System.Environment (getArgs)--- > import System.Exit (exitFailure)--- > import System.IO (hPutStrLn, stderr)--- >--- > iface :: Either ErrorMsg Interface--- > iface = interface ...--- >--- > main :: IO ()--- > main = case interfaceResult of--- >   Left errorMsg -> do--- >     hPutStrLn stderr $ "Error initializing interface: " ++ errorMsg--- >     exitFailure--- >   Right iface -> do--- >     args <- getArgs--- >     _ <- run [iface] args--- >     return ()+-- @+-- import "Foreign.Hoppy.Generator.Main" ('defaultMain')+-- import "Foreign.Hoppy.Generator.Spec" ('ErrorMsg', 'Interface', 'interface')+--+-- interfaceResult :: Either 'ErrorMsg' 'Interface'+-- interfaceResult = 'interface' ...+--+-- main :: IO ()+-- main = 'defaultMain' interfaceResult+-- @ module Foreign.Hoppy.Generator.Main (   Action (..),+  defaultMain,   run,   ) where @@ -59,6 +52,7 @@ import qualified Foreign.Hoppy.Generator.Language.Haskell.Internal as Haskell import Foreign.Hoppy.Generator.Spec import System.Directory (createDirectoryIfMissing, doesDirectoryExist)+import System.Environment (getArgs) import System.Exit (exitFailure, exitSuccess) import System.FilePath ((</>), takeDirectory) import System.IO (hPutStrLn, stderr)@@ -109,6 +103,24 @@   _ -> case Haskell.generate $ cacheInterface cache of     l@(Left _) -> return (cache, l)     r@(Right gen) -> return (cache { generatedHaskell = Just gen }, r)++-- | This provides a simple @main@ function for a generator.  Define your @main@+-- as:+--+-- @+-- main = defaultMain $ 'interface' ...+-- @+--+-- Refer to 'run' for how to use the command-line interface.+defaultMain :: Either String Interface -> IO ()+defaultMain interfaceResult = case interfaceResult of+  Left errorMsg -> do+    hPutStrLn stderr $ "Error initializing interface: " ++ errorMsg+    exitFailure+  Right iface -> do+    args <- getArgs+    _ <- run [iface] args+    return ()  -- | @run interfaces args@ runs the driver with the command-line arguments from -- @args@ against the listed interfaces, and returns the list of actions
src/Foreign/Hoppy/Generator/Spec/Base.hs view
@@ -1416,7 +1416,8 @@ makeClass :: Identifier           -> Maybe ExtName           -- ^ An optional external name; will be automatically derived from the-          -- identifier if absent.+          -- identifier if absent by dropping leading namespaces, and taking the+          -- last component (sans template arguments).           -> [Class]  -- ^ Superclasses.           -> [ClassEntity]           -> Class@@ -1563,7 +1564,7 @@     -- add exports.   , classHaskellConversionToCppFn :: Maybe (Haskell.Generator ())     -- ^ Produces a Haskell expression that evaluates to a function that takes-    -- an object of the type that 'classHaskellConversionType' generates, and+    -- an value of the type that 'classHaskellConversionType' generates, and     -- returns a non-const handle for a new C++ object in IO.  The generator     -- must output code and may add imports, but must not add exports.     --@@ -1571,9 +1572,10 @@     -- present.   , classHaskellConversionFromCppFn :: Maybe (Haskell.Generator ())     -- ^ Produces a Haskell expression that evaluates to a function that takes a-    -- const handle for a C++ object, and returns an value of the type that-    -- 'classHaskellConversionType' generates, in IO.  The generator must output-    -- code and may add imports, but must not add exports.+    -- const handle for a C++ object, and returns a value of the type that+    -- 'classHaskellConversionType' generates, in IO.  It should not delete the+    -- handle.  The generator must output code and may add imports, but must not+    -- add exports.     --     -- If this field is present, then 'classHaskellConversionType' must also be     -- present.
src/Foreign/Hoppy/Generator/Types.hs view
@@ -154,7 +154,8 @@ -- | A handle for calling foreign code from C++. callbackT = Internal_TCallback --- | An instance of a class.+-- | An instance of a class.  When used in a parameter or return type and not+-- wrapped in a 'ptrT' or 'refT', this is a by-value object. objT = Internal_TObj  -- | A special case of 'objT' that is only allowed when passing objects from