hslua 0.7.0 → 0.7.1
raw patch · 5 files changed
+35/−9 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +7/−0
- README.md +2/−0
- hslua.cabal +8/−4
- src/Foreign/Lua/Types/FromLuaStack.hs +1/−1
- test/Foreign/LuaTest.hs +17/−4
CHANGELOG.md view
@@ -1,4 +1,11 @@ ## Changelog+### 0.7.1++- The flag `lua_32bits` was added to allow users to compile Lua for 32-bit+ systems.+- When reading a list, throw an error if the lua value isn't a table instead of+ silently returning an empty list.+ ### 0.7.0 - Tuples from pairs to octuples have been made instances of `FromLuaStack` and
README.md view
@@ -1,6 +1,7 @@ # hslua – Lua interpreter interface for Haskell [![Build Status]](https://travis-ci.org/osa1/hslua)+[![AppVeyor Status]](https://ci.appveyor.com/project/tarleb/hslua-r2y18) [![Coverage Status]](https://coveralls.io/github/osa1/hslua?branch=master) [![Hackage]](https://hackage.haskell.org/package/hslua) @@ -8,6 +9,7 @@ and lua. [Build Status]: https://travis-ci.org/osa1/hslua.svg?branch=master+[AppVeyor Status]: https://ci.appveyor.com/api/projects/status/ldutrilgxhpcau94/branch/master?svg=true [Coverage Status]: https://coveralls.io/repos/osa1/hslua/badge.svg?branch=master&service=github [Hackage]: http://img.shields.io/hackage/v/hslua.svg
hslua.cabal view
@@ -1,5 +1,5 @@ name: hslua-version: 0.7.0+version: 0.7.1 stability: beta cabal-version: >= 1.8 license: MIT@@ -43,6 +43,10 @@ description: Compile Lua with -DLUA_USE_APICHECK. default: False +flag lua_32bits+ description: Compile Lua with -DLUA_32BITS+ default: False+ flag luajit description: Link with LuaJIT. This implies flag system-lua as well. default: False@@ -83,7 +87,7 @@ if impl(ghc < 7.10) hs-source-dirs: prelude other-modules: Prelude- ghc-options: -Wall -O2+ ghc-options: -Wall extensions: CPP if flag(system-lua) || flag(luajit) || flag(lua501) || flag(lua502) c-sources: safer-api/safer-api.c@@ -165,8 +169,8 @@ cc-options: "-DLUA_USE_POSIX" ld-options: "-Wl,-E" - if os(windows)- cc-options: "-D__NO_ISOCEXT"+ if flag(lua_32bits)+ cc-options: "-DLUA_32BITS" if flag(apicheck) cc-options: "-DLUA_USE_APICHECK"
src/Foreign/Lua/Types/FromLuaStack.hs view
@@ -127,7 +127,7 @@ peek = fmap T.unpack . peek instance FromLuaStack a => FromLuaStack [a] where- peek = toList+ peek = typeChecked "table" istable toList instance (Ord a, FromLuaStack a, FromLuaStack b) => FromLuaStack (Map a b) where peek idx = fromList <$> pairsFromTable idx
test/Foreign/LuaTest.hs view
@@ -103,7 +103,7 @@ mt1 <- peek (-1) <* pop 1 :: Lua ByteString liftIO (assert (mt1 == "yup")) - , testGroup "stack values"+ , testGroup "Getting strings to and from the stack" [ testCase "unicode ByteString" $ do let val = T.pack "öçşiğüİĞı" val' <- runLua $ do@@ -139,9 +139,22 @@ , testGroup "luaopen_base returns the right number of tables" testOpenBase , testGroup "C functions"- [ testCase "pushing a C function to and calling it from Lua" $- -- Closures would usually be defined on the Haskell, unless the upvalues- -- cannot be read from the stack.+ [ testCase "Registering a C function and calling it from Lua" $+ let comp :: Lua [String]+ comp = do+ fn <- newCFunction (return . words :: String -> Lua [String])+ register "words" fn+ res <- dostring "return words('Caffeine induced nonsense')"+ freeCFunction fn+ if res == OK+ then peek (-1)+ else throwLuaError "Error in words function."+ in assertEqual "greeting function failed"+ (Right ["Caffeine", "induced", "nonsense"]) =<< runLuaEither comp++ , testCase "pushing a C closure to and calling it from Lua" $+ -- Closures would usually be defined on the Haskell side, unless the+ -- upvalues cannot be read from the stack (e.g., a lua function). let greeter :: String -> HaskellFunction greeter greetee = do greeting <- peek (upvalueindex 1)