Type initialization using objects

This commit is contained in:
barsdeveloper
2023-01-02 00:22:50 +01:00
parent d391480f2c
commit 984bf32b51
43 changed files with 1511 additions and 831 deletions

View File

@@ -1,4 +1,3 @@
import CalculatedType from "./CalculatedType"
import GuidEntity from "./GuidEntity"
import IEntity from "./IEntity"
import IntegerEntity from "./IntegerEntity"
@@ -10,13 +9,13 @@ import RotatorEntity from "./RotatorEntity"
import SimpleSerializationRotatorEntity from "./SimpleSerializationRotatorEntity"
import SimpleSerializationVector2DEntity from "./SimpleSerializationVector2DEntity"
import SimpleSerializationVectorEntity from "./SimpleSerializationVectorEntity"
import TypeInitialization from "./TypeInitialization"
import SubAttributesDeclaration from "./SubObject"
import UnionType from "./UnionType"
import Utility from "../Utility"
import Vector2DEntity from "./Vector2DEntity"
import VectorEntity from "./VectorEntity"
/** @typedef {import("./TypeInitialization").AnyValue} AnyValue */
/** @typedef {import("./IEntity").AnyValue} AnyValue */
/** @template {AnyValue} T */
export default class PinEntity extends IEntity {
@@ -40,38 +39,67 @@ export default class PinEntity extends IEntity {
}
static lookbehind = "Pin"
static attributes = {
PinId: GuidEntity,
PinId: {
type: GuidEntity,
},
PinName: "",
PinFriendlyName: new TypeInitialization(new UnionType(LocalizedTextEntity, String), false, null),
PinToolTip: new TypeInitialization(String, false, ""),
Direction: new TypeInitialization(String, false, ""),
PinType: {
PinFriendlyName: {
type: new UnionType(LocalizedTextEntity, String),
showDefault: false,
},
PinToolTip: {
type: String,
showDefault: false,
},
Direction: {
type: String,
showDefault: false,
},
PinType: new SubAttributesDeclaration({
PinCategory: "",
PinSubCategory: "",
PinSubCategoryObject: ObjectReferenceEntity,
PinSubCategoryMemberReference: null,
PinValueType: null,
ContainerType: ObjectReferenceEntity,
PinSubCategoryObject: {
type: ObjectReferenceEntity,
},
PinSubCategoryMemberReference: {
type: ObjectReferenceEntity,
value: null,
},
PinValueType: {
type: String,
value: null,
},
ContainerType: {
type: ObjectReferenceEntity,
},
bIsReference: false,
bIsConst: false,
bIsWeakPointer: false,
bIsUObjectWrapper: false,
bSerializeAsSinglePrecisionFloat: false,
}),
LinkedTo: {
type: [PinReferenceEntity],
showDefault: false,
},
DefaultValue: {
/** @param {PinEntity} pinEntity */
type: pinEntity => pinEntity.getEntityType(true) ?? String,
serialized: true,
showDefault: false,
},
AutogeneratedDefaultValue: {
type: String,
showDefault: false,
},
DefaultObject: {
type: ObjectReferenceEntity,
showDefault: false,
value: null,
},
PersistentGuid: {
type: GuidEntity,
},
LinkedTo: new TypeInitialization([PinReferenceEntity], false),
DefaultValue:
new CalculatedType(
/** @param {PinEntity} pinEntity */
pinEntity => new TypeInitialization(
pinEntity.getEntityType(true) ?? String,
false,
undefined,
true
)
),
AutogeneratedDefaultValue: new TypeInitialization(String, false),
DefaultObject: new TypeInitialization(ObjectReferenceEntity, false, null),
PersistentGuid: GuidEntity,
bHidden: false,
bNotConnectable: false,
bDefaultValueIsReadOnly: false,
@@ -80,6 +108,10 @@ export default class PinEntity extends IEntity {
bOrphanedPin: false,
}
static {
this.cleanupAttributes(this.attributes)
}
constructor(values = {}, suppressWarns = false) {
super(values, suppressWarns)
/** @type {GuidEntity} */ this.PinId