]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Script.hh
new convenient script methods
[chaz/yoink] / src / Moof / Script.hh
index 9af54402ae74846e88418531d8b679e71595c02d..620db5bc6906c82bd58446be23a2075367c20208 100644 (file)
@@ -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 <boost/shared_ptr.hpp>
 #include <lua.hpp>
 
-#include <Moof/Log.hh>
-
 
 namespace Mf {
 
@@ -412,6 +411,19 @@ public:
                        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.
@@ -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());
This page took 0.018935 seconds and 4 git commands to generate.