Change indirection and preprocessing symbols
This commit is contained in:
parent
1910e93d71
commit
29503614cc
3 changed files with 11 additions and 11 deletions
|
@ -8,7 +8,7 @@ module.exports = {
|
||||||
back: true,
|
back: true,
|
||||||
text: '',
|
text: '',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
mirrored: '!mirrored'
|
mirrored: '=mirrored'
|
||||||
},
|
},
|
||||||
body: p => {
|
body: p => {
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@ const footprint = exports._footprint = (config, name, points, point, net_indexer
|
||||||
for (const net_ref of (fp.nets || [])) {
|
for (const net_ref of (fp.nets || [])) {
|
||||||
let net = nets[net_ref]
|
let net = nets[net_ref]
|
||||||
a.sane(net, `${name}.nets.${net_ref}`, 'string')()
|
a.sane(net, `${name}.nets.${net_ref}`, 'string')()
|
||||||
if (net.startsWith('!') && point) {
|
if (net.startsWith('=') && point) {
|
||||||
const indirect = net.substring(1)
|
const indirect = net.substring(1)
|
||||||
net = point.meta[indirect]
|
net = point.meta[indirect]
|
||||||
a.sane(net, `${name}.nets.${net_ref} --> ${point.meta.name}.${indirect}`, 'string')()
|
a.sane(net, `${name}.nets.${net_ref} --> ${point.meta.name}.${indirect}`, 'string')()
|
||||||
|
@ -187,7 +187,7 @@ const footprint = exports._footprint = (config, name, points, point, net_indexer
|
||||||
for (const param of (Object.keys(fp.params || {}))) {
|
for (const param of (Object.keys(fp.params || {}))) {
|
||||||
let value = params[param] === undefined ? fp.params[param] : params[param]
|
let value = params[param] === undefined ? fp.params[param] : params[param]
|
||||||
if (value === undefined) throw new Error(`Field "${name}.params.${param}" is missing!`)
|
if (value === undefined) throw new Error(`Field "${name}.params.${param}" is missing!`)
|
||||||
if (a.type(value)() == 'string' && value.startsWith('!') && point) {
|
if (a.type(value)() == 'string' && value.startsWith('=') && point) {
|
||||||
const indirect = value.substring(1)
|
const indirect = value.substring(1)
|
||||||
value = point.meta[indirect]
|
value = point.meta[indirect]
|
||||||
if (value === undefined) throw new Error(`Field "${name}.params.${param} --> ${point.meta.name}.${indirect}" is missing!`)
|
if (value === undefined) throw new Error(`Field "${name}.params.${param} --> ${point.meta.name}.${indirect}" is missing!`)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const u = require('./utils')
|
const u = require('./utils')
|
||||||
const a = require('./assert')
|
const a = require('./assert')
|
||||||
|
|
||||||
const unnest = exports.unnest = (config) => {
|
const unnest = exports.unnest = config => {
|
||||||
if (a.type(config)() !== 'object') return config
|
if (a.type(config)() !== 'object') return config
|
||||||
const result = {}
|
const result = {}
|
||||||
for (const [key, val] of Object.entries(config)) {
|
for (const [key, val] of Object.entries(config)) {
|
||||||
|
@ -14,7 +14,7 @@ const _extend = exports._extend = (to, from) => {
|
||||||
const to_type = a.type(to)()
|
const to_type = a.type(to)()
|
||||||
const from_type = a.type(from)()
|
const from_type = a.type(from)()
|
||||||
if (from === undefined || from === null) return to
|
if (from === undefined || from === null) return to
|
||||||
if (from === '!!unset') return undefined
|
if (from === '$unset') return undefined
|
||||||
if (to_type != from_type) return from
|
if (to_type != from_type) return from
|
||||||
if (from_type == 'object') {
|
if (from_type == 'object') {
|
||||||
const res = u.deepcopy(to)
|
const res = u.deepcopy(to)
|
||||||
|
@ -47,21 +47,21 @@ const _inherit = exports._inherit = (config, root, breadcrumbs) => {
|
||||||
for (const [key, val] of Object.entries(config)) {
|
for (const [key, val] of Object.entries(config)) {
|
||||||
breadcrumbs.push(key)
|
breadcrumbs.push(key)
|
||||||
let newval = _inherit(val, root, breadcrumbs)
|
let newval = _inherit(val, root, breadcrumbs)
|
||||||
if (newval && newval.extends !== undefined) {
|
if (newval && newval.$extends !== undefined) {
|
||||||
let candidates = u.deepcopy(newval.extends)
|
let candidates = u.deepcopy(newval.$extends)
|
||||||
if (a.type(candidates)() !== 'array') candidates = [candidates]
|
if (a.type(candidates)() !== 'array') candidates = [candidates]
|
||||||
const list = [newval]
|
const list = [newval]
|
||||||
while (candidates.length) {
|
while (candidates.length) {
|
||||||
const path = candidates.shift()
|
const path = candidates.shift()
|
||||||
const other = u.deepcopy(u.deep(root, path))
|
const other = u.deepcopy(u.deep(root, path))
|
||||||
a.assert(other, `"${path}" (reached from "${breadcrumbs.join('.')}.extends") does not name a valid inheritance target!`)
|
a.assert(other, `"${path}" (reached from "${breadcrumbs.join('.')}.$extends") does not name a valid inheritance target!`)
|
||||||
let parents = other.extends || []
|
let parents = other.$extends || []
|
||||||
if (a.type(parents)() !== 'array') parents = [parents]
|
if (a.type(parents)() !== 'array') parents = [parents]
|
||||||
candidates = candidates.concat(parents)
|
candidates = candidates.concat(parents)
|
||||||
list.unshift(other)
|
list.unshift(other)
|
||||||
}
|
}
|
||||||
newval = extend.apply(this, list)
|
newval = extend.apply(this, list)
|
||||||
delete newval.extends
|
delete newval.$extends
|
||||||
}
|
}
|
||||||
result[key] = newval
|
result[key] = newval
|
||||||
breadcrumbs.pop()
|
breadcrumbs.pop()
|
||||||
|
@ -69,4 +69,4 @@ const _inherit = exports._inherit = (config, root, breadcrumbs) => {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
const inherit = exports.inherit = (config) => _inherit(config, config, [])
|
const inherit = exports.inherit = config => _inherit(config, config, [])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue