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,
|
||||
text: '',
|
||||
align: 'left',
|
||||
mirrored: '!mirrored'
|
||||
mirrored: '=mirrored'
|
||||
},
|
||||
body: p => {
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ const footprint = exports._footprint = (config, name, points, point, net_indexer
|
|||
for (const net_ref of (fp.nets || [])) {
|
||||
let net = nets[net_ref]
|
||||
a.sane(net, `${name}.nets.${net_ref}`, 'string')()
|
||||
if (net.startsWith('!') && point) {
|
||||
if (net.startsWith('=') && point) {
|
||||
const indirect = net.substring(1)
|
||||
net = point.meta[indirect]
|
||||
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 || {}))) {
|
||||
let value = params[param] === undefined ? fp.params[param] : params[param]
|
||||
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)
|
||||
value = point.meta[indirect]
|
||||
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 a = require('./assert')
|
||||
|
||||
const unnest = exports.unnest = (config) => {
|
||||
const unnest = exports.unnest = config => {
|
||||
if (a.type(config)() !== 'object') return config
|
||||
const result = {}
|
||||
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 from_type = a.type(from)()
|
||||
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 (from_type == 'object') {
|
||||
const res = u.deepcopy(to)
|
||||
|
@ -47,21 +47,21 @@ const _inherit = exports._inherit = (config, root, breadcrumbs) => {
|
|||
for (const [key, val] of Object.entries(config)) {
|
||||
breadcrumbs.push(key)
|
||||
let newval = _inherit(val, root, breadcrumbs)
|
||||
if (newval && newval.extends !== undefined) {
|
||||
let candidates = u.deepcopy(newval.extends)
|
||||
if (newval && newval.$extends !== undefined) {
|
||||
let candidates = u.deepcopy(newval.$extends)
|
||||
if (a.type(candidates)() !== 'array') candidates = [candidates]
|
||||
const list = [newval]
|
||||
while (candidates.length) {
|
||||
const path = candidates.shift()
|
||||
const other = u.deepcopy(u.deep(root, path))
|
||||
a.assert(other, `"${path}" (reached from "${breadcrumbs.join('.')}.extends") does not name a valid inheritance target!`)
|
||||
let parents = other.extends || []
|
||||
a.assert(other, `"${path}" (reached from "${breadcrumbs.join('.')}.$extends") does not name a valid inheritance target!`)
|
||||
let parents = other.$extends || []
|
||||
if (a.type(parents)() !== 'array') parents = [parents]
|
||||
candidates = candidates.concat(parents)
|
||||
list.unshift(other)
|
||||
}
|
||||
newval = extend.apply(this, list)
|
||||
delete newval.extends
|
||||
delete newval.$extends
|
||||
}
|
||||
result[key] = newval
|
||||
breadcrumbs.pop()
|
||||
|
@ -69,4 +69,4 @@ const _inherit = exports._inherit = (config, root, breadcrumbs) => {
|
|||
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