Copyright | © 2007–2012 Gracjan Polak; © 2012–2016 Ömer Sinan Ağacan; © 2017-2023 Albert Krewinkel |
---|---|
License | MIT |
Maintainer | Albert Krewinkel <tarleb@hslua.org> |
Stability | beta |
Portability | non-portable (depends on GHC) |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Lua.Types
Contents
Description
The core Lua types, including mappings of Lua types to Haskell.
Synopsis
- newtype State = State (Ptr ())
- type Reader = FunPtr (State -> Ptr () -> Ptr CSize -> IO (Ptr CChar))
- newtype TypeCode = TypeCode {
- fromTypeCode :: CInt
- type CFunction = FunPtr PreCFunction
- type PreCFunction = State -> IO NumResults
- type WarnFunction = FunPtr (Ptr () -> CString -> LuaBool -> IO ())
- type PreWarnFunction = Ptr () -> CString -> LuaBool -> IO ()
- newtype LuaBool = LuaBool CInt
- newtype Integer = Integer Int64
- newtype Number = Number Double
- newtype StackIndex = StackIndex {}
- newtype NumArgs = NumArgs {
- fromNumArgs :: CInt
- newtype NumResults = NumResults {}
- newtype OPCode = OPCode CInt
- newtype ArithOPCode = ArithOPCode CInt
- newtype StatusCode = StatusCode CInt
- newtype GCCode = GCCode CInt
Documentation
An opaque structure that points to a thread and indirectly (through the thread) to the whole state of a Lua interpreter. The Lua library is fully reentrant: it has no global variables. All information about a state is accessible through this structure.
Synonym for lua_State *
. See
lua_State.
type Reader = FunPtr (State -> Ptr () -> Ptr CSize -> IO (Ptr CChar)) Source #
The reader function used by
.
Every time it needs another piece of the chunk, lua_load calls the
reader, passing along its data parameter. The reader must return a
pointer to a block of memory with a new piece of the chunk and set
size to the block size. The block must exist until the reader
function is called again. To signal the end of the chunk, the reader
must return load
NULL
or set size to zero. The reader function may
return pieces of any size greater than zero.
See lua_Reader.
Integer code used to encode the type of a Lua value.
Constructors
TypeCode | |
Fields
|
Instances
Show TypeCode Source # | |
Eq TypeCode Source # | |
Ord TypeCode Source # | |
Defined in Lua.Types |
type CFunction = FunPtr PreCFunction Source #
Type for C functions.
In order to communicate properly with Lua, a C function must use the
following protocol, which defines the way parameters and results are
passed: a C function receives its arguments from Lua in its stack in
direct order (the first argument is pushed first). So, when the
function starts,
returns the
number of arguments received by the function. The first argument (if
any) is at index 1 and its last argument is at index
lua_gettop
. To return values to Lua, a C
function just pushes them onto the stack, in direct order (the first
result is pushed first), and returns the number of results. Any other
value in the stack below the results will be properly discarded by
Lua. Like a Lua function, a C function called by Lua can also return
many results.lua_gettop
See lua_CFunction.
type PreCFunction = State -> IO NumResults Source #
Type of Haskell functions that can be turned into C functions.
This is the same as a dereferenced CFunction
.
type WarnFunction = FunPtr (Ptr () -> CString -> LuaBool -> IO ()) Source #
The type of warning functions, called by Lua to emit warnings. The
first parameter is an opaque pointer set by lua_setwarnf
. The
second parameter is the warning message. The third parameter is a
boolean that indicates whether the message is to be continued by the
message in the next call.
See warn for more details about warnings.
type PreWarnFunction = Ptr () -> CString -> LuaBool -> IO () Source #
Type of Haskell functions that can be turned into a WarnFunction.
This is the same as a dereferenced WarnFunction
.
Boolean value returned by a Lua C API function. This is a
and should be interpreted as CInt
iff the value is False
0
,
otherwise.True
Instances
Storable LuaBool Source # | |
Defined in Lua.Types Methods sizeOf :: LuaBool -> Int Source # alignment :: LuaBool -> Int Source # peekElemOff :: Ptr LuaBool -> Int -> IO LuaBool Source # pokeElemOff :: Ptr LuaBool -> Int -> LuaBool -> IO () Source # peekByteOff :: Ptr b -> Int -> IO LuaBool Source # pokeByteOff :: Ptr b -> Int -> LuaBool -> IO () Source # | |
Show LuaBool Source # | |
Eq LuaBool Source # | |
The type of integers in Lua.
By default this type is
, but that can be changed to
different values in Lua. (See Int64
LUA_INT_TYPE
in luaconf.h
.)
See lua_Integer.
Instances
Bounded Integer Source # | |
Enum Integer Source # | |
Defined in Lua.Types Methods succ :: Integer -> Integer Source # pred :: Integer -> Integer Source # toEnum :: Int -> Integer Source # fromEnum :: Integer -> Int Source # enumFrom :: Integer -> [Integer] Source # enumFromThen :: Integer -> Integer -> [Integer] Source # enumFromTo :: Integer -> Integer -> [Integer] Source # enumFromThenTo :: Integer -> Integer -> Integer -> [Integer] Source # | |
Num Integer Source # | |
Defined in Lua.Types | |
Read Integer Source # | |
Integral Integer Source # | |
Defined in Lua.Types Methods quot :: Integer -> Integer -> Integer Source # rem :: Integer -> Integer -> Integer Source # div :: Integer -> Integer -> Integer Source # mod :: Integer -> Integer -> Integer Source # quotRem :: Integer -> Integer -> (Integer, Integer) Source # | |
Real Integer Source # | |
Show Integer Source # | |
Eq Integer Source # | |
Ord Integer Source # | |
The type of floats in Lua.
By default this type is
, but that can be changed in Lua to
a single float or a long double. (See Double
LUA_FLOAT_TYPE
in
luaconf.h
.)
See lua_Number.
Instances
newtype StackIndex Source #
A stack index
Constructors
StackIndex | |
Fields |
Instances
The number of arguments consumed curing a function call.
Constructors
NumArgs | |
Fields
|
Instances
Num NumArgs Source # | |
Defined in Lua.Types | |
Show NumArgs Source # | |
Eq NumArgs Source # | |
Ord NumArgs Source # | |
newtype NumResults Source #
The number of results returned by a function call.
Constructors
NumResults | |
Fields |
Instances
Num NumResults Source # | |
Defined in Lua.Types Methods (+) :: NumResults -> NumResults -> NumResults Source # (-) :: NumResults -> NumResults -> NumResults Source # (*) :: NumResults -> NumResults -> NumResults Source # negate :: NumResults -> NumResults Source # abs :: NumResults -> NumResults Source # signum :: NumResults -> NumResults Source # fromInteger :: Integer -> NumResults Source # | |
Show NumResults Source # | |
Eq NumResults Source # | |
Defined in Lua.Types Methods (==) :: NumResults -> NumResults -> Bool Source # (/=) :: NumResults -> NumResults -> Bool Source # | |
Ord NumResults Source # | |
Defined in Lua.Types Methods compare :: NumResults -> NumResults -> Ordering Source # (<) :: NumResults -> NumResults -> Bool Source # (<=) :: NumResults -> NumResults -> Bool Source # (>) :: NumResults -> NumResults -> Bool Source # (>=) :: NumResults -> NumResults -> Bool Source # max :: NumResults -> NumResults -> NumResults Source # min :: NumResults -> NumResults -> NumResults Source # |
Relational operator code.
Instances
Storable OPCode Source # | |
Defined in Lua.Types Methods sizeOf :: OPCode -> Int Source # alignment :: OPCode -> Int Source # peekElemOff :: Ptr OPCode -> Int -> IO OPCode Source # pokeElemOff :: Ptr OPCode -> Int -> OPCode -> IO () Source # peekByteOff :: Ptr b -> Int -> IO OPCode Source # pokeByteOff :: Ptr b -> Int -> OPCode -> IO () Source # | |
Show OPCode Source # | |
Eq OPCode Source # | |
newtype ArithOPCode Source #
Arithmetic operator code.
Constructors
ArithOPCode CInt |
Instances
Storable ArithOPCode Source # | |
Defined in Lua.Types Methods sizeOf :: ArithOPCode -> Int Source # alignment :: ArithOPCode -> Int Source # peekElemOff :: Ptr ArithOPCode -> Int -> IO ArithOPCode Source # pokeElemOff :: Ptr ArithOPCode -> Int -> ArithOPCode -> IO () Source # peekByteOff :: Ptr b -> Int -> IO ArithOPCode Source # pokeByteOff :: Ptr b -> Int -> ArithOPCode -> IO () Source # peek :: Ptr ArithOPCode -> IO ArithOPCode Source # poke :: Ptr ArithOPCode -> ArithOPCode -> IO () Source # | |
Show ArithOPCode Source # | |
Eq ArithOPCode Source # | |
Defined in Lua.Types Methods (==) :: ArithOPCode -> ArithOPCode -> Bool Source # (/=) :: ArithOPCode -> ArithOPCode -> Bool Source # |
newtype StatusCode Source #
Integer code used to signal the status of a thread or computation.
Constructors
StatusCode CInt |
Instances
Storable StatusCode Source # | |
Defined in Lua.Types Methods sizeOf :: StatusCode -> Int Source # alignment :: StatusCode -> Int Source # peekElemOff :: Ptr StatusCode -> Int -> IO StatusCode Source # pokeElemOff :: Ptr StatusCode -> Int -> StatusCode -> IO () Source # peekByteOff :: Ptr b -> Int -> IO StatusCode Source # pokeByteOff :: Ptr b -> Int -> StatusCode -> IO () Source # peek :: Ptr StatusCode -> IO StatusCode Source # poke :: Ptr StatusCode -> StatusCode -> IO () Source # | |
Show StatusCode Source # | |
Eq StatusCode Source # | |
Defined in Lua.Types Methods (==) :: StatusCode -> StatusCode -> Bool Source # (/=) :: StatusCode -> StatusCode -> Bool Source # |
Garbage-Collection
Garbage-collection options.
Instances
Storable GCCode Source # | |
Defined in Lua.Types Methods sizeOf :: GCCode -> Int Source # alignment :: GCCode -> Int Source # peekElemOff :: Ptr GCCode -> Int -> IO GCCode Source # pokeElemOff :: Ptr GCCode -> Int -> GCCode -> IO () Source # peekByteOff :: Ptr b -> Int -> IO GCCode Source # pokeByteOff :: Ptr b -> Int -> GCCode -> IO () Source # | |
Show GCCode Source # | |
Eq GCCode Source # | |