Kiritow
bc189b4951
分离各SDL类的包装代码. 事件分发处理全部转移至Lua Init层. C层只提供获取事件的方法. 这样有助于提高性能,以及今后Coroutine scheduler的添加.
63 lines
1.1 KiB
C++
63 lines
1.1 KiB
C++
#include "LuaVM.h"
|
|
|
|
void pushvalue(lua_State* L, int val)
|
|
{
|
|
lua_pushinteger(L, val);
|
|
}
|
|
|
|
void pushvalue(lua_State* L, double val)
|
|
{
|
|
lua_pushnumber(L, val);
|
|
}
|
|
|
|
void pushvalue(lua_State* L, const char* str)
|
|
{
|
|
lua_pushstring(L, str);
|
|
}
|
|
|
|
void pushvalue(lua_State* L, const char* str, int len)
|
|
{
|
|
lua_pushlstring(L, str, len);
|
|
}
|
|
|
|
void pushvalue(lua_State* L, const std::string& str)
|
|
{
|
|
lua_pushlstring(L, str.c_str(), str.size());
|
|
}
|
|
|
|
void pushvalue(lua_State* L, lua_CFunction fn)
|
|
{
|
|
lua_pushcfunction(L, fn);
|
|
}
|
|
|
|
void pushvalue(lua_State* L, lua_CFunction fn, int nup)
|
|
{
|
|
lua_pushcclosure(L, fn, nup);
|
|
}
|
|
|
|
|
|
template<>
|
|
const char* getvalue(lua_State* L, int index) // LUA_TSTRING
|
|
{
|
|
return luaL_checkstring(L, index);
|
|
}
|
|
|
|
template<>
|
|
std::string getvalue(lua_State* L, int index) // LUA_TSTRING
|
|
{
|
|
size_t sz;
|
|
const char* s = luaL_checklstring(L, index, &sz);
|
|
return std::string(s, sz);
|
|
}
|
|
|
|
template<>
|
|
int getvalue(lua_State* L, int index) // LUA_TNUMBER
|
|
{
|
|
return (const int)luaL_checkinteger(L, index);
|
|
}
|
|
|
|
template<>
|
|
double getvalue(lua_State* L, int index) // LUA_TNUMBER
|
|
{
|
|
return luaL_checknumber(L, index);
|
|
} |