From 6755e7ec02b0825b0e48c7e455154d020c6efc983bf8b1a32070a47fb137e156 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Thu, 9 Oct 2025 22:28:54 +0300 Subject: [PATCH] PREC command could be used in theory with FLOAT --- c/lib/schema.c | 10 +++++----- go/schema/check.go | 4 ++-- spec/schema/cmds | 10 ++++++---- spec/schema/tcl | 4 ++-- tcl/schema.tcl | 12 ++++++------ 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/c/lib/schema.c b/c/lib/schema.c index bb2d853..7f1b937 100644 --- a/c/lib/schema.c +++ b/c/lib/schema.c @@ -35,7 +35,7 @@ static const char CmdLT[] = "<"; static const char CmdNotExists[] = "!E"; static const char CmdSchema[] = "S"; static const char CmdTake[] = "."; -static const char CmdTimePrec[] = "TP"; +static const char CmdPrec[] = "P"; static const char CmdType[] = "T"; static const char CmdUTC[] = "UTC"; @@ -473,7 +473,7 @@ Eached: } err.code = KEKSSchemaErrNo; } - } else if (KEKSStrEqual(&(schema->list[idxSchema].atom), CmdTimePrec)) { + } else if (KEKSStrEqual(&(schema->list[idxSchema].atom), CmdPrec)) { idxSchema = schema->list[idxSchema].next; if (idxSchema == 0) { err.code = KEKSSchemaErrInvalidSchema; @@ -483,10 +483,10 @@ Eached: err.offSchema = schema->offsets[idxSchema]; if (schema->list[idxSchema].atom.typ != KEKSItemPint) { err.code = KEKSSchemaErrInvalidSchema; - err.msg = "non-int TIMEPREC"; + err.msg = "non-int PREC"; return err; } - err.msg = "TIMEPREC"; + err.msg = "PREC"; err.code = KEKSSchemaErrNo; if (v != SIZE_MAX) { if (data->list[v].atom.typ != KEKSItemTAI64) { @@ -562,7 +562,7 @@ Eached: break; default: err.code = KEKSSchemaErrInvalidSchema; - err.msg = "unknown TIMEPREC value"; + err.msg = "unknown PREC value"; return err; } } diff --git a/go/schema/check.go b/go/schema/check.go index 1dde03e..2b47b93 100644 --- a/go/schema/check.go +++ b/go/schema/check.go @@ -39,7 +39,7 @@ const ( CmdNotExists = "!E" CmdSchema = "S" CmdTake = "." - CmdTimePrec = "TP" + CmdPrec = "P" CmdType = "T" CmdUTC = "UTC" Magic = "schema" @@ -486,7 +486,7 @@ func Check(schemaName string, schemas map[string][][]any, data any) error { }} } } - case CmdTimePrec: + case CmdPrec: if vs == nil { continue } diff --git a/spec/schema/cmds b/spec/schema/cmds index 5a4b8c0..6e750ee 100644 --- a/spec/schema/cmds +++ b/spec/schema/cmds @@ -54,10 +54,11 @@ LT | ["<", n] SCHEMA | ["S", s] Check chosen (if it exists) element against schema named "s". -TIMEPREC | ["TP", p] - Check that chosen (if it exists) element, of time type, has value of - maximal specified time precision. "p" is integer with following - possible values: +PREC | ["P", p] + Check that chosen (if it exists) element, has specified precision. + It chosen element of time type, then check its value is at most + precise as 10^{-p} seconds. "p" is integer with following possible + values: 0: only full seconds allowed, no parts; 3: only up to milliseconds; 6: only up to microseconds; @@ -65,6 +66,7 @@ TIMEPREC | ["TP", p] 12: only up to picoseconds; 15: only up to femtoseconds; 18: up to attoseconds; + If chosen element of float type, then TODO. UTC | ["UTC"] Check that chosen (if it exists) element, of TAI type, diff --git a/spec/schema/tcl b/spec/schema/tcl index a664a4c..2651db3 100644 --- a/spec/schema/tcl +++ b/spec/schema/tcl @@ -70,8 +70,8 @@ strings are not empty. "=v" checks that given bin/str/hexlet/magic has specified binary value. -"prec=p" issues TIMEPREC command, but instead of specifying the raw -integer values, you choose one of: s, ms, us, ns, ps, fs. +"prec=p" issues PREC command, but instead of specifying the raw +integer values, you choose one of: s, ms, us, ns, ps, fs for time type. "utc" issues UTC command. diff --git a/tcl/schema.tcl b/tcl/schema.tcl index 30d193d..b8a373b 100755 --- a/tcl/schema.tcl +++ b/tcl/schema.tcl @@ -27,7 +27,7 @@ proc EQ {v} {subst {LIST {{STR =} {BIN $v}}}} proc GT {n} {subst {LIST {{STR >} {INT $n}}}} proc LT {n} {subst {LIST {{STR <} {INT $n}}}} proc SCHEMA {s} {subst {LIST {{STR S} {STR $s}}}} -proc TIMEPREC {p} {subst {LIST {{STR TP} {INT $p}}}} +proc PREC {p} {subst {LIST {{STR P} {INT $p}}}} proc UTC {} {return {LIST {{STR UTC}}}} proc TAKE {k} { @@ -55,7 +55,7 @@ proc TYPE {types} { subst {LIST {$l}} } -set timeprecArgs [dict create s 0 ms 3 us 6 ns 9 ps 12 fs 15] +set precArgs [dict create s 0 ms 3 us 6 ns 9 ps 12 fs 15] proc field {k types args} { upvar _cmds _cmds buf buf @@ -99,9 +99,9 @@ proc field {k types args} { set i [lsearch -glob $args "prec=*"] if {$i != -1} { set p [string range [lindex $args $i] 5 end] - variable timeprecArgs - set p [dict get $timeprecArgs $p] - lappend _cmds [TIMEPREC $p] + variable precArgs + set p [dict get $precArgs $p] + lappend _cmds [PREC $p] } if {[lsearch -exact $args utc] != -1} { lappend _cmds [UTC] @@ -145,7 +145,7 @@ proc do {v} { MAP $_pairs } -namespace export TAKE EXISTS !EXISTS EACH EQ TYPE GT LT SCHEMA TIMEPREC UTC +namespace export TAKE EXISTS !EXISTS EACH EQ TYPE GT LT SCHEMA PREC UTC namespace export do process field } -- 2.51.0