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  

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  

Private static functions  

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  

Members detail  

State()  

This constructor is declared in QtLua/qtluastate.hh source file, line 108.

~State()  

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.

bool _debug_output  

This variable is declared in QtLua/qtluastate.hh source file, line 335.

This member access is private.

static char _key_item_metatable  

This variable is declared in QtLua/qtluastate.hh source file, line 326.

This member access is private.

static char _key_this  

This variable is declared in QtLua/qtluastate.hh source file, line 327.

This member access is private.

static char _key_threads  

This variable is declared in QtLua/qtluastate.hh source file, line 325.

This member access is private.

lua_State *_lst  

This variable is declared in QtLua/qtluastate.hh source file, line 333.

This member access is private.

current thread state

lua_State *_mst  

This variable is declared in QtLua/qtluastate.hh source file, line 332.

This member access is private.

main thread state

This variable is declared in QtLua/qtluastate.hh source file, line 330.

This member access is private.

bool _yield_on_return  

This variable is declared in QtLua/qtluastate.hh source file, line 334.

This member access is private.

Value at(const Value &key) const  

This function is declared in QtLua/qtluastate.hh source file, line 166.

Index operation on global table.

See also State::operator[] function.

Value at(const String &key) const  

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.

void enable_qdebug_print(bool enabled = true)  

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.

ValueBase::List exec_chunk(QIODevice &io)  

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.

ValueBase::List exec_statements(const String &statements)  

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.

void gc_collect()  

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.

Value get_global(const String &path) const  

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.

void get_global_r(const String &name, Value &value, int tblidx) const  

This function is declared in QtLua/qtluastate.hh source file, line 289.

This member access is private.

lua_State * get_lua_state() const  

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.

static int lua_cmd_each(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 299.

This member access is private.

static int lua_cmd_help(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 302.

This member access is private.

static int lua_cmd_iterator(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 298.

This member access is private.

static int lua_cmd_list(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 301.

This member access is private.

static int lua_cmd_plugin(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 303.

This member access is private.

static int lua_cmd_print(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 300.

This member access is private.

static int lua_cmd_qtype(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 304.

This member access is private.

void lua_do(void (*func)(::lua_State *) )  

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.

static int lua_meta_item_add(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 307.

This member access is private.

static int lua_meta_item_call(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 321.

This member access is private.

static int lua_meta_item_concat(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 314.

This member access is private.

static int lua_meta_item_div(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 310.

This member access is private.

static int lua_meta_item_eq(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 316.

This member access is private.

static int lua_meta_item_gc(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 322.

This member access is private.

static int lua_meta_item_index(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 319.

This member access is private.

static int lua_meta_item_le(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 318.

This member access is private.

static int lua_meta_item_len(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 315.

This member access is private.

static int lua_meta_item_lt(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 317.

This member access is private.

static int lua_meta_item_mod(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 311.

This member access is private.

static int lua_meta_item_mul(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 309.

This member access is private.

static int lua_meta_item_newindex(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 320.

This member access is private.

static int lua_meta_item_pow(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 312.

This member access is private.

static int lua_meta_item_sub(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 308.

This member access is private.

static int lua_meta_item_unm(lua_State *st)  

This function is declared in QtLua/qtluastate.hh source file, line 313.

This member access is private.

static void lua_pgettable(lua_State *st, int index)  

This function is declared in QtLua/qtluastate.hh source file, line 293.

This member access is private.

static int lua_pnext(lua_State *st, int index)  

This function is declared in QtLua/qtluastate.hh source file, line 295.

This member access is private.

static void lua_psettable(lua_State *st, int index)  

This function is declared in QtLua/qtluastate.hh source file, line 294.

This member access is private.

int lua_version() const  

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.

Value operator[](const Value &key) const  

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.

Value operator[](const String &key) const  

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.

ValueRef operator[](const Value &key)  

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.

ValueRef operator[](const String &key)  

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.

void reg_c_function(const char *name, int (*fcn)(::lua_State *) )  

This function is declared in QtLua/qtluastate.hh source file, line 291.

This member access is private.

static template <typename QObject_T> void register_qobject_meta()  

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.

void set_global(const String &path, const Value &value)  

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.

void set_global_r(const String &name, const Value &value, int tblidx)  

This function is declared in QtLua/qtluastate.hh source file, line 288.

This member access is private.

void check_empty_stack() const  

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.

Value eval_expr(bool use_lua, const String &expr)  

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.

Valid XHTML 1.0 StrictGenerated by diaxen on Sat Mar 30 16:23:03 2013 using MkDoc