Expose love.markDeprecated.

Arguments are (level, name, apitype, deprecationtype [, replacementname]). Call it inside a function.
This commit is contained in:
Alex Szpakowski
2021-06-06 18:16:56 -03:00
parent 199632e791
commit 5ef1709c02
7 changed files with 66 additions and 13 deletions
+6 -6
View File
@@ -1195,25 +1195,25 @@ int w_newVolumeTexture(lua_State *L)
int w_newImage(lua_State *L)
{
//luax_markdeprecated(L, "love.graphics.newImage", API_FUNCTION, DEPRECATED_RENAMED, "love.graphics.newTexture");
//luax_markdeprecated(L, 1, "love.graphics.newImage", API_FUNCTION, DEPRECATED_RENAMED, "love.graphics.newTexture");
return w_newTexture(L);
}
int w_newCubeImage(lua_State *L)
{
//luax_markdeprecated(L, "love.graphics.newCubeImage", API_FUNCTION, DEPRECATED_RENAMED, "love.graphics.newCubeTexture");
//luax_markdeprecated(L, 1, "love.graphics.newCubeImage", API_FUNCTION, DEPRECATED_RENAMED, "love.graphics.newCubeTexture");
return w_newCubeTexture(L);
}
int w_newArrayImage(lua_State *L)
{
//luax_markdeprecated(L, "love.graphics.newArrayImage", API_FUNCTION, DEPRECATED_RENAMED, "love.graphics.newArrayTexture");
//luax_markdeprecated(L, 1, "love.graphics.newArrayImage", API_FUNCTION, DEPRECATED_RENAMED, "love.graphics.newArrayTexture");
return w_newArrayTexture(L);
}
int w_newVolumeImage(lua_State *L)
{
//luax_markdeprecated(L, "love.graphics.newVolumeImage", API_FUNCTION, DEPRECATED_RENAMED, "love.graphics.newVolumeTexture");
//luax_markdeprecated(L, 1, "love.graphics.newVolumeImage", API_FUNCTION, DEPRECATED_RENAMED, "love.graphics.newVolumeTexture");
return w_newVolumeTexture(L);
}
@@ -2644,7 +2644,7 @@ static int w__getFormats(lua_State *L, int idx, bool (*isFormatSupported)(PixelF
int w_getCanvasFormats(lua_State *L)
{
luax_markdeprecated(L, "love.graphics.getCanvasFormats", API_FUNCTION, DEPRECATED_REPLACED, "love.graphics.getTextureFormats");
luax_markdeprecated(L, 1, "love.graphics.getCanvasFormats", API_FUNCTION, DEPRECATED_REPLACED, "love.graphics.getTextureFormats");
bool (*supported)(PixelFormat);
@@ -2681,7 +2681,7 @@ int w_getCanvasFormats(lua_State *L)
int w_getImageFormats(lua_State *L)
{
luax_markdeprecated(L, "love.graphics.getImageFormats", API_FUNCTION, DEPRECATED_REPLACED, "love.graphics.getTextureFormats");
luax_markdeprecated(L, 1, "love.graphics.getImageFormats", API_FUNCTION, DEPRECATED_REPLACED, "love.graphics.getTextureFormats");
const auto supported = [](PixelFormat format) -> bool
{
+26
View File
@@ -352,6 +352,29 @@ static int w__requestRecordingPermission(lua_State *L)
return 0;
}
static int w_love_markDeprecated(lua_State *L)
{
int level = (int)luaL_checkinteger(L, 1);
const char *name = luaL_checkstring(L, 2);
const char *apiname = luaL_checkstring(L, 3);
const char *deprecationtname = luaL_checkstring(L, 4);
love::APIType api;
if (!love::getConstant(apiname, api))
return love::luax_enumerror(L, "API type", love::getConstants(api), apiname);
love::DeprecationType dtype;
if (!love::getConstant(deprecationtname, dtype))
return love::luax_enumerror(L, "deprecation type", love::getConstants(dtype), deprecationtname);
const char *replacement = nullptr;
if (dtype != love::DEPRECATED_NO_REPLACEMENT)
replacement = luaL_checkstring(L, 5);
love::luax_markdeprecated(L, level, name, api, dtype, replacement);
return 0;
}
static int w_love_setDeprecationOutput(lua_State *L)
{
bool enable = love::luax_checkboolean(L, 1);
@@ -482,6 +505,9 @@ int luaopen_love(lua_State *L)
lua_setfield(L, -2, "_deprecation");
lua_pushcfunction(L, w_love_markDeprecated);
lua_setfield(L, -2, "markDeprecated");
lua_pushcfunction(L, w_love_setDeprecationOutput);
lua_setfield(L, -2, "setDeprecationOutput");
+1 -1
View File
@@ -80,7 +80,7 @@ static int readWindowSettings(lua_State *L, int idx, WindowSettings &settings)
lua_getfield(L, idx, settingName(Window::SETTING_HIGHDPI));
if (!lua_isnoneornil(L, -1))
{
luax_markdeprecated(L, "window.highdpi", API_FIELD, DEPRECATED_REPLACED, "t.highdpi in love.conf");
luax_markdeprecated(L, 1, "window.highdpi", API_FIELD, DEPRECATED_REPLACED, "t.highdpi in love.conf");
bool highdpi = luax_checkboolean(L, -1);
if (!instance()->isOpen())
setHighDPIAllowed(highdpi);