diff options
Diffstat (limited to 'Runtime/Lua/LuaHelper.cpp')
-rw-r--r-- | Runtime/Lua/LuaHelper.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Runtime/Lua/LuaHelper.cpp b/Runtime/Lua/LuaHelper.cpp index f1dc349..71fe782 100644 --- a/Runtime/Lua/LuaHelper.cpp +++ b/Runtime/Lua/LuaHelper.cpp @@ -5,6 +5,7 @@ #include "Runtime/Graphics/Color.h"
using namespace LuaBind;
+using namespace std;
template <>
Rect State::GetValue < Rect >(int idx, const Rect value)
@@ -207,4 +208,32 @@ bool LuaHelper::IsType(LuaBind::State& state, const char* typeName, int idx) bool LuaHelper::InstantiateClass(LuaBind::State& state, const char* classFullName)
{
return false;
+}
+
+bool LuaHelper::GetLuaClass(LuaBind::State& state, const char* fullName)
+{
+ if (fullName == NULL || strlen(fullName) == 0)
+ return false;
+ int top = state.GetTop();
+ lua_pushvalue(state, LUA_GLOBALSINDEX); + string name = fullName; + while (name.size() > 0) + { + int dot = name.find('.'); + dot = dot != string::npos ? dot : name.size(); + string pkg = name.substr(0, dot); + if (dot < name.size()) + name = name.substr(dot + 1, name.size() - dot - 1); + else + name = ""; + lua_getfield(state, -1, pkg.c_str()); + if (lua_isnil(state, -1)) + { + lua_settop(state, top); + return false; + } + } + lua_replace(state, top + 1); + lua_settop(state, top + 1); + return true; }
\ No newline at end of file |