Comments in benilla-app, the UI script layer: one line of fact each, no history, no record numbers (#184)
Part of #41: the first of five `benilla-app` pieces. This one is the UI script layer: `ui_script` with its test harnesses, the text engine and layout (`ui_text`), the UI pass and the UI model panes. Its comments are rewritten to the rule in `docs/METHOD.md`, which is what the code does and the reference fact behind it, in a line. 22,041 comment lines become 7,133. - **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: - On a fresh login the reference fires `PLAYER_LOGIN` and `PLAYER_ENTERING_WORLD` from the player's create (`0x5deb60` → `0x4908c0`); only a `/reload` goes through `0x490168`. The comments now state both paths. - `ComputeStep` (`0x5ca2d0`) applies negative pair kerns and rounds up. It does have a kerning term. - A fallback icon global and the retired `UiPanels.xml` panels no longer exist. The comments that named them now describe the stock FrameXML mechanism that replaced them. - Stock FrameXML line citations are checked against the stock 1.12 files and corrected, and several misattributed files are fixed (`MainMenuBarArtFrame` lives in `MainMenuBar.xml`). - Dozens more turned up on the way: docs sitting on the wrong item, removed functions, stale counts and links. - **Deviation labels.** "Deviation:" now marks only a choice with a reason. An unbuilt behaviour says so plainly. - **Verification.** Every file strips to identical code, and `cargo fmt --check` is clean. Five 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 (#183 among them). 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
fd386e75ae
commit
eba558a5d2
@@ -1,15 +1,11 @@
|
||||
//! The stock `Interface\FrameXML\BasicControls.xml` — the reference's second file, driven the way
|
||||
//! an addon drives it.
|
||||
//!
|
||||
//! Nothing benilla ships calls `message`, `TEXT` or `_ERRORMESSAGE`; their only consumers are
|
||||
//! third-party addons (26 call `TEXT`, ~10 genuinely call `message`, two replace `_ERRORMESSAGE`).
|
||||
//! So every test here enters from Lua the way those addons do.
|
||||
//! The stock `BasicControls.xml`: `message`, `_ERRORMESSAGE`, `TEXT` and the `DialogBoxFrame`
|
||||
//! kit, driven from Lua the way addons call them.
|
||||
|
||||
use benilla_ui::script::UiScript;
|
||||
|
||||
use super::test_ui::load_ui as load_xml;
|
||||
|
||||
/// Fonts then BasicControls — the manifest's own order, and the whole dependency this file has.
|
||||
/// Fonts.xml is BasicControls.xml's one dependency.
|
||||
fn basic_controls() -> UiScript {
|
||||
let mut s = UiScript::new().unwrap();
|
||||
load_xml(&s, "Interface\\FrameXML\\Fonts.xml");
|
||||
@@ -19,8 +15,6 @@ fn basic_controls() -> UiScript {
|
||||
s
|
||||
}
|
||||
|
||||
/// **`message("...")` puts its text in the dialog and shows it** — the whole contract, and the
|
||||
/// reason the frame has to exist rather than the function being a stub that prints somewhere.
|
||||
#[test]
|
||||
fn message_shows_the_script_errors_dialog_carrying_its_text() {
|
||||
benilla_formats::wow_data_or_skip!();
|
||||
@@ -39,7 +33,7 @@ fn message_shows_the_script_errors_dialog_carrying_its_text() {
|
||||
"Validation error: [nil]"
|
||||
);
|
||||
|
||||
// The ref guard: a second message while the dialog is up does NOT overwrite the first.
|
||||
// A second message while the dialog is up keeps the first (`BasicControls.xml:7`).
|
||||
s.run(r#"message("second")"#).unwrap();
|
||||
assert_eq!(
|
||||
s.eval::<String>("return ScriptErrors_Message:GetText()")
|
||||
@@ -48,14 +42,11 @@ fn message_shows_the_script_errors_dialog_carrying_its_text() {
|
||||
"`if not ScriptErrors:IsVisible()` — the first error is the one you keep"
|
||||
);
|
||||
|
||||
// And OKAY hides it, which is the only way it closes.
|
||||
s.run("ScriptErrorsButton:Click()").unwrap();
|
||||
assert!(!s.eval::<bool>("return ScriptErrors:IsVisible()").unwrap());
|
||||
assert!(s.errors().is_empty(), "{:?}", s.errors());
|
||||
}
|
||||
|
||||
/// `_ERRORMESSAGE` is the reference's own name for the body, it **returns its argument**, and it
|
||||
/// is replaceable — which is the entire point for the two corpus addons that replace it.
|
||||
#[test]
|
||||
fn error_message_returns_its_argument_and_can_be_replaced() {
|
||||
benilla_formats::wow_data_or_skip!();
|
||||
@@ -66,7 +57,7 @@ fn error_message_returns_its_argument_and_can_be_replaced() {
|
||||
"the ref returns `message` — a caller may chain on it"
|
||||
);
|
||||
|
||||
// ImprovedErrorFrame's shape: swap the global, then `message` must route through the swap.
|
||||
// ImprovedErrorFrame's pattern: `message` calls whatever `_ERRORMESSAGE` is now.
|
||||
s.run(
|
||||
r#"Captured = nil
|
||||
_ERRORMESSAGE = function(m) Captured = m return m end
|
||||
@@ -77,11 +68,7 @@ fn error_message_returns_its_argument_and_can_be_replaced() {
|
||||
assert!(s.errors().is_empty(), "{:?}", s.errors());
|
||||
}
|
||||
|
||||
/// The reference's closing line is transcribed since decision 1305: BasicControls installs
|
||||
/// `seterrorhandler(_ERRORMESSAGE)`, so a script error pops the dialog like the real client's —
|
||||
/// and the host channel stays sighted because the ENGINE records every caught error before the
|
||||
/// dispatch ever runs (that dual channel is what dissolved the old divergence, whose guard this
|
||||
/// test used to be).
|
||||
/// `BasicControls.xml:16` installs `_ERRORMESSAGE` as the error handler.
|
||||
#[test]
|
||||
fn error_message_is_the_installed_handler_and_the_host_channel_stays_sighted() {
|
||||
benilla_formats::wow_data_or_skip!();
|
||||
@@ -91,8 +78,7 @@ fn error_message_is_the_installed_handler_and_the_host_channel_stays_sighted() {
|
||||
.unwrap(),
|
||||
"the reference's own default handler is installed (1305)"
|
||||
);
|
||||
// An addon's pcall wrapper calls geterrorhandler()(msg) — with _ERRORMESSAGE installed that
|
||||
// pops the dialog, exactly as it does in the real client.
|
||||
// An addon's pcall wrapper reports through `geterrorhandler()`, which pops the dialog.
|
||||
s.run(r#"geterrorhandler()("reported")"#).unwrap();
|
||||
assert!(
|
||||
s.eval::<bool>("return ScriptErrors:IsVisible()").unwrap(),
|
||||
@@ -103,8 +89,7 @@ fn error_message_is_the_installed_handler_and_the_host_channel_stays_sighted() {
|
||||
.unwrap(),
|
||||
"reported"
|
||||
);
|
||||
// And an ENGINE-caught error still reaches `UiScript::errors()` — the instruments' channel —
|
||||
// with the dispatch adding the dialog on top, not instead.
|
||||
// An engine-caught error still lands in `errors()`; the dispatch adds the dialog on top.
|
||||
s.run("BrokenProbe = CreateFrame('Frame') BrokenProbe:RegisterEvent('B271_PROBE') BrokenProbe:SetScript('OnEvent', function() error('fault') end)")
|
||||
.unwrap();
|
||||
s.fire_event("B271_PROBE", vec![]);
|
||||
@@ -120,7 +105,6 @@ fn error_message_is_the_installed_handler_and_the_host_channel_stays_sighted() {
|
||||
);
|
||||
}
|
||||
|
||||
/// `TEXT` is the identity function, and 26 corpus addons call it because shipped FrameXML does.
|
||||
#[test]
|
||||
fn text_is_the_identity_function_the_corpus_expects() {
|
||||
benilla_formats::wow_data_or_skip!();
|
||||
@@ -132,9 +116,6 @@ fn text_is_the_identity_function_the_corpus_expects() {
|
||||
assert_eq!(s.eval::<i64>("return TEXT(7)").unwrap(), 7);
|
||||
}
|
||||
|
||||
/// The dialog kit an addon inherits from directly: `DialogBoxFrame` plus the three named textures.
|
||||
/// The OKAY button must hide *the caller's* frame, and `$parent` must resolve against the caller's
|
||||
/// name — `MyDialogButton`, never `DialogBoxFrameButton`.
|
||||
#[test]
|
||||
fn a_dialog_box_from_the_template_names_and_closes_the_callers_frame() {
|
||||
benilla_formats::wow_data_or_skip!();
|
||||
|
||||
Reference in New Issue
Block a user