diff --git a/src/common/runtime.cpp b/src/common/runtime.cpp index e3415e1cc..180aade43 100644 --- a/src/common/runtime.cpp +++ b/src/common/runtime.cpp @@ -623,7 +623,7 @@ int luax_convobj(lua_State *L, int idx, const char *mod, const char *fn) return 0; } -int luax_convobj(lua_State *L, int idxs[], int n, const char *mod, const char *fn) +int luax_convobj(lua_State *L, const int idxs[], int n, const char *mod, const char *fn) { luax_getfunction(L, mod, fn); for (int i = 0; i < n; i++) @@ -638,6 +638,12 @@ int luax_convobj(lua_State *L, int idxs[], int n, const char *mod, const char *f return 0; } +int luax_convobj(lua_State *L, const std::vector& idxs, const char *module, const char *function) +{ + const int *idxPtr = idxs.size() > 0 ? &idxs[0] : nullptr; + return luax_convobj(L, idxPtr, (int) idxs.size(), module, function); +} + int luax_pconvobj(lua_State *L, int idx, const char *mod, const char *fn) { // Convert string to a file. @@ -649,7 +655,7 @@ int luax_pconvobj(lua_State *L, int idx, const char *mod, const char *fn) return ret; } -int luax_pconvobj(lua_State *L, int idxs[], int n, const char *mod, const char *fn) +int luax_pconvobj(lua_State *L, const int idxs[], int n, const char *mod, const char *fn) { luax_getfunction(L, mod, fn); for (int i = 0; i < n; i++) @@ -662,6 +668,12 @@ int luax_pconvobj(lua_State *L, int idxs[], int n, const char *mod, const char * return ret; } +int luax_pconvobj(lua_State *L, const std::vector& idxs, const char *module, const char *function) +{ + const int *idxPtr = idxs.size() > 0 ? &idxs[0] : nullptr; + return luax_pconvobj(L, idxPtr, (int) idxs.size(), module, function); +} + int luax_insist(lua_State *L, int idx, const char *k) { // Convert to absolute index if necessary. diff --git a/src/common/runtime.h b/src/common/runtime.h index 90cacbb99..0e6e2de63 100644 --- a/src/common/runtime.h +++ b/src/common/runtime.h @@ -389,11 +389,13 @@ int luax_convobj(lua_State *L, int idx, const char *module, const char *function * @param module The module in the love table. * @param function The function in the module. **/ -int luax_convobj(lua_State *L, int idxs[], int n, const char *module, const char *function); +int luax_convobj(lua_State *L, const int idxs[], int n, const char *module, const char *function); +int luax_convobj(lua_State *L, const std::vector& idxs, const char *module, const char *function); // pcall versions of the above int luax_pconvobj(lua_State *L, int idx, const char *module, const char *function); -int luax_pconvobj(lua_State *L, int idxs[], int n, const char *module, const char *function); +int luax_pconvobj(lua_State *L, const int idxs[], int n, const char *module, const char *function); +int luax_pconvobj(lua_State *L, const std::vector& idxs, const char *module, const char *function); /** * 'Insist' that a table 'k' exists in the table at idx. Insistence involves that the diff --git a/src/modules/graphics/wrap_Graphics.cpp b/src/modules/graphics/wrap_Graphics.cpp index 4f5f78283..08af41121 100644 --- a/src/modules/graphics/wrap_Graphics.cpp +++ b/src/modules/graphics/wrap_Graphics.cpp @@ -1091,7 +1091,7 @@ int w_newFont(lua_State *L) for (int i = 0; i < lua_gettop(L); i++) idxs.push_back(i + 1); - luax_convobj(L, &idxs[0], (int) idxs.size(), "font", "newRasterizer"); + luax_convobj(L, idxs, "font", "newRasterizer"); } love::font::Rasterizer *rasterizer = luax_checktype(L, 1); @@ -1122,7 +1122,7 @@ int w_newImageFont(lua_State *L) for (int i = 0; i < lua_gettop(L); i++) idxs.push_back(i + 1); - luax_convobj(L, &idxs[0], (int) idxs.size(), "font", "newImageRasterizer"); + luax_convobj(L, idxs, "font", "newImageRasterizer"); } love::font::Rasterizer *rasterizer = luax_checktype(L, 1);