code wiki / (root) / nx_state_machine.nx

nx_state_machine.nx

buildroot/runtime/nx_state_machine.nx

4492 B119 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind librarytopic state
docsdependenciesstructsconstsfunctions

about

nx_state_machine.nx -- generic state-transition primitive. Many primitives have sealed-state-machine shapes (nx_cell.state, nx_yield.state, nx_treaty.state, nx_recovery.phase). This is the shared substrate for that pattern: caller declares N states + a transition table, gets atomic transitions + queries. Composes with anything that has lifecycle states; useful for app- level state machines beyond the substrate primitives.

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_tier.nx nx_state_machine.nx nx_crypto_event_compose_test.nx nx_state_machine_test.nx

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_crypto_event_compose_test.nxnx_state_machine_test.nx

structs

28struct NxStateMachine

consts

14const NX_SM_OK: nx_int = 0
15const NX_SM_ERR_BAD_FROM: nx_int = 1
16const NX_SM_ERR_BAD_TO: nx_int = 2
17const NX_SM_ERR_BAD_TRANSITION: nx_int = 3
18const NX_SM_ERR_TABLE_FULL: nx_int = 4

functions

37func nx_state_machine_new(states_count: nx_int, initial_state: nx_int) -> *NxStateMachine
called by 2: mainmain calls 1: sys_mmap
70func nx_state_machine_allow(sm: *NxStateMachine, from: nx_int, to: nx_int) -> nx_int
called by 2: mainmain
82func nx_state_machine_is_allowed(sm: *NxStateMachine, from: nx_int, to: nx_int) -> nx_int
97func nx_state_machine_transition(sm: *NxStateMachine, to_state: nx_int) -> nx_int
106func nx_state_machine_current(sm: *NxStateMachine) -> nx_int
called by 2: mainmain
110func nx_state_machine_transitions(sm: *NxStateMachine) -> nx_int
called by 1: main
116func nx_state_machine_reset(sm: *NxStateMachine) -> nx_int
called by 1: main