Lutok: anonymous_namespace{state.cpp} Namespace Reference

Lutok 0.4

- Main Page
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

All Classes Namespaces Files Functions Variables Macros
Functions
anonymous_namespace{state.cpp} Namespace Reference

## Functions
static int | protected_getglobal (lua_State *state)
| Wrapper around lua_getglobal to run in a protected environment.
static int | protected_gettable (lua_State *state)
| Wrapper around lua_gettable to run in a protected environment.
static int | protected_next (lua_State *state)
| Wrapper around lua_next to run in a protected environment.
static int | protected_setglobal (lua_State *state)
| Wrapper around lua_setglobal to run in a protected environment.
static int | protected_settable (lua_State *state)
| Wrapper around lua_settable to run in a protected environment.
static int | call_cxx_function_from_c (lutok::cxx_function function, lua_State *raw_state) throw ()
| Calls a C++ Lua function from a C calling environment.
static int | cxx_closure_trampoline (lua_State *raw_state)
| Lua glue to call a C++ closure.
static int | cxx_function_trampoline (lua_State *raw_state)
| Lua glue to call a C++ function.

## Function Documentation

static int anonymous_namespace{state.cpp}::call_cxx_function_from_c | ( | lutok::cxx_function | function,
|  | lua_State * | raw_state
| ) |  | throw ()
| static

Calls a C++ Lua function from a C calling environment.

Any errors reported by the C++ function are caught and reported to the caller as Lua errors.

Parameters:

  function | The C++ function to call.
  raw_state | The raw Lua state.

Returns:
  The number of return values pushed onto the Lua stack by the function.

static int anonymous_namespace{state.cpp}::cxx_closure_trampoline | ( | lua_State * | raw_state | ) |
| static

Lua glue to call a C++ closure.

This Lua binding is actually a closure that we have constructed from the state.push_cxx_closure() method. The closure contains the same upvalues provided by the user plus an extra upvalue that contains the address of the C++ function we have to call. All we do here is safely delegate the execution to the wrapped C++ closure.

Parameters:

  raw_state | The Lua C API state.

Returns:
  The number of return values of the called closure.

static int anonymous_namespace{state.cpp}::cxx_function_trampoline | ( | lua_State * | raw_state | ) |
| static

Lua glue to call a C++ function.

This Lua binding is actually a closure that we have constructed from the state.push_cxx_function() method. The closure has a single upvalue that contains the address of the C++ function we have to call. All we do here is safely delegate the execution to the wrapped C++ function.

Parameters:

  raw_state | The Lua C API state.

Returns:
  The number of return values of the called function.

static int anonymous_namespace{state.cpp}::protected_getglobal | ( | lua_State * | state | ) |
| static

Wrapper around lua_getglobal to run in a protected environment.

Precondition:
  stack(-1) is the name of the global to get.

Postcondition:
  stack(-1) is the value of the global.

Parameters:

  state | The Lua C API state.

Returns:
  The number of return values pushed onto the stack.

static int anonymous_namespace{state.cpp}::protected_gettable | ( | lua_State * | state | ) |
| static

Wrapper around lua_gettable to run in a protected environment.

Precondition:
  stack(-2) is the table to get the element from.
  stack(-1) is the table index.

Postcondition:
  stack(-1) is the value of stack(-2)[stack(-1)].

Parameters:

  state | The Lua C API state.

Returns:
  The number of return values pushed onto the stack.

static int anonymous_namespace{state.cpp}::protected_next | ( | lua_State * | state | ) |
| static

Wrapper around lua_next to run in a protected environment.

Precondition:
  stack(-2) is the table to get the next element from.
  stack(-1) is the last processed key.

Postcondition:
  stack(-1) is the value of next(stack(-2), stack(-1)).

Parameters:

  state | The Lua C API state.

Returns:
  The number of return values pushed onto the stack.

static int anonymous_namespace{state.cpp}::protected_setglobal | ( | lua_State * | state | ) |
| static

Wrapper around lua_setglobal to run in a protected environment.

Precondition:
  stack(-2) is the name of the global to set.
  stack(-1) is the value to set the global to.

Parameters:

  state | The Lua C API state.

Returns:
  The number of return values pushed onto the stack.

static int anonymous_namespace{state.cpp}::protected_settable | ( | lua_State * | state | ) |
| static

Wrapper around lua_settable to run in a protected environment.

Precondition:
  stack(-3) is the table to set the element into.
  stack(-2) is the table index.
  stack(-1) is the value to set.

Parameters:

  state | The Lua C API state.

Returns:
  The number of return values pushed onto the stack.