Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use builtin luaL_loadfile

  • Loading branch information...
commit 2e46b7e5f8900058222838551825417a72746fc4 1 parent 2ee2113
@jamessanders authored
Showing with 5 additions and 2 deletions.
  1. +0 −1  src/.#lauxlib.h
  2. +5 −1 src/Scripting/Lua.hs
View
1  src/.#lauxlib.h
View
6 src/Scripting/Lua.hs
@@ -370,6 +370,7 @@ foreign import ccall "lauxlib.h luaL_newmetatable" c_luaL_newmetatable :: LuaSta
foreign import ccall "lauxlib.h luaL_argerror" c_luaL_argerror :: LuaState -> CInt -> Ptr CChar -> IO CInt
foreign import ccall "lauxlib.h luaL_ref" c_luaL_ref :: LuaState -> CInt -> IO CInt
+foreign import ccall "lauxlib.h luaL_loadfile" c_lua_loadfile :: LuaState -> CString -> IO CInt
foreign import ccall "ntrljmp.h lua_neutralize_longjmp" c_lua_neutralize_longjmp :: LuaState -> IO CInt
foreign import ccall "ntrljmp.h &lua_neutralize_longjmp" c_lua_neutralize_longjmp_addr :: FunPtr (LuaState -> IO CInt)
@@ -642,8 +643,11 @@ lessthan l i j = liftM (/=0) (c_lua_lessthan l (fromIntegral i) (fromIntegral j)
-- | See @luaL_loadfile@ in Lua Reference Manual.
loadfile :: LuaState -> String -> IO Int
-loadfile l f = readFile f >>= \c -> loadstring l c f
+--loadfile l f = readFile f >>= \c -> loadstring l c f
+loadfile l f = do
+ i <- withCAString f $ \path -> c_lua_loadfile l path
+ return $ fromIntegral i
foreign import ccall "wrapper" mkStringReader :: LuaReader -> IO (FunPtr LuaReader)
Please sign in to comment.
Something went wrong with that request. Please try again.