Cut shell/actions, bank_ops, app comment bloat ~48% (comments only, zero code change)

This commit is contained in:
2026-07-29 20:49:31 -04:00
parent 1f24c4b095
commit 58c6d49261
19 changed files with 514 additions and 1074 deletions
+19 -52
View File
@@ -1,28 +1,10 @@
#pragma once
// action_registry — shared registration plumbing + the Q-W6 registration TABLE.
//
// Two layers, one TU:
//
// * The Q-W4 plumbing (channelIdFor / registerAction): the durable interned-string
// store the action families register through, so a composed command id keeps ONE
// stable pointer from register to the mirror-unregister, and the
// register-a-command_id-then-gaccel sequence has one implementation. The
// design_view / bank / ingest families still register row-by-row through this.
//
// * The Q-W6 registration TABLE (ActionTableRow + registerActionTable /
// actionTableHandleCommand / actionTableCommandId / unregisterActionTable): the
// data-driven home of main.cpp's own action family (capture scopes, panel toggle,
// insert, batch, realtime, recapture, version). One row = one action (FOREVER-
// STABLE id suffix, display phrase, flat function-pointer handler); registration
// iterates the rows, hookcommand dispatch walks the same rows, and unload
// mirror-unregisters from them — adding an action touches the table only (OCP).
// Handlers are plain function pointers (a static dispatch walk, no std::function,
// no virtual — the §3 performance guardrail); gaccel + interned-id storage is
// owned here for the module lifetime, so REAPER's held pointers stay valid and
// the '-command_id' unregister re-presents the IDENTICAL pointer registered.
//
// Includes reaper_plugin.h (gaccel_register_t / reaper_plugin_info_t full defs);
// only the action-family TUs and main.cpp include this header.
// action_registry — shared REAPER registration plumbing, plus a data-driven action
// table (ActionTableRow) so adding an action means adding one row, not touching
// register/dispatch/unregister separately (OCP). Interned command-id/label strings
// persist for the module lifetime: REAPER holds those pointers, and an unregister
// must re-present the SAME one. Handlers are flat function pointers, never
// std::function/virtual (hot-path-adjacent dispatch discipline).
#include <cstddef>
@@ -30,27 +12,19 @@
namespace reasampler {
// Returns the channel-qualified command id for `suffix`, interning it once for the
// process lifetime. Called by BOTH registerAction and each family's unregister path,
// so a '-command_id' presents the IDENTICAL string pointer registered earlier.
// Interns the channel-qualified command id for `suffix` once per process, so a
// '-command_id' unregister presents the IDENTICAL pointer registered earlier.
const char* channelIdFor(const char* suffix);
// Mints a command id from a channel-qualified SUFFIX and registers its gaccel
// (Actions-list entry with a channel-qualified label PHRASE). Returns the command id
// (0 on failure). Both the composed id and label are interned durably — REAPER holds
// the desc pointer, and the id must survive to the mirror-unregister. The gaccel
// storage itself is caller-owned (file-scope in the family TU).
// Mints a command id from `suffix`, registers its gaccel with label `phrase`.
// Returns the id (0 on failure); gaccel storage is caller-owned.
int registerAction(reaper_plugin_info_t* rec, const char* suffix,
gaccel_register_t& accel, const char* phrase);
// --- The registration table (Q-W6) -------------------------------------------
// --- The registration table ---------------------------------------------------
// One bindable action. `suffix` and `phrase` are the channel-AGNOSTIC pieces (the
// registry composes the full id/label via channelCommandId / channelActionName);
// both must have static storage duration (string literals, or a pure static table
// like captureActionTable()). `run` fires when the minted command does; `arg` is an
// opaque per-row value passed through to it (e.g. a captureActionTable row index, or
// a bool-like flag), so sibling actions can share one handler without captures.
// `suffix`/`phrase` are channel-agnostic and must have static storage duration.
// `arg` is an opaque per-row value so sibling actions can share one handler.
struct ActionTableRow {
const char* suffix; // FOREVER-STABLE command-id suffix — never change shipped
const char* phrase; // Actions-list display phrase (after the channel prefix)
@@ -58,26 +32,19 @@ struct ActionTableRow {
int arg = 0; // opaque per-row handler argument
};
// Registers every row (command_id -> gaccel, via the same interning plumbing as
// registerAction) in table order. Rows are COPIED into registry-owned storage whose
// element addresses never move (REAPER holds each gaccel pointer until unload).
// Call once at load; a failed command_id mint (cmd 0) leaves that row inert but
// still mirror-unregistered on unload (harmless, matches the pre-table behavior).
// Rows are copied into registry-owned storage whose addresses never move (REAPER
// holds each gaccel pointer until unload).
void registerActionTable(reaper_plugin_info_t* rec, const ActionTableRow* rows,
std::size_t count);
// Dispatches one fired command: fires the matching row's handler and returns true;
// false when the command belongs to no table row (caller's hookcommand keeps
// looking, per the claim-only contract). A flat walk over the registered rows.
bool actionTableHandleCommand(int command);
// The minted command id for `suffix` (0 when unregistered / mint failed). For the
// callers that need a raw command id outside dispatch — e.g. the toggleaction
// checked-state hook resolving TOGGLE_BANK_PANEL once at load.
// 0 when unregistered / mint failed — for callers needing a raw id outside dispatch
// (e.g. the toggleaction checked-state hook).
int actionTableCommandId(const char* suffix);
// Mirror-unregisters every table row (reverse table order): '-gaccel' with the same
// held storage, '-command_id' with the SAME interned pointer used at register.
// Mirror-unregisters every table row (reverse order): '-gaccel' with the held
// storage, '-command_id' with the SAME interned pointer used at register.
void unregisterActionTable(reaper_plugin_info_t* rec);
} // namespace reasampler