瀏覽代碼

Remove defines. It still crashes though.

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> 10 年之前
父節點
當前提交
41da69ba68
共有 2 個檔案被更改,包括 3 行新增76 行删除
  1. +3
    -1
      src/application/application.cpp
  2. +0
    -75
      src/application/baselua.h

+ 3
- 1
src/application/application.cpp 查看文件

@@ -74,7 +74,9 @@ Application::Application(char const *name, ivec2 resolution, float framerate)
data = new ApplicationData(name, resolution, framerate);

g_world.ExecLua("lua/init.lua");
int32_t gravity = g_world.GetVar<int32_t>("gravity");
float gravity = g_world.GetLuaNumber("gravity");
gravity = g_world.GetVar<float>("gravity");
gravity = gravity;
}

bool Application::MustTick()


+ 0
- 75
src/application/baselua.h 查看文件

@@ -19,81 +19,6 @@
namespace lol
{

//-----------------------------------------------------------------------------
#define LOLUA_CLASS_STATIC(ClassType, FuncName) Static ## ClassType ## FuncName
#define LOLUA_CLASS_METHOD(ClassType, FuncName) Method ## ClassType ## FuncName
#define LOLUA_CLASS_STATIC_C(ClassType, FuncName) Static ## #ClassType ## #FuncName
#define LOLUA_CLASS_METHOD_C(ClassType, FuncName) Method ## #ClassType ## #FuncName

#define LOLUA_BEGIN_CTOR(ClassType) \
ClassType* ClassType##New(lua_State* L) \
{ \
int arg_idx = 1; \

#define LOLUA_END_CTOR(ClassType, ...) \
return new ClassType(__VA_ARGS__); \
} \

#define LOLUA_BEGIN_STATIC(FuncName) \
int FuncName(lua_State* L) \
{ \
int arg_idx = 1; \

#define LOLUA_BEGIN_CLASS_STATIC(ClassType, FuncName) \
int LOLUA_CLASS_STATIC(ClassType, FuncName)(lua_State* L) \
{ \
int arg_idx = 1; \

#define LOLUA_BEGIN_CLASS_METHOD(ClassType, FuncName) \
int LOLUA_CLASS_METHOD(ClassType, FuncName)(lua_State* L) \
{ \
int arg_idx = 1; \
ClassType* this_ptr = luaW_check<ClassType>(L, arg_idx); \

#define LOLUA_CALL_FUNC(FuncName, ...) FuncName(__VA_ARGS__);
#define LOLUA_CALL_FUNC_RET(FuncName, ...) auto result = FuncName(__VA_ARGS__);
#define LOLUA_CALL_STATIC(ClassType, FuncName, ...) ClassType::FuncName(__VA_ARGS__);
#define LOLUA_CALL_STATIC_RET(ClassType, FuncName, ...) auto result = ClassType::FuncName(__VA_ARGS__);
#define LOLUA_CALL_METHOD(FuncName, ...) this_ptr->FuncName(__VA_ARGS__);
#define LOLUA_CALL_METHOD_RET(FuncName, ...) auto result = this_ptr->FuncName(__VA_ARGS__);

#define LOLUA_ARG_STRING(VarName) String VarName = luaL_checkstring(L, arg_idx++);
#define LOLUA_ARG_CHAR(VarName) const char* VarName = luaL_checkstring(L, arg_idx++);
#define LOLUA_ARG_DOUBLE(VarName) double VarName = luaL_checknumber(L, arg_idx++);
#define LOLUA_ARG_INT(VarName) int32_t VarName = luaL_checkinteger(L, arg_idx++);
#define LOLUA_ARG_UINT(VarName) uint32_t VarName = luaL_checkunsigned(L, arg_idx++);
#define LOLUA_ARG_OBJ(VarType, VarName) VarType* VarName = luaW_check<VarType>(L, arg_idx++);

#define LOLUA_END_FUNC_STRING(VarName) lua_pushstring(L, VarName.C()); return 1; }
#define LOLUA_END_FUNC_CHAR(VarName) lua_pushstring(L, VarName); return 1; }
#define LOLUA_END_FUNC_FLOAT(VarName) lua_pushnumber(L, VarName); return 1; }
#define LOLUA_END_FUNC_INT(VarName) lua_pushinteger(L, VarName); return 1; }
#define LOLUA_END_FUNC_UINT(VarName) lua_pushunsigned(L, VarName); return 1; }
#define LOLUA_END_FUNC_OBJ(VarName) luaW_push<VarType>(L, VarName); return 1; }
#define LOLUA_END_FUNC_STRING_RESULT LOLUA_END_FUNC_STRING(result)
#define LOLUA_END_FUNC_CHAR_RESULT LOLUA_END_FUNC_CHAR(result)
#define LOLUA_END_FUNC_FLOAT_RESULT LOLUA_END_FUNC_FLOAT(result)
#define LOLUA_END_FUNC_INT_RESULT LOLUA_END_FUNC_INT(result)
#define LOLUA_END_FUNC_UINT_RESULT LOLUA_END_FUNC_UINT(result)
#define LOLUA_END_FUNC_OBJ_RESULT LOLUA_END_FUNC_OBJ(result)
#define LOLUA_END_FUNC_VOID return 0; }

#define LOLUA_BEGIN_TABLE_STATIC(ClassType) static luaL_Reg ClassType##StaticTable[] = {
#define LOLUA_BEGIN_TABLE_METHOD(ClassType) static luaL_Reg ClassType##MethodTable[] = {
#define LOLUA_ADD_TABLE_STATIC(ClassType, FuncName) { LOLUA_CLASS_STATIC_C(ClassType, FuncName), LOLUA_CLASS_STATIC(ClassType, FuncName) },
#define LOLUA_ADD_TABLE_METHOD(ClassType, FuncName) { LOLUA_CLASS_METHOD_C(ClassType, FuncName), LOLUA_CLASS_METHOD(ClassType, FuncName) },
#define LOLUA_END_TABLE { NULL, NULL } };

#define LOLUA_DEFINE_CLASS_LIBRARY(ClassType) \
static int luaopen_##ClassType(lua_State* L) \
{ luaW_register<ClassType>(L, #ClassType, ClassType##StaticTable, ClassType##MethodTable, ClassType##New); return 1; }\

#define LOLUA_NEW_STATE(VarName) lua_State* L = (VarName = luaL_newstate());
#define LOLUA_USE_STATE(VarName) lua_State* L = VarName;
#define LOLUA_REGISTER_CLASS_LIBRARY(ClassType) luaopen_##ClassType(L);

#define LOLUA_REGISTER_STATIC(LuaFuncName, CppFuncName) lua_pushcfunction(L, CppFuncName); lua_setglobal(L, #LuaFuncName);

//-----------------------------------------------------------------------------
class LuaObject
{


Loading…
取消
儲存