Extra generic functions to interact with Lua.
More...
#include <map>
#include <string>
#include <vector>
#include <lutok/state.hpp>
Go to the source code of this file.
|
| void | lutok::create_module (state &, const std::string &, const std::map< std::string, cxx_function > &) |
| | Creates a module: i.e.
|
| |
| unsigned int | lutok::do_file (state &, const std::string &, const int, const int, const int) |
| | Loads and processes a Lua file.
|
| |
| unsigned int | lutok::do_string (state &, const std::string &, const int, const int, const int) |
| | Processes a Lua script.
|
| |
| void | lutok::eval (state &, const std::string &, const int) |
| | Convenience function to evaluate a Lua expression.
|
| |
Extra generic functions to interact with Lua.
◆ create_module()
| void lutok::create_module |
( |
state & | s, |
|
|
const std::string & | name, |
|
|
const std::map< std::string, cxx_function > & | members ) |
Creates a module: i.e.
a table with a set of methods in it.
- Parameters
-
| s | The Lua state. |
| name | The name of the module to create. |
| members | The list of member functions to add to the module. |
◆ do_file()
| unsigned int lutok::do_file |
( |
state & | s, |
|
|
const std::string & | file, |
|
|
const int | nargs, |
|
|
const int | nresults, |
|
|
const int | errfunc ) |
Loads and processes a Lua file.
This is a replacement for luaL_dofile but with proper error reporting and stack control.
- Parameters
-
| s | The Lua state. |
| file | The file to load. |
| nargs | The number of arguments on the stack to pass to the file. |
| nresults | The number of results to expect; -1 for any. |
| errfunc | If not 0, index of a function in the stack to act as an error handler. |
- Returns
- The number of results left on the stack.
- Exceptions
-
| error | If there is a problem processing the file. |
◆ do_string()
| unsigned int lutok::do_string |
( |
state & | s, |
|
|
const std::string & | str, |
|
|
const int | nargs, |
|
|
const int | nresults, |
|
|
const int | errfunc ) |
Processes a Lua script.
This is a replacement for luaL_dostring but with proper error reporting and stack control.
- Parameters
-
| s | The Lua state. |
| str | The string to process. |
| nargs | The number of arguments on the stack to pass to the chunk. |
| nresults | The number of results to expect; -1 for any. |
| errfunc | If not 0, index of a function in the stack to act as an error handler. |
- Returns
- The number of results left on the stack.
- Exceptions
-
| error | If there is a problem processing the string. |
◆ eval()
| void lutok::eval |
( |
state & | s, |
|
|
const std::string & | expression, |
|
|
const int | nresults ) |
Convenience function to evaluate a Lua expression.
- Parameters
-
| s | The Lua state. |
| expression | The textual expression to evaluate. |
| nresults | The number of results to leave on the stack. Must be positive. |
- Exceptions
-
| api_error | If there is a problem evaluating the expression. |