Hello community, here is the log from the commit of package ghc-hslua for openSUSE:Leap:15.2 checked in at 2020-02-19 18:39:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/ghc-hslua (Old) and /work/SRC/openSUSE:Leap:15.2/.ghc-hslua.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-hslua" Wed Feb 19 18:39:19 2020 rev:11 rq:771332 version:1.0.3.2 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/ghc-hslua/ghc-hslua.changes 2020-01-15 15:02:08.405801180 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.ghc-hslua.new.26092/ghc-hslua.changes 2020-02-19 18:39:19.838051782 +0100 @@ -1,0 +2,56 @@ +Fri Nov 8 16:13:53 UTC 2019 - Peter Simons <[email protected]> + +- Drop obsolete group attributes. + +------------------------------------------------------------------- +Thu Aug 22 02:02:16 UTC 2019 - [email protected] + +- Update hslua to version 1.0.3.2. + ### 1.0.3.2 + + Released 2019-08-21. + + - Added flag to use hardcoded values for registry keys: The names + of the registry keys used to store package information are + available as CPP values from file lauxlib.h since Lua 5.3.4; + compiling HsLua against older Lua versions was not possible, as + those values were expected to exist. + + The respective values are now hardcoded into HsLua, and a new + flag `hardcode-reg-key` is introduced, which will cause the use + of these hardcoded values instead of those defined in + lauxlib.h. Using this flag makes it possible to compile hslua + against all Lua 5.3.* versions. + + - Added missing C files for benchmarking to list of + *extra-source-files*. + +------------------------------------------------------------------- +Thu May 9 02:01:19 UTC 2019 - [email protected] + +- Update hslua to version 1.0.3.1. + ### 1.0.3.1 + + Released 2019-05-08. + + - Prevent filenames being treated as strings in debug messages. + Lua's `loadbuffer` takes a `source` description as an argument, + which is used for debug messages. The `loadfile` function now + adds a special prefix (`@`) to `source`, thus marking it as a + filename. + +------------------------------------------------------------------- +Sun May 5 02:01:21 UTC 2019 - [email protected] + +- Update hslua to version 1.0.3. + ### 1.0.3 + + Released 2019-05-04. + + - New module `Foreign.Lua.Module`, containing helper functions to + define and load modules from Haskell. + + - Improve documentation of `open<lib>` (many thanks to Christian + Charukiewicz.) + +------------------------------------------------------------------- Old: ---- hslua-1.0.2.tar.gz New: ---- hslua-1.0.3.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-hslua.spec ++++++ --- /var/tmp/diff_new_pack.RQl657/_old 2020-02-19 18:39:20.270052312 +0100 +++ /var/tmp/diff_new_pack.RQl657/_new 2020-02-19 18:39:20.274052317 +0100 @@ -19,11 +19,10 @@ %global pkg_name hslua %bcond_with tests Name: ghc-%{pkg_name} -Version: 1.0.2 +Version: 1.0.3.2 Release: 0 Summary: Bindings to Lua, an embeddable scripting language License: MIT -Group: Development/Libraries/Haskell URL: https://hackage.haskell.org/package/%{pkg_name} Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz BuildRequires: ghc-Cabal-devel @@ -54,7 +53,6 @@ %package devel Summary: Haskell %{pkg_name} library development files -Group: Development/Libraries/Haskell Requires: %{name} = %{version}-%{release} Requires: ghc-compiler = %{ghc_version} Requires(post): ghc-compiler = %{ghc_version} ++++++ hslua-1.0.2.tar.gz -> hslua-1.0.3.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-1.0.2/CHANGELOG.md new/hslua-1.0.3.2/CHANGELOG.md --- old/hslua-1.0.2/CHANGELOG.md 1970-01-01 01:00:00.000000000 +0100 +++ new/hslua-1.0.3.2/CHANGELOG.md 1970-01-01 01:00:00.000000000 +0100 @@ -1,5 +1,45 @@ ## Changelog + +### 1.0.3.2 + +Released 2019-08-21. + +- Added flag to use hardcoded values for registry keys: The names + of the registry keys used to store package information are + available as CPP values from file lauxlib.h since Lua 5.3.4; + compiling HsLua against older Lua versions was not possible, as + those values were expected to exist. + + The respective values are now hardcoded into HsLua, and a new + flag `hardcode-reg-key` is introduced, which will cause the use + of these hardcoded values instead of those defined in + lauxlib.h. Using this flag makes it possible to compile hslua + against all Lua 5.3.* versions. + +- Added missing C files for benchmarking to list of + *extra-source-files*. + +### 1.0.3.1 + +Released 2019-05-08. + +- Prevent filenames being treated as strings in debug messages. + Lua's `loadbuffer` takes a `source` description as an argument, + which is used for debug messages. The `loadfile` function now + adds a special prefix (`@`) to `source`, thus marking it as a + filename. + +### 1.0.3 + +Released 2019-05-04. + +- New module `Foreign.Lua.Module`, containing helper functions to + define and load modules from Haskell. + +- Improve documentation of `open<lib>` (many thanks to Christian + Charukiewicz.) + ### 1.0.2 Released 2019-01-05. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-1.0.2/benchmark/benchmark-functions.h new/hslua-1.0.3.2/benchmark/benchmark-functions.h --- old/hslua-1.0.2/benchmark/benchmark-functions.h 1970-01-01 01:00:00.000000000 +0100 +++ new/hslua-1.0.3.2/benchmark/benchmark-functions.h 1970-01-01 01:00:00.000000000 +0100 @@ -0,0 +1,5 @@ +#include "lua.h" + +int hslua_getlfield(lua_State *L, int index, const char *k, size_t len); + +int hslua_setfield(lua_State *L, int index, const char *k); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-1.0.2/hslua.cabal new/hslua-1.0.3.2/hslua.cabal --- old/hslua-1.0.2/hslua.cabal 1970-01-01 01:00:00.000000000 +0100 +++ new/hslua-1.0.3.2/hslua.cabal 1970-01-01 01:00:00.000000000 +0100 @@ -1,5 +1,5 @@ name: hslua -version: 1.0.2 +version: 1.0.3.2 synopsis: Bindings to Lua, an embeddable scripting language description: HsLua provides bindings, wrappers, types, and helper functions to bridge Haskell and <https://www.lua.org/ Lua>. @@ -23,6 +23,8 @@ build-type: Simple extra-source-files: cbits/lua-5.3.5/*.h cbits/error-conversion/*.h + benchmark/benchmark-functions.h + benchmark/benchmark-functions.c README.md CHANGELOG.md test/lua/*.lua @@ -70,6 +72,15 @@ description: Use @pkg-config@ to discover library and include paths. Setting this flag implies `system-lua`. +flag hardcode-reg-keys + default: False + manual: True + + description: Don't use CAPI to determine the names of certain registry + key names but Use hard coded values for instead. This + flag is required when compiling against Lua 5.3.3 or + earlier, as those do not expose the necessary information + in the @lauxlib.h@ header file. library exposed-modules: Foreign.Lua @@ -79,6 +90,7 @@ , Foreign.Lua.Core.RawBindings , Foreign.Lua.Core.Types , Foreign.Lua.FunctionCalling + , Foreign.Lua.Module , Foreign.Lua.Types , Foreign.Lua.Types.Peekable , Foreign.Lua.Types.Pushable @@ -174,6 +186,9 @@ if flag(allow-unsafe-gc) cpp-options: -DALLOW_UNSAFE_GC + if flag(hardcode-reg-keys) + cpp-options: -DHARDCODE_REG_KEYS + test-suite test-hslua type: exitcode-stdio-1.0 @@ -186,6 +201,7 @@ , Foreign.Lua.Core.AuxiliaryTests , Foreign.Lua.Core.ErrorTests , Foreign.Lua.FunctionCallingTests + , Foreign.Lua.ModuleTests , Foreign.Lua.TypesTests , Foreign.Lua.Types.PeekableTests , Foreign.Lua.Types.PushableTests diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-1.0.2/src/Foreign/Lua/Core/Auxiliary.hsc new/hslua-1.0.3.2/src/Foreign/Lua/Core/Auxiliary.hsc --- old/hslua-1.0.2/src/Foreign/Lua/Core/Auxiliary.hsc 1970-01-01 01:00:00.000000000 +0100 +++ new/hslua-1.0.3.2/src/Foreign/Lua/Core/Auxiliary.hsc 1970-01-01 01:00:00.000000000 +0100 @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE OverloadedStrings #-} {-| Module : Foreign.Lua.Core.Auxiliary Copyright : © 2007–2012 Gracjan Polak, @@ -35,14 +36,13 @@ import Control.Exception (IOException, try) import Data.ByteString (ByteString) -import Foreign.C ( CChar, CInt (CInt), CSize (CSize), CString - , withCString, peekCString ) +import Data.Monoid ((<>)) +import Foreign.C ( CChar, CInt (CInt), CSize (CSize), CString, withCString ) import Foreign.Lua.Core.Constants (multret, registryindex) import Foreign.Lua.Core.Error (hsluaErrorRegistryField, throwTopMessage) import Foreign.Lua.Core.Types (Lua, Reference, StackIndex, Status, liftLua) import Foreign.Marshal.Alloc (alloca) import Foreign.Ptr -import System.IO.Unsafe (unsafePerformIO) import qualified Data.ByteString as B import qualified Foreign.Lua.Core.Functions as Lua @@ -50,6 +50,11 @@ import qualified Foreign.Lua.Utf8 as Utf8 import qualified Foreign.Storable as Storable +#ifndef HARDCODE_REG_KEYS +import System.IO.Unsafe (unsafePerformIO) +import qualified Foreign.C as C +#endif + ##ifdef ALLOW_UNSAFE_GC ##define SAFTY unsafe ##else @@ -62,19 +67,27 @@ -- | Key, in the registry, for table of loaded modules. loadedTableRegistryField :: String -loadedTableRegistryField = unsafePerformIO (peekCString c_loaded_table) +#ifdef HARDCODE_REG_KEYS +loadedTableRegistryField = "_LOADED" +#else +loadedTableRegistryField = unsafePerformIO (C.peekCString c_loaded_table) {-# NOINLINE loadedTableRegistryField #-} foreign import capi "lauxlib.h value LUA_LOADED_TABLE" c_loaded_table :: CString +#endif -- | Key, in the registry, for table of preloaded loaders. preloadTableRegistryField :: String -preloadTableRegistryField = unsafePerformIO (peekCString c_preload_table) +#ifdef HARDCODE_REG_KEYS +preloadTableRegistryField = "_PRELOAD" +#else +preloadTableRegistryField = unsafePerformIO (C.peekCString c_preload_table) {-# NOINLINE preloadTableRegistryField #-} foreign import capi "lauxlib.h value LUA_PRELOAD_TABLE" c_preload_table :: CString +#endif -- | Loads and runs the given string. -- @@ -182,7 +195,7 @@ loadfile :: FilePath -- ^ filename -> Lua Status loadfile fp = Lua.liftIO contentOrError >>= \case - Right script -> loadbuffer script fp + Right script -> loadbuffer script ("@" <> fp) Left e -> do Lua.pushstring (Utf8.fromString (show e)) return Lua.ErrFile diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-1.0.2/src/Foreign/Lua/Core/Functions.hs new/hslua-1.0.3.2/src/Foreign/Lua/Core/Functions.hs --- old/hslua-1.0.2/src/Foreign/Lua/Core/Functions.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/hslua-1.0.3.2/src/Foreign/Lua/Core/Functions.hs 1970-01-01 01:00:00.000000000 +0100 @@ -474,62 +474,63 @@ next :: StackIndex -> Lua Bool next idx = boolFromFailable =<< liftLua (\l -> hslua_next l idx) --- | Opens all standard Lua libraries into the current state. +-- | Opens all standard Lua libraries into the current state and sets each +-- library name as a global value. -- -- See also: -- <https://www.lua.org/manual/5.3/manual.html#luaL_openlibs luaL_openlibs>. openlibs :: Lua () openlibs = liftLua luaL_openlibs --- | Opens all standard Lua libraries into the current state. +-- | Pushes Lua's /base/ library onto the stack. -- --- | See <https://www.lua.org/manual/5.3/manual.html#pdf-luaopen_base luaopen_base>. +-- See <https://www.lua.org/manual/5.3/manual.html#pdf-luaopen_base luaopen_base>. openbase :: Lua () openbase = pushcfunction lua_open_base_ptr *> call 0 multret --- | Opens Lua's /debug/ library into the current state. +-- | Pushes Lua's /debug/ library onto the stack. -- -- See also: -- <https://www.lua.org/manual/5.3/manual.html#pdf-luaopen_debug luaopen_debug>. opendebug :: Lua () opendebug = pushcfunction lua_open_debug_ptr *> call 0 multret --- | Opens Lua's /io/ library into the current state. +-- | Pushes Lua's /io/ library onto the stack. -- -- See also: -- <https://www.lua.org/manual/5.3/manual.html#pdf-luaopen_io luaopen_io>. openio :: Lua () openio = pushcfunction lua_open_io_ptr *> call 0 multret --- | Opens Lua's /math/ library into the current state. +-- | Pushes Lua's /math/ library onto the stack. -- -- See also: -- <https://www.lua.org/manual/5.3/manual.html#pdf-luaopen_math luaopen_math>. openmath :: Lua () openmath = pushcfunction lua_open_math_ptr *> call 0 multret --- | Opens Lua's /os/ library into the current state. +-- | Pushes Lua's /os/ library onto the stack. -- -- See also: -- <https://www.lua.org/manual/5.3/manual.html#pdf-luaopen_os luaopen_os>. openos :: Lua () openos = pushcfunction lua_open_os_ptr *> call 0 multret --- | Opens Lua's /package/ library into the current state. +-- | Pushes Lua's /package/ library onto the stack. -- -- See also: -- <https://www.lua.org/manual/5.3/manual.html#pdf-luaopen_package luaopen_package>. openpackage :: Lua () openpackage = pushcfunction lua_open_package_ptr *> call 0 multret --- | Opens Lua's /string/ library into the current state. +-- | Pushes Lua's /string/ library onto the stack. -- -- See also: -- <https://www.lua.org/manual/5.3/manual.html#pdf-luaopen_string luaopen_string>. openstring :: Lua () openstring = pushcfunction lua_open_string_ptr *> call 0 multret --- | Opens Lua's /table/ library into the current state. +-- | Pushes Lua's /table/ library onto the stack. -- -- See also: -- <https://www.lua.org/manual/5.3/manual.html#pdf-luaopen_table luaopen_table>. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-1.0.2/src/Foreign/Lua/Module.hs new/hslua-1.0.3.2/src/Foreign/Lua/Module.hs --- old/hslua-1.0.2/src/Foreign/Lua/Module.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/hslua-1.0.3.2/src/Foreign/Lua/Module.hs 1970-01-01 01:00:00.000000000 +0100 @@ -0,0 +1,81 @@ +{-| +Module : Foreign.Lua.Module +Copyright : © 2019 Albert Krewinkel +License : MIT +Maintainer : Albert Krewinkel <[email protected]> +Stability : alpha +Portability : Requires GHC 8 or later. + +Utility functions for HsLua modules. +-} +module Foreign.Lua.Module + ( requirehs + , preloadhs + , addfield + , addfunction + , create + ) +where + +import Control.Monad (unless) +import Foreign.Lua.Core +import Foreign.Lua.Types (Pushable, push) +import Foreign.Lua.FunctionCalling (ToHaskellFunction, pushHaskellFunction) + +-- | Load a module, defined by a Haskell action, under the given name. +-- +-- Similar to @luaL_required@: After checking "loaded" table, calls +-- @pushMod@ to push a module to the stack, and registers the result in +-- @package.loaded@ table. +-- +-- The @pushMod@ function must push exactly one element to the top of +-- the stack. This is not checked, but failure to do so will lead to +-- problems. Lua's @package@ module must have been loaded by the time +-- this function is invoked. +-- +-- Leaves a copy of the module on the stack. +requirehs :: String -> Lua () -> Lua () +requirehs modname pushMod = do + -- get table of loaded modules + getfield registryindex loadedTableRegistryField + + -- Check whether module has already been loaded. + getfield stackTop modname -- LOADED[modname] + alreadyLoaded <- toboolean stackTop + + unless alreadyLoaded $ do + pop 1 -- remove field + pushMod -- push module + pushvalue stackTop -- make copy of module + -- add module under the given name (LOADED[modname] = module) + setfield (nthFromTop 3) modname + + remove (nthFromTop 2) -- remove table of loaded modules + +-- | Registers a preloading function. Takes an module name and the Lua +-- operation which produces the package. +preloadhs :: String -> Lua NumResults -> Lua () +preloadhs name pushMod = do + getfield registryindex preloadTableRegistryField + pushHaskellFunction pushMod + setfield (nthFromTop 2) name + pop 1 + +-- | Add a string-indexed field to the table at the top of the stack. +addfield :: Pushable a => String -> a -> Lua () +addfield name value = do + push name + push value + rawset (nthFromTop 3) + +-- | Attach a function to the table at the top of the stack, using the +-- given name. +addfunction :: ToHaskellFunction a => String -> a -> Lua () +addfunction name fn = do + push name + pushHaskellFunction fn + rawset (nthFromTop 3) + +-- | Create a new module (i.e., a Lua table). +create :: Lua () +create = newtable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-1.0.2/src/Foreign/Lua.hs new/hslua-1.0.3.2/src/Foreign/Lua.hs --- old/hslua-1.0.2/src/Foreign/Lua.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/hslua-1.0.3.2/src/Foreign/Lua.hs 1970-01-01 01:00:00.000000000 +0100 @@ -67,14 +67,21 @@ , setglobal' , raiseError , Optional (Optional, fromOptional) - -- ** retrieving values + -- ** Retrieving values , popValue + -- ** Modules + , requirehs + , preloadhs + , create + , addfield + , addfunction ) where import Prelude hiding (compare, concat) import Foreign.Lua.Core import Foreign.Lua.FunctionCalling +import Foreign.Lua.Module import Foreign.Lua.Types import Foreign.Lua.Userdata ( pushAny, peekAny ) import Foreign.Lua.Util diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-1.0.2/test/Foreign/Lua/ModuleTests.hs new/hslua-1.0.3.2/test/Foreign/Lua/ModuleTests.hs --- old/hslua-1.0.2/test/Foreign/Lua/ModuleTests.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/hslua-1.0.3.2/test/Foreign/Lua/ModuleTests.hs 1970-01-01 01:00:00.000000000 +0100 @@ -0,0 +1,82 @@ +{-# LANGUAGE OverloadedStrings #-} +{-| +Module : Foreign.Lua.ModuleTests +Copyright : © 2019 Albert Krewinkel +License : MIT +Maintainer : Albert Krewinkel <[email protected]> +Stability : alpha +Portability : Requires GHC 8 or later. + +Tests creating and loading of modules with Haskell. +-} +module Foreign.Lua.ModuleTests (tests) where + +import Foreign.Lua (Lua) +import Foreign.Lua.Module (addfield, addfunction, create, preloadhs, requirehs) +import Test.HsLua.Util ((=:), pushLuaExpr, shouldBeResultOf) +import Test.Tasty (TestTree, testGroup) + +import qualified Foreign.Lua as Lua + +-- | Specifications for Attributes parsing functions. +tests :: TestTree +tests = testGroup "Module" + [ testGroup "requirehs" + [ "pushes module to stack" =: + 1 `shouldBeResultOf` do + Lua.openlibs + old <- Lua.gettop + requirehs "foo" (Lua.pushnumber 5.0) + new <- Lua.gettop + return (new - old) + + , "module can be loaded with `require`" =: + let testModule = "string as a module" :: String + in testModule `shouldBeResultOf` do + Lua.openlibs + requirehs "test.module" (Lua.push testModule) + pushLuaExpr "require 'test.module'" + Lua.peek Lua.stackTop + ] + + , testGroup "preloadhs" + [ "does not modify the stack" =: + 0 `shouldBeResultOf` do + Lua.openlibs + old <- Lua.gettop + preloadhs "foo" (1 <$ Lua.pushnumber 5.0) + new <- Lua.gettop + return (new - old) + + , "module can be loaded with `require`" =: + let testModule = "string as a module" :: String + in testModule `shouldBeResultOf` do + Lua.openlibs + preloadhs "test.module" (1 <$ Lua.push testModule) + pushLuaExpr "require 'test.module'" + Lua.peek Lua.stackTop + ] + + , testGroup "creation helpers" + [ "create produces a table" =: + Lua.TypeTable `shouldBeResultOf` do + create + Lua.ltype Lua.stackTop + + , "addfield modifies table" =: + Lua.Integer 23 `shouldBeResultOf` do + create + addfield "field_name" (23 :: Int) + Lua.getfield Lua.stackTop "field_name" + Lua.peek Lua.stackTop + + , "addfunction modifies table" =: + Lua.Integer 5 `shouldBeResultOf` do + create + addfunction "minus18" (return . subtract 18 :: Int -> Lua Int) + Lua.getfield Lua.stackTop "minus18" + Lua.pushinteger 23 + Lua.call 1 1 + Lua.peek Lua.stackTop + ] + ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hslua-1.0.2/test/test-hslua.hs new/hslua-1.0.3.2/test/test-hslua.hs --- old/hslua-1.0.2/test/test-hslua.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/hslua-1.0.3.2/test/test-hslua.hs 1970-01-01 01:00:00.000000000 +0100 @@ -24,6 +24,7 @@ import qualified Foreign.LuaTests import qualified Foreign.Lua.CoreTests import qualified Foreign.Lua.FunctionCallingTests +import qualified Foreign.Lua.ModuleTests import qualified Foreign.Lua.TypesTests import qualified Foreign.Lua.Types.PeekableTests import qualified Foreign.Lua.Types.PushableTests @@ -45,5 +46,6 @@ , Foreign.Lua.Types.PushableTests.tests ] , Foreign.Lua.UserdataTests.tests + , Foreign.Lua.ModuleTests.tests , Foreign.LuaTests.tests ]
