hslua-0.6.0: A Lua language interpreter embedding in Haskell

Copyright© 2007–2012 Gracjan Polak
2012–2016 Ömer Sinan Ağacan
2017 Albert Krewinkel
LicenseMIT
MaintainerAlbert Krewinkel <tarleb+hslua@zeitkraut.de>
Stabilitybeta
PortabilityForeignFunctionInterface, GeneralizedNewtypeDeriving
Safe HaskellNone
LanguageHaskell98

Foreign.Lua.Api.Types

Description

The core Lua types, including mappings of Lua types to Haskell.

Synopsis

Documentation

newtype LuaState Source #

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.

Constructors

LuaState (Ptr ()) 

type LuaAlloc = Ptr () -> Ptr () -> CSize -> CSize -> IO (Ptr ()) Source #

Synonym for lua_Alloc. See lua_Alloc.

type LuaReader = Ptr () -> Ptr () -> Ptr CSize -> IO (Ptr CChar) Source #

The reader function used by lua_load. 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 NULL or set size to zero. The reader function may return pieces of any size greater than zero.

See lua_Reader.

type LuaWriter = LuaState -> Ptr CChar -> CSize -> Ptr () -> IO CInt Source #

Synonym for lua_Writer. See lua_Writer.

type CFunction = FunPtr (LuaState -> IO CInt) 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, gettop 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 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.

See lua_CFunction.

type LuaInteger = Int64 Source #

The type of integers in Lua.

By default this type is Int64, but that can be changed to different values in lua. (See LUA_INT_TYPE in luaconf.h.)

See lua_Integer.

type LuaNumber = Double Source #

The type of floats in Lua.

By default this type is Double, but that can be changed in Lua to a single float or a long double. (See LUA_FLOAT_TYPE in luaconf.h.)

See lua_Number.

data LTYPE Source #

Enumeration used as type tag. See lua_type.

Constructors

TNONE

non-valid stack index

TNIL

type of lua's nil value

TBOOLEAN

type of lua booleans

TLIGHTUSERDATA

type of light userdata

TNUMBER

type of lua numbers. See LuaNumber

TSTRING

type of lua string values

TTABLE

type of lua tables

TFUNCTION

type of functions, either normal or CFunction

TUSERDATA

type of full user data

TTHREAD

type of lua threads

toLuaType :: CInt -> LTYPE Source #

Convert number to lua type.

fromLuaType :: LTYPE -> CInt Source #

Convert Lua type to its C representation.

data LuaRelation Source #

Lua comparison operations.

Constructors

LuaEQ

Correponds to lua's equality (==) operator.

LuaLT

Correponds to lua's strictly-lesser-than (<) operator

LuaLE

Correponds to lua's lesser-or-equal (<=) operator

fromLuaRelation :: LuaRelation -> CInt Source #

Convert relation operator to its C representation.

data LuaStatus Source #

Lua status values.

Constructors

LuaOK

success

LuaYield

yielding / suspended coroutine

LuaErrRun

a runtime rror

LuaErrSyntax

syntax error during precompilation

LuaErrMem

memory allocation (out-of-memory) error.

LuaErrErr

error while running the message handler.

LuaErrGcmm

error while running a __gc metamethod.

toLuaStatus :: CInt -> LuaStatus Source #

Convert C integer constant to LuaStatus.

newtype NumArgs Source #

The number of arguments expected a function.

Constructors

NumArgs 

Fields