From 73d19cc02ab775523dea3f1210c8262f95794e51 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 25 Sep 2022 17:21:26 -0700 Subject: [PATCH] Scripting: Add reference to the top-level engine in engine contexts --- include/mgba/script/context.h | 2 ++ src/script/engines/lua.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/mgba/script/context.h b/include/mgba/script/context.h index 10d4fa757..7c8543cc5 100644 --- a/include/mgba/script/context.h +++ b/include/mgba/script/context.h @@ -49,6 +49,8 @@ struct mScriptEngine2 { struct mScriptEngineContext { struct mScriptContext* context; + struct mScriptEngine2* engine; + void (*destroy)(struct mScriptEngineContext*); bool (*isScript)(struct mScriptEngineContext*, const char* name, struct VFile* vf); diff --git a/src/script/engines/lua.c b/src/script/engines/lua.c index 66a8b0eff..2a72172e9 100644 --- a/src/script/engines/lua.c +++ b/src/script/engines/lua.c @@ -288,10 +288,10 @@ static const luaL_Reg _mSTList[] = { }; struct mScriptEngineContext* _luaCreate(struct mScriptEngine2* engine, struct mScriptContext* context) { - UNUSED(engine); struct mScriptEngineContextLua* luaContext = calloc(1, sizeof(*luaContext)); luaContext->d = (struct mScriptEngineContext) { .context = context, + .engine = engine, .destroy = _luaDestroy, .isScript = _luaIsScript, .getGlobal = _luaGetGlobal,