/**
* @file Script.hh
* A thin wrapper over Lua. This is not meant as a complicated binding
- * package between C++ and Lua. It does not try to make the boundary
- * invisible. It does not hide the concept of the Lua stack, but rather
+ * package between C++ and Lua. It is not meant to obscure the division
+ * between C++ and Lua but rather to clarify it and make it more
+ * manageable. It does not hide the concept of the Lua stack, but rather
* provides that mechanism with a certain level of abstraction while also
* providing a cleaner, more consistent API.
*/
#include <boost/shared_ptr.hpp>
#include <lua.hpp>
-#include <Moof/Log.hh>
-
namespace Mf {
return true;
}
+ /**
+ * Get the value of a field from the table.
+ */
+
+ template <typename T, typename V>
+ bool get(T& value, V field) const
+ {
+ pushField(field);
+ bool ret = Slot(mState, -1).get(value);
+ lua_pop(mState, 1);
+ return ret;
+ }
+
/**
* Copy the value and push the copy to the stack.
}
- void pushMetatable() const
+ void pushMetaTable() const
{
lua_getmetatable(mState, index);
}
lua_setglobal(mState, name.c_str());
}
-
Result doString(const std::string& commands)
{
return (Result)luaL_dostring(mState, commands.c_str());