Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package ghc-hslua-core for openSUSE:Factory checked in at 2023-04-14 13:13:00 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-hslua-core (Old) and /work/SRC/openSUSE:Factory/.ghc-hslua-core.new.19717 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-hslua-core" Fri Apr 14 13:13:00 2023 rev:5 rq:1079182 version:2.3.1 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-hslua-core/ghc-hslua-core.changes 2023-04-04 21:20:41.485289083 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-hslua-core.new.19717/ghc-hslua-core.changes 2023-04-14 13:13:09.919593778 +0200 @@ -1,0 +2,34 @@ +Thu Apr 13 17:23:49 UTC 2023 - Peter Simons <[email protected]> + +- Update hslua-core to version 2.3.1. + ## hslua-core-2.3.1 + + Released 2023-03-17. + + - New module *HsLua.Core.Debug*: the module provides bindings to + a subset of functions of the Lua debug interface. Currently + the module only exports `getupvalue` and `setupvalue`, both of + which are also re-exported from *HsLua.Core*. + + ## hslua-core-2.3.0 + + Released 2023-03-13. + + - The functions `loadfile`, `dofile`, and `dofileTrace` now + expect the argument to be of type `Maybe FilePath`. The + functions load from *stdin* when the argument is `Nothing`. + + - Added `setwarnf'` for simple warning messgae handling: The + built-in method of setting a warn function is flexible but not + straight-forward to use. The new `setwarnf'` function allows + to set a Haskell action as a warning hook: the default warning + behavior is kept in place, but, in addition to the default + action, the hook is called on the concatenated warning + messages. This can be used to plug Lua warnings into an + application specific Haskell reporting system. + + - Export `GCManagedState`, `newGCManagedState`, + `closeGCManagedState`, and `withGCManagedState` from + `HsLua.Core`. + +------------------------------------------------------------------- Old: ---- hslua-core-2.2.1.tar.gz New: ---- hslua-core-2.3.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-hslua-core.spec ++++++ --- /var/tmp/diff_new_pack.um7TOU/_old 2023-04-14 13:13:11.415602333 +0200 +++ /var/tmp/diff_new_pack.um7TOU/_new 2023-04-14 13:13:11.419602356 +0200 @@ -20,7 +20,7 @@ %global pkgver %{pkg_name}-%{version} %bcond_with tests Name: ghc-%{pkg_name} -Version: 2.2.1 +Version: 2.3.1 Release: 0 Summary: Bindings to Lua, an embeddable scripting language License: MIT ++++++ hslua-core-2.2.1.tar.gz -> hslua-core-2.3.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/CHANGELOG.md new/hslua-core-2.3.1/CHANGELOG.md --- old/hslua-core-2.2.1/CHANGELOG.md 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/CHANGELOG.md 2001-09-09 03:46:40.000000000 +0200 @@ -2,6 +2,36 @@ `hslua-core` uses [PVP Versioning][]. +## hslua-core-2.3.1 + +Released 2023-03-17. + +- New module *HsLua.Core.Debug*: the module provides bindings to + a subset of functions of the Lua debug interface. Currently + the module only exports `getupvalue` and `setupvalue`, both of + which are also re-exported from *HsLua.Core*. + +## hslua-core-2.3.0 + +Released 2023-03-13. + +- The functions `loadfile`, `dofile`, and `dofileTrace` now + expect the argument to be of type `Maybe FilePath`. The + functions load from *stdin* when the argument is `Nothing`. + +- Added `setwarnf'` for simple warning messgae handling: The + built-in method of setting a warn function is flexible but not + straight-forward to use. The new `setwarnf'` function allows + to set a Haskell action as a warning hook: the default warning + behavior is kept in place, but, in addition to the default + action, the hook is called on the concatenated warning + messages. This can be used to plug Lua warnings into an + application specific Haskell reporting system. + +- Export `GCManagedState`, `newGCManagedState`, + `closeGCManagedState`, and `withGCManagedState` from + `HsLua.Core`. + ## hslua-core-2.2.1 Released 2022-06-19. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/LICENSE new/hslua-core-2.3.1/LICENSE --- old/hslua-core-2.2.1/LICENSE 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/LICENSE 2001-09-09 03:46:40.000000000 +0200 @@ -1,7 +1,7 @@ Copyright © 1994-2022 Lua.org, PUC-Rio. Copyright © 2007-2012 Gracjan Polak Copyright © 2012-2015 Ãmer Sinan AÄacan -Copyright © 2016-2022 Albert Krewinkel +Copyright © 2016-2023 Albert Krewinkel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/hslua-core.cabal new/hslua-core-2.3.1/hslua-core.cabal --- old/hslua-core-2.2.1/hslua-core.cabal 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/hslua-core.cabal 2001-09-09 03:46:40.000000000 +0200 @@ -1,6 +1,6 @@ cabal-version: 2.2 name: hslua-core -version: 2.2.1 +version: 2.3.1 synopsis: Bindings to Lua, an embeddable scripting language description: Wrappers and helpers to bridge Haskell and <https://www.lua.org/ Lua>. @@ -12,23 +12,22 @@ license: MIT license-file: LICENSE author: Albert Krewinkel, Gracjan Polak, Ãmer Sinan AÄacan -maintainer: [email protected] +maintainer: [email protected] copyright: © 2007â2012 Gracjan Polak; © 2012â2016 Ãmer Sinan AÄacan; - © 2017-2022 Albert Krewinkel + © 2017-2023 Albert Krewinkel category: Foreign build-type: Simple extra-source-files: README.md , CHANGELOG.md , test/lua/*.lua -tested-with: GHC == 8.0.2 - , GHC == 8.2.2 - , GHC == 8.4.4 +tested-with: GHC == 8.4.4 , GHC == 8.6.5 , GHC == 8.8.4 , GHC == 8.10.7 , GHC == 9.0.2 - , GHC == 9.2.3 + , GHC == 9.2.5 + , GHC == 9.4.4 source-repository head type: git @@ -36,10 +35,10 @@ common common-options default-language: Haskell2010 - build-depends: base >= 4.8 && < 5 + build-depends: base >= 4.11 && < 5 , bytestring >= 0.10.2 && < 0.12 , exceptions >= 0.8 && < 0.11 - , lua >= 2.2.1 && < 2.3 + , lua >= 2.3.1 && < 2.4 , mtl >= 2.2 && < 2.4 , text >= 1.2 && < 2.1 ghc-options: -Wall @@ -59,6 +58,7 @@ import: common-options exposed-modules: HsLua.Core , HsLua.Core.Closures + , HsLua.Core.Debug , HsLua.Core.Error , HsLua.Core.Package , HsLua.Core.Run @@ -69,6 +69,7 @@ , HsLua.Core.Utf8 other-modules: HsLua.Core.Auxiliary , HsLua.Core.Primary + , HsLua.Core.Warn reexported-modules: lua:Lua hs-source-dirs: src default-extensions: LambdaCase @@ -89,6 +90,7 @@ other-modules: HsLua.CoreTests , HsLua.Core.AuxiliaryTests , HsLua.Core.ClosuresTests + , HsLua.Core.DebugTests , HsLua.Core.ErrorTests , HsLua.Core.PackageTests , HsLua.Core.PrimaryTests @@ -96,6 +98,7 @@ , HsLua.Core.TraceTests , HsLua.Core.UnsafeTests , HsLua.Core.UserdataTests + , HsLua.Core.WarnTests , Test.Tasty.HsLua , Test.HsLua.Arbitrary build-depends: hslua-core diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/src/HsLua/Core/Auxiliary.hs new/hslua-core-2.3.1/src/HsLua/Core/Auxiliary.hs --- old/hslua-core-2.2.1/src/HsLua/Core/Auxiliary.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/src/HsLua/Core/Auxiliary.hs 2001-09-09 03:46:40.000000000 +0200 @@ -6,9 +6,9 @@ Module : HsLua.Core.Auxiliary Copyright : © 2007â2012 Gracjan Polak; © 2012â2016 Ãmer Sinan AÄacan; - © 2017-2022 Albert Krewinkel + © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : beta Portability : non-portable (depends on GHC) @@ -87,8 +87,8 @@ -- | Loads and runs the given file. Note that the filepath is -- interpreted by Lua, not Haskell. The resulting chunk is named using -- the UTF8 encoded filepath. -dofile :: FilePath -> LuaE e Status -dofile fp = loadfile fp >>= \case +dofile :: Maybe FilePath -> LuaE e Status +dofile mfp = loadfile mfp >>= \case Lua.OK -> Lua.pcall 0 multret Nothing err -> return err {-# INLINABLE dofile #-} @@ -161,8 +161,9 @@ {-# INLINABLE loadbuffer #-} -- | Loads a file as a Lua chunk. This function uses @lua_load@ (see --- @'Lua.load'@) to load the chunk in the file named filename. The first --- line in the file is ignored if it starts with a @#@. +-- @'Lua.load'@) to load the chunk in the file named @filename@. If +-- filename is @Nothing@, then it loads from the standard input. The +-- first line in the file is ignored if it starts with a @#@. -- -- The string mode works as in function @'Lua.load'@. -- @@ -174,15 +175,19 @@ -- it. -- -- See <https://www.lua.org/manual/5.4/manual.html#luaL_loadfile luaL_loadfile>. -loadfile :: FilePath -- ^ filename +loadfile :: Maybe FilePath -- ^ filename -> LuaE e Status -loadfile fp = liftLua $ \l -> do +loadfile mfp = liftLua $ \l -> do #if defined(mingw32_HOST_OS) fsEncoding <- GHC.mkTextEncoding "CP0" -- a.k.a CP_ACP #else fsEncoding <- GHC.getFileSystemEncoding #endif - GHC.withCString fsEncoding fp $! fmap Lua.toStatus . luaL_loadfile l + case mfp of + Just fp -> + GHC.withCString fsEncoding fp $! fmap Lua.toStatus . luaL_loadfile l + Nothing -> + Lua.toStatus <$!> luaL_loadfile l nullPtr {-# INLINABLE loadfile #-} -- | Loads a string as a Lua chunk. This function uses @lua_load@ to diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/src/HsLua/Core/Closures.hs new/hslua-core-2.3.1/src/HsLua/Core/Closures.hs --- old/hslua-core-2.2.1/src/HsLua/Core/Closures.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/src/HsLua/Core/Closures.hs 2001-09-09 03:46:40.000000000 +0200 @@ -2,9 +2,9 @@ Module : HsLua.Core.Closures Copyright : © 2007â2012 Gracjan Polak; © 2012â2016 Ãmer Sinan AÄacan; - © 2017-2022 Albert Krewinkel + © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : beta Portability : non-portable (depends on GHC) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/src/HsLua/Core/Debug.hs new/hslua-core-2.3.1/src/HsLua/Core/Debug.hs --- old/hslua-core-2.2.1/src/HsLua/Core/Debug.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/hslua-core-2.3.1/src/HsLua/Core/Debug.hs 2001-09-09 03:46:40.000000000 +0200 @@ -0,0 +1,62 @@ +{-| +Module : HsLua.Core.Debug +Copyright : © 2023 Albert Krewinkel +License : MIT +Maintainer : Albert Krewinkel <[email protected]> + +Bindings to Lua's debug interface. +-} +module HsLua.Core.Debug + ( getupvalue + , setupvalue + ) where + +import Control.Monad ((<$!>)) +import Foreign.C (CString) +import Foreign.Ptr (nullPtr) +import HsLua.Core.Types (LuaE, Name (Name), StackIndex, liftLua) +import Lua.Debug (lua_getupvalue, lua_setupvalue) +import qualified Data.ByteString as B + +-- | Gets information about the @n@-th upvalue of the closure at index +-- @funcindex@. It pushes the upvalue's value onto the stack and returns +-- its name. Returns 'Nothing' (and pushes nothing) when the index @n@ +-- is greater than the number of upvalues. +-- +-- See +-- <https://www.lua.org/manual/5.4/manual.html#pdf-debug.getupvalue debug.getupvalue> +-- for more information about upvalues. +-- +-- @[0, +(0|1), -]@ +-- +-- Wraps 'lua_getupvalue'. +getupvalue :: StackIndex -- ^ funcindex + -> Int -- ^ n + -> LuaE e (Maybe Name) +getupvalue idx n = liftLua $ \l -> + lua_getupvalue l idx (fromIntegral n) >>= toMaybeName + +-- | Sets the value of a closureâs upvalue. It assigns the value on the +-- top of the stack to the upvalue and returns its name. It also pops +-- the value from the stack. +-- +-- Returns 'Nothing' (and pops nothing) when the index @n@ is greater +-- than the number of upvalues. +-- +-- Parameters @funcindex@ and @n@ are as in the function 'getupvalue'. +-- +-- @[-(0|1), +0, -]@ +-- +-- Wraps 'lua_setupvalue'. +setupvalue :: StackIndex -- ^ funcindex + -> Int -- ^ n + -> LuaE e (Maybe Name) +setupvalue idx n = liftLua $ \l -> + lua_setupvalue l idx (fromIntegral n) >>= toMaybeName + +-- | Convert a (possibly @NULL@) null-terminated C string to a name. +toMaybeName :: CString -> IO (Maybe Name) +toMaybeName cstr = + if cstr == nullPtr + then return Nothing + else Just . Name <$!> B.packCString cstr diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/src/HsLua/Core/Error.hs new/hslua-core-2.3.1/src/HsLua/Core/Error.hs --- old/hslua-core-2.2.1/src/HsLua/Core/Error.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/src/HsLua/Core/Error.hs 2001-09-09 03:46:40.000000000 +0200 @@ -8,9 +8,9 @@ {-# OPTIONS_GHC -Wno-warnings-deprecations #-} {-| Module : HsLua.Core.Error -Copyright : © 2017-2022 Albert Krewinkel +Copyright : © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Lua exceptions and exception handling. -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/src/HsLua/Core/Package.hs new/hslua-core-2.3.1/src/HsLua/Core/Package.hs --- old/hslua-core-2.2.1/src/HsLua/Core/Package.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/src/HsLua/Core/Package.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,8 +1,8 @@ {-| Module : HsLua.Core.Package -Copyright : © 2019-2022 Albert Krewinkel +Copyright : © 2019-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : alpha Portability : Requires GHC 8 or later. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/src/HsLua/Core/Primary.hs new/hslua-core-2.3.1/src/HsLua/Core/Primary.hs --- old/hslua-core-2.2.1/src/HsLua/Core/Primary.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/src/HsLua/Core/Primary.hs 2001-09-09 03:46:40.000000000 +0200 @@ -3,9 +3,9 @@ Module : HsLua.Core.Primary Copyright : © 2007â2012 Gracjan Polak; © 2012â2016 Ãmer Sinan AÄacan; - © 2017-2022 Albert Krewinkel + © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : beta Portability : non-portable (depends on GHC) @@ -888,6 +888,15 @@ setiuservalue idx n = liftLua $ \l -> fromLuaBool <$!> lua_setiuservalue l idx (fromIntegral n) +-- | Sets the warning function to be used by Lua to emit warnings (see +-- 'WarnFunction'). The @ud@ parameter sets the value @ud@ passed to the +-- warning function. +setwarnf :: WarnFunction -- ^ f + -> Ptr () -- ^ ud + -> LuaE e () +setwarnf f ud = liftLua $ \l -> + lua_setwarnf l f ud + -- | Returns the status of this Lua thread. -- -- The status can be 'OK' for a normal thread, an error value if the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/src/HsLua/Core/Run.hs new/hslua-core-2.3.1/src/HsLua/Core/Run.hs --- old/hslua-core-2.2.1/src/HsLua/Core/Run.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/src/HsLua/Core/Run.hs 2001-09-09 03:46:40.000000000 +0200 @@ -2,9 +2,9 @@ Module : HsLua.Core.Run Copyright : © 2007â2012 Gracjan Polak; © 2012â2016 Ãmer Sinan AÄacan; - © 2017-2022 Albert Krewinkel + © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : beta Portability : non-portable (depends on GHC) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/src/HsLua/Core/Trace.hs new/hslua-core-2.3.1/src/HsLua/Core/Trace.hs --- old/hslua-core-2.2.1/src/HsLua/Core/Trace.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/src/HsLua/Core/Trace.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,9 +1,9 @@ {-# LANGUAGE TypeApplications #-} {-| Module : HsLua.Core.Trace -Copyright : © 2017-2022 Albert Krewinkel +Copyright : © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Helper functions to call Lua functions with tracebacks. -} @@ -44,7 +44,7 @@ -- | Run the given file as a Lua program, while also adding a -- traceback to the error message if an error occurs. -dofileTrace :: FilePath -> LuaE e Status +dofileTrace :: Maybe FilePath -> LuaE e Status dofileTrace fp = loadfile fp >>= \case OK -> pcallTrace 0 multret s -> pure s diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/src/HsLua/Core/Types.hs new/hslua-core-2.3.1/src/HsLua/Core/Types.hs --- old/hslua-core-2.2.1/src/HsLua/Core/Types.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/src/HsLua/Core/Types.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,12 +1,11 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-| Module : HsLua.Core.Types Copyright : © 2007â2012 Gracjan Polak; © 2012â2016 Ãmer Sinan AÄacan; - © 2017-2022 Albert Krewinkel + © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : beta Portability : non-portable (depends on GHC) @@ -81,9 +80,6 @@ , toReference ) import qualified HsLua.Core.Utf8 as Utf8 -#if !MIN_VERSION_base(4,12,0) -import Data.Semigroup (Semigroup) -#endif -- | Environment in which Lua computations are evaluated. newtype LuaEnvironment = LuaEnvironment @@ -129,6 +125,9 @@ {-# INLINABLE runWith #-} -- | Run the given operation, but crash if any Haskell exceptions occur. +-- +-- This function is identical to 'runWith'; it exists for backwards +-- compatibility. unsafeRunWith :: State -> LuaE e a -> IO a unsafeRunWith = runWith @@ -153,7 +152,7 @@ | TypeFunction -- ^ type of functions, either normal or @'CFunction'@ | TypeUserdata -- ^ type of full user data | TypeThread -- ^ type of Lua threads - deriving (Bounded, Eq, Ord, Show) + deriving (Bounded, Eq, Ord, Show, Read) instance Enum Type where fromEnum = fromIntegral . fromTypeCode . fromType diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/src/HsLua/Core/Unsafe.hs new/hslua-core-2.3.1/src/HsLua/Core/Unsafe.hs --- old/hslua-core-2.2.1/src/HsLua/Core/Unsafe.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/src/HsLua/Core/Unsafe.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,9 +1,9 @@ {-# OPTIONS_GHC -Wno-warnings-deprecations #-} {-| Module : HsLua.Core.Unsafe -Copyright : © 2019-2022 Albert Krewinkel +Copyright : © 2019-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Unsafe Lua functions. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/src/HsLua/Core/Userdata.hs new/hslua-core-2.3.1/src/HsLua/Core/Userdata.hs --- old/hslua-core-2.2.1/src/HsLua/Core/Userdata.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/src/HsLua/Core/Userdata.hs 2001-09-09 03:46:40.000000000 +0200 @@ -3,9 +3,9 @@ Module : HsLua.Core.Userdata Copyright : © 2007â2012 Gracjan Polak; © 2012â2016 Ãmer Sinan AÄacan; - © 2017-2022 Albert Krewinkel + © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : beta Portability : non-portable (depends on GHC) @@ -29,7 +29,9 @@ -- | Creates a new userdata wrapping the given Haskell object. The -- userdata is pushed to the top of the stack. -newhsuserdatauv :: forall a e. a -> Int -> LuaE e () +newhsuserdatauv :: forall a e. a -- ^ Haskell object + -> Int -- ^ number of extra userdata values + -> LuaE e () newhsuserdatauv x nuvalue = liftLua $ \l -> hslua_newhsuserdatauv l x (fromIntegral nuvalue) {-# INLINABLE newhsuserdatauv #-} @@ -38,6 +40,8 @@ -- Haskell value; checks whether a metatable of that name has been -- registered yet and uses the registered table if possible. -- +-- Returns 'True' if a new metatable was created, and 'False' otherwise. +-- -- Using a metatable created by this functions ensures that the pointer -- to the Haskell value will be freed when the userdata object is -- garbage collected in Lua. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/src/HsLua/Core/Utf8.hs new/hslua-core-2.3.1/src/HsLua/Core/Utf8.hs --- old/hslua-core-2.2.1/src/HsLua/Core/Utf8.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/src/HsLua/Core/Utf8.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,8 +1,8 @@ {-| Module : HsLua.Core.Utf8 -Copyright : © 2018-2022 Albert Krewinkel +Copyright : © 2018-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : beta Portability : portable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/src/HsLua/Core/Warn.hs new/hslua-core-2.3.1/src/HsLua/Core/Warn.hs --- old/hslua-core-2.2.1/src/HsLua/Core/Warn.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/hslua-core-2.3.1/src/HsLua/Core/Warn.hs 2001-09-09 03:46:40.000000000 +0200 @@ -0,0 +1,42 @@ +{-| +Module : HsLua.Core.Warn +Copyright : © 2023 Albert Krewinkel +License : MIT +Maintainer : Albert Krewinkel <[email protected]> + +Simpler interface to the Lua warnings system. + +This module simplifies the process of setting a custom warn function. +-} +module HsLua.Core.Warn + ( setwarnf' + ) where + +import Data.ByteString (ByteString) +import HsLua.Core.Closures (pushHaskellFunction) +import HsLua.Core.Error (LuaError) +import HsLua.Core.Primary (tostring) +import HsLua.Core.Types (LuaE, NumResults (..), liftLua, nthBottom) +import Lua.Warn (hsluaL_setwarnf) + +-- | Sets a warning function. This is a simplified version of +-- 'lua_setwarnf'. The given function is called with the concatenated +-- warning components as the single argument. +-- +-- Control messages are handled internally and are /not/ passed on the +-- warning hook. As with the default warning function, the control +-- messages @\@on@ and @\@off@ can switch error reporting to stderr on +-- and off. The given Haskell function will be called in either case, +-- even when the error is not written to stderr. +-- +-- Wraps 'hsluaL_setwarnf'. +setwarnf' :: LuaError e + => (ByteString -> LuaE e ()) + -> LuaE e () +setwarnf' fn = do + pushHaskellFunction $ do + mbmsg <- tostring (nthBottom 1) + case mbmsg of + Nothing -> pure (NumResults 0) -- couldn't get warning msg; do nothing + Just msg -> NumResults 0 <$ fn msg + liftLua hsluaL_setwarnf diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/src/HsLua/Core.hs new/hslua-core-2.3.1/src/HsLua/Core.hs --- old/hslua-core-2.2.1/src/HsLua/Core.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/src/HsLua/Core.hs 2001-09-09 03:46:40.000000000 +0200 @@ -2,9 +2,9 @@ Module : HsLua.Core Copyright : © 2007â2012 Gracjan Polak; © 2012â2016 Ãmer Sinan AÄacan; - © 2017-2022 Albert Krewinkel + © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : beta Portability : non-portable (depends on GHC) @@ -19,6 +19,10 @@ run , runWith , runEither + , GCManagedState + , newGCManagedState + , closeGCManagedState + , withGCManagedState -- * Lua Computations , LuaE (..) , Lua @@ -144,6 +148,7 @@ , concat , pushglobaltable , register + , setwarnf -- * loading libraries , openbase , opendebug @@ -183,6 +188,13 @@ , callTrace , dofileTrace , dostringTrace + -- ** Warnings + , setwarnf' + + -- * Debug interface + , getupvalue + , setupvalue + -- * Haskell userdata values -- -- | Push arbitrary Haskell values to the Lua stack. @@ -214,6 +226,7 @@ import HsLua.Core.Auxiliary import HsLua.Core.Closures +import HsLua.Core.Debug import HsLua.Core.Error import HsLua.Core.Package import HsLua.Core.Primary @@ -221,3 +234,4 @@ import HsLua.Core.Trace import HsLua.Core.Types as Lua import HsLua.Core.Userdata +import HsLua.Core.Warn diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/test/HsLua/Core/ClosuresTests.hs new/hslua-core-2.3.1/test/HsLua/Core/ClosuresTests.hs --- old/hslua-core-2.2.1/test/HsLua/Core/ClosuresTests.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/test/HsLua/Core/ClosuresTests.hs 2001-09-09 03:46:40.000000000 +0200 @@ -2,10 +2,10 @@ {-# OPTIONS_GHC -fno-warn-deprecations #-} {-| Module : HsLua.Core.ClosuresTests -Copyright : © 2017-2022 Albert Krewinkel +Copyright : © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : stable Portability : portable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/test/HsLua/Core/DebugTests.hs new/hslua-core-2.3.1/test/HsLua/Core/DebugTests.hs --- old/hslua-core-2.2.1/test/HsLua/Core/DebugTests.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/hslua-core-2.3.1/test/HsLua/Core/DebugTests.hs 2001-09-09 03:46:40.000000000 +0200 @@ -0,0 +1,37 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# OPTIONS_GHC -fno-warn-deprecations #-} +{-| +Module : HsLua.Core.DebugTests +Copyright : © 2023 Albert Krewinkel +License : MIT +Maintainer : Albert Krewinkel <[email protected]> + +Test the debug interface. +-} +module HsLua.Core.DebugTests (tests) where + +import HsLua.Core as Lua +import Test.Tasty.HsLua ((=:), shouldBeResultOf) +import Test.Tasty (TestTree, testGroup) + +-- | Specifications for Attributes parsing functions. +tests :: TestTree +tests = testGroup "Debug" + [ "getupvalue" =: + Just "x" `shouldBeResultOf` do + loadstring "local x = 0; return function () return x + 23 end" + call 0 1 + getupvalue top 1 + + , "setupvalue" =: + (Just "i", Just 28) `shouldBeResultOf` do + loadstring "local i = 0; return function () return i + 23 end" + call 0 1 + -- set 'x' to 5 + pushinteger 5 + name <- setupvalue (nth 2) 1 + -- call function and check the returned value + call 0 1 + i <- tointeger top + return (name, i) + ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/test/HsLua/Core/PackageTests.hs new/hslua-core-2.3.1/test/HsLua/Core/PackageTests.hs --- old/hslua-core-2.2.1/test/HsLua/Core/PackageTests.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/test/HsLua/Core/PackageTests.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,10 +1,10 @@ {-# LANGUAGE OverloadedStrings #-} {-| Module : HsLua.Core.RunTests -Copyright : © 2017-2022 Albert Krewinkel +Copyright : © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : stable Portability : portable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/test/HsLua/Core/RunTests.hs new/hslua-core-2.3.1/test/HsLua/Core/RunTests.hs --- old/hslua-core-2.2.1/test/HsLua/Core/RunTests.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/test/HsLua/Core/RunTests.hs 2001-09-09 03:46:40.000000000 +0200 @@ -3,10 +3,10 @@ {-# OPTIONS_GHC -fno-warn-deprecations #-} {-| Module : HsLua.Core.RunTests -Copyright : © 2017-2022 Albert Krewinkel +Copyright : © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : stable Portability : portable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/test/HsLua/Core/TraceTests.hs new/hslua-core-2.3.1/test/HsLua/Core/TraceTests.hs --- old/hslua-core-2.2.1/test/HsLua/Core/TraceTests.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/test/HsLua/Core/TraceTests.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,10 +1,10 @@ {-# LANGUAGE OverloadedStrings #-} {-| Module : HsLua.Core.TraceTests -Copyright : © 2017-2022 Albert Krewinkel +Copyright : © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : stable Portability : portable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/test/HsLua/Core/UnsafeTests.hs new/hslua-core-2.3.1/test/HsLua/Core/UnsafeTests.hs --- old/hslua-core-2.2.1/test/HsLua/Core/UnsafeTests.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/test/HsLua/Core/UnsafeTests.hs 2001-09-09 03:46:40.000000000 +0200 @@ -2,9 +2,9 @@ {-# LANGUAGE OverloadedStrings #-} {-| Module : HsLua.Core.UnsafeTests -Copyright : © 2021-2022 Albert Krewinkel +Copyright : © 2021-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : beta Tests for bindings to unsafe functions. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/test/HsLua/Core/UserdataTests.hs new/hslua-core-2.3.1/test/HsLua/Core/UserdataTests.hs --- old/hslua-core-2.2.1/test/HsLua/Core/UserdataTests.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/test/HsLua/Core/UserdataTests.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,10 +1,10 @@ {-# LANGUAGE OverloadedStrings #-} {-| Module : HsLua.Core.UserdataTests -Copyright : © 2017-2022 Albert Krewinkel +Copyright : © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Tests that any data type can be pushed to Lua. -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/test/HsLua/Core/WarnTests.hs new/hslua-core-2.3.1/test/HsLua/Core/WarnTests.hs --- old/hslua-core-2.2.1/test/HsLua/Core/WarnTests.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/hslua-core-2.3.1/test/HsLua/Core/WarnTests.hs 2001-09-09 03:46:40.000000000 +0200 @@ -0,0 +1,33 @@ +{-# LANGUAGE OverloadedStrings #-} +{-| +Module : HsLua.Core.WarnTests +Copyright : © 2017-2023 Albert Krewinkel +License : MIT + +Maintainer : Albert Krewinkel <[email protected]> + +Check that setting hook for warning messages works. +-} +module HsLua.Core.WarnTests (tests) where + +import HsLua.Core +import Test.Tasty.HsLua ((=:), shouldBeResultOf) +import Test.Tasty (TestTree, testGroup) + +-- | Specifications for Attributes parsing functions. +tests :: TestTree +tests = testGroup "Warn" + [ "warnings get handled" =: + Just "Hi Mom!" `shouldBeResultOf` do + openlibs + setwarnf' $ \msg -> do + pushstring msg + setfield registryindex "hslua testing" + stat <- dostring "warn('Hi', ' ', 'Mom!')" + case stat of + OK -> do + getfield registryindex "hslua testing" + tostring top + _ -> do + throwErrorAsException + ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/test/HsLua/CoreTests.hs new/hslua-core-2.3.1/test/HsLua/CoreTests.hs --- old/hslua-core-2.2.1/test/HsLua/CoreTests.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/test/HsLua/CoreTests.hs 2001-09-09 03:46:40.000000000 +0200 @@ -3,10 +3,10 @@ {-# OPTIONS_GHC -fno-warn-deprecations #-} {-| Module : HsLua.CoreTests -Copyright : © 2017-2022 Albert Krewinkel +Copyright : © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : stable Portability : portable @@ -34,6 +34,7 @@ import qualified Data.ByteString as B import qualified HsLua.Core.AuxiliaryTests import qualified HsLua.Core.ClosuresTests +import qualified HsLua.Core.DebugTests import qualified HsLua.Core.ErrorTests import qualified HsLua.Core.PackageTests import qualified HsLua.Core.PrimaryTests @@ -41,6 +42,7 @@ import qualified HsLua.Core.TraceTests import qualified HsLua.Core.UnsafeTests import qualified HsLua.Core.UserdataTests +import qualified HsLua.Core.WarnTests import qualified Foreign.Marshal as Foreign import qualified Foreign.Ptr as Foreign import qualified Test.QuickCheck.Monadic as QCMonadic @@ -345,17 +347,17 @@ , testGroup "loadfile" [ "file error should be returned when file does not exist" =: - ErrFile `shouldBeResultOf` loadfile "./file-does-not-exist.lua" + ErrFile `shouldBeResultOf` loadfile (Just "./file-does-not-exist.lua") , "loading an invalid file should give a syntax error" =: - ErrSyntax `shouldBeResultOf` loadfile "test/lua/syntax-error.lua" + ErrSyntax `shouldBeResultOf` loadfile (Just "test/lua/syntax-error.lua") , "loading a valid program should succeed" =: - OK `shouldBeResultOf` loadfile "./test/lua/example.lua" + OK `shouldBeResultOf` loadfile (Just "./test/lua/example.lua") , "example fib program should be loaded correctly" =: Just 8 `shouldBeResultOf` do - loadfile "./test/lua/example.lua" *> call 0 0 + loadfile (Just "./test/lua/example.lua") *> call 0 0 getglobal "fib" pushinteger 6 call 1 1 @@ -364,20 +366,20 @@ , testGroup "dofile" [ "file error should be returned when file does not exist" =: - ErrFile `shouldBeResultOf` dofile "./file-does-not-exist.lua" + ErrFile `shouldBeResultOf` dofile (Just "./file-does-not-exist.lua") , "loading an invalid file should give a syntax error" =: - ErrSyntax `shouldBeResultOf` dofile "test/lua/syntax-error.lua" + ErrSyntax `shouldBeResultOf` dofile (Just "test/lua/syntax-error.lua") , "loading a failing program should give an run error" =: - ErrRun `shouldBeResultOf` dofile "test/lua/error.lua" + ErrRun `shouldBeResultOf` dofile (Just "test/lua/error.lua") , "loading a valid program should succeed" =: - OK `shouldBeResultOf` dofile "./test/lua/example.lua" + OK `shouldBeResultOf` dofile (Just "./test/lua/example.lua") , "example fib program should be loaded correctly" =: Just 21 `shouldBeResultOf` do - _ <- dofile "./test/lua/example.lua" + _ <- dofile (Just "./test/lua/example.lua") getglobal "fib" pushinteger 8 call 1 1 @@ -454,6 +456,8 @@ , HsLua.Core.TraceTests.tests , HsLua.Core.UnsafeTests.tests , HsLua.Core.UserdataTests.tests + , HsLua.Core.WarnTests.tests + , HsLua.Core.DebugTests.tests ] compareWith :: (Lua.Integer -> Lua.Integer -> Bool) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/test/Test/HsLua/Arbitrary.hs new/hslua-core-2.3.1/test/Test/HsLua/Arbitrary.hs --- old/hslua-core-2.2.1/test/Test/HsLua/Arbitrary.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/test/Test/HsLua/Arbitrary.hs 2001-09-09 03:46:40.000000000 +0200 @@ -2,10 +2,10 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} {-| Module : HsLua.Core.RunTests -Copyright : © 2017-2022 Albert Krewinkel +Copyright : © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : stable Portability : portable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/test/Test/Tasty/HsLua.hs new/hslua-core-2.3.1/test/Test/Tasty/HsLua.hs --- old/hslua-core-2.2.1/test/Test/Tasty/HsLua.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/test/Test/Tasty/HsLua.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,9 +1,9 @@ {-# LANGUAGE OverloadedStrings #-} {-| Module : Test.Tasty.HsLua -Copyright : © 2017-2022 Albert Krewinkel +Copyright : © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Stability : beta Portability : non-portable (depends on GHC) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-core-2.2.1/test/test-hslua-core.hs new/hslua-core-2.3.1/test/test-hslua-core.hs --- old/hslua-core-2.2.1/test/test-hslua-core.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/hslua-core-2.3.1/test/test-hslua-core.hs 2001-09-09 03:46:40.000000000 +0200 @@ -1,8 +1,8 @@ {-| Module : Main -Copyright : © 2017-2022 Albert Krewinkel +Copyright : © 2017-2023 Albert Krewinkel License : MIT -Maintainer : Albert Krewinkel <[email protected]> +Maintainer : Albert Krewinkel <[email protected]> Tests for HsLua.Core. -}
