Lua-API++  2015-02-12-3
Lua-API++ library
lua Namespace Reference

Every thing in Lua API++ library is contained inside this namespace. More...

Classes

struct  ClosureInfo
 Closure properties. [Lua 5.2+ only] More...
 
class  Context
 Access point to Lua context. More...
 
class  Nil
 Type of nil value. More...
 
class  RegistryKey
 Key for registry-stored values. More...
 
class  Retval
 Return value for Lua functions. More...
 
class  State
 Lua state object. More...
 
class  Table
 Table object with specialized interface. Similar to Value, it owns a stack slot. More...
 
class  Temporary
 Temporary Lua value. More...
 
struct  TypeID
 Determine Lua type ID from native type. More...
 
class  Valobj
 Lua-compatible value. More...
 
class  Valref
 Non-owning reference to Lua value. More...
 
class  Valset
 Valset is an STL-compatible container for contiguous Lua stack slots. Its primary use is accepting multiple return values. More...
 
class  Value
 Owner of a single stack slot. More...
 

Typedefs

using LFunction = Retval(*)(Context &)
 Pointer to Lua API++ compatible function. More...
 
using CFunction = int(*)(lua_State *)
 C function callable by Lua (plain Lua API format). More...
 
typedef void * LightUserData
 Light userdata. More...
 

Enumerations

enum  ValueType {
  None = -1, Nil, Boolean, LightUserdata,
  Number, String, Table, Function,
  C_Function, UserData, Thread, Any
}
 Types of Lua values. More...
 

Functions

template<LFunction F>
int mkcf (lua_State *l)
 Wrapper for LFunction that creates a proper Lua-compatible C function. More...
 

Variables

static constexpr Nil nil {}
 Constant representing nil value. More...
 

Detailed Description

Every thing in Lua API++ library is contained inside this namespace.


Class Documentation

struct lua::ClosureInfo

Closure properties. [Lua 5.2+ only]

See also
lua::Valref::getClosureInfo
Class Members
size_t nUpvalues Amount of upvalues.
size_t nParameters Amount of parameters.
bool variadic Whether function accepts variable number of arguments.
class lua::Nil

Type of nil value.

This type can be used in type checks with function is.

class lua::Temporary

Temporary Lua value.

This is not an actual type, see the explanation.

See also
lua::Valref
class lua::Valobj

Lua-compatible value.

This is not an actual type, it designates any type of value that is or can become a Lua value: references to Lua stack, temporaries, native numbers and strings, userdata etc.

Typedef Documentation

typedef Retval(* LFunction)(Context &)

Pointer to Lua API++ compatible function.

Lua-API++ compatible function.

See also
lua::mkcf
using CFunction = int (*)(lua_State*)

C function callable by Lua (plain Lua API format).

See also
lua::mkcf
typedef void* LightUserData

Light userdata.

This typedef is provided for explicit designation of light userdata.

Enumeration Type Documentation

enum ValueType
strong

Types of Lua values.

This enum is used to identify actual types of Lua values both in compile-time and runtime.

Enumerator
None 

not a Lua value

Nil 

absence of data

Boolean 

boolean

LightUserdata 

light userdata

Number 

number

String 

string

Table 

table

Function 

Lua function.

C_Function 

Lua-compatible C function.

UserData 

full userdata

Thread 

Lua documentation names this object "coroutine", but Lua API names it "thread".

Any 

Lua value with content type indeterminable at the time of query.

Function Documentation

int lua::mkcf ( lua_State *  l)

Wrapper for LFunction that creates a proper Lua-compatible C function.

template<LFunction F> mkcf
This template converts Lua API++ compatible function to a proper Lua-compatible C function (mkcf is short for "make C function"). The wrapper creates Context object and passes it to wrapped function, then converts returned Retval to number of returned values. All exceptions that come from wrapped function are intercepted and converted to Lua runtime errors. Example:

Retval someFunction(Context& context) {return context.ret();}
CFunction cf = mkcf<someFunction>;

Note the lack of round parentheses when using mkcf template.

Note
Unlike closure function, mkcf creates individual wrapper for each LFunctions. It doesn't reserve first upvalue for internal use.

Variable Documentation

constexpr Nil nil {}
static

Constant representing nil value.

Note
It is possible to check values for emptiness by comparing (equality or inequality) against nil value, but is<Nil>() is more efficient.