Working with Lua table functions
For our Lua executor, we want to call table functions with the same level of support as calling global functions. Similar to call
and vcall
, we can define two functions named tcall
and vtcall
that call table functions and return a single value and a list of values respectively.
We need to add two more pieces of information to the new C++ member functions – namely, the following:
- The table name, which is obvious
- Whether we should pass the
self
argument to the table function
More on the latter point:
- When the table function does not refer
self
and is used like C++ static member functions, we do not need to passself
- When the table function refers
self
and is used like C++ member functions, we need to passself
Let’s implement the code to reinforce what we have just talked about.
Implementing table function support
In LuaExecutor.h
, add the following declarations:
class LuaExecutor { public...