State class reference
[Base module]
Declaration
#include <QtLua/State>
namespace QtLua {
class State;
};
This class is a member of the QtLua namespace.
This class is declared in QtLua/qtluastate.hh source file, line 95.
Description
This class wraps the lua interpreter state.
This class provides various functions to execute lua code, access lua variables from C++ and load lua libraries.
Some functions in this class may throw an exception to handle lua errors, see Error handling and exceptions.
This class provides Qt slots and signals for use with the Console widget. This enables table names completion and error messages reporting on user console.
Members
Functions
- State()
- ~State()
- Value at(const Value &key) const
- Value at(const String &key) const
- void enable_qdebug_print(bool enabled = [...])
- ValueBase::List exec_chunk(QIODevice &io)
- ValueBase::List exec_statements(const String &statements)
- void gc_collect()
- Value get_global(const String &path) const
- lua_State * get_lua_state() const
- void lua_do(void (*func)(::lua_State *) )
- int lua_version() const
- bool openlib(Library lib)
- Value operator[](const Value &key) const
- Value operator[](const String &key) const
- ValueRef operator[](const Value &key)
- ValueRef operator[](const String &key)
- void set_global(const String &path, const Value &value)
- void check_empty_stack() const
Private functions
- void fill_completion_list_r(String &path, const String &prefix, QStringList &list, const Value &tbl, int &cursor_offset)
- void get_global_r(const String &name, Value &value, int tblidx) const
- void output_str(const String &str)
- void reg_c_function(const char *name, int (*fcn)(::lua_State *) )
- void set_global_r(const String &name, const Value &value, int tblidx)
Static function
- static template void register_qobject_meta()
Private static functions
- static State * get_this(lua_State *st)
- static int lua_cmd_each(lua_State *st)
- static int lua_cmd_help(lua_State *st)
- static int lua_cmd_iterator(lua_State *st)
- static int lua_cmd_list(lua_State *st)
- static int lua_cmd_plugin(lua_State *st)
- static int lua_cmd_print(lua_State *st)
- static int lua_cmd_qtype(lua_State *st)
- static int lua_meta_item_add(lua_State *st)
- static int lua_meta_item_call(lua_State *st)
- static int lua_meta_item_concat(lua_State *st)
- static int lua_meta_item_div(lua_State *st)
- static int lua_meta_item_eq(lua_State *st)
- static int lua_meta_item_gc(lua_State *st)
- static int lua_meta_item_index(lua_State *st)
- static int lua_meta_item_le(lua_State *st)
- static int lua_meta_item_len(lua_State *st)
- static int lua_meta_item_lt(lua_State *st)
- static int lua_meta_item_mod(lua_State *st)
- static int lua_meta_item_mul(lua_State *st)
- static int lua_meta_item_newindex(lua_State *st)
- static int lua_meta_item_pow(lua_State *st)
- static int lua_meta_item_sub(lua_State *st)
- static int lua_meta_item_unm(lua_State *st)
- static void lua_pgettable(lua_State *st, int index)
- static int lua_pnext(lua_State *st, int index)
- static void lua_psettable(lua_State *st, int index)
Slots
- void exec(const QString &statements)
- void fill_completion_list(const QString &prefix, QStringList &list, int &cursor_offset)
- Value eval_expr(bool use_lua, const String &expr)
Signal
- void output(const QString &str)
Private fields
- bool _debug_output
- static char _key_item_metatable
- static char _key_this
- static char _key_threads
- lua_State *_lst
- lua_State *_mst
- wrapper_hash_t _whash
- bool _yield_on_return
Members detail
This constructor is declared in QtLua/qtluastate.hh source file, line 108.
This destructor is declared in QtLua/qtluastate.hh source file, line 121.
Lua interpreter state is checked for remaining Value objects with references to UserData objects when destroyed.
Program is aborted if such references are found because these objects would try to access the destroyed State later and probably crash.
QtLua takes care of clearing all global variables before performing this sanity check.
This variable is declared in QtLua/qtluastate.hh source file, line 335.
This member access is private.
This variable is declared in QtLua/qtluastate.hh source file, line 326.
This member access is private.
This variable is declared in QtLua/qtluastate.hh source file, line 327.
This member access is private.
This variable is declared in QtLua/qtluastate.hh source file, line 325.
This member access is private.
This variable is declared in QtLua/qtluastate.hh source file, line 333.
This member access is private.
current thread state
This variable is declared in QtLua/qtluastate.hh source file, line 332.
This member access is private.
main thread state
wrapper_hash_t _whash
This variable is declared in QtLua/qtluastate.hh source file, line 330.
This member access is private.
This variable is declared in QtLua/qtluastate.hh source file, line 334.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 166.
Index operation on global table.
See also State::operator[] function.
This function is declared in QtLua/qtluastate.hh source file, line 172.
Index operation on global table, shortcut for string key access.
See also State::operator[] function.
This function is declared in QtLua/qtluastate.hh source file, line 246.
This function function may be used to enable forwarding of lua print function output to Qt debug output.
See also Predefined lua functions section.
void exec(const QString &statements)
This Qt slot is declared in QtLua/qtluastate.hh source file, line 256.
This member is a Qt slot.
This slot function execute the given script string and initiate a garbage collection cycle. It will catch and print lua errors using the State::output signal.
See also Console class.
This function is declared in QtLua/qtluastate.hh source file, line 127.
Execute a lua chuck read from QIODevice .
See also Error handling and exceptions section.
This function is declared in QtLua/qtluastate.hh source file, line 133.
Execute a lua script string.
See also Error handling and exceptions section.
void fill_completion_list(const QString &prefix, QStringList &list, int &cursor_offset)
This Qt slot is declared in QtLua/qtluastate.hh source file, line 262.
This member is a Qt slot.
Lua global variables completion handler. May be connected to Console widget for default global variables completion behavior.
void fill_completion_list_r(String &path, const String &prefix, QStringList &list, const Value &tbl, int &cursor_offset)
This function is declared in QtLua/qtluastate.hh source file, line 286.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 137.
Initiate a garbage collection cycle. This is useful to ensure all unused UserData based objects are destroyed.
This function is declared in QtLua/qtluastate.hh source file, line 147.
Get global variable. If path contains '.', intermediate tables will be accessed. The State::operator[] function may be used if no intermediate table access is needed.
This function is declared in QtLua/qtluastate.hh source file, line 289.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 222.
This function returns a pointer to the internal Lua state.
static State * get_this(lua_State *st)
This function is declared in QtLua/qtluastate.hh source file, line 282.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 299.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 302.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 298.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 301.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 303.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 300.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 304.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 217.
Call given function pointer with internal lua_State pointer. Can be used to register extra libraries or access internal lua interpreter directly.
Use with care if you are nor familiar with the lua C API.
This function is declared in QtLua/qtluastate.hh source file, line 307.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 321.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 314.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 310.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 316.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 322.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 319.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 318.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 315.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 317.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 311.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 309.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 320.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 312.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 308.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 313.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 293.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 295.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 294.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 240.
this function returns lua version. Result is 500 for lua pior to version 5.1.
bool openlib(Library lib)
This function is declared in QtLua/qtluastate.hh source file, line 208.
This function open a lua standard library or QtLua lua library. The function returns true if the library is available.
See also Library enum and QtLua lua libraries section.
This function is declared in QtLua/qtluastate.hh source file, line 160.
Index operation on global table. This function return a Value object which is a copy of the requested global variable. This value can be modified but will not change the original lua variable.
// code from examples/cpp/value/global.cc:32
QtLua::State state;
QtLua::State const & const_state = state;
// Access global table from lua
state.exec_statements("foo = 5");
// Access global table from C++
int foo = const_state["foo"];
See also State::at function.
This function is declared in QtLua/qtluastate.hh source file, line 180.
Index operation on global table, shortcut for string key access.
See also State::operator[] function and State::at function.
This function is declared in QtLua/qtluastate.hh source file, line 192.
Index operation on global table. This function return a ValueRef object which is a modifiable reference to requested global variable. It can be assigned to modify original lua value:
// code from examples/cpp/value/global.cc:32
QtLua::State state;
// Access global table from lua
state.exec_statements("foo = 5");
// Access global table from C++
state["bar"] = 5;
See also State::at function.
This function is declared in QtLua/qtluastate.hh source file, line 200.
Index operation on global table, shortcut for string key access.
See also State::operator[] function and State::at function.
void output(const QString &str)
This Qt signal is declared in QtLua/qtluastate.hh source file, line 275.
This member is a Qt signal.
Text output signal. This signal is used to report errors and display output of the lua print() function.
See also Predefined lua functions section.
void output_str(const String &str)
This function is declared in QtLua/qtluastate.hh source file, line 279.
This member access is private.
This function is declared in QtLua/qtluastate.hh source file, line 291.
This member access is private.
This template function is declared in QtLua/qtluastate.hh source file, line 230.
This template function adds a new entry to the qt.meta lua table. This allows lua script to access QObject members and create new objects of this type using the qt.new_qobject lua function.
This function is declared in QtLua/qtluastate.hh source file, line 142.
Set a global variable. If path contains '.', intermediate tables will be created on the fly. The State::operator[] function may be used if no intermediate table access is needed.
This function is declared in QtLua/qtluastate.hh source file, line 288.
This member access is private.
This function is for internal use only.
This function is declared in QtLua/qtluastate.hh source file, line 235.
This function asserts internal lua stack is empty.
This Qt slot is for internal use only.
This Qt slot is declared in QtLua/qtluastate.hh source file, line 267.
This member is a Qt slot.
This function return a lua value from an expression.