Skip to content

refactor: merge HookLibraries into HookLibrary - #14

Merged
philpax merged 1 commit into
mainfrom
refactor/merge-hook-libraries
Jul 3, 2026
Merged

refactor: merge HookLibraries into HookLibrary#14
philpax merged 1 commit into
mainfrom
refactor/merge-hook-libraries

Conversation

@philpax

@philpax philpax commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Merges HookLibraries into HookLibrary so that HookLibrary can nest child HookLibrary instances, enabling arbitrary composition. The separate HookLibraries type is removed.

Changes

  • HookLibrary gains children: Vec<HookLibrary> — child libraries are enabled after (and disabled before) the parent's own binders and patches, with a mirrored enable/disable sequence:
    • Enable: [self.binders → self.patches → children]
    • Disable: [children → self.patches → self.binders] (exact reverse)
  • with_hook_library(child) builder method for adding child libraries
  • enable(self, &mut Patcher) convenience method ported from HookLibraries::enable
  • HookLibraries struct and impl block removed entirely
  • Unit tests added for nesting behavior (5 tests, Windows-only #[cfg(target_os = "windows")]):
    • test_child_binder_enabled — parent + child binders both enabled
    • test_child_binder_disabled — all binders return to 0 after disable
    • test_nested_children — 3-level nesting (parent → child → grandchild)
    • test_enable_returns_selfenable() returns Ok(Self)
    • test_disable_order — verifies disable order is reverse of enable
  • CI workflow updated: clippy now uses --all-targets (lints test code), and a cargo test step was added

Test plan

  • cargo clippy --target x86_64-pc-windows-msvc --all-targets -- -Dwarnings passes (0 warnings)
  • grep -rn HookLibraries returns zero matches
  • cargo test --target x86_64-pc-windows-msvc passes in CI (Windows)

Closes #13

Add a `children: Vec<HookLibrary>` field to `HookLibrary` and a
`with_hook_library` builder method, enabling arbitrary composition.
`set_enabled` now delegates to children with a mirrored enable/disable
sequence: enable [self → children], disable [children → self].

The separate `HookLibraries` type is removed; `enable(self, &mut Patcher)`
is ported from it. Adds unit tests for nesting behavior and a CI test job.
@philpax
philpax merged commit db66882 into main Jul 3, 2026
2 checks passed
@philpax
philpax deleted the refactor/merge-hook-libraries branch July 3, 2026 09:20
philpax added a commit to ferrobrew/jc3vr that referenced this pull request Jul 4, 2026
re-utilities merged HookLibraries into HookLibrary
(ferrobrew/re-utilities#14): a library now nests children via
with_hook_library. The top-level aggregator builds one parent library,
graphics_engine's leaves each own a standalone library instead of
folding extend functions, and input nests locomotion and look rather
than reaching across module boundaries for binders.

Closes #21.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Merge HookLibrary and HookLibraries

1 participant