feat(lua): global wipe, the table.wipe alias

On a stock 1.12.1 client, ScrollBoxListView, ScrollUtil, Menu and the
DebugTools table inspector failed with "attempt to call global `wipe'":
those ports call bare wipe(), and only Turtle's client defines that
global. Stock 1.12.1 has only the table.wipe that ClassicAPI registers.

3.3.5 makes the alias in FrameScript's compat preamble, next to tinsert
and tremove (wipe = tab.wipe). 1.12's preamble is older than table.wipe,
so Wipe.cpp now registers the same C function as the global wipe as well
as table.wipe, with a LuaGlobals descriptor.

CallbackRegistry, MixinUtil and SecureTypes lose their "1.12 has no
global wipe" notes and their table.wipe locals, and now match retail.
This commit is contained in:
Brues
2026-10-31 16:44:34 -05:00
parent d1cdb47c3e
commit 090cfc3bfd
7 changed files with 23 additions and 16 deletions
+1 -1
View File
@@ -104,7 +104,7 @@ In the Frame rows, a name that starts with `:` is a method of the widget that th
| [Loot](docs/API.md#loot) | `C_Loot.GetNearbyLootableUnits`, `C_Loot.GetLastScanResults`, `C_Loot.IsScanInProgress`, `C_Loot.LootAllCorpses`, `C_Loot.LootUnit`, `C_Loot.LootUnitItem`, `C_Loot.ScanNearbyLoot` |
| [LootHistory](docs/API.md#loothistory) | `C_LootHistory.GetNumItems`, `C_LootHistory.GetItem`, `C_LootHistory.GetPlayerInfo`, `C_LootHistory.Clear` |
| [LossOfControl](docs/API.md#lossofcontrol) | `C_LossOfControl.GetActiveLossOfControlData`, `C_LossOfControl.GetActiveLossOfControlDataCount`, `C_LossOfControl.GetSchoolLockout` |
| [Lua](docs/API.md#lua) | `collectgarbage` (5.1 options), `coroutine.create`, `coroutine.resume`, `coroutine.running`, `coroutine.status`, `coroutine.wrap`, `coroutine.yield`, `CreateFromMixins`, `math.fmod`, `math.huge`, `math.modf`, `Mixin`, `select`, `strcmputf8i`, `strconcat`, `string.concat`, `string.gmatch`, `string.gsub` (table replacement), `string.join`, `string.match`, `string.reverse`, `string.split`, `string.trim`, `strjoin`, `strlenutf8`, `strmatch`, `strreplace`, `strrev`, `strsplit`, `strsplittable`, `strtrim`, `table.count`, `table.maxn`, `table.wipe`, `unpack` (range args), `xpcall` (argument forwarding) |
| [Lua](docs/API.md#lua) | `collectgarbage` (5.1 options), `coroutine.create`, `coroutine.resume`, `coroutine.running`, `coroutine.status`, `coroutine.wrap`, `coroutine.yield`, `CreateFromMixins`, `math.fmod`, `math.huge`, `math.modf`, `Mixin`, `select`, `strcmputf8i`, `strconcat`, `string.concat`, `string.gmatch`, `string.gsub` (table replacement), `string.join`, `string.match`, `string.reverse`, `string.split`, `string.trim`, `strjoin`, `strlenutf8`, `strmatch`, `strreplace`, `strrev`, `strsplit`, `strsplittable`, `strtrim`, `table.count`, `table.maxn`, `table.wipe`, `unpack` (range args), `wipe`, `xpcall` (argument forwarding) |
| [Macros](docs/API.md#macros) | `C_Macro.CreateMacro`, `C_Macro.EditMacro`, `C_Macro.SetMacroDisplay`, `DeleteMacro` / `EditMacro` / `GetMacroInfo` / `PickupMacro` by name, `GetLooseMacroIcons`, `GetLooseMacroItemIcons`, `GetMacroBody`, `GetMacroIcons`, `GetMacroItem`, `GetMacroItemIcons`, `GetMacroSpell`, `GetRunningMacro`, `GetRunningMacroButton`, `RunMacroText`, `SetMacroItem`, `SetMacroSpell`, `StopMacro` |
| [Mail](docs/API.md#mail) | `GetInboxItemLink`, `GetSendMailItemLink` |
| [Map](docs/API.md#map) | `C_Map.CanSetUserWaypointOnMap`, `C_Map.ClearUserWaypoint`, `C_Map.GetAreaInfo`, `C_Map.GetAreas`, `C_Map.GetAreaTriggerInfo`, `C_Map.GetAreaTriggers`, `C_Map.GetBestMapForUnit`, `C_Map.GetFallbackWorldMapID`, `C_Map.GetMapAreaIDs`, `C_Map.GetMapArtLayers`, `C_Map.GetMapArtLayerTextures`, `C_Map.GetMapChildrenInfo`, `C_Map.GetMapInfo`, `C_Map.GetMapInfoAtPosition`, `C_Map.GetMapOverlays`, `C_Map.GetMapPosFromWorldPos`, `C_Map.GetMapRectOnMap`, `C_Map.GetMapWorldSize`, `C_Map.GetPlayerMapPosition`, `C_Map.GetUserWaypoint`, `C_Map.GetUserWaypointFromHyperlink`, `C_Map.GetUserWaypointHyperlink`, `C_Map.GetUserWaypointPositionForMap`, `C_Map.GetWorldPosFromMapPos`, `C_Map.HasUserWaypoint`, `C_Map.MapHasArt`, `C_Map.SetUserWaypoint` |
+4 -3
View File
@@ -643,7 +643,7 @@ build instructions.
- [`unpack(list [, i [, j]])`](#unpacklist--i--j)
- [`xpcall(f, msgh [, arg1, ...])`](#xpcallf-msgh--arg1-)
- [`collectgarbage(opt [, arg])`](#collectgarbageopt--arg)
- [`table.wipe(t)`](#tablewipet)
- [`table.wipe(t)` / `wipe(t)`](#tablewipet--wipet)
- [`table.count(tbl)`](#tablecounttbl)
- [`table.maxn(t)`](#tablemaxnt)
- [Stale table lengths (5.1 healing)](#stale-table-lengths-51-healing)
@@ -15057,10 +15057,11 @@ optional numeric threshold and errored on every string option
- A number (or no argument) keeps the stock threshold behavior
unchanged.
### `table.wipe(t)`
### `table.wipe(t)` / `wipe(t)`
Removes every key from `t`, leaving it empty but preserving its
internal hash and array capacity. Returns `t` for chaining.
internal hash and array capacity. Returns `t` for chaining. `wipe` is
the same function as a global.
```lua
local cache = {}
+2 -3
View File
@@ -32,9 +32,8 @@ namespace {
// that are not base-library functions at all. So do not derive this from
// the engine's `luaopen_base` table (`0x00811E28`, 36 entries — see
// BlizzardScriptAPI.md §3); that is a different set with a different
// purpose. Names with no 1.12 counterpart (`wipe` is `table.wipe` here; the
// secure family does not exist) stay for parity of the error an addon
// sees. Sorted alphabetically.
// purpose. Names with no 1.12 counterpart (the secure family does not
// exist) stay for parity of the error an addon sees. Sorted alphabetically.
const char *const kUnhookableNames[] = {
"getfenv", "getmetatable", "hooksecurefunc", "ipairs", "issecurevalue",
"issecurevariable", "next", "pairs", "pcall", "pcallwithenv", "rawget",
@@ -10,7 +10,6 @@
-- (an error goes to the error handler and the other callbacks still run),
-- but every call to a vararg function builds an `arg` table in Lua 5.0,
-- which would cost a table per callback per event.
-- - 1.12 has no global wipe, so UnregisterEvents uses table.wipe.
local secureexecuterange = secureexecuterange;
local securecallfunction = securecallfunction;
@@ -19,7 +18,6 @@ local error = error;
local pairs = pairs;
local rawset = rawset;
local next = next;
local wipe = table.wipe;
local GetOrCreateTableEntry = GetOrCreateTableEntry;
local CallbackType = EnumUtil.MakeEnum("Closure", "Function");
@@ -1,9 +1,4 @@
-- Backport of retail's Blizzard_SharedXML/MixinUtil.lua.
--
-- Implementation differences from the retail source:
-- - wipe is table.wipe here.
local wipe = table.wipe;
-- The following function is used with permission from Daniel Stephens
-- texture - Texture
@@ -4,7 +4,6 @@
-- - 1.12 has no secret values, so the issecretvalue asserts are dropped.
-- - Lua 5.0 has no `...` as an expression and no `#` operator; varargs
-- forward through unpack(arg) and lengths come from table.getn.
-- - wipe is table.wipe here.
local assert = assert;
local ContainsIf = ContainsIf;
@@ -23,7 +22,7 @@ local tCount = table.count;
local tDeleteItem = tDeleteItem;
local tinsert = table.insert;
local tremove = table.remove;
local wipe = table.wipe;
local wipe = wipe;
-- Secure types are expected to be used by Blizzard code to prevent taint propagation
-- while accessing values, particularly in cases where container types are used that can have
+15
View File
@@ -72,8 +72,23 @@ static int __fastcall Script_table_wipe(void *L) {
return 1;
}
// --- Documentation ----------------------------------------------------------
const Game::Doc::Field kWipeArgs[] = {
Game::Doc::Req("tbl", "table"),
};
const Game::Doc::Field kWipeRets[] = {
Game::Doc::Req("tbl", "table", "The same table, now empty."),
};
const Game::Doc::Function kWipe{"Removes every key from a table.", kWipeArgs, kWipeRets,
"LuaGlobals"};
// `wipe` is the global alias 3.3.5's FrameScript compat preamble sets next
// to `tinsert` / `tremove` (`wipe = tab.wipe`). 1.12's preamble predates
// table.wipe, so the alias is registered here; retail FrameXML calls it.
static void RegisterLuaFunctions() {
Game::Lua::RegisterTableFunction("table", "wipe", &Script_table_wipe);
Game::Lua::RegisterGlobalFunction("wipe", &Script_table_wipe, &kWipe);
}
static const Game::ModuleAutoRegister _autoreg{&RegisterLuaFunctions};