Lifecycle hooks: @OnStart/@OnQuit, @OnDespawn, @OnAttach (like @OnSpawn)
Adds the rest of the game/entity/property lifecycle as @-hooks, each firing at one timeline moment and reducing to ordinary code: - @OnStart / @OnQuit (program): @OnStart aliases the Start phase; @OnQuit runs in the frame loop's done: block, after the loop stops and before teardown. - @OnDespawn(Model) (entity): a destructor. Despawn doesn't statically know the entity's model, so hooks compile to @on_despawn_<Model>(entity) functions and emit_despawn dispatches on @L_kind. Symmetric with @OnSpawn. - @OnAttach(Property): fires in emit_init_component once a property is attached and seeded, with the property bound by name. Registries + parsing mirror @OnSpawn. examples/lifecycle.ludic narrates the whole timeline (output 1 700 50 950 2). Behaviour-preserving (goldens byte-identical, despawn users unaffected when no hooks registered); test.sh 16/16, fixpoint holds. Deferred: @OnDetach (per-property runtime dispatch) and scene @OnEnter/@OnExit (need scene support in the compiler). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
28abd3a2c3
commit
6e11212cf2
8 changed files with 3993 additions and 3258 deletions
5
test.sh
5
test.sh
|
|
@ -56,6 +56,11 @@ if ./selfhost/game-build.sh build/ludicc examples/annotations.ludic "/tmp/ludic_
|
|||
&& [ "$(/tmp/ludic_ann </dev/null | tr '\n' ' ')" = "3 25 0 0 " ]; then
|
||||
ok "annotations.ludic (@Queries / @Computed / @OnSpawn / @Handles)"
|
||||
else bad "annotations: $(tail -1 /tmp/ann.out)"; fi
|
||||
# Lifecycle hooks fire in timeline order: @OnStart @OnAttach @OnSpawn @OnDespawn @OnQuit.
|
||||
if ./selfhost/game-build.sh build/ludicc examples/lifecycle.ludic "/tmp/ludic_life" >/tmp/life.out 2>&1 \
|
||||
&& [ "$(/tmp/ludic_life </dev/null | tr '\n' ' ')" = "1 700 50 950 2 " ]; then
|
||||
ok "lifecycle.ludic (@OnStart/@OnAttach/@OnSpawn/@OnDespawn/@OnQuit in order)"
|
||||
else bad "lifecycle: $(tail -1 /tmp/life.out)"; fi
|
||||
# --- Toolchain-agent CLI smoke tests append below this line ---
|
||||
echo "== self-hosted front-end binaries (ludicc / ludic) =="
|
||||
# The two commands are one multi-call native binary built from the seed with
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue