diff --git a/src/app/script/image_class.cpp b/src/app/script/image_class.cpp index f240d2748..eaa29e7f0 100644 --- a/src/app/script/image_class.cpp +++ b/src/app/script/image_class.cpp @@ -30,10 +30,6 @@ struct ImageObj { : image(image) , cel(cel) { } - ImageObj(ImageObj&& that) { - std::swap(image, that.image); - std::swap(cel, that.cel); - } ImageObj(const ImageObj&) = delete; ImageObj& operator=(const ImageObj&) = delete; }; @@ -45,7 +41,7 @@ int Image_new(lua_State* L) const int colorMode = (lua_isnone(L, 3) ? doc::IMAGE_RGB: lua_tointeger(L, 3)); doc::ImageRef image(doc::Image::create((doc::PixelFormat)colorMode, w, h)); - push_obj(L, ImageObj(image, nullptr)); + push_new(L, image, nullptr); return 1; } @@ -53,7 +49,7 @@ int Image_clone(lua_State* L) { auto obj = get_obj(L, 1); doc::ImageRef cloned(doc::Image::createCopy(obj->image.get())); - push_obj(L, ImageObj(cloned, nullptr)); + push_new(L, cloned, nullptr); return 1; } @@ -169,7 +165,7 @@ void register_image_class(lua_State* L) void push_cel_image(lua_State* L, doc::Cel* cel) { - push_obj(L, ImageObj(cel->imageRef(), cel)); + push_new(L, cel->imageRef(), cel); } } // namespace script diff --git a/src/app/script/luacpp.h b/src/app/script/luacpp.h index d9ef9fd6b..f5dff0bf9 100644 --- a/src/app/script/luacpp.h +++ b/src/app/script/luacpp.h @@ -43,13 +43,6 @@ template void push_obj(lua_State* L, const T& obj) { lua_setmetatable(L, -2); } -template void push_obj(lua_State* L, T&& obj) { - using RRT = typename std::remove_reference::type; - new (lua_newuserdata(L, sizeof(RRT))) RRT(std::move(obj)); - luaL_getmetatable(L, get_mtname()); - lua_setmetatable(L, -2); -} - template T* push_ptr(lua_State* L, T* ptr) { *(T**)lua_newuserdata(L, sizeof(T*)) = ptr; luaL_getmetatable(L, get_mtname()); diff --git a/src/app/script/selection_class.cpp b/src/app/script/selection_class.cpp index 4a4ff0f51..1126426e2 100644 --- a/src/app/script/selection_class.cpp +++ b/src/app/script/selection_class.cpp @@ -31,12 +31,6 @@ struct SelectionObj { : mask(mask) , sprite(sprite) { } - SelectionObj(SelectionObj&& that) - : mask(that.mask) - , sprite(that.sprite) { - that.mask = nullptr; - that.sprite = nullptr; - } ~SelectionObj() { if (!sprite && mask) delete mask; @@ -47,7 +41,7 @@ struct SelectionObj { int Selection_new(lua_State* L) { - push_obj(L, SelectionObj(new Mask, nullptr)); + push_new(L, new Mask, nullptr); return 1; } @@ -182,7 +176,7 @@ void register_selection_class(lua_State* L) void push_sprite_selection(lua_State* L, Sprite* sprite) { - push_obj(L, SelectionObj(nullptr, sprite)); + push_new(L, nullptr, sprite); } } // namespace script