attributes: @Clip(field) resolved as @Node is, and @OneOf takes constants as well as a prefix - one argument ending in _ is a prefix, otherwise each is a constant that must exist; reseeded
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ebfbabdfd8
commit
34c2ac2cb9
9 changed files with 73220 additions and 71912 deletions
|
|
@ -1,5 +1,5 @@
|
|||
# attrs_node.ludic — @Node(model): a string naming a node inside the glTF another field of the same
|
||||
# record names. That field is @Asset("gltf") itself, or an @Ref(R) whose record has exactly one
|
||||
# attrs_node.ludic — @Node(model) / @Clip(model): a string naming a node or a clip inside the glTF
|
||||
# another field of the same record names. That field is @Asset("gltf") itself, or an @Ref(R) whose record has exactly one
|
||||
# @Asset("gltf") field (the model is found through the row). Anything else is an error naming it.
|
||||
|
||||
# the field of record d called name, or null
|
||||
|
|
@ -45,8 +45,8 @@ function at_gltf_count(r: Node) -> int {
|
|||
}
|
||||
return n
|
||||
}
|
||||
function at_check_node(d: Node, f: Node, target: pointer) -> void {
|
||||
let where = `field {d.s}.{f.s}: @Node({target})`
|
||||
function at_check_node(d: Node, f: Node, a: pointer, target: pointer) -> void {
|
||||
let where = `field {d.s}.{f.s}: @{a}({target})`
|
||||
let t = at_field_of(d, target)
|
||||
if t == null {
|
||||
perr_at(f.file, f.line, f.col, `{where} names no field - {d.s} has no field {target}`)
|
||||
|
|
@ -67,3 +67,41 @@ function at_check_node(d: Node, f: Node, target: pointer) -> void {
|
|||
perr_at(f.file, f.line, f.col, `{where}: {target} is an @Ref({reg}), and its record {g_rg_type[r]} has {n} @Asset("gltf") fields, not one`)
|
||||
}
|
||||
}
|
||||
|
||||
# @OneOf: one argument ending in _ is a prefix; otherwise every argument is a constant that must exist
|
||||
function at_check_oneof(d: Node, f: Node, j: int) -> void {
|
||||
let first = g_at_first[j]
|
||||
if g_at_nargs[j] == 1 and first[len(first) - 1] == '_' { return }
|
||||
let names = at_arg_names(g_at_args[j])
|
||||
var i = 0
|
||||
while i < len(names) {
|
||||
if not at_const_exists(names[i]) {
|
||||
perr_at(f.file, f.line, f.col, `field {d.s}.{f.s}: @OneOf names {names[i]}, and there is no constant {names[i]}`)
|
||||
}
|
||||
i += 1
|
||||
}
|
||||
}
|
||||
# the names in an attribute's JSON arguments (["A", "B"]): each a quoted identifier
|
||||
function at_arg_names(args: pointer) -> []pointer {
|
||||
let out = new []pointer
|
||||
var i = 0
|
||||
var at = -1
|
||||
while i < len(args) {
|
||||
if args[i] == '"' {
|
||||
if at < 0 { at = i + 1 } else {
|
||||
push(out, args[at .. i])
|
||||
at = -1
|
||||
}
|
||||
}
|
||||
i += 1
|
||||
}
|
||||
return out
|
||||
}
|
||||
function at_const_exists(name: pointer) -> bool {
|
||||
var i = 0
|
||||
while i < len(prog) {
|
||||
if prog[i].kind == N_CONST and prog[i].s != null and vis_plain(prog[i].s) == name { return true }
|
||||
i += 1
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue