{-# LANGUAGE LambdaCase #-}
module HsLua.List
( luaopen_list_ptr
, pushListModule
, newListMetatable
) where
import Data.ByteString (useAsCString)
import Foreign.C
import HsLua.Core
foreign import ccall unsafe "listmod.c &luaopen_list"
luaopen_list_ptr :: CFunction
pushListModule :: LuaError e => LuaE e ()
pushListModule :: forall e. LuaError e => LuaE e ()
pushListModule = do
CFunction -> LuaE e ()
forall e. CFunction -> LuaE e ()
pushcfunction CFunction
luaopen_list_ptr
NumArgs -> NumResults -> LuaE e ()
forall e. LuaError e => NumArgs -> NumResults -> LuaE e ()
call NumArgs
0 NumResults
1
foreign import ccall "listmod.c lualist_newmetatable"
lualist_newmetatable :: State -> CString -> IO CInt
newListMetatable :: Name -> LuaE e () -> LuaE e ()
newListMetatable :: forall e. Name -> LuaE e () -> LuaE e ()
newListMetatable (Name ByteString
name) LuaE e ()
setup = do
l <- LuaE e State
forall e. LuaE e State
state
liftIO (useAsCString name (lualist_newmetatable l)) >>= \case
CInt
0 -> () -> LuaE e ()
forall a. a -> LuaE e a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
CInt
_ -> LuaE e ()
setup