Skip to content

Commit

Permalink
Drop cpcall from API
Browse files Browse the repository at this point in the history
The function is deprecated in new lua versions, as one can simply push
the C function with lua_pushcfunction and call it with pcall. It's also
not very likely to be useful in a Haskell setting.
  • Loading branch information
tarleb committed Jul 23, 2017
1 parent 8240f1c commit 080ffbd
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions src/Foreign/Lua/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ module Foreign.Lua.Api (
, setmetatable
-- ** load and call functions (load and run Lua code)
, call
, cpcall
, pcall
, loadfile
, loadstring
Expand Down Expand Up @@ -301,25 +300,6 @@ copy fromidx toidx = do
insert toidx
#endif

{-# DEPRECATED cpcall "You can simply push the function with lua_pushcfunction\
and call it with pcall." #-}
-- | Calls the C function func in protected mode. func starts with only one
-- element in its stack, a light userdata containing ud. In case of errors,
-- lua_cpcall returns the same error codes as lua_pcall, plus the error object
-- on the top of the stack; otherwise, it returns zero, and does not change the
-- stack. All values returned by func are discarded.
--
-- See <https://www.lua.org/manual/5.1/manual.html#lua_cpcall lua_cpcall>.
cpcall :: FunPtr LuaCFunction -> Ptr a -> Lua LuaStatus
#if LUA_VERSION_NUMBER >= 502
cpcall a c = do
pushcfunction a
pushlightuserdata c
pcall 1 0 Nothing
#else
cpcall a c = liftLua $ \l -> fmap toLuaStatus (lua_cpcall l a c)
#endif

-- | Creates a new empty table and pushes it onto the stack. Parameter narr is a
-- hint for how many elements the table will have as a sequence; parameter nrec
-- is a hint for how many other elements the table will have. Lua may use these
Expand Down

0 comments on commit 080ffbd

Please sign in to comment.