an reference to lua object
More...
#include <lua.h>
|
| LuaRef ()=default |
| construct an nil ref
|
|
| LuaRef (LuaRef &&other) |
| move constructor from another LuaRef
|
|
| LuaRef (const LuaRef &other) |
| copy constructor
|
|
LuaRef & | operator= (LuaRef &&other) |
| assign operator from other
|
|
LuaRef & | operator= (const LuaRef &other) |
| assign operator from other
|
|
| ~LuaRef () |
| destructor
|
|
void | swap (LuaRef &other) |
| swap content with another ref
|
|
template<typename T > |
T | Get () const |
| Get content out as type T.
|
|
template<typename T > |
T * | GetUDataPtr () const |
| Get user data pointer from LuaRef.
|
|
bool | is_nil () const |
|
template<typename... Args> |
LuaRef | operator() (Args &&...args) const |
| invoke the LuaRef as function
|
|
LuaRef | operator[] (const std::string &key) const |
| Get field from the lua table. The reference must be a table.
|
|
LuaRef | operator[] (size_t index) const |
| Get field from the lua array The reference must be a array.
|
|
template<typename T > |
LuaRef & | SetField (const std::string &key, const T &value) |
| Set field of lua table. The reference must be a table.
|
|
void | SetByPopStack_ (LuaState *s) |
| Set LuaRef to the value on top of the stack. This state must be nil. This is API used by developer.
|
|
|
struct | lua_stack::Handler< LuaRef > |
|
class | LuaState |
|
std::ostream & | operator<< (std::ostream &os, const LuaRef &r) |
|
an reference to lua object
◆ LuaRef() [1/2]
dmlc::LuaRef::LuaRef |
( |
LuaRef && |
other | ) |
|
|
inline |
move constructor from another LuaRef
- Parameters
-
other | The other LuaRef to be moved |
◆ LuaRef() [2/2]
dmlc::LuaRef::LuaRef |
( |
const LuaRef & |
other | ) |
|
|
inline |
copy constructor
- Parameters
-
other | The other LuaRef to be copied |
◆ Get()
template<typename T >
T dmlc::LuaRef::Get |
( |
| ) |
const |
|
inline |
Get content out as type T.
- Template Parameters
-
- Returns
- the corresponding c type.
◆ GetUDataPtr()
template<typename T >
T * dmlc::LuaRef::GetUDataPtr |
( |
| ) |
const |
|
inline |
Get user data pointer from LuaRef.
CAREFUL when getting userdata(e.g. pointer to Tensor's storage) from LuaRef. Remember they are managed by Lua, and can get deleted when all the LuaRef to the userdata destructs. A good practice is always use a LuaRef to keep the userdata alive when you need them from C++ side.
- Template Parameters
-
T | the type of pointer to be fetched. |
- Returns
- the corresponding c type.
◆ is_nil()
bool dmlc::LuaRef::is_nil |
( |
| ) |
const |
|
inline |
- Returns
- whether the value is nil
◆ operator()()
template<typename... Args>
LuaRef dmlc::LuaRef::operator() |
( |
Args &&... |
args | ) |
const |
|
inline |
invoke the LuaRef as function
- Parameters
-
args | Arguments to be passed. |
- Template Parameters
-
Args | arguments to be passed. |
- Returns
- The first return value.
◆ operator=() [1/2]
assign operator from other
- Parameters
-
other | The other LuaRef to be copy or moved. |
- Returns
- self
◆ operator=() [2/2]
assign operator from other
- Parameters
-
other | The other LuaRef to be copy or moved. |
- Returns
- self
◆ operator[]() [1/2]
LuaRef dmlc::LuaRef::operator[] |
( |
const std::string & |
key | ) |
const |
|
inline |
Get field from the lua table. The reference must be a table.
- Parameters
-
- Returns
- a new ref to the corresponding field.
◆ operator[]() [2/2]
LuaRef dmlc::LuaRef::operator[] |
( |
size_t |
index | ) |
const |
|
inline |
Get field from the lua array The reference must be a array.
- Parameters
-
index | The index to the array, Note: the index convention follows lua table, starts from 1 |
- Returns
- a new ref to the corresponding field.
◆ SetByPopStack_()
void dmlc::LuaRef::SetByPopStack_ |
( |
LuaState * |
s | ) |
|
|
inline |
Set LuaRef to the value on top of the stack. This state must be nil. This is API used by developer.
- Parameters
-
s | the corresponding lua state. |
◆ SetField()
template<typename T >
LuaRef & dmlc::LuaRef::SetField |
( |
const std::string & |
key, |
|
|
const T & |
value |
|
) |
| |
|
inline |
Set field of lua table. The reference must be a table.
- Parameters
-
key | The key to the table |
value | Lua convertable value to be setted. |
- Returns
- self.
◆ swap()
void dmlc::LuaRef::swap |
( |
LuaRef & |
other | ) |
|
|
inline |
swap content with another ref
- Parameters
-
other | another LuaRef to be swaped. |
The documentation for this class was generated from the following file:
- External/xgboost/dmlc-core/include/dmlc/lua.h