#include <LuaVariable.hpp>
Public Types | |
| typedef std::vector< LuaValue > | KeyList |
| A sequence of keys, used to access nested tables. | |
Public Member Functions | |
| const LuaValue & | operator= (const LuaValue &rhs) |
| LuaValue | value () const |
| LuaVariable | operator[] (const LuaValue &key) const |
| LuaValueList | operator() (const LuaValueList ¶ms) |
| LuaValueList | operator() () |
| LuaValueList | operator() (const LuaValue ¶m) |
| LuaValueList | operator() (const LuaValue ¶m1, const LuaValue ¶m2) |
| LuaValueList | operator() (const LuaValue ¶m1, const LuaValue ¶m2, const LuaValue ¶m3) |
| LuaValueList | operator() (const LuaValue ¶m1, const LuaValue ¶m2, const LuaValue ¶m3, const LuaValue ¶m4) |
| LuaValueList | operator() (const LuaValue ¶m1, const LuaValue ¶m2, const LuaValue ¶m3, const LuaValue ¶m4, const LuaValue ¶m5) |
| bool | operator== (const LuaValue &rhs) const |
| bool | operator== (const LuaVariable &rhs) const |
| bool | operator!= (const LuaVariable &rhs) const |
| const KeyList & | getKeys () const |
| void | pushLastTable () |
| lua_State * | getState () |
Private Member Functions | |
| LuaVariable (lua_State *state, const LuaValue &key, const KeyList &predKeys=KeyList()) | |
| void | pushTheReferencedValue () const |
Private Attributes | |
| lua_State * | state_ |
The Lua state in which this LuaVariable lives. | |
| KeyList | keys_ |
Friends | |
| class | LuaState |
LuaValue, a LuaVariable necessarily has a real counterpart in a Lua state. Thus, when something is assigned to a LuaVariable, the value of the corresponding variable in the Lua state is changed, too.
LuaVariables cannot be directly constructed. They are designed to be returned by LuaState's subscript operator.
Definition at line 43 of file LuaVariable.hpp.
| typedef std::vector<LuaValue> Diluculum::LuaVariable::KeyList |
| Diluculum::LuaVariable::LuaVariable | ( | lua_State * | state, | |
| const LuaValue & | key, | |||
| const KeyList & | predKeys = KeyList() | |||
| ) | [private] |
Constructs a LuaVariable.
LuaVariable directly. For Diluculum users, the only allowed way to create a new LuaVariable is by using LuaState's subscript operator. | state | The lua_State* in which the variable represented by this LuaVariable resides. | |
| key | The "key" used to access the variable represented by this LuaVariable. This can be variable name (for the case of a global variable) or a "real" key (when it is a field in a possibly nested table). | |
| predKeys | The sequence of keys used to access the table that contains the variable represented by this LuaVariable. For a global variable, this list will be empty. For a variable stored in a possibly nested table, the list can be arbitrarily long. |
| const KeyList& Diluculum::LuaVariable::getKeys | ( | ) | const [inline] |
Returns the sequence of keys used to reach this variable.
Definition at line 253 of file LuaVariable.hpp.
References keys_.
| lua_State* Diluculum::LuaVariable::getState | ( | ) | [inline] |
Returns the LuaState in which this LuaVariable lives.
Definition at line 271 of file LuaVariable.hpp.
References state_.
| bool Diluculum::LuaVariable::operator!= | ( | const LuaVariable & | rhs | ) | const [inline] |
Checks whether this LuaVariable refers to a different variable than rhs.
| rhs | The variable against which the comparison will be done. |
false if both involved LuaVariables refer to the same variable. true otherwise. Definition at line 243 of file LuaVariable.hpp.
| LuaValueList Diluculum::LuaVariable::operator() | ( | const LuaValue & | param1, | |
| const LuaValue & | param2, | |||
| const LuaValue & | param3, | |||
| const LuaValue & | param4, | |||
| const LuaValue & | param5 | |||
| ) |
Assuming that this LuaVariable holds a function, calls this function and returns its return values. Both "pure" Lua functions and functions written in C/C++ and "exported" to Lua are supported.
| param1 | The first parameter to be passed to the function being called | |
| param2 | The second parameter to be passed to the function being called | |
| param3 | The third parameter to be passed to the function being called | |
| param4 | The fourth parameter to be passed to the function being called | |
| param5 | The fifth parameter to be passed to the function being called |
| TypeMismatchError | If this LuaVariable tries to subscript something that is not a table. | |
| LuaRunTimeError | If something bad happens while executing the function. |
| LuaValueList Diluculum::LuaVariable::operator() | ( | const LuaValue & | param1, | |
| const LuaValue & | param2, | |||
| const LuaValue & | param3, | |||
| const LuaValue & | param4 | |||
| ) |
Assuming that this LuaVariable holds a function, calls this function and returns its return values. Both "pure" Lua functions and functions written in C/C++ and "exported" to Lua are supported.
| param1 | The first parameter to be passed to the function being called | |
| param2 | The second parameter to be passed to the function being called | |
| param3 | The third parameter to be passed to the function being called | |
| param4 | The fourth parameter to be passed to the function being called |
| TypeMismatchError | If this LuaVariable tries to subscript something that is not a table. | |
| LuaRunTimeError | If something bad happens while executing the function. |
| LuaValueList Diluculum::LuaVariable::operator() | ( | const LuaValue & | param1, | |
| const LuaValue & | param2, | |||
| const LuaValue & | param3 | |||
| ) |
Assuming that this LuaVariable holds a function, calls this function and returns its return values. Both "pure" Lua functions and functions written in C/C++ and "exported" to Lua are supported.
| param1 | The first parameter to be passed to the function being called | |
| param2 | The second parameter to be passed to the function being called | |
| param3 | The third parameter to be passed to the function being called |
| TypeMismatchError | If this LuaVariable tries to subscript something that is not a table. | |
| LuaRunTimeError | If something bad happens while executing the function. |
| LuaValueList Diluculum::LuaVariable::operator() | ( | const LuaValue & | param1, | |
| const LuaValue & | param2 | |||
| ) |
Assuming that this LuaVariable holds a function, calls this function and returns its return values. Both "pure" Lua functions and functions written in C/C++ and "exported" to Lua are supported.
| param1 | The first parameter to be passed to the function being called | |
| param2 | The second parameter to be passed to the function being called |
| TypeMismatchError | If this LuaVariable tries to subscript something that is not a table. | |
| LuaRunTimeError | If something bad happens while executing the function. |
| LuaValueList Diluculum::LuaVariable::operator() | ( | const LuaValue & | param | ) |
Assuming that this LuaVariable holds a function, calls this function and returns its return values. Both "pure" Lua functions and functions written in C/C++ and "exported" to Lua are supported.
| param | The one and only parameter to be passed to the function being called |
| TypeMismatchError | If this LuaVariable tries to subscript something that is not a table. | |
| LuaRunTimeError | If something bad happens while executing the function. |
| LuaValueList Diluculum::LuaVariable::operator() | ( | ) |
Assuming that this LuaVariable holds a function, calls this function (without passing any parameter to it) and returns its return values. Both "pure" Lua functions and functions written in C/C++ and "exported" to Lua are supported.
| TypeMismatchError | If this LuaVariable tries to subscript something that is not a table. | |
| LuaRunTimeError | If something bad happens while executing the function. |
| LuaValueList Diluculum::LuaVariable::operator() | ( | const LuaValueList & | params | ) |
Assuming that this LuaVariable holds a function, calls this function and returns its return values. Both "pure" Lua functions and functions written in C/C++ and "exported" to Lua are supported.
| params | All the parameters to be passed to the function being called. The first parameter at index 0, the second at index 1 and so on. |
| TypeMismatchError | If this LuaVariable tries to subscript something that is not a table. | |
| LuaRunTimeError | If something bad happens while executing the function. |
Assigns a new value to this LuaVariable. The corresponding variable in the Lua state is updated accordingly.
LuaVariable to another LuaVariable (using the compiler-generated assignment operator). In that case, the LuaVariable at the left hand side will refer to the same variable as the LuaVariable at the right hand side, but no values will be changed. | rhs | The new value for the variable. |
rhs, so that a sequence of assignments, like a = b = c = 1; works. Actually, returning rhs is the same as returning this->value(), that perhaps make more sense. | TypeMismatchError | If this LuaVariable tries to subscript something that is not a table. |
DILUCULUM_REGISTER_OBJECT() macro. If someday the implementation here is replaced with something better, remember to change there, too. | bool Diluculum::LuaVariable::operator== | ( | const LuaVariable & | rhs | ) | const [inline] |
Checks whether this LuaVariable refers to the same variable as rhs.
| rhs | The variable against which the comparison will be done. |
true if both involved LuaVariables refer to the same variable. false otherwise. Definition at line 234 of file LuaVariable.hpp.
| bool Diluculum::LuaVariable::operator== | ( | const LuaValue & | rhs | ) | const [inline] |
Checks whether the value stored in this variable is equal to the value at rhs.
| rhs | The value against which the comparison will be done. |
true if this variable's value is equal to rhs. false otherwise. | TypeMismatchError | If this LuaVariable tries to subscript something that is not a table. |
Definition at line 225 of file LuaVariable.hpp.
References value().
| LuaVariable Diluculum::LuaVariable::operator[] | ( | const LuaValue & | key | ) | const |
Assuming that this LuaVariable holds a table, returns the value whose index is key.
| key | The key whose value is desired. |
key. LuaVariable doesn't hold a table. But an exception will be thrown if one tries to access the value of the returned variable (see value()). | void Diluculum::LuaVariable::pushLastTable | ( | ) |
Pushes into the Lua stack the table storing this variable. Now, let's try to make this clearer... First, every Lua variable is stored in a table (even global variables, because Lua stores them in a "table of globals"). So, this method will find the table where this variable is stored (traversing a sequence of nested tables, if necessary), and push it onto the Lua stack (of the state_ Lua state).
| void Diluculum::LuaVariable::pushTheReferencedValue | ( | ) | const [private] |
Pushes onto the Lua stack the value referenced by this LuaVariable.
| TypeMismatchError | If this LuaVariable tries to subscript something that is not a table. |
| LuaValue Diluculum::LuaVariable::value | ( | ) | const |
Returns the value associated with this variable. If the variable does not exist, returns Nil.
| TypeMismatchError | If this LuaVariable tries to subscript something that is not a table. |
Referenced by operator==().
friend class LuaState [friend] |
Definition at line 45 of file LuaVariable.hpp.
KeyList Diluculum::LuaVariable::keys_ [private] |
The sequence of keys used to get to this variable. For a global variable, this will consist of a single key; for variables inside nested tables, this sequence can be arbitrarily long.
Just to relate this with the parameters passed to the constructor: this sequence equals to predKeys parameter, with the key parameter appended to it.
Definition at line 312 of file LuaVariable.hpp.
Referenced by getKeys(), operator!=(), and operator==().
lua_State* Diluculum::LuaVariable::state_ [private] |
The Lua state in which this LuaVariable lives.
Definition at line 303 of file LuaVariable.hpp.
Referenced by getState(), operator!=(), and operator==().
1.5.9