Skip to content

Commit 0292879

Browse files
committed
style: clarify relative offset correction
1 parent 2863282 commit 0292879

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/binding-factory.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ const luaBindings: Record<string, luaBindingFactoryFunc> = {
3030
lua_getfield: function(L: LuaState, index: number, k: string) {
3131
(this as Lua).lua_pushstring(L, k);
3232

33-
// If the index is a relative offset, it needs to be corrected for the grown stack
34-
const isOffset = index < 0 && index !== LUA_GLOBALSINDEX_50;
33+
// Relative offsets must move if the stack pointer moves
34+
const isRelativeOffset = index < 0 && index !== LUA_GLOBALSINDEX_50;
3535

36-
return (this as Lua).lua_gettable(L, isOffset ? index - 1 : index);
36+
return (this as Lua).lua_gettable(L, isRelativeOffset ? index - 1 : index);
3737
},
3838
lua_setfield: function(L: LuaState, index: number, k: string) {
3939
// The value to set is expected to be on the top of the stack
@@ -44,10 +44,10 @@ const luaBindings: Record<string, luaBindingFactoryFunc> = {
4444
// Swap key and value because settable expects stack in that order
4545
(this as Lua).lua_insert(L, -2);
4646

47-
// If the index is a relative offset, it needs to be corrected for the grown stack
48-
const isOffset = index < 0 && index !== LUA_GLOBALSINDEX_50;
47+
// Relative offsets must move if the stack pointer moves
48+
const isRelativeOffset = index < 0 && index !== LUA_GLOBALSINDEX_50;
4949

50-
const result = (this as Lua).lua_settable(L, isOffset ? index - 1 : index);
50+
const result = (this as Lua).lua_settable(L, isRelativeOffset ? index - 1 : index);
5151

5252
return result;
5353
},

0 commit comments

Comments
 (0)