From a16ce94158c9cf22a19c0e73dfe2e992a8302af1 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 8 Dec 2018 22:05:31 +0800 Subject: =?UTF-8?q?*=E5=8E=BB=E9=99=A4shared=20template?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua/modules/graphics/je_lua_bitmap.cpp | 35 ++++++++++++++---------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'src/lua/modules/graphics/je_lua_bitmap.cpp') diff --git a/src/lua/modules/graphics/je_lua_bitmap.cpp b/src/lua/modules/graphics/je_lua_bitmap.cpp index 8d8b76e..cd0bb18 100644 --- a/src/lua/modules/graphics/je_lua_bitmap.cpp +++ b/src/lua/modules/graphics/je_lua_bitmap.cpp @@ -13,12 +13,10 @@ namespace JinEngine const char* Jin_Lua_Bitmap = "Bitmap"; - typedef Shared& SharedBitmap; - - LUA_IMPLEMENT inline SharedBitmap checkBitmap(lua_State* L) + LUA_IMPLEMENT inline Bitmap* checkBitmap(lua_State* L) { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Bitmap); - return luaObj->getShared(); + LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Bitmap); + return luaObj->getObject(); } LUA_IMPLEMENT int l_gc(lua_State* L) @@ -30,25 +28,25 @@ namespace JinEngine LUA_IMPLEMENT int l_getWidth(lua_State* L) { - SharedBitmap shared = checkBitmap(L); - int w = shared->getWidth(); + Bitmap* bitmap = checkBitmap(L); + int w = bitmap->getWidth(); luax_pushinteger(L, w); return 1; } LUA_IMPLEMENT int l_getHeight(lua_State* L) { - SharedBitmap shared = checkBitmap(L); - int h = shared->getHeight(); + Bitmap* bitmap = checkBitmap(L); + int h = bitmap->getHeight(); luax_pushinteger(L, h); return 1; } LUA_IMPLEMENT int l_getSize(lua_State* L) { - SharedBitmap shared = checkBitmap(L); - int w = shared->getWidth(); - int h = shared->getHeight(); + Bitmap* bitmap = checkBitmap(L); + int w = bitmap->getWidth(); + int h = bitmap->getHeight(); luax_pushinteger(L, w); luax_pushinteger(L, h); return 2; @@ -56,10 +54,10 @@ namespace JinEngine LUA_IMPLEMENT int l_getPixel(lua_State* L) { - SharedBitmap shared = checkBitmap(L); + Bitmap* bitmap = checkBitmap(L); int x = luax_checkinteger(L, 2); int y = luax_checkinteger(L, 3); - Color col = shared->getPixel(x, y); + Color col = bitmap->getPixel(x, y); luax_pushinteger(L, col.r); luax_pushinteger(L, col.g); luax_pushinteger(L, col.b); @@ -69,7 +67,7 @@ namespace JinEngine LUA_IMPLEMENT int l_setPixel(lua_State* L) { - SharedBitmap shared = checkBitmap(L); + Bitmap* bitmap = checkBitmap(L); int x = luax_checkinteger(L, 2); int y = luax_checkinteger(L, 3); if (!luax_istable(L, 4)) @@ -81,16 +79,15 @@ namespace JinEngine unsigned int g = luax_rawgetnumber(L, 4, 2); unsigned int b = luax_rawgetnumber(L, 4, 3); unsigned int a = luax_rawgetnumber(L, 4, 4); - shared->setPixel(Color(r, g, b, a), x, y); + bitmap->setPixel(Color(r, g, b, a), x, y); return 0; } LUA_IMPLEMENT int l_clone(lua_State* L) { - SharedBitmap shared = checkBitmap(L); - Bitmap* bitmap = shared.getObject(); + Bitmap* bitmap = checkBitmap(L); Bitmap* b = bitmap->clone(); - LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared(b, Jin_Lua_Bitmap)); + LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared(b, Jin_Lua_Bitmap)); return 1; } -- cgit v1.1-26-g67d0