mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-06 15:47:30 +08:00
Grammar refactoring
* Grammar refactoring WIP * ISerializer.grammar * Fixing various bugs in the grammar * Small touch that improoves performance * Fix unknown values grammar * Various fixes * Serialization refactoring to drop suboject logic * Details fixed * Entity attributes initialization refactoring * JSDoc error fixed * Rename value key to default * Remove useless default * Revert string keys
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/** @typedef {import("./IEntity").default} IEntity */
|
||||
|
||||
export default class CalculatedType {
|
||||
export default class ComputedType {
|
||||
|
||||
#f
|
||||
|
||||
@@ -10,7 +10,7 @@ export default class CalculatedType {
|
||||
}
|
||||
|
||||
/** @param {IEntity} entity */
|
||||
calculate(entity) {
|
||||
compute(entity) {
|
||||
return this.#f(entity)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ export default class FormatTextEntity extends IEntity {
|
||||
static lookbehind = "LOCGEN_FORMAT_NAMED"
|
||||
static attributes = {
|
||||
value: {
|
||||
type: [new UnionType(LocalizedTextEntity, InvariantTextEntity, FormatTextEntity)]
|
||||
type: [new UnionType(LocalizedTextEntity, InvariantTextEntity, FormatTextEntity)],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -27,5 +27,6 @@ export default class FunctionReferenceEntity extends IEntity {
|
||||
super(values)
|
||||
/** @type {ObjectReferenceEntity} */ this.MemberParent
|
||||
/** @type {String} */ this.MemberName
|
||||
/** @type {GuidEntity} */ this.MemberGuid
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@ import IEntity from "./IEntity.js"
|
||||
export default class GuidEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
value: "",
|
||||
value: {
|
||||
default: "",
|
||||
},
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
import ComputedType from "./ComputedType.js"
|
||||
import SerializerFactory from "../serialization/SerializerFactory.js"
|
||||
import SubAttributesDeclaration from "./SubObject.js"
|
||||
import UnionType from "./UnionType.js"
|
||||
import Utility from "../Utility.js"
|
||||
|
||||
/**
|
||||
* @typedef {(entity: IEntity) => AnyValue} ValueSupplier
|
||||
* @typedef {(entity: IEntity) => AnyValueConstructor<AnyValue>} TypeSupplier
|
||||
* @typedef {IEntity | String | Number | BigInt | Boolean} AnySimpleValue
|
||||
* @typedef {AnySimpleValue | AnySimpleValue[]} AnyValue
|
||||
* @typedef {{
|
||||
* [key: String]: AttributeInformation | AnyValue | SubAttributesDeclaration
|
||||
* [key: String]: AttributeInformation
|
||||
* }} AttributeDeclarations
|
||||
* @typedef {typeof IEntity} EntityConstructor
|
||||
* @typedef {{
|
||||
* type?: AnyValueConstructor<AnyValue> | AnyValueConstructor<AnyValue>[] | UnionType | TypeSupplier,
|
||||
* value?: AnyValue | ValueSupplier,
|
||||
* type?: AnyValueConstructor<AnyValue> | AnyValueConstructor<AnyValue>[] | UnionType | ComputedType,
|
||||
* default?: AnyValue | ValueSupplier,
|
||||
* showDefault?: Boolean,
|
||||
* nullable?: Boolean,
|
||||
* ignored?: Boolean,
|
||||
@@ -32,6 +31,7 @@ import Utility from "../Utility.js"
|
||||
|
||||
export default class IEntity {
|
||||
|
||||
static lookbehind = ""
|
||||
/** @type {AttributeDeclarations} */
|
||||
static attributes = {}
|
||||
static defaultAttribute = {
|
||||
@@ -43,138 +43,6 @@ export default class IEntity {
|
||||
}
|
||||
|
||||
constructor(values = {}, suppressWarns = false) {
|
||||
/**
|
||||
* @param {Object} target
|
||||
* @param {Object} attributes
|
||||
* @param {Object} values
|
||||
* @param {String} prefix
|
||||
*/
|
||||
const defineAllAttributes = (target, attributes, values = {}, prefix = "") => {
|
||||
const valuesNames = Object.keys(values)
|
||||
const attributesNames = Object.keys(attributes)
|
||||
const allAttributesNames = Utility.mergeArrays(attributesNames, valuesNames)
|
||||
for (let attributeName of allAttributesNames) {
|
||||
let value = Utility.objectGet(values, [attributeName])
|
||||
/** @type {AttributeInformation} */
|
||||
let attribute = attributes[attributeName]
|
||||
|
||||
if (attribute instanceof SubAttributesDeclaration) {
|
||||
target[attributeName] = {}
|
||||
defineAllAttributes(
|
||||
target[attributeName],
|
||||
attribute.attributes,
|
||||
values[attributeName],
|
||||
attributeName + "."
|
||||
)
|
||||
continue
|
||||
}
|
||||
|
||||
if (!suppressWarns) {
|
||||
if (!(attributeName in attributes)) {
|
||||
console.warn(
|
||||
`UEBlueprint: Attribute ${prefix}${attributeName} in the serialized data is not defined in `
|
||||
+ `${this.constructor.name}.attributes`
|
||||
)
|
||||
} else if (
|
||||
valuesNames.length > 0
|
||||
&& !(attributeName in values)
|
||||
&& !(!attribute.showDefault || attribute.ignored)
|
||||
) {
|
||||
console.warn(
|
||||
`UEBlueprint: ${this.constructor.name} will add attribute ${prefix}${attributeName} not `
|
||||
+ "defined in the serialized data"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (!attribute) {
|
||||
// Remember attributeName can come from the values and be not defined in the attributes
|
||||
target[attributeName] = value
|
||||
continue
|
||||
}
|
||||
|
||||
let defaultValue = attribute.value
|
||||
let defaultType = attribute.type
|
||||
if (attribute.serialized && defaultType instanceof Function) {
|
||||
// If the attribute is serialized, the type must contain a function providing the type
|
||||
defaultType = /** @type {TypeSupplier} */(defaultType)(this)
|
||||
}
|
||||
if (defaultType instanceof Array) {
|
||||
defaultType = Array
|
||||
}
|
||||
if (defaultValue instanceof Function) {
|
||||
defaultValue = defaultValue(this)
|
||||
}
|
||||
if (defaultType === undefined) {
|
||||
defaultType = Utility.getType(defaultValue)
|
||||
}
|
||||
const assignAttribute = !attribute.predicate
|
||||
? v => target[attributeName] = v
|
||||
: v => {
|
||||
Object.defineProperties(target, {
|
||||
["#" + attributeName]: {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
},
|
||||
[attributeName]: {
|
||||
enumerable: true,
|
||||
get() {
|
||||
return this["#" + attributeName]
|
||||
},
|
||||
set(v) {
|
||||
if (!attribute.predicate?.(v)) {
|
||||
console.warn(
|
||||
`UEBlueprint: Tried to assign attribute ${prefix}${attributeName} to `
|
||||
+ `${this.constructor.name} not satisfying the predicate`
|
||||
)
|
||||
return
|
||||
}
|
||||
this["#" + attributeName] = v
|
||||
}
|
||||
},
|
||||
})
|
||||
this[attributeName] = v
|
||||
}
|
||||
|
||||
if (value !== undefined) {
|
||||
// Remember value can still be null
|
||||
if (value?.constructor === String && attribute.serialized && defaultType !== String) {
|
||||
value = SerializerFactory
|
||||
.getSerializer(/** @type {AnyValueConstructor<*>} */(defaultType))
|
||||
.deserialize(/** @type {String} */(value))
|
||||
}
|
||||
assignAttribute(Utility.sanitize(value, /** @type {AnyValueConstructor<*>} */(defaultType)))
|
||||
continue // We have a value, need nothing more
|
||||
}
|
||||
if (defaultType instanceof UnionType) {
|
||||
if (defaultValue != undefined) {
|
||||
defaultType = defaultType.types.find(
|
||||
type => defaultValue instanceof type || defaultValue.constructor == type
|
||||
) ?? defaultType.getFirstType()
|
||||
} else {
|
||||
defaultType = defaultType.getFirstType()
|
||||
}
|
||||
}
|
||||
if (defaultValue === undefined) {
|
||||
defaultValue = Utility.sanitize(new /** @type {AnyValueConstructor<*>} */(defaultType)())
|
||||
}
|
||||
if (!attribute.showDefault) {
|
||||
assignAttribute(undefined) // Declare undefined to preserve the order of attributes
|
||||
continue
|
||||
}
|
||||
if (attribute.serialized) {
|
||||
if (defaultType !== String && defaultValue.constructor === String) {
|
||||
defaultValue = SerializerFactory
|
||||
.getSerializer(/** @type {AnyValueConstructor<*>} */(defaultType))
|
||||
.deserialize(defaultValue)
|
||||
}
|
||||
}
|
||||
assignAttribute(Utility.sanitize(
|
||||
/** @type {AnyValue} */(defaultValue),
|
||||
/** @type {AnyValueConstructor<AnyValue>} */(defaultType)
|
||||
))
|
||||
}
|
||||
}
|
||||
const attributes = /** @type {typeof IEntity} */(this.constructor).attributes
|
||||
if (values.constructor !== Object && Object.keys(attributes).length === 1) {
|
||||
// Where there is just one attribute, option can be the value of that attribute
|
||||
@@ -182,39 +50,141 @@ export default class IEntity {
|
||||
[Object.keys(attributes)[0]]: values
|
||||
}
|
||||
}
|
||||
defineAllAttributes(this, attributes, values)
|
||||
const valuesNames = Object.keys(values)
|
||||
const attributesNames = Object.keys(attributes)
|
||||
const allAttributesNames = Utility.mergeArrays(attributesNames, valuesNames)
|
||||
for (let attributeName of allAttributesNames) {
|
||||
let value = values[attributeName]
|
||||
let attribute = /** @type {AttributeInformation} */(attributes[attributeName])
|
||||
|
||||
if (!suppressWarns) {
|
||||
if (!(attributeName in attributes)) {
|
||||
console.warn(
|
||||
`UEBlueprint: Attribute ${attributeName} in the serialized data is not defined in `
|
||||
+ `${this.constructor.name}.attributes`
|
||||
)
|
||||
} else if (
|
||||
valuesNames.length > 0
|
||||
&& !(attributeName in values)
|
||||
&& !(!attribute.showDefault || attribute.ignored)
|
||||
) {
|
||||
console.warn(
|
||||
`UEBlueprint: ${this.constructor.name} will add attribute ${attributeName} not `
|
||||
+ "defined in the serialized data"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (!attribute) {
|
||||
// Remember attributeName can come from the values and be not defined in the attributes
|
||||
// In that case just assign it and skip the rest
|
||||
this[attributeName] = value
|
||||
continue
|
||||
}
|
||||
|
||||
let defaultValue = attribute.default
|
||||
let defaultType = attribute.type
|
||||
if (defaultType instanceof ComputedType) {
|
||||
defaultType = defaultType.compute(this)
|
||||
}
|
||||
if (defaultType instanceof Array) {
|
||||
defaultType = Array
|
||||
}
|
||||
if (defaultValue instanceof Function) {
|
||||
defaultValue = defaultValue(this)
|
||||
}
|
||||
if (defaultType === undefined) {
|
||||
defaultType = Utility.getType(defaultValue)
|
||||
}
|
||||
const assignAttribute = !attribute.predicate
|
||||
? v => this[attributeName] = v
|
||||
: v => {
|
||||
Object.defineProperties(this, {
|
||||
["#" + attributeName]: {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
},
|
||||
[attributeName]: {
|
||||
enumerable: true,
|
||||
get() {
|
||||
return this["#" + attributeName]
|
||||
},
|
||||
set(v) {
|
||||
if (!attribute.predicate?.(v)) {
|
||||
console.warn(
|
||||
`UEBlueprint: Tried to assign attribute ${attributeName} to `
|
||||
+ `${this.constructor.name} not satisfying the predicate`
|
||||
)
|
||||
return
|
||||
}
|
||||
this["#" + attributeName] = v
|
||||
}
|
||||
},
|
||||
})
|
||||
this[attributeName] = v
|
||||
}
|
||||
|
||||
if (value !== undefined) {
|
||||
// Remember value can still be null
|
||||
if (value?.constructor === String && attribute.serialized && defaultType !== String) {
|
||||
value = SerializerFactory
|
||||
.getSerializer(/** @type {AnyValueConstructor<*>} */(defaultType))
|
||||
.deserialize(/** @type {String} */(value))
|
||||
}
|
||||
assignAttribute(Utility.sanitize(value, /** @type {AnyValueConstructor<*>} */(defaultType)))
|
||||
continue // We have a value, need nothing more
|
||||
}
|
||||
if (defaultType instanceof UnionType) {
|
||||
if (defaultValue != undefined) {
|
||||
defaultType = defaultType.types.find(
|
||||
type => defaultValue instanceof type || defaultValue.constructor == type
|
||||
) ?? defaultType.getFirstType()
|
||||
} else {
|
||||
defaultType = defaultType.getFirstType()
|
||||
}
|
||||
}
|
||||
if (defaultValue === undefined) {
|
||||
defaultValue = Utility.sanitize(new /** @type {AnyValueConstructor<*>} */(defaultType)())
|
||||
}
|
||||
if (!attribute.showDefault) {
|
||||
assignAttribute(undefined) // Declare undefined to preserve the order of attributes
|
||||
continue
|
||||
}
|
||||
if (attribute.serialized) {
|
||||
if (defaultType !== String && defaultValue.constructor === String) {
|
||||
defaultValue = SerializerFactory
|
||||
.getSerializer(/** @type {AnyValueConstructor<*>} */(defaultType))
|
||||
.deserialize(defaultValue)
|
||||
}
|
||||
}
|
||||
assignAttribute(Utility.sanitize(
|
||||
/** @type {AnyValue} */(defaultValue),
|
||||
/** @type {AnyValueConstructor<AnyValue>} */(defaultType)
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {AttributeDeclarations} attributes */
|
||||
static cleanupAttributes(attributes, prefix = "") {
|
||||
for (const attributeName in attributes) {
|
||||
if (attributes[attributeName] instanceof SubAttributesDeclaration) {
|
||||
this.cleanupAttributes(
|
||||
/** @type {SubAttributesDeclaration} */(attributes[attributeName]).attributes,
|
||||
prefix + "." + attributeName
|
||||
)
|
||||
continue
|
||||
}
|
||||
if (attributes[attributeName].constructor !== Object) {
|
||||
attributes[attributeName] = {
|
||||
value: attributes[attributeName],
|
||||
}
|
||||
}
|
||||
const attribute = /** @type {AttributeInformation} */(attributes[attributeName])
|
||||
if (attribute.type === undefined && !(attribute.value instanceof Function)) {
|
||||
attribute.type = Utility.getType(attribute.value)
|
||||
if (attribute.type === undefined && !(attribute.default instanceof Function)) {
|
||||
attribute.type = Utility.getType(attribute.default)
|
||||
}
|
||||
attributes[attributeName] = {
|
||||
...IEntity.defaultAttribute,
|
||||
...attribute,
|
||||
}
|
||||
if (attribute.value === undefined && attribute.type === undefined) {
|
||||
throw new Error(
|
||||
`UEBlueprint: Expected either "type" or "value" property in ${this.name} attribute ${prefix}`
|
||||
+ attributeName
|
||||
)
|
||||
if (attribute.default === undefined) {
|
||||
if (attribute.type === undefined) {
|
||||
throw new Error(
|
||||
`UEBlueprint: Expected either "type" or "value" property in ${this.name} attribute ${prefix}`
|
||||
+ attributeName
|
||||
)
|
||||
}
|
||||
attribute[attributeName] = Utility.sanitize(undefined, attribute.type)
|
||||
}
|
||||
if (attribute.value === null) {
|
||||
if (attribute.default === null) {
|
||||
attributes[attributeName].nullable = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@ import IEntity from "./IEntity.js"
|
||||
export default class IdentifierEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
value: "",
|
||||
value: {
|
||||
default: "",
|
||||
},
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
@@ -5,7 +5,7 @@ export default class Integer64Entity extends IEntity {
|
||||
static attributes = {
|
||||
...super.attributes,
|
||||
value: {
|
||||
value: 0n,
|
||||
default: 0n,
|
||||
predicate: v => v >= -(1n << 63n) && v < 1n << 63n,
|
||||
},
|
||||
}
|
||||
@@ -14,9 +14,10 @@ export default class Integer64Entity extends IEntity {
|
||||
this.cleanupAttributes(this.attributes)
|
||||
}
|
||||
|
||||
/** @param {BigInt | Number} value */
|
||||
constructor(value = 0) {
|
||||
super(value)
|
||||
/** @type {Number} */ this.value
|
||||
/** @type {BigInt | Number} */ this.value
|
||||
}
|
||||
|
||||
valueOf() {
|
||||
|
||||
@@ -5,7 +5,7 @@ export default class IntegerEntity extends IEntity {
|
||||
static attributes = {
|
||||
...super.attributes,
|
||||
value: {
|
||||
value: 0,
|
||||
default: 0,
|
||||
predicate: v => v % 1 == 0 && v > 1 << 31 && v < -(1 << 31),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ export default class InvariantTextEntity extends IEntity {
|
||||
|
||||
static lookbehind = "INVTEXT"
|
||||
static attributes = {
|
||||
value: "",
|
||||
value: {
|
||||
default: "",
|
||||
},
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
@@ -4,13 +4,23 @@ import IEntity from "./IEntity.js"
|
||||
export default class KeyBindingEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
ActionName: "",
|
||||
bShift: false,
|
||||
bCtrl: false,
|
||||
bAlt: false,
|
||||
bCmd: false,
|
||||
ActionName: {
|
||||
default: "",
|
||||
},
|
||||
bShift: {
|
||||
default: false,
|
||||
},
|
||||
bCtrl: {
|
||||
default: false,
|
||||
},
|
||||
bAlt: {
|
||||
default: false,
|
||||
},
|
||||
bCmd: {
|
||||
default: false,
|
||||
},
|
||||
Key: {
|
||||
type: IdentifierEntity
|
||||
type: IdentifierEntity,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -19,11 +29,6 @@ export default class KeyBindingEntity extends IEntity {
|
||||
}
|
||||
|
||||
constructor(values = {}) {
|
||||
values.ActionName = values.ActionName ?? ""
|
||||
values.bShift = values.bShift ?? false
|
||||
values.bCtrl = values.bCtrl ?? false
|
||||
values.bAlt = values.bAlt ?? false
|
||||
values.bCmd = values.bCmd ?? false
|
||||
super(values)
|
||||
/** @type {String} */ this.ActionName
|
||||
/** @type {Boolean} */ this.bShift
|
||||
|
||||
@@ -19,7 +19,7 @@ export default class LinearColorEntity extends IEntity {
|
||||
},
|
||||
A: {
|
||||
type: RealUnitEntity,
|
||||
value: () => new RealUnitEntity(1),
|
||||
default: () => new RealUnitEntity(1),
|
||||
},
|
||||
H: {
|
||||
type: RealUnitEntity,
|
||||
|
||||
@@ -5,9 +5,15 @@ export default class LocalizedTextEntity extends IEntity {
|
||||
|
||||
static lookbehind = "NSLOCTEXT"
|
||||
static attributes = {
|
||||
namespace: "",
|
||||
key: "",
|
||||
value: "",
|
||||
namespace: {
|
||||
default: "",
|
||||
},
|
||||
key: {
|
||||
default: "",
|
||||
},
|
||||
value: {
|
||||
default: "",
|
||||
},
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
@@ -3,7 +3,7 @@ import Utility from "../Utility.js"
|
||||
|
||||
export default class NaturalNumberEntity extends IntegerEntity {
|
||||
|
||||
constructor(values) {
|
||||
constructor(values = 0) {
|
||||
super(values)
|
||||
this.value = Math.round(Utility.clamp(this.value, 0))
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ export default class ObjectEntity extends IEntity {
|
||||
Class: {
|
||||
type: ObjectReferenceEntity,
|
||||
},
|
||||
Name: "",
|
||||
Name: {
|
||||
default: "",
|
||||
},
|
||||
AxisKey: {
|
||||
type: SymbolEntity,
|
||||
showDefault: false,
|
||||
@@ -29,21 +31,21 @@ export default class ObjectEntity extends IEntity {
|
||||
showDefault: false,
|
||||
},
|
||||
bIsPureFunc: {
|
||||
value: false,
|
||||
default: false,
|
||||
showDefault: false,
|
||||
},
|
||||
bIsConstFunc: {
|
||||
value: false,
|
||||
default: false,
|
||||
showDefault: false,
|
||||
},
|
||||
VariableReference: {
|
||||
type: VariableReferenceEntity,
|
||||
value: null,
|
||||
default: null,
|
||||
showDefault: false,
|
||||
},
|
||||
SelfContextInfo: {
|
||||
type: SymbolEntity,
|
||||
value: null,
|
||||
default: null,
|
||||
showDefault: false,
|
||||
},
|
||||
DelegatePropertyName: {
|
||||
@@ -60,12 +62,12 @@ export default class ObjectEntity extends IEntity {
|
||||
},
|
||||
EventReference: {
|
||||
type: FunctionReferenceEntity,
|
||||
value: null,
|
||||
default: null,
|
||||
showDefault: false,
|
||||
},
|
||||
FunctionReference: {
|
||||
type: FunctionReferenceEntity,
|
||||
value: null,
|
||||
default: null,
|
||||
showDefault: false,
|
||||
},
|
||||
CustomFunctionName: {
|
||||
@@ -74,12 +76,12 @@ export default class ObjectEntity extends IEntity {
|
||||
},
|
||||
TargetType: {
|
||||
type: ObjectReferenceEntity,
|
||||
value: null,
|
||||
default: null,
|
||||
showDefault: false,
|
||||
},
|
||||
MacroGraphReference: {
|
||||
type: MacroGraphReferenceEntity,
|
||||
value: null,
|
||||
default: null,
|
||||
showDefault: false,
|
||||
},
|
||||
Enum: {
|
||||
@@ -136,7 +138,7 @@ export default class ObjectEntity extends IEntity {
|
||||
},
|
||||
bColorCommentBubble: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
default: false,
|
||||
showDefault: false,
|
||||
},
|
||||
MoveMode: {
|
||||
@@ -173,12 +175,12 @@ export default class ObjectEntity extends IEntity {
|
||||
},
|
||||
AdvancedPinDisplay: {
|
||||
type: IdentifierEntity,
|
||||
value: null,
|
||||
default: null,
|
||||
showDefault: false,
|
||||
},
|
||||
EnabledState: {
|
||||
type: IdentifierEntity,
|
||||
value: null,
|
||||
default: null,
|
||||
showDefault: false,
|
||||
},
|
||||
NodeGuid: {
|
||||
@@ -190,7 +192,7 @@ export default class ObjectEntity extends IEntity {
|
||||
},
|
||||
ErrorMsg: {
|
||||
type: String,
|
||||
value: "",
|
||||
default: "",
|
||||
showDefault: false,
|
||||
},
|
||||
CustomProperties: {
|
||||
@@ -412,7 +414,7 @@ export default class ObjectEntity extends IEntity {
|
||||
}
|
||||
|
||||
getDelegatePin() {
|
||||
return this.CustomProperties?.find(pin => pin.PinType.PinCategory === "delegate")
|
||||
return this.CustomProperties?.find(pin => pin.PinType$PinCategory === "delegate")
|
||||
}
|
||||
|
||||
nodeDisplayName() {
|
||||
|
||||
@@ -3,8 +3,12 @@ import IEntity from "./IEntity.js"
|
||||
export default class ObjectReferenceEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
type: "",
|
||||
path: "",
|
||||
type: {
|
||||
default: "",
|
||||
},
|
||||
path: {
|
||||
default: "",
|
||||
},
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
@@ -3,7 +3,9 @@ import IEntity from "./IEntity.js"
|
||||
export default class PathSymbolEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
value: "",
|
||||
value: {
|
||||
default: "",
|
||||
},
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import ByteEntity from "./ByteEntity.js"
|
||||
import ComputedType from "./ComputedType.js"
|
||||
import Configuration from "../Configuration.js"
|
||||
import EnumEntity from "./EnumEntity.js"
|
||||
import FormatTextEntity from "./FormatTextEntity.js"
|
||||
@@ -17,7 +18,6 @@ import RotatorEntity from "./RotatorEntity.js"
|
||||
import SimpleSerializationRotatorEntity from "./SimpleSerializationRotatorEntity.js"
|
||||
import SimpleSerializationVector2DEntity from "./SimpleSerializationVector2DEntity.js"
|
||||
import SimpleSerializationVectorEntity from "./SimpleSerializationVectorEntity.js"
|
||||
import SubAttributesDeclaration from "./SubObject.js"
|
||||
import UnionType from "./UnionType.js"
|
||||
import Utility from "../Utility.js"
|
||||
import Vector2DEntity from "./Vector2DEntity.js"
|
||||
@@ -56,7 +56,9 @@ export default class PinEntity extends IEntity {
|
||||
PinId: {
|
||||
type: GuidEntity,
|
||||
},
|
||||
PinName: "",
|
||||
PinName: {
|
||||
default: "",
|
||||
},
|
||||
PinFriendlyName: {
|
||||
type: new UnionType(LocalizedTextEntity, FormatTextEntity, String),
|
||||
showDefault: false,
|
||||
@@ -69,36 +71,48 @@ export default class PinEntity extends IEntity {
|
||||
type: String,
|
||||
showDefault: false,
|
||||
},
|
||||
PinType: new SubAttributesDeclaration({
|
||||
PinCategory: "",
|
||||
PinSubCategory: "",
|
||||
PinSubCategoryObject: {
|
||||
type: ObjectReferenceEntity,
|
||||
},
|
||||
PinSubCategoryMemberReference: {
|
||||
type: FunctionReferenceEntity,
|
||||
value: null,
|
||||
},
|
||||
PinValueType: {
|
||||
type: PinTypeEntity,
|
||||
value: null,
|
||||
},
|
||||
ContainerType: {
|
||||
type: PathSymbolEntity,
|
||||
},
|
||||
bIsReference: false,
|
||||
bIsConst: false,
|
||||
bIsWeakPointer: false,
|
||||
bIsUObjectWrapper: false,
|
||||
bSerializeAsSinglePrecisionFloat: false,
|
||||
}),
|
||||
PinType$PinCategory: {
|
||||
default: "",
|
||||
},
|
||||
PinType$PinSubCategory: {
|
||||
default: "",
|
||||
},
|
||||
PinType$PinSubCategoryObject: {
|
||||
type: ObjectReferenceEntity,
|
||||
},
|
||||
PinType$PinSubCategoryMemberReference: {
|
||||
type: FunctionReferenceEntity,
|
||||
default: null,
|
||||
},
|
||||
PinType$PinValueType: {
|
||||
type: PinTypeEntity,
|
||||
default: null,
|
||||
},
|
||||
PinType$ContainerType: {
|
||||
type: PathSymbolEntity,
|
||||
},
|
||||
PinType$bIsReference: {
|
||||
default: false,
|
||||
},
|
||||
PinType$bIsConst: {
|
||||
default: false,
|
||||
},
|
||||
PinType$bIsWeakPointer: {
|
||||
default: false,
|
||||
},
|
||||
PinType$bIsUObjectWrapper: {
|
||||
default: false,
|
||||
},
|
||||
PinType$bSerializeAsSinglePrecisionFloat: {
|
||||
default: false,
|
||||
},
|
||||
LinkedTo: {
|
||||
type: [PinReferenceEntity],
|
||||
showDefault: false,
|
||||
},
|
||||
DefaultValue: {
|
||||
/** @param {PinEntity} pinEntity */
|
||||
type: pinEntity => pinEntity.getEntityType(true) ?? String,
|
||||
type: new ComputedType(pinEntity => pinEntity.getEntityType(true) ?? String),
|
||||
serialized: true,
|
||||
showDefault: false,
|
||||
},
|
||||
@@ -109,17 +123,29 @@ export default class PinEntity extends IEntity {
|
||||
DefaultObject: {
|
||||
type: ObjectReferenceEntity,
|
||||
showDefault: false,
|
||||
value: null,
|
||||
default: null,
|
||||
},
|
||||
PersistentGuid: {
|
||||
type: GuidEntity,
|
||||
},
|
||||
bHidden: false,
|
||||
bNotConnectable: false,
|
||||
bDefaultValueIsReadOnly: false,
|
||||
bDefaultValueIsIgnored: false,
|
||||
bAdvancedView: false,
|
||||
bOrphanedPin: false,
|
||||
bHidden: {
|
||||
default: false,
|
||||
},
|
||||
bNotConnectable: {
|
||||
default: false,
|
||||
},
|
||||
bDefaultValueIsReadOnly: {
|
||||
default: false,
|
||||
},
|
||||
bDefaultValueIsIgnored: {
|
||||
default: false,
|
||||
},
|
||||
bAdvancedView: {
|
||||
default: false,
|
||||
},
|
||||
bOrphanedPin: {
|
||||
default: false,
|
||||
},
|
||||
}
|
||||
|
||||
static {
|
||||
@@ -133,21 +159,17 @@ export default class PinEntity extends IEntity {
|
||||
/** @type {LocalizedTextEntity | String} */ this.PinFriendlyName
|
||||
/** @type {String} */ this.PinToolTip
|
||||
/** @type {String} */ this.Direction
|
||||
/**
|
||||
* @type {{
|
||||
* PinCategory: String,
|
||||
* PinSubCategory: String,
|
||||
* PinSubCategoryObject: ObjectReferenceEntity,
|
||||
* PinSubCategoryMemberReference: FunctionReferenceEntity,
|
||||
* PinValueType: PinTypeEntity,
|
||||
* ContainerType: PathSymbolEntity,
|
||||
* bIsReference: Boolean,
|
||||
* bIsConst: Boolean,
|
||||
* bIsWeakPointer: Boolean,
|
||||
* bIsUObjectWrapper: Boolean,
|
||||
* bSerializeAsSinglePrecisionFloat: Boolean,
|
||||
* }}
|
||||
*/ this.PinType
|
||||
/** @type {String} */ this.PinType$PinCategory
|
||||
/** @type {String} */ this.PinType$PinSubCategory
|
||||
/** @type {ObjectReferenceEntity} */ this.PinType$PinSubCategoryObject
|
||||
/** @type {FunctionReferenceEntity} */ this.PinType$PinSubCategoryMemberReference
|
||||
/** @type {PinTypeEntity} */ this.PinType$PinValueType
|
||||
/** @type {PathSymbolEntity} */ this.PinType$ContainerType
|
||||
/** @type {Boolean} */ this.PinType$bIsReference
|
||||
/** @type {Boolean} */ this.PinType$bIsConst
|
||||
/** @type {Boolean} */ this.PinType$bIsWeakPointer
|
||||
/** @type {Boolean} */ this.PinType$bIsUObjectWrapper
|
||||
/** @type {Boolean} */ this.PinType$bIsUObjectWrapper
|
||||
/** @type {PinReferenceEntity[]} */ this.LinkedTo
|
||||
/** @type {T} */ this.DefaultValue
|
||||
/** @type {String} */ this.AutogeneratedDefaultValue
|
||||
@@ -162,12 +184,12 @@ export default class PinEntity extends IEntity {
|
||||
}
|
||||
|
||||
getType() {
|
||||
const subCategory = this.PinType.PinSubCategoryObject
|
||||
if (this.PinType.PinCategory === "struct" || this.PinType.PinCategory === "object") {
|
||||
const subCategory = this.PinType$PinSubCategoryObject
|
||||
if (this.PinType$PinCategory === "struct" || this.PinType$PinCategory === "object") {
|
||||
return subCategory.path
|
||||
}
|
||||
if (
|
||||
this.PinType.PinCategory === "byte"
|
||||
this.PinType$PinCategory === "byte"
|
||||
&& (
|
||||
subCategory.type === Configuration.nodeType.enum
|
||||
|| subCategory.type === Configuration.nodeType.userDefinedEnum
|
||||
@@ -175,7 +197,7 @@ export default class PinEntity extends IEntity {
|
||||
) {
|
||||
return "enum"
|
||||
}
|
||||
return this.PinType.PinCategory
|
||||
return this.PinType$PinCategory
|
||||
}
|
||||
|
||||
getEntityType(alternative = false) {
|
||||
@@ -201,17 +223,17 @@ export default class PinEntity extends IEntity {
|
||||
|
||||
/** @param {PinEntity} other */
|
||||
copyTypeFrom(other) {
|
||||
this.PinType.PinCategory = other.PinType.PinCategory
|
||||
this.PinType.PinSubCategory = other.PinType.PinSubCategory
|
||||
this.PinType.PinSubCategoryObject = other.PinType.PinSubCategoryObject
|
||||
this.PinType.PinSubCategoryMemberReference = other.PinType.PinSubCategoryMemberReference
|
||||
this.PinType.PinValueType = other.PinType.PinValueType
|
||||
this.PinType.ContainerType = other.PinType.ContainerType
|
||||
this.PinType.bIsReference = other.PinType.bIsReference
|
||||
this.PinType.bIsConst = other.PinType.bIsConst
|
||||
this.PinType.bIsWeakPointer = other.PinType.bIsWeakPointer
|
||||
this.PinType.bIsUObjectWrapper = other.PinType.bIsUObjectWrapper
|
||||
this.PinType.bSerializeAsSinglePrecisionFloat = other.PinType.bSerializeAsSinglePrecisionFloat
|
||||
this.PinType$PinCategory = other.PinType$PinCategory
|
||||
this.PinType$PinSubCategory = other.PinType$PinSubCategory
|
||||
this.PinType$PinSubCategoryObject = other.PinType$PinSubCategoryObject
|
||||
this.PinType$PinSubCategoryMemberReference = other.PinType$PinSubCategoryMemberReference
|
||||
this.PinType$PinValueType = other.PinType$PinValueType
|
||||
this.PinType$ContainerType = other.PinType$ContainerType
|
||||
this.PinType$bIsReference = other.PinType$bIsReference
|
||||
this.PinType$bIsConst = other.PinType$bIsConst
|
||||
this.PinType$bIsWeakPointer = other.PinType$bIsWeakPointer
|
||||
this.PinType$bIsUObjectWrapper = other.PinType$bIsUObjectWrapper
|
||||
this.PinType$bSerializeAsSinglePrecisionFloat = other.PinType$bSerializeAsSinglePrecisionFloat
|
||||
}
|
||||
|
||||
getDefaultValue(maybeCreate = false) {
|
||||
@@ -222,7 +244,7 @@ export default class PinEntity extends IEntity {
|
||||
}
|
||||
|
||||
isExecution() {
|
||||
return this.PinType.PinCategory === "exec"
|
||||
return this.PinType$PinCategory === "exec"
|
||||
}
|
||||
|
||||
isHidden() {
|
||||
@@ -280,13 +302,13 @@ export default class PinEntity extends IEntity {
|
||||
}
|
||||
|
||||
getSubCategory() {
|
||||
return this.PinType.PinSubCategoryObject.path
|
||||
return this.PinType$PinSubCategoryObject.path
|
||||
}
|
||||
|
||||
/** @return {CSSResult} */
|
||||
pinColor() {
|
||||
return Configuration.pinColor[this.getType()]
|
||||
?? Configuration.pinColor[this.PinType.PinCategory]
|
||||
?? Configuration.pinColor[this.PinType$PinCategory]
|
||||
?? Configuration.pinColor["default"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,23 +4,23 @@ export default class PinTypeEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
TerminalCategory: {
|
||||
value: "",
|
||||
default: "",
|
||||
showDefault: false,
|
||||
},
|
||||
TerminalSubCategory: {
|
||||
value: "",
|
||||
default: "",
|
||||
showDefault: false,
|
||||
},
|
||||
bTerminalIsConst: {
|
||||
value: false,
|
||||
default: false,
|
||||
showDefault: false,
|
||||
},
|
||||
bTerminalIsWeakPointer: {
|
||||
value: false,
|
||||
default: false,
|
||||
showDefault: false,
|
||||
},
|
||||
bTerminalIsUObjectWrapper: {
|
||||
value: false,
|
||||
default: false,
|
||||
showDefault: false,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ export default class RotatorEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
R: {
|
||||
value: 0,
|
||||
default: 0,
|
||||
},
|
||||
P: {
|
||||
value: 0,
|
||||
default: 0,
|
||||
},
|
||||
Y: {
|
||||
value: 0,
|
||||
default: 0,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
export default class SerializedType {
|
||||
|
||||
#types
|
||||
get types() {
|
||||
return this.#types
|
||||
}
|
||||
set types(v) {
|
||||
this.#types = v
|
||||
}
|
||||
|
||||
#stringFallback
|
||||
get stringFallback() {
|
||||
return this.#stringFallback
|
||||
}
|
||||
set stringFallback(v) {
|
||||
this.#stringFallback = v
|
||||
}
|
||||
|
||||
constructor([...acceptedTypes], stringFallback = true) {
|
||||
this.#types = [...new Set([
|
||||
...acceptedTypes,
|
||||
...(stringFallback ? [String] : [])
|
||||
])]
|
||||
this.#stringFallback = stringFallback
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
/** @typedef {import("./IEntity").AttributeDeclarations} AttributeDeclarations */
|
||||
|
||||
export default class SubAttributesDeclaration {
|
||||
|
||||
/** @param {AttributeDeclarations} attributes */
|
||||
constructor(attributes) {
|
||||
this.attributes = attributes
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@ import IEntity from "./IEntity.js"
|
||||
export default class SymbolEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
value: "",
|
||||
value: {
|
||||
default: "",
|
||||
},
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
@@ -4,7 +4,9 @@ import Utility from "../Utility.js"
|
||||
export default class RealUnitEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
value: 0,
|
||||
value: {
|
||||
default: 0,
|
||||
},
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
@@ -3,9 +3,8 @@ import IEntity from "./IEntity.js"
|
||||
export default class UnknownKeysEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
lookbehind:
|
||||
{
|
||||
value: "",
|
||||
lookbehind: {
|
||||
default: "",
|
||||
showDefault: false,
|
||||
ignore: true,
|
||||
},
|
||||
@@ -16,7 +15,7 @@ export default class UnknownKeysEntity extends IEntity {
|
||||
}
|
||||
|
||||
constructor(values) {
|
||||
super(values)
|
||||
super(values, true)
|
||||
/** @type {String} */ this.lookbehind
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,15 +5,17 @@ export default class VariableReferenceEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
MemberScope: {
|
||||
value: "",
|
||||
default: "",
|
||||
showDefault: false,
|
||||
},
|
||||
MemberName: "",
|
||||
MemberName: {
|
||||
default: "",
|
||||
},
|
||||
MemberGuid: {
|
||||
type: GuidEntity,
|
||||
},
|
||||
bSelfContext: {
|
||||
value: false,
|
||||
default: false,
|
||||
showDefault: false,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ export default class Vector2DEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
X: {
|
||||
value: 0,
|
||||
default: 0,
|
||||
expected: true,
|
||||
},
|
||||
Y: {
|
||||
value: 0,
|
||||
default: 0,
|
||||
expected: true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -4,15 +4,15 @@ export default class VectorEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
X: {
|
||||
value: 0,
|
||||
default: 0,
|
||||
expected: true,
|
||||
},
|
||||
Y: {
|
||||
value: 0,
|
||||
default: 0,
|
||||
expected: true,
|
||||
},
|
||||
Z: {
|
||||
value: 0,
|
||||
default: 0,
|
||||
expected: true,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user