mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Replaced most cases of type bits and type name strings in love's Lua wrapper code with type id's.
--HG-- branch : minor
This commit is contained in:
@@ -52,7 +52,7 @@ int w_newRasterizer(lua_State *L)
|
||||
[&]() { d->release(); }
|
||||
);
|
||||
|
||||
luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
|
||||
luax_pushtype(L, FONT_RASTERIZER_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ int w_newTrueTypeRasterizer(lua_State *L)
|
||||
{
|
||||
love::Data *d = nullptr;
|
||||
|
||||
if (luax_istype(L, 1, DATA_T))
|
||||
if (luax_istype(L, 1, DATA_ID))
|
||||
d = luax_checkdata(L, 1);
|
||||
else
|
||||
d = filesystem::luax_getfiledata(L, 1);
|
||||
@@ -95,14 +95,14 @@ int w_newTrueTypeRasterizer(lua_State *L)
|
||||
);
|
||||
}
|
||||
|
||||
luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
|
||||
luax_pushtype(L, FONT_RASTERIZER_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void convimagedata(lua_State *L, int idx)
|
||||
{
|
||||
if (lua_isstring(L, idx) || luax_istype(L, idx, FILESYSTEM_FILE_T) || luax_istype(L, idx, FILESYSTEM_FILE_DATA_T))
|
||||
if (lua_isstring(L, idx) || luax_istype(L, idx, FILESYSTEM_FILE_ID) || luax_istype(L, idx, FILESYSTEM_FILE_DATA_ID))
|
||||
luax_convobj(L, idx, "image", "newImageData");
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ int w_newBMFontRasterizer(lua_State *L)
|
||||
lua_rawgeti(L, 2, i);
|
||||
|
||||
convimagedata(L, -1);
|
||||
image::ImageData *id = luax_checktype<image::ImageData>(L, -1, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
image::ImageData *id = luax_checktype<image::ImageData>(L, -1, IMAGE_IMAGE_DATA_ID);
|
||||
images.push_back(id);
|
||||
id->retain();
|
||||
|
||||
@@ -132,7 +132,7 @@ int w_newBMFontRasterizer(lua_State *L)
|
||||
for (int i = 2; i <= lua_gettop(L); i++)
|
||||
{
|
||||
convimagedata(L, i);
|
||||
image::ImageData *id = luax_checktype<image::ImageData>(L, i, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
image::ImageData *id = luax_checktype<image::ImageData>(L, i, IMAGE_IMAGE_DATA_ID);
|
||||
images.push_back(id);
|
||||
id->retain();
|
||||
}
|
||||
@@ -143,7 +143,7 @@ int w_newBMFontRasterizer(lua_State *L)
|
||||
[&]() { d->release(); for (auto id : images) id->release(); }
|
||||
);
|
||||
|
||||
luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
|
||||
luax_pushtype(L, FONT_RASTERIZER_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -154,12 +154,12 @@ int w_newImageRasterizer(lua_State *L)
|
||||
|
||||
convimagedata(L, 1);
|
||||
|
||||
image::ImageData *d = luax_checktype<image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
image::ImageData *d = luax_checktype<image::ImageData>(L, 1, IMAGE_IMAGE_DATA_ID);
|
||||
std::string glyphs = luax_checkstring(L, 2);
|
||||
|
||||
luax_catchexcept(L, [&](){ t = instance()->newImageRasterizer(d, glyphs); });
|
||||
|
||||
luax_pushtype(L, "Rasterizer", FONT_RASTERIZER_T, t);
|
||||
luax_pushtype(L, FONT_RASTERIZER_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ int w_newGlyphData(lua_State *L)
|
||||
t = instance()->newGlyphData(r, g);
|
||||
}
|
||||
|
||||
luax_pushtype(L, "GlyphData", FONT_GLYPH_DATA_T, t);
|
||||
luax_pushtype(L, FONT_GLYPH_DATA_ID, t);
|
||||
t->release();
|
||||
return 1;
|
||||
}
|
||||
@@ -217,7 +217,7 @@ extern "C" int luaopen_love_font(lua_State *L)
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "font";
|
||||
w.flags = MODULE_T;
|
||||
w.type = MODULE_ID;
|
||||
w.functions = functions;
|
||||
w.types = types;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user