git: 9b16231032dd - main - loader: Create new gfx table
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 16 Feb 2024 04:00:24 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=9b16231032ddb40be282d76ec0d82b3a0ec96d60 commit 9b16231032ddb40be282d76ec0d82b3a0ec96d60 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2024-02-16 03:53:07 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-02-16 03:59:22 +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 --- 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");