code wiki / _hdl_build / nx_seg_schema.nx

nx_seg_schema.nx

buildroot/runtime/_hdl_build/nx_seg_schema.nx

3256 B69 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic seg
docsdependenciesstructsconstsfunctions

about

nx_seg_schema.nx -- CAP-SEG-SCHEMA: a self-describing schema + typing + backward/forward EVOLUTION layer for the sovereign store (Avro-class). A schema = ordered fields {name, type, required}. It is SELF-DESCRIBING (sc_encode packs it to bytes storable as a store record; sc_decode reads it back). Evolution safety is MECHANIZED and matches the API-contract-stability doctrine: a new schema is a SAFE evolution of the old iff it (a) keeps every old field with the same type -- no remove/rename/retype -- and (b) adds only OPTIONAL fields (a new REQUIRED field breaks old records). A LIBRARY (no main -> run its _gate). license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_seg_schema.nx nx_seg_schema_gate.nx

imports: nx_syscalls.nx

imported by: nx_seg_schema_gate.nx

structs

none

consts

9const SC_STR: i64 = 1
10const SC_INT: i64 = 2
11const SC_BYTES: i64 = 3
12const SC_OPT: i64 = 0
13const SC_REQ: i64 = 1
14const SC_SAFE: i64 = 0
15const SC_REMOVED: i64 = 1
16const SC_RETYPED: i64 = 2
17const SC_NEWREQ: i64 = 3

functions

19func sc_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8) { if a[i]!=b[i] { return 0 } i=i+1 } if b[i]!=(0 as u8) { return 0 } return 1 }
called by 2: sc_findmain
20func sc_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: sc_encode
21func sc_w32(p: *u8, o: i64, v: i64) -> i64 { p[o]=((v>>24)&0xff) as u8; p[o+1]=((v>>16)&0xff) as u8; p[o+2]=((v>>8)&0xff) as u8; p[o+3]=(v&0xff) as u8; return o+4 }
called by 1: sc_encode
22func sc_r32(p: *u8, o: i64) -> i64 { let a: i64=p[o]; let b: i64=p[o+1]; let c: i64=p[o+2]; let d: i64=p[o+3]; return (((((a<<8)|b)<<8)|c)<<8)|d }
called by 1: sc_decode
23func sc_find(name: *u8, names: *i64, n: i64) -> i64 { var i: i64=0; while i<n { if sc_streq((names[i]) as *u8, name)==1 { return i } i=i+1 } return 0-1 }
called by 1: sc_compat calls 1: sc_streq
26func sc_encode(n: i64, names: *i64, types: *i64, req: *i64, out: *u8) -> i64
called by 1: main calls 2: sc_w32sc_slen
40func sc_decode(b: *u8, out_names: *i64, out_types: *i64, out_req: *i64) -> i64
called by 1: main calls 2: sc_r32sys_mmap
54func sc_compat(n1: i64, names1: *i64, types1: *i64, n2: i64, names2: *i64, types2: *i64, req2: *i64) -> i64
called by 1: main calls 1: sc_find