Skip to content

Parameter Packs for ECS#108

Merged
ctreffs merged 26 commits intomasterfrom
parameter-packs
Feb 13, 2026
Merged

Parameter Packs for ECS#108
ctreffs merged 26 commits intomasterfrom
parameter-packs

Conversation

@ctreffs
Copy link
Member

@ctreffs ctreffs commented Feb 13, 2026

Description

This PR refactors Fireblade ECS to leverage Swift Parameter Packs (SE-0393), replacing the previous Sourcery-based code generation for Family types. This modernization results in a significantly smaller codebase, easier maintenance, and a more idiomatic Swift API while maintaining strict feature parity and performance.

Key Features & Improvements

  • Variadic Families: Replaced Family1 through Family8 (and beyond) with a single, variadic Family<each C: Component>.
  • Sequence Conformance: Restored full Sequence and IteratorProtocol support for Family, enabling the familiar for (pos, vel) in family syntax without performance degradation.
  • Codable Feature Parity: Reimplemented family serialization to ensure identical JSON output structure. The FamilyMemberContainer logic has been preserved to maintain compatibility with existing serialized data.
  • Unified Nexus API:
    • Nexus.family(requiresAll: ...) now accepts an arbitrary number of component types.
    • Nexus.createEntity(with: ...) now supports parameter packs for type-safe entity creation.
    • A dedicated requires: overload for single-component families has been maintained for ease of use.
  • Sendable Conformance: Family, ComponentsIterator, EntityIterator, and EntityComponentIterator now conform to Sendable, improving thread safety guarantees.
  • Tooling Cleanup: Removed Sourcery dependency, including .sourcery.yml, templates, and Mintfile entries.
  • Documentation: Updated DocC documentation to reflect the new API and removed all broken links to deprecated generated types. Documentation analysis now passes with 0 errors.

Testing

  • Migrated all existing tests to the new variadic API.
  • Added a comprehensive suite of tests (FamilyTests1.swift through FamilyTests8.swift) to verify API correctness across varying component counts (1 to 8+).
  • Verified Codable round-trip and feature parity with FamilyCodingTests.swift.
  • All 138 tests pass successfully.

Source Impact

  • Breaking Change: Family1, Family2, etc. type aliases are removed in favor of Family<C1, C2, ...>.
  • Breaking Change: Deployment target bumped to macOS 14+ / iOS 17+ to support the required Swift runtime features for generic parameter packs.

Checklist

  • I've read the Contribution Guidelines
  • I've followed the coding style of the rest of the project.
  • I've added tests covering all new code paths my change adds to the project (to the extent possible).
  • I've added benchmarks covering new functionality (if appropriate).
  • I've verified that my change does not break any existing tests or introduce unexpected benchmark regressions.
  • I've updated the documentation (if appropriate).

@ctreffs ctreffs self-assigned this Feb 13, 2026
@ctreffs ctreffs added the enhancement New feature or request label Feb 13, 2026
@ctreffs ctreffs changed the title Refactor ECS to use Swift Parameter Packs Parameter Packs for ECS Feb 13, 2026
@ctreffs ctreffs marked this pull request as ready for review February 13, 2026 13:16
@ctreffs ctreffs merged commit df50d32 into master Feb 13, 2026
12 of 14 checks passed
@ctreffs ctreffs deleted the parameter-packs branch February 13, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant