Comments in benilla-ui: one line of fact each, no history, no record numbers (#143)
Part of #41: the comments of `benilla-ui` (the Lua UI engine, its FrameXML loader and its widgets) are rewritten to the rule in `docs/METHOD.md`, which is what the code does and the reference fact behind it, in a line. 43,140 comment lines become 15,161. - **The mechanical strip.** The citations that were only a private record number go first, and each edit is shown to be a pure removal. - **Wrong facts corrected.** The rewrite corrects the comments that stated wrong facts. Among them: - `0x64a480` is the case-sensitive compare (a byte `repz cmpsb`), and `0x64a4c0` the case-insensitive one. - A frame's id sits at `+0xb0`, not `+0xb4`. `EnableKeyboard`/`IsKeyboardEnabled` are `0x776ec0`/`0x776f90`. - A region's unpinned edge has no fallback to its owner's rect: the owner supplies only the scale. - `$parent` expands to the nearest named ancestor, or "Top" when none is named (`0x76c5b0`), not simply to the parent. - A StatusBar fills from its internal normalised fraction, not from `GetValue()`. - The addresses of `StartDuel` and `StartDuelUnit` were swapped. - Many "untraced" notes now give the traced reference fact: the drag threshold, the per-grip sizing edges, the empty-`autoFocus` skip, and `SetTexCoordModifiesRect`'s default. - Stock FrameXML line citations are checked against the stock 1.12 files and corrected. `ref-` file names become the stock file names. - **Deviation labels.** "Deviation:" now marks only a choice with a reason. A surface that exists only for the retired Era addon target says so plainly: it is not 1.12. - **Verification.** Every file strips to identical code, and `cargo fmt --check` is clean. Nine second readers compared every file old against new, restored the facts the rewrite had dropped, and checked each new citation against the code, the stock files, vmangos and the reference. Behaviour differences the rewrite surfaced are filed as their own issues (#131–#142), and more are being validated. The comments here state what the code does. String literals are untouched; they are #92. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8505187668
commit
fd386e75ae
@@ -1,27 +1,21 @@
|
||||
//! The chat slash handlers' engine verbs that are not sends, channels, or window state —
|
||||
//! `DoEmote`, `RandomRoll`, `AssistByName`, `UninviteByName`, `ConsoleExec`, `LoggingChat`,
|
||||
//! `LoggingCombat`. Each is what a stock `ChatFrame.lua` built-in handler calls once it has
|
||||
//! parsed the line (`SlashCmdList` walk, decision 1195); the app used to parse these lines
|
||||
//! itself (`ui_chat/input/parse.rs`) and now drains what the reference's own Lua decided.
|
||||
//!
|
||||
//! Every verb is a queue or a flag — the engine-free seam (0068 §3): the VM never sees the wire,
|
||||
//! the app drains and sends. Registrar addresses:
|
||||
//! `0x49fd30 DoEmote`, `0x48c7b0 RandomRoll`, `0x489c40 AssistByName`, `0x48a610 UninviteByName`.
|
||||
//! The engine verbs stock `ChatFrame.lua`'s slash handlers call that are not sends, channels or
|
||||
//! window state: `DoEmote` (`0x49fd30`), `RandomRoll` (`0x48c7b0`), `AssistByName` (`0x489c40`),
|
||||
//! `UninviteByName` (`0x48a610`), `ConsoleExec`, `LoggingChat` and `LoggingCombat`. Each is a
|
||||
//! queue or a flag the app drains.
|
||||
|
||||
use mlua::{Lua, MultiValue, Value};
|
||||
|
||||
use super::Model;
|
||||
|
||||
/// `DoEmote(token [, target])` — the `EmotesText.dbc` **name token** (`"WAVE"`, not `/wave`) and
|
||||
/// the optional target name the handler split off the line.
|
||||
/// `DoEmote(token [, target])`: the `EmotesText.dbc` name token (`"WAVE"`, not `/wave`) and an
|
||||
/// optional target name.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct EmoteRequest {
|
||||
pub token: String,
|
||||
pub target: Option<String>,
|
||||
}
|
||||
|
||||
/// Lua number coercion the way the reference's `lua_tonumber` does it: an integer, a float, or a
|
||||
/// string that parses; anything else is 0.
|
||||
/// The reference's `lua_tonumber` coercion: a number or a numeric string; anything else is 0.
|
||||
fn to_u32(v: &Value) -> u32 {
|
||||
match v {
|
||||
Value::Integer(i) => u32::try_from(*i).unwrap_or(0),
|
||||
@@ -53,8 +47,7 @@ impl super::UiScript {
|
||||
std::mem::take(&mut self.model_mut().emote_requests)
|
||||
}
|
||||
|
||||
/// `RandomRoll(min, max)` calls since the last drain, as the app sends them
|
||||
/// (`CMSG_RANDOM_ROLL`).
|
||||
/// `RandomRoll(min, max)` calls since the last drain, each a `CMSG_RANDOM_ROLL`.
|
||||
pub fn take_roll_requests(&mut self) -> Vec<(u32, u32)> {
|
||||
std::mem::take(&mut self.model_mut().roll_requests)
|
||||
}
|
||||
@@ -64,21 +57,18 @@ impl super::UiScript {
|
||||
std::mem::take(&mut self.model_mut().uninvite_requests)
|
||||
}
|
||||
|
||||
/// `ConsoleExec` lines whose first word is not a registered CVar — the console commands the
|
||||
/// app owns (`reloadui`, …). A CVar line is written to the store directly and never appears
|
||||
/// here.
|
||||
/// `ConsoleExec` lines that write no CVar: the app's console commands (`reloadui`, …).
|
||||
pub fn take_console_lines(&mut self) -> Vec<String> {
|
||||
std::mem::take(&mut self.model_mut().console_lines)
|
||||
}
|
||||
|
||||
/// `(chat, combat)` — the two logging flags as `LoggingChat`/`LoggingCombat` last set them.
|
||||
/// `(chat, combat)`, as `LoggingChat` and `LoggingCombat` last set them.
|
||||
pub fn logging_flags(&self) -> (bool, bool) {
|
||||
let model = self.model_mut();
|
||||
(model.logging_chat, model.logging_combat)
|
||||
}
|
||||
|
||||
/// Whether either logging flag moved since the last drain — the app's cue to open or close
|
||||
/// its log files.
|
||||
/// Whether a logging flag moved since the last drain: the app's cue to open or close its logs.
|
||||
pub fn take_logging_changes(&mut self) -> bool {
|
||||
std::mem::take(&mut self.model_mut().logging_changed)
|
||||
}
|
||||
@@ -138,12 +128,9 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
|
||||
})?,
|
||||
)?;
|
||||
|
||||
// ConsoleExec("name value") — the console line `/console` hands over. A registered CVar
|
||||
// WITH a value is written the way `SetCVar` writes it (same store, same change queue, no
|
||||
// CVAR_UPDATE token), synchronously, so a script reading it back on the next line sees the
|
||||
// write. Everything else — a command name, or a bare CVar name, which the reference's
|
||||
// per-CVar console command answers with `CVar "%s" is "%s"` (`0x63dde0`) — is a line for
|
||||
// the host's command registry (decision 2303).
|
||||
// `ConsoleExec("name value")`: a registered CVar with a value is written at once, as `SetCVar`
|
||||
// writes it; anything else, a bare CVar name included (the reference answers it with
|
||||
// `CVar "%s" is "%s"`, `0x63dde0`), goes to the app's command registry.
|
||||
g.set(
|
||||
"ConsoleExec",
|
||||
lua.create_function(|lua, line: Option<String>| {
|
||||
@@ -252,8 +239,7 @@ mod tests {
|
||||
"0.8",
|
||||
"the CVar store is the same one SetCVar writes, matched case-insensitively"
|
||||
);
|
||||
// A bare CVar name is the host's to answer (2303: the reference prints its value from
|
||||
// the per-CVar console command), so it rides the command lane like `reloadui`.
|
||||
// A bare CVar name, whose value the reference prints, goes to the command lane.
|
||||
assert_eq!(
|
||||
s.take_console_lines(),
|
||||
vec!["reloadui".to_string(), "uiScale".to_string()]
|
||||
|
||||
Reference in New Issue
Block a user