Date: Tue, 16 Apr 2024 20:12:45 GMT From: Warner Losh <imp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 73fac51c5726 - stable/14 - loader: Create new gfx table Message-ID: <202404162012.43GKCjb3037789@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=73fac51c572655a3d0e55af410f42dc15713ef31 commit 73fac51c572655a3d0e55af410f42dc15713ef31 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2024-02-16 03:53:07 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-04-16 19:54:23 +0000 loader: Create new gfx table Create a new gfx global table. Put into it all the graphics bindings that we have in loader today. For now, have compatability binding for loader. Remove them from loader. Sponsored by: Netflix Reviewed by: kevans, jhb Differential Revision: https://reviews.freebsd.org/D43902 (cherry picked from commit 9b16231032ddb40be282d76ec0d82b3a0ec96d60) --- stand/common/interp_lua.c | 27 +++++++++++++++++++++++++++ stand/liblua/lutils.c | 1 - 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/stand/common/interp_lua.c b/stand/common/interp_lua.c index 3f758baebc2d..a347526b67c9 100644 --- a/stand/common/interp_lua.c +++ b/stand/common/interp_lua.c @@ -97,6 +97,31 @@ static const luaL_Reg loadedlibs[] = { {NULL, NULL} }; +static void +interp_init_md(lua_State *L) +{ + luaL_requiref(L, "gfx", luaopen_gfx, 1); + lua_pop(L, 1); /* Remove lib */ + + /* + * Add in the comparability references in the loader table. Doing it with + * a pseudo-embedded script is easier than the raw calls. + */ + if (luaL_dostring(L, + "loader.fb_bezier = gfx.fb_bezier\n" + "loader.fb_drawrect = gfx.fb_drawrect\n" + "loader.fb_line = gfx.fb_line\n" + "loader.fb_putimage = gfx.fb_putimage\n" + "loader.fb_setpixel = gfx.fb_setpixel\n" + "loader.term_drawrect = gfx.term_drawrect\n" + "loader.term_putimage = gfx.term_putimage") != 0) { + lua_pop(L, 1); + const char *errstr = lua_tostring(L, -1); + errstr = errstr == NULL ? "unknown" : errstr; + printf("Error adding compat loader bindings: %s.\n", errstr); + } +} + void interp_init(void) { @@ -123,6 +148,8 @@ interp_init(void) lua_pop(luap, 1); /* remove lib */ } + interp_init_md(luap); + filename = getenv("loader_lua"); if (filename == NULL) filename = LOADER_LUA; diff --git a/stand/liblua/lutils.c b/stand/liblua/lutils.c index 20876f965f0c..0be9f5f28ac3 100644 --- a/stand/liblua/lutils.c +++ b/stand/liblua/lutils.c @@ -439,7 +439,6 @@ int luaopen_loader(lua_State *L) { luaL_newlib(L, loaderlib); - luaopen_gfx(L); /* Add loader.machine and loader.machine_arch properties */ lua_pushstring(L, MACHINE); lua_setfield(L, -2, "machine");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202404162012.43GKCjb3037789>