Various improvements (#13)

* Union lookbehind

* Fix quoted inline array
This commit is contained in:
barsdeveloper
2023-09-02 14:08:29 +02:00
committed by GitHub
parent 11f819e6d9
commit fd991b94b3
17 changed files with 313 additions and 144 deletions

View File

@@ -11,7 +11,7 @@ import ObjectReferenceEntity from "./ObjectReferenceEntity.js"
import PinEntity from "./PinEntity.js"
import SVGIcon from "../SVGIcon.js"
import SymbolEntity from "./SymbolEntity.js"
import UnionType from "./UnionType.js"
import Union from "./Union.js"
import UnknownPinEntity from "./UnknownPinEntity.js"
import Utility from "../Utility.js"
import VariableReferenceEntity from "./VariableReferenceEntity.js"
@@ -33,9 +33,12 @@ export default class ObjectEntity extends IEntity {
ObjectRef: {
type: ObjectReferenceEntity,
},
PinTags: {
type: [null],
inlined: true,
},
PinNames: {
type: [String],
default: undefined, // To keep the order, may be defined in additionalPinInserter()
inlined: true,
},
AxisKey: {
@@ -46,7 +49,6 @@ export default class ObjectEntity extends IEntity {
},
NumAdditionalInputs: {
type: Number,
default: undefined, // To keep the order, may be defined in additionalPinInserter()
},
bIsPureFunc: {
type: Boolean,
@@ -224,7 +226,7 @@ export default class ObjectEntity extends IEntity {
type: String,
},
CustomProperties: {
type: [new UnionType(PinEntity, UnknownPinEntity)],
type: [new Union(PinEntity, UnknownPinEntity)],
},
}
@@ -305,6 +307,7 @@ export default class ObjectEntity extends IEntity {
/** @type {String} */ this.Name
/** @type {ObjectReferenceEntity?} */ this.ExportPath
/** @type {ObjectReferenceEntity?} */ this.ObjectRef
/** @type {null[]} */ this.PinTags
/** @type {String[]} */ this.PinNames
/** @type {SymbolEntity?} */ this.AxisKey
/** @type {SymbolEntity?} */ this.InputAxisKey
@@ -993,13 +996,23 @@ export default class ObjectEntity extends IEntity {
case Configuration.paths.multiGate:
pinEntities ??= () => this.getPinEntities().filter(pinEntity => pinEntity.isOutput())
pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.match(/^\s*Out[_\s]+(\d+)\s*$/i)?.[1])
pinNameFromIndex ??= (index, min = -1, max = -1) => `Out ${index >= 0 ? index : min > 0 ? "Out 0" : max + 1}`
pinNameFromIndex ??= (index, min = -1, max = -1) =>
`Out ${index >= 0 ? index : min > 0 ? "Out 0" : max + 1}`
break
case Configuration.paths.switchInteger:
pinEntities ??= () => this.getPinEntities().filter(pinEntity => pinEntity.isOutput())
pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.match(/^\s*(\d+)\s*$/)?.[1])
pinNameFromIndex ??= (index, min = -1, max = -1) => (index < 0 ? max + 1 : index).toString()
break
case Configuration.paths.switchGameplayTag:
pinNameFromIndex ??= (index, min = -1, max = -1) => {
const result = `Case_${index >= 0 ? index : min > 0 ? "0" : max + 1}`
this.PinNames ??= []
this.PinNames.push(result)
delete this.PinTags[this.PinTags.length - 1]
this.PinTags[this.PinTags.length] = null
return result
}
case Configuration.paths.switchName:
case Configuration.paths.switchString:
pinEntities ??= () => this.getPinEntities().filter(pinEntity => pinEntity.isOutput())