lugre_bitmask_L.cpp
Go to the documentation of this file.00001 #include "lugre_prefix.h"
00002 #include "lugre_bitmask.h"
00003 #include "lugre_luabind.h"
00004
00005 extern "C" {
00006 #include "lua.h"
00007 #include "lauxlib.h"
00008 #include "lualib.h"
00009 }
00010
00011 namespace Lugre {
00012
00013 class cBitMask_L : public cLuaBind<cBitMask> { public:
00014
00015
00017 virtual void RegisterMethods (lua_State *L) { PROFILE
00018 #define REGISTER_METHOD(methodname) mlMethod.push_back(make_luaL_reg(#methodname,&cBitMask_L::methodname));
00019
00020 REGISTER_METHOD(Destroy);
00021 REGISTER_METHOD(GetSize);
00022 REGISTER_METHOD(GetWrap);
00023 REGISTER_METHOD(SetWrap);
00024 REGISTER_METHOD(TestBit);
00025 }
00026
00027
00028
00030 static int Destroy (lua_State *L) { PROFILE
00031 delete checkudata_alive(L);
00032 return 0;
00033 }
00034
00036 static int GetSize (lua_State *L) { PROFILE
00037 cBitMask* mybitmask = checkudata_alive(L);
00038 lua_pushnumber(L,mybitmask->miW);
00039 lua_pushnumber(L,mybitmask->miH);
00040 return 2;
00041 }
00042
00044 static int GetWrap (lua_State *L) { PROFILE
00045 lua_pushboolean(L,checkudata_alive(L)->GetWrap());
00046 return 1;
00047 }
00048
00050 static int SetWrap (lua_State *L) { PROFILE
00051 bool bWrap = (lua_gettop(L) >= 2 && !lua_isnil(L,2)) ? lua_toboolean(L,2) : false;
00052 checkudata_alive(L)->SetWrap(bWrap);
00053 return 0;
00054 }
00055
00057 static int TestBit (lua_State *L) { PROFILE
00058 lua_pushboolean(L,checkudata_alive(L)->TestBit(luaL_checkint(L,2),luaL_checkint(L,3)));
00059 return 1;
00060 }
00061
00062 virtual const char* GetLuaTypeName () { return "lugre.bitmask"; }
00063 };
00064
00065
00067 void cBitMask::LuaRegister (lua_State *L) { PROFILE
00068 cLuaBind<cBitMask>::GetSingletonPtr(new cBitMask_L())->LuaRegister(L);
00069 }
00070
00071 };