X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FScript.hh;h=620db5bc6906c82bd58446be23a2075367c20208;hp=9af54402ae74846e88418531d8b679e71595c02d;hb=58c1f9a499d3bb80ea2869b29c714f61e656d48d;hpb=751d631f20a2ba523c011b9059d6fc07d83077eb diff --git a/src/Moof/Script.hh b/src/Moof/Script.hh index 9af5440..620db5b 100644 --- a/src/Moof/Script.hh +++ b/src/Moof/Script.hh @@ -15,8 +15,9 @@ /** * @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. */ @@ -32,8 +33,6 @@ #include #include -#include - namespace Mf { @@ -412,6 +411,19 @@ public: return true; } + /** + * Get the value of a field from the table. + */ + + template + 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. @@ -447,7 +459,7 @@ public: } - void pushMetatable() const + void pushMetaTable() const { lua_getmetatable(mState, index); } @@ -569,7 +581,6 @@ public: lua_setglobal(mState, name.c_str()); } - Result doString(const std::string& commands) { return (Result)luaL_dostring(mState, commands.c_str());