mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 12:54:27 +00:00
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
This commit is contained in:
parent
061b68a760
commit
9b16231032
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue