hslua 1.0.3.1 → 1.0.3.2
raw patch · 4 files changed
+56/−6 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +20/−0
- benchmark/benchmark-functions.h +5/−0
- hslua.cabal +15/−1
- src/Foreign/Lua/Core/Auxiliary.hsc +16/−5
CHANGELOG.md view
@@ -1,5 +1,25 @@ ## 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.
+ benchmark/benchmark-functions.h view
@@ -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);
hslua.cabal view
@@ -1,5 +1,5 @@ name: hslua-version: 1.0.3.1+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,7 +72,16 @@ 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 , Foreign.Lua.Core@@ -174,6 +185,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
src/Foreign/Lua/Core/Auxiliary.hsc view
@@ -37,14 +37,12 @@ import Control.Exception (IOException, try) import Data.ByteString (ByteString) import Data.Monoid ((<>))-import Foreign.C ( CChar, CInt (CInt), CSize (CSize), CString- , withCString, peekCString )+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@@ -52,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@@ -64,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. --