Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
brinkqiang committed Dec 1, 2018
1 parent 1e9b137 commit a80c6ea
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions include/dmlua_opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@ struct LuaReader
}
};

template <typename T>
struct LuaReader<T*>
{
static inline T* Read(lua_State* L, int index)
{
if (CluaTypeid::Instance().get_name<T>()) {
return (T*)tolua_tousertype(L, index, CluaTypeid::Instance().get_name<T>());
}
else {
return (T*)tolua_touserdata(L, index, NULL);
}
}
};

template <typename T>
struct LuaReader<T&>
{
static inline T& Read(lua_State* L, int index)
{
if (CluaTypeid::Instance().get_name<T>()) {
return *(T*)tolua_tousertype(L, index, CluaTypeid::Instance().get_name<T>());
}
else {
return *(T*)tolua_touserdata(L, index, NULL);
}
}
};

template <>
struct LuaReader<void>
{
Expand Down

0 comments on commit a80c6ea

Please sign in to comment.