Various fixes, tests and refactoring

This commit is contained in:
barsdeveloper
2023-01-17 22:22:25 +01:00
parent bb84b31b07
commit 47106f748d
26 changed files with 580 additions and 234 deletions

View File

@@ -1,5 +1,5 @@
import ByteEntity from "./ByteEntity"
import SymbolEntity from "./SymbolEntity"
export default class EnumEntity extends ByteEntity {
export default class EnumEntity extends SymbolEntity {
}

View File

@@ -52,7 +52,8 @@ export default class IEntity {
const defineAllAttributes = (target, attributes, values = {}, prefix = "") => {
const valuesNames = Object.keys(values)
const attributesNames = Object.keys(attributes)
for (let attributeName of Utility.mergeArrays(attributesNames, valuesNames)) {
const allAttributesNames = Utility.mergeArrays(attributesNames, valuesNames)
for (let attributeName of allAttributesNames) {
let value = Utility.objectGet(values, [attributeName])
/** @type {AttributeInformation} */
let attribute = attributes[attributeName]
@@ -234,4 +235,21 @@ export default class IEntity {
return Object.keys(this).length
- Object.keys(/** @type {typeof IEntity} */(this.constructor).attributes).length
}
/** @param {IEntity} other */
equals(other) {
const thisKeys = Object.keys(this)
const otherKeys = Object.keys(this)
if (thisKeys.length != otherKeys.length) {
return false
}
for (const key of thisKeys) {
if (this[key] instanceof IEntity && !this[key].equals(other[key])) {
return false
} else if (!Utility.equals(this[key], other[key])) {
return false
}
}
return true
}
}

View File

@@ -1,4 +1,6 @@
import ByteEntity from "./ByteEntity"
import Configuration from "../Configuration"
import EnumEntity from "./EnumEntity"
import FunctionReferenceEntity from "./FunctionReferenceEntity"
import GuidEntity from "./GuidEntity"
import IEntity from "./IEntity"
@@ -32,6 +34,7 @@ export default class PinEntity extends IEntity {
"/Script/CoreUObject.Vector2D": Vector2DEntity,
"bool": Boolean,
"byte": ByteEntity,
"enum": EnumEntity,
"exec": String,
"int": IntegerEntity,
"int64": Integer64Entity,
@@ -155,8 +158,18 @@ export default class PinEntity extends IEntity {
}
getType() {
if (this.PinType.PinCategory == "struct" || this.PinType.PinCategory == "object") {
return this.PinType.PinSubCategoryObject.path
const subCategory = this.PinType.PinSubCategoryObject
if (this.PinType.PinCategory === "struct" || this.PinType.PinCategory === "object") {
return subCategory.path
}
if (
this.PinType.PinCategory === "byte"
&& (
subCategory.type === Configuration.nodeType.enum
|| subCategory.type === Configuration.nodeType.userDefinedEnum
)
) {
return "enum"
}
return this.PinType.PinCategory
}
@@ -229,20 +242,18 @@ export default class PinEntity extends IEntity {
* @param {PinEntity} targetPinEntity
*/
linkTo(targetObjectName, targetPinEntity) {
/** @type {PinReferenceEntity[]} */
this.LinkedTo
const linkFound = this.LinkedTo?.find(pinReferenceEntity => {
return pinReferenceEntity.objectName.toString() == targetObjectName
&& pinReferenceEntity.pinGuid.valueOf() == targetPinEntity.PinId.valueOf()
})
const linkFound = this.LinkedTo?.some(pinReferenceEntity =>
pinReferenceEntity.objectName.toString() == targetObjectName
&& pinReferenceEntity.pinGuid.valueOf() == targetPinEntity.PinId.valueOf()
)
if (!linkFound) {
(this.LinkedTo ?? (this.LinkedTo = [])).push(new PinReferenceEntity({
(this.LinkedTo ??= []).push(new PinReferenceEntity({
objectName: targetObjectName,
pinGuid: targetPinEntity.PinId,
}))
return true
}
return false
return false // Already linked
}
/**