diff --git a/src/common/deprecation.cpp b/src/common/deprecation.cpp index 5c7fa28c1..0dca9d0e1 100644 --- a/src/common/deprecation.cpp +++ b/src/common/deprecation.cpp @@ -114,8 +114,6 @@ std::string getDeprecationNotice(const DeprecationInfo &info, bool usewhere) notice += "field "; else if (info.apiType == API_CONSTANT) notice += "constant "; - else - notice += "API "; notice += info.name; @@ -193,6 +191,7 @@ STRINGMAP_BEGIN(APIType, API_MAX_ENUM, apiType) { "callback", API_CALLBACK }, { "field", API_FIELD }, { "constant", API_CONSTANT }, + { "custom", API_CUSTOM }, } STRINGMAP_END(APIType, API_MAX_ENUM, apiType) diff --git a/src/common/deprecation.h b/src/common/deprecation.h index 33c2eac11..9678c778d 100644 --- a/src/common/deprecation.h +++ b/src/common/deprecation.h @@ -36,6 +36,7 @@ enum APIType API_CALLBACK, API_FIELD, API_CONSTANT, + API_CUSTOM, API_MAX_ENUM }; diff --git a/src/modules/graphics/wrap_Graphics.cpp b/src/modules/graphics/wrap_Graphics.cpp index b5b1462a3..07526e9a5 100644 --- a/src/modules/graphics/wrap_Graphics.cpp +++ b/src/modules/graphics/wrap_Graphics.cpp @@ -1538,6 +1538,44 @@ static void luax_optbuffersettings(lua_State *L, int idx, Buffer::Settings &sett lua_pop(L, 1); } +static Buffer::DataDeclaration luax_checkdatadeclaration(lua_State* L, int formattableidx, int arrayindex, int declindex, bool requirename) +{ + Buffer::DataDeclaration decl("", DATAFORMAT_MAX_ENUM); + + lua_getfield(L, declindex, "name"); + if (requirename && lua_type(L, -1) != LUA_TSTRING) + { + std::ostringstream ss; + ss << "'name' field expected in array element #"; + ss << arrayindex; + ss << " of format table"; + std::string str = ss.str(); + luaL_argerror(L, formattableidx, str.c_str()); + } + else if (!lua_isnoneornil(L, -1)) + decl.name = luax_checkstring(L, -1); + lua_pop(L, 1); + + lua_getfield(L, declindex, "format"); + if (lua_type(L, -1) != LUA_TSTRING) + { + std::ostringstream ss; + ss << "'format' field expected in array element #"; + ss << arrayindex; + ss << " of format table"; + std::string str = ss.str(); + luaL_argerror(L, formattableidx, str.c_str()); + } + const char* formatstr = luaL_checkstring(L, -1); + if (!getConstant(formatstr, decl.format)) + luax_enumerror(L, "data format", getConstants(decl.format), formatstr); + lua_pop(L, 1); + + decl.arrayLength = luax_intflag(L, declindex, "arraylength", 0); + + return decl; +} + static void luax_checkbufferformat(lua_State *L, int idx, std::vector &format) { if (lua_type(L, idx) == LUA_TSTRING) @@ -1558,29 +1596,7 @@ static void luax_checkbufferformat(lua_State *L, int idx, std::vector