- bool isBoolean() const { return (bool)lua_isboolean(state, index); }
- bool isFunction() const { return (bool)lua_isfunction(state, index); }
- bool isNil() const { return (bool)lua_isnil(state, index); }
- bool isNone() const { return (bool)lua_isnone(state, index); }
- bool isValid() const { return state != 0 && !isNone(); }
- bool isNoneOrNil() const { return (bool)lua_isnoneornil(state, index); }
- bool isNumber() const { return (bool)lua_isnumber(state, index); }
- bool isString() const { return (bool)lua_isstring(state, index); }
- bool isTable() const { return (bool)lua_istable(state, index); }
- bool isThread() const { return (bool)lua_isthread(state, index); }
- bool isData() const { return (bool)lua_isuserdata(state, index); }
- bool isLightData() const { return (bool)lua_islightuserdata(state, index); }
+ bool isBoolean() const
+ { return (bool)lua_isboolean(mScript.mState, index); }
+ bool isImportedFunction() const
+ { return (bool)lua_iscfunction(mScript.mState, index); }
+ bool isFunction() const
+ { return (bool)lua_isfunction(mScript.mState, index); }
+ bool isNil() const
+ { return (bool)lua_isnil(mScript.mState, index); }
+ bool isNone() const
+ { return (bool)lua_isnone(mScript.mState, index); }
+ bool isNoneOrNil() const
+ { return (bool)lua_isnoneornil(mScript.mState, index); }
+ bool isNumber() const
+ { return (bool)lua_isnumber(mScript.mState, index); }
+ bool isString() const
+ { return (bool)lua_isstring(mScript.mState, index); }
+ bool isTable() const
+ { return (bool)lua_istable(mScript.mState, index); }
+ bool isThread() const
+ { return (bool)lua_isthread(mScript.mState, index); }
+ bool isData() const
+ { return (bool)lua_isuserdata(mScript.mState, index); }
+ bool isLightData() const
+ { return (bool)lua_islightuserdata(mScript.mState, index); }
+
+ /**
+ * Check the value and throw an error if its the wrong type.
+ * There's a little caveat: This method never returns because it
+ * does a long jump. Consequently, constructed C++ objects which
+ * exist on the stack between the current frame and some lua
+ * function will not be destructed. That's not a problem for
+ * objects that only exist on the stack, but any objects that
+ * allocate memory on the heap (such as containers or strings) will
+ * leak. Therefore, you should only call this method after
+ * cleaning up such objects. The best thing to do for defining
+ * functions is to simply check all the parameters at the get-go
+ * before any C++ objects are even constructed.
+ */
+
+ void requireType(Type t) const
+ {
+ if (t != type())
+ {
+ luaL_typerror(mScript.mState, index,
+ lua_typename(mScript.mState, t));
+ }
+ }
+
+ void raise(const char* error)
+ {
+ luaL_argerror(mScript.mState, index, error);
+ }
+
+
+ Slot& requireBoolean()
+ {
+ if (!isBoolean())
+ {
+ luaL_typerror(mScript.mState, index, "boolean");
+ }
+ return *this;
+ }
+ Slot& requireNumber()
+ {
+ if (!isNumber())
+ {
+ luaL_typerror(mScript.mState, index, "number");
+ }
+ return *this;
+ }
+ Slot& requireString()
+ {
+ if (!isString())
+ {
+ luaL_typerror(mScript.mState, index, "string");
+ }
+ return *this;
+ }
+ Slot& requireTable()
+ {
+ if (!isTable())
+ {
+ luaL_typerror(mScript.mState, index, "table");
+ }
+ return *this;
+ }
+ Slot& requireFunction()
+ {
+ if (!isFunction())
+ {
+ luaL_typerror(mScript.mState, index, "function");
+ }
+ return *this;
+ }
+ Slot& requireData()
+ {
+ if (!isData())
+ {
+ luaL_typerror(mScript.mState, index, "data");
+ }
+ return *this;
+ }
+ Slot& requireNil()
+ {
+ if (!isNil())
+ {
+ luaL_typerror(mScript.mState, index, "nil");
+ }
+ return *this;
+ }
+ Slot& requireThread()
+ {
+ if (!isThread())
+ {
+ luaL_typerror(mScript.mState, index, "thread");
+ }
+ return *this;
+ }
+