Skip to content

scene: fix indexed SceneScript layer queries and object identity - #155

Merged
hypengw merged 1 commit into
waywallen:mainfrom
nztom:bugfix/scenescript-layer-access
Oct 20, 2026
Merged

hypengw merged 1 commit into
waywallen:mainfrom
nztom:bugfix/scenescript-layer-access

Conversation

@nztom

@nztom nztom commented Oct 6, 2026

Copy link
Copy Markdown

SceneScripts that call thisScene.getLayerCount() currently fail during initialization because the method is missing. Numeric getLayer(index) is treated as a name, and enumeration includes internal camera nodes. These behaviours can leave scripted layers hidden or select the wrong layer. Repeated lookups also return different JavaScript objects for the same native layer.

This change adds layer counting and integer-index lookup, sharing traversal order and layer membership with enumeration and its custom includes(). Authored and dynamically created layers are tracked separately from internal nodes. Native layer wrappers are cached so thisLayer, named lookup, indexed lookup, and enumeration agree on object identity; property-script wrappers retain their separate animation behaviour.

Script-bound layers are registered before module evaluation and initialization, including scripts created inside a layer factory. Root replacement preserves cached identity for retained layers and releases discarded cache references. Unbound queries return empty defaults, while standalone runtimes retain tree queries.

The implementation reuses the existing rstd containers, node accessors, QuickJS wrapper helpers, and TreeContains. No imports or dependencies are added.

Validation

  • All 109 script-runtime tests pass, including 14 added regressions covering indexing, membership, identity, mutation, sorting, dynamic creation/reuse, nested initialization, root replacement, and empty/unbound scenes. The initial 12 regressions were also verified to fail on unmodified upstream.
  • All 13 test executables build; ten test executables pass.
  • Three corpus-dependent executables had 41 failures reproduced on both unmodified upstream and the initial candidate. These failures require missing corpus samples; those executables were not rerun after the final follow-up commits.
  • Repository-wide lito format --check passes with upstream's pinned clang-format 22.1.5 (229 files).

API reference: Wallpaper Engine IScene.

@nztom
nztom marked this pull request as ready for review October 6, 2026 04:03
@hypengw
hypengw merged commit 0474297 into waywallen:main Oct 20, 2026
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.

2 participants