mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:50:33 +08:00
Fix Function reference
This commit is contained in:
181
dist/ueblueprint.js
vendored
181
dist/ueblueprint.js
vendored
@@ -644,34 +644,6 @@ class Utility {
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {Attribute | AttributeTypeDescription} T
|
||||
* @param {T} value
|
||||
* @returns {AttributeConstructor<T>}
|
||||
*/
|
||||
static getType(value) {
|
||||
if (value === null) {
|
||||
return null
|
||||
}
|
||||
if (value?.constructor === Object && /** @type {AttributeInformation} */(value)?.type instanceof Function) {
|
||||
return /** @type {AttributeInformation} */(value).type
|
||||
}
|
||||
return /** @type {AttributeConstructor<any>} */(value?.constructor)
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {Attribute} V
|
||||
* @template {AttributeConstructor<V>} C
|
||||
* @param {C} type
|
||||
* @returns {value is InstanceType<C>}
|
||||
*/
|
||||
static isValueOfType(value, type, acceptNull = false) {
|
||||
if (type instanceof MirroredEntity) {
|
||||
type = type.getTargetType();
|
||||
}
|
||||
return (acceptNull && value === null) || value instanceof type || value?.constructor === type
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Number} x
|
||||
* @param {Number} y
|
||||
@@ -2320,23 +2292,33 @@ class Parsernostrum {
|
||||
return this.times(0, n)
|
||||
}
|
||||
|
||||
/** @returns {Parsernostrum<T?>} */
|
||||
opt() {
|
||||
/**
|
||||
* @param {any} emptyResult
|
||||
* @returns {Parsernostrum<T?>}
|
||||
*/
|
||||
opt(emptyResult = "") {
|
||||
let success = Parsernostrum.success();
|
||||
if (emptyResult !== "") {
|
||||
success = success.map(() => emptyResult);
|
||||
}
|
||||
// @ts-expect-error
|
||||
return Parsernostrum.alt(this, Parsernostrum.success())
|
||||
return Parsernostrum.alt(this, success)
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {Parsernostrum} P
|
||||
* @param {P} separator
|
||||
*/
|
||||
sepBy(separator, allowTrailing = false) {
|
||||
const results = Parsernostrum.seq(
|
||||
sepBy(separator, atLeast = 1, allowTrailing = false) {
|
||||
let result = Parsernostrum.seq(
|
||||
this,
|
||||
Parsernostrum.seq(separator, this).map(Parsernostrum.#secondElementGetter).many()
|
||||
)
|
||||
.map(Parsernostrum.#arrayFlatter);
|
||||
return results
|
||||
Parsernostrum.seq(separator, this).map(Parsernostrum.#secondElementGetter).atLeast(atLeast - 1),
|
||||
...(allowTrailing ? [separator.opt([])] : [])
|
||||
).map(Parsernostrum.#arrayFlatter);
|
||||
if (atLeast === 0) {
|
||||
result = result.opt([]);
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
skipSpace() {
|
||||
@@ -2400,7 +2382,7 @@ class IEntity {
|
||||
/** @type {(v: String) => String} */
|
||||
static same = v => v
|
||||
|
||||
/** @type {(entity: Attribute, serialized: String) => String} */
|
||||
/** @type {(entity: IEntity, serialized: String) => String} */
|
||||
static notWrapped = (entity, serialized) => serialized
|
||||
|
||||
/** @type {(entity: IEntity, serialized: String) => String} */
|
||||
@@ -2485,21 +2467,6 @@ class IEntity {
|
||||
return self.name
|
||||
}
|
||||
|
||||
/** @param {String} key */
|
||||
showProperty(key) {
|
||||
/** @type {IEntity} */
|
||||
let value = this[key];
|
||||
const Self = this.Self();
|
||||
if (Self.silent && Self.default !== undefined) {
|
||||
if (Self["#default"] === undefined) {
|
||||
Self["#default"] = Self.default(Self);
|
||||
}
|
||||
const defaultValue = Self["#default"];
|
||||
return !value.equals(defaultValue)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @template {typeof IEntity} T
|
||||
@@ -2508,6 +2475,7 @@ class IEntity {
|
||||
*/
|
||||
static asUniqueClass() {
|
||||
if (this.name.length) {
|
||||
// @ts-expect-error
|
||||
return class extends this { }
|
||||
}
|
||||
return this
|
||||
@@ -2592,6 +2560,21 @@ class IEntity {
|
||||
return /** @type {T} */(this.constructor)
|
||||
}
|
||||
|
||||
/** @param {String} key */
|
||||
showProperty(key) {
|
||||
/** @type {IEntity} */
|
||||
let value = this[key];
|
||||
const Self = this.Self();
|
||||
if (Self.silent && Self.default !== undefined) {
|
||||
if (Self["#default"] === undefined) {
|
||||
Self["#default"] = Self.default(Self);
|
||||
}
|
||||
const defaultValue = Self["#default"];
|
||||
return !value.equals(defaultValue)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {String} attribute
|
||||
@@ -2709,7 +2692,7 @@ class IEntity {
|
||||
if (this instanceof IEntity && this.trailing && result.length) {
|
||||
result += Self.attributeSeparator;
|
||||
}
|
||||
return wrap(this, result)
|
||||
return wrap(/** @type {IEntity} */(this), result)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2748,47 +2731,6 @@ class AlternativesEntity extends IEntity {
|
||||
}
|
||||
}
|
||||
|
||||
/** @template {typeof IEntity} T */
|
||||
class MirroredEntity$1 extends IEntity {
|
||||
|
||||
/** @type {typeof IEntity} */
|
||||
static type
|
||||
|
||||
/** @param {() => InstanceType<T>} getter */
|
||||
constructor(getter = null) {
|
||||
super();
|
||||
this.getter = getter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {typeof IEntity} T
|
||||
* @param {T} type
|
||||
*/
|
||||
static of(type) {
|
||||
const result = this.asUniqueClass();
|
||||
result.type = type;
|
||||
result.grammar = result.getTargetType().grammar.map(v => new this());
|
||||
return result
|
||||
}
|
||||
|
||||
/** @returns {typeof IEntity} */
|
||||
static getTargetType() {
|
||||
const result = this.type;
|
||||
if (result.prototype instanceof MirroredEntity$1) {
|
||||
return /** @type {typeof MirroredEntity} */(result).getTargetType()
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
toString(
|
||||
insideString = false,
|
||||
indentation = "",
|
||||
printKey = this.Self().printKey,
|
||||
) {
|
||||
return this.getter().toString(insideString, indentation, printKey)
|
||||
}
|
||||
}
|
||||
|
||||
class Grammar {
|
||||
|
||||
/** @type {String} */
|
||||
@@ -2909,11 +2851,11 @@ class Grammar {
|
||||
* @param {T} entityType
|
||||
* @return {Parsernostrum<InstanceType<T>>}
|
||||
*/
|
||||
static createEntityGrammar(entityType, entriesSeparator = this.commaSeparation, complete = false) {
|
||||
static createEntityGrammar(entityType, entriesSeparator = this.commaSeparation, complete = false, minKeys = 1) {
|
||||
const lookbehind = entityType.lookbehind instanceof Array ? entityType.lookbehind.join("|") : entityType.lookbehind;
|
||||
return Parsernostrum.seq(
|
||||
Parsernostrum.reg(new RegExp(String.raw`(${lookbehind})\s*\(\s*`), 1),
|
||||
this.createAttributeGrammar(entityType).sepBy(entriesSeparator),
|
||||
this.createAttributeGrammar(entityType).sepBy(entriesSeparator, minKeys),
|
||||
Parsernostrum.reg(/\s*(,\s*)?\)/, 1), // optional trailing comma
|
||||
)
|
||||
.map(([lookbehind, attributes, trailing]) => {
|
||||
@@ -4960,7 +4902,7 @@ class FunctionReferenceEntity extends IEntity {
|
||||
MemberGuid: GuidEntity,
|
||||
}
|
||||
/** @type {P<FunctionReferenceEntity>} */
|
||||
static grammar = Grammar.createEntityGrammar(this)
|
||||
static grammar = Grammar.createEntityGrammar(this, Grammar.commaSeparation, false, 0)
|
||||
|
||||
constructor(values) {
|
||||
super(values);
|
||||
@@ -5697,6 +5639,47 @@ class MacroGraphReferenceEntity extends IEntity {
|
||||
}
|
||||
}
|
||||
|
||||
/** @template {typeof IEntity} T */
|
||||
class MirroredEntity$1 extends IEntity {
|
||||
|
||||
/** @type {typeof IEntity} */
|
||||
static type
|
||||
|
||||
/** @param {() => InstanceType<T>} getter */
|
||||
constructor(getter = null) {
|
||||
super();
|
||||
this.getter = getter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {typeof IEntity} T
|
||||
* @param {T} type
|
||||
*/
|
||||
static of(type) {
|
||||
const result = this.asUniqueClass();
|
||||
result.type = type;
|
||||
result.grammar = result.getTargetType().grammar.map(v => new this());
|
||||
return result
|
||||
}
|
||||
|
||||
/** @returns {typeof IEntity} */
|
||||
static getTargetType() {
|
||||
const result = this.type;
|
||||
if (result.prototype instanceof MirroredEntity$1) {
|
||||
return /** @type {typeof MirroredEntity} */(result).getTargetType()
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
toString(
|
||||
insideString = false,
|
||||
indentation = "",
|
||||
printKey = this.Self().printKey,
|
||||
) {
|
||||
return this.getter().toString(insideString, indentation, printKey)
|
||||
}
|
||||
}
|
||||
|
||||
class NaturalNumberEntity extends IntegerEntity {
|
||||
|
||||
static grammar = Parsernostrum.numberNatural.map(v => new this(v))
|
||||
@@ -6100,7 +6083,7 @@ class ObjectEntity extends IEntity {
|
||||
}
|
||||
let inputIndex = 0;
|
||||
let outputIndex = 0;
|
||||
this.CustomProperties?.forEach((pinEntity, i) => {
|
||||
this.getCustomproperties().forEach((pinEntity, i) => {
|
||||
pinEntity.objectEntity = this;
|
||||
pinEntity.pinIndex = pinEntity.isInput()
|
||||
? inputIndex++
|
||||
|
||||
6
dist/ueblueprint.min.js
vendored
6
dist/ueblueprint.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -212,34 +212,6 @@ export default class Utility {
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {Attribute | AttributeTypeDescription} T
|
||||
* @param {T} value
|
||||
* @returns {AttributeConstructor<T>}
|
||||
*/
|
||||
static getType(value) {
|
||||
if (value === null) {
|
||||
return null
|
||||
}
|
||||
if (value?.constructor === Object && /** @type {AttributeInformation} */(value)?.type instanceof Function) {
|
||||
return /** @type {AttributeInformation} */(value).type
|
||||
}
|
||||
return /** @type {AttributeConstructor<any>} */(value?.constructor)
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {Attribute} V
|
||||
* @template {AttributeConstructor<V>} C
|
||||
* @param {C} type
|
||||
* @returns {value is InstanceType<C>}
|
||||
*/
|
||||
static isValueOfType(value, type, acceptNull = false) {
|
||||
if (type instanceof MirroredEntity) {
|
||||
type = type.getTargetType()
|
||||
}
|
||||
return (acceptNull && value === null) || value instanceof type || value?.constructor === type
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Number} x
|
||||
* @param {Number} y
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {{
|
||||
* type?: AttributeTypeDescription,
|
||||
* default?: T,
|
||||
* nullable?: Boolean,
|
||||
* ignored?: Boolean,
|
||||
* serialized?: Boolean,
|
||||
* expected?: Boolean,
|
||||
* inlined?: Boolean,
|
||||
* quoted?: Boolean,
|
||||
* silent?: Boolean,
|
||||
* uninitialized?: Boolean,
|
||||
* predicate?: (value: T) => Boolean,
|
||||
* }} AttributeInfoSource
|
||||
*/
|
||||
|
||||
/** @template T */
|
||||
export default class AttributeInfo {
|
||||
|
||||
/** @typedef {keyof AttributeInfo<number>} AttributeKey */
|
||||
|
||||
static #default = {
|
||||
nullable: false,
|
||||
ignored: false, // Never serialize or deserialize
|
||||
serialized: false, // Value is written and read as string
|
||||
expected: false, // Must be there
|
||||
inlined: false, // The key is a subobject or array and printed as inlined (A.B=123, A(0)=123)
|
||||
quoted: false, // Key is serialized with quotes
|
||||
silent: false, // Do not serialize if default
|
||||
uninitialized: false, // Do not initialize with default
|
||||
}
|
||||
|
||||
/** @param {AttributeInfoSource<T>} source */
|
||||
constructor(source) {
|
||||
this.type = source.type ?? source.default?.constructor
|
||||
this.default = source.default
|
||||
this.nullable = source.nullable ?? source.default === null
|
||||
this.ignored = source.ignored
|
||||
this.serialized = source.serialized
|
||||
this.expected = source.expected
|
||||
this.inlined = source.inlined
|
||||
this.quoted = source.quoted
|
||||
this.silent = source.silent
|
||||
this.uninitialized = source.uninitialized
|
||||
this.predicate = source.predicate
|
||||
if (this.type === Array && this.default instanceof Array && this.default.length > 0) {
|
||||
this.type = this.default
|
||||
.map(v => v.constructor)
|
||||
.reduce((acc, cur) => acc.includes(cur) ? acc : (acc.push(cur), acc), [])
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {AttributeTypeDescription} D
|
||||
* @param {D} type
|
||||
* @returns {AttributeInfo<DescribedType<type>>}
|
||||
*/
|
||||
static createType(type) {
|
||||
return new AttributeInfo({ type })
|
||||
}
|
||||
|
||||
/**
|
||||
* @template V
|
||||
* @param {V} value
|
||||
*/
|
||||
static createValue(value) {
|
||||
return new AttributeInfo({ default: value })
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {IEntity | Object} source
|
||||
* @param {String} attribute
|
||||
* @param {AttributeKey} key
|
||||
*/
|
||||
static hasAttribute(source, attribute, key, type = /** @type {EntityConstructor} */(source.constructor)) {
|
||||
const entity = /** @type {IEntity} */(source)
|
||||
const result = entity.attributes[attribute]?.[key]
|
||||
return /** @type {result} */(
|
||||
result
|
||||
?? type?.attributes?.[attribute]?.[key]
|
||||
?? AttributeInfo.#default[key]
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {IEntity | Object} S
|
||||
* @template {EntityConstructor} C
|
||||
* @template {keyof C["attributes"]} A
|
||||
* @template {keyof C["attributes"][attribute]} K
|
||||
* @param {S} source
|
||||
* @param {A} attribute
|
||||
* @param {K} key
|
||||
* @param {C} type
|
||||
* @returns {C["attributes"][attribute][key]}
|
||||
*/
|
||||
static getAttribute(source, attribute, key, type = /** @type {C} */(source.constructor)) {
|
||||
let result = source["attributes"]?.[attribute]?.[key]
|
||||
// Remember null is a valid asignment value for some attributes
|
||||
if (result !== undefined) {
|
||||
return result
|
||||
}
|
||||
result = /** @type {C["attributes"]} */(type?.attributes)?.[attribute]?.[key]
|
||||
if (result !== undefined) {
|
||||
return result
|
||||
}
|
||||
result = /** @type {C["attributes"][attribute]} */(AttributeInfo.#default)[key]
|
||||
if (result !== undefined) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {AttributeKey} key */
|
||||
get(key) {
|
||||
return this[key] ?? AttributeInfo.#default[key]
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ export default class FunctionReferenceEntity extends IEntity {
|
||||
MemberGuid: GuidEntity,
|
||||
}
|
||||
/** @type {P<FunctionReferenceEntity>} */
|
||||
static grammar = Grammar.createEntityGrammar(this)
|
||||
static grammar = Grammar.createEntityGrammar(this, Grammar.commaSeparation, false, 0)
|
||||
|
||||
constructor(values) {
|
||||
super(values)
|
||||
|
||||
@@ -7,7 +7,7 @@ export default class IEntity {
|
||||
/** @type {(v: String) => String} */
|
||||
static same = v => v
|
||||
|
||||
/** @type {(entity: Attribute, serialized: String) => String} */
|
||||
/** @type {(entity: IEntity, serialized: String) => String} */
|
||||
static notWrapped = (entity, serialized) => serialized
|
||||
|
||||
/** @type {(entity: IEntity, serialized: String) => String} */
|
||||
@@ -92,21 +92,6 @@ export default class IEntity {
|
||||
return self.name
|
||||
}
|
||||
|
||||
/** @param {String} key */
|
||||
showProperty(key) {
|
||||
/** @type {IEntity} */
|
||||
let value = this[key]
|
||||
const Self = this.Self()
|
||||
if (Self.silent && Self.default !== undefined) {
|
||||
if (Self["#default"] === undefined) {
|
||||
Self["#default"] = Self.default(Self)
|
||||
}
|
||||
const defaultValue = Self["#default"]
|
||||
return !value.equals(defaultValue)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @template {typeof IEntity} T
|
||||
@@ -115,6 +100,7 @@ export default class IEntity {
|
||||
*/
|
||||
static asUniqueClass() {
|
||||
if (this.name.length) {
|
||||
// @ts-expect-error
|
||||
return class extends this { }
|
||||
}
|
||||
return this
|
||||
@@ -199,6 +185,21 @@ export default class IEntity {
|
||||
return /** @type {T} */(this.constructor)
|
||||
}
|
||||
|
||||
/** @param {String} key */
|
||||
showProperty(key) {
|
||||
/** @type {IEntity} */
|
||||
let value = this[key]
|
||||
const Self = this.Self()
|
||||
if (Self.silent && Self.default !== undefined) {
|
||||
if (Self["#default"] === undefined) {
|
||||
Self["#default"] = Self.default(Self)
|
||||
}
|
||||
const defaultValue = Self["#default"]
|
||||
return !value.equals(defaultValue)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {String} attribute
|
||||
@@ -316,6 +317,6 @@ export default class IEntity {
|
||||
if (this instanceof IEntity && this.trailing && result.length) {
|
||||
result += Self.attributeSeparator
|
||||
}
|
||||
return wrap(this, result)
|
||||
return wrap(/** @type {IEntity} */(this), result)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ export default class ObjectEntity extends IEntity {
|
||||
}
|
||||
let inputIndex = 0
|
||||
let outputIndex = 0
|
||||
this.CustomProperties?.forEach((pinEntity, i) => {
|
||||
this.getCustomproperties().forEach((pinEntity, i) => {
|
||||
pinEntity.objectEntity = this
|
||||
pinEntity.pinIndex = pinEntity.isInput()
|
||||
? inputIndex++
|
||||
|
||||
@@ -2,9 +2,7 @@ import Parsernostrum from "parsernostrum"
|
||||
import Configuration from "../Configuration.js"
|
||||
import Utility from "../Utility.js"
|
||||
import AlternativesEntity from "../entity/AlternativesEntity.js"
|
||||
import AttributeInfo from "../entity/AttributeInfo.js"
|
||||
import IEntity from "../entity/IEntity.js"
|
||||
import MirroredEntity from "../entity/MirroredEntity.js"
|
||||
|
||||
export default class Grammar {
|
||||
|
||||
@@ -126,11 +124,11 @@ export default class Grammar {
|
||||
* @param {T} entityType
|
||||
* @return {Parsernostrum<InstanceType<T>>}
|
||||
*/
|
||||
static createEntityGrammar(entityType, entriesSeparator = this.commaSeparation, complete = false) {
|
||||
static createEntityGrammar(entityType, entriesSeparator = this.commaSeparation, complete = false, minKeys = 1) {
|
||||
const lookbehind = entityType.lookbehind instanceof Array ? entityType.lookbehind.join("|") : entityType.lookbehind
|
||||
return Parsernostrum.seq(
|
||||
Parsernostrum.reg(new RegExp(String.raw`(${lookbehind})\s*\(\s*`), 1),
|
||||
this.createAttributeGrammar(entityType).sepBy(entriesSeparator),
|
||||
this.createAttributeGrammar(entityType).sepBy(entriesSeparator, minKeys),
|
||||
Parsernostrum.reg(/\s*(,\s*)?\)/, 1), // optional trailing comma
|
||||
)
|
||||
.map(([lookbehind, attributes, trailing]) => {
|
||||
|
||||
@@ -6,16 +6,15 @@ import BooleanEntity from "../js/entity/BooleanEntity.js"
|
||||
import ByteEntity from "../js/entity/ByteEntity.js"
|
||||
import ColorChannelEntity from "../js/entity/ColorChannelEntity.js"
|
||||
import FormatTextEntity from "../js/entity/FormatTextEntity.js"
|
||||
import FunctionReferenceEntity from "../js/entity/FunctionReferenceEntity.js"
|
||||
import GuidEntity from "../js/entity/GuidEntity.js"
|
||||
import IEntity from "../js/entity/IEntity.js"
|
||||
import IntegerEntity from "../js/entity/IntegerEntity.js"
|
||||
import KeyBindingEntity from "../js/entity/KeyBindingEntity.js"
|
||||
import LinearColorEntity from "../js/entity/LinearColorEntity.js"
|
||||
import NaturalNumberEntity from "../js/entity/NaturalNumberEntity.js"
|
||||
import NullEntity from "../js/entity/NullEntity.js"
|
||||
import NumberEntity from "../js/entity/NumberEntity.js"
|
||||
import ObjectReferenceEntity from "../js/entity/ObjectReferenceEntity.js"
|
||||
import PinEntity from "../js/entity/PinEntity.js"
|
||||
import RotatorEntity from "../js/entity/RotatorEntity.js"
|
||||
import SimpleSerializationRotatorEntity from "../js/entity/SimpleSerializationRotatorEntity.js"
|
||||
import SimpleSerializationVector2DEntity from "../js/entity/SimpleSerializationVector2DEntity.js"
|
||||
@@ -278,27 +277,127 @@ test("FormatTextEntity", () => {
|
||||
expect(() => grammar.parse("LOCGEN_FORMAT_NAMED")).toThrow("Could not parse")
|
||||
})
|
||||
|
||||
test("FunctionReferenceEntity", () => {
|
||||
let grammar = FunctionReferenceEntity.grammar
|
||||
{
|
||||
const s = `(MemberParent=/Script/Engine.BlueprintGeneratedClass'"/Temp/Untitled_1.Untitled_C"',MemberName="MoveCharacterRandomLocation",MemberGuid=9C3BF2E5A27C4B45825C025A224639EA)`
|
||||
const value = grammar.parse(s)
|
||||
expect(value).toBeInstanceOf(FunctionReferenceEntity)
|
||||
expect(value.equals(new FunctionReferenceEntity({
|
||||
MemberParent: new ObjectReferenceEntity(
|
||||
"/Script/Engine.BlueprintGeneratedClass",
|
||||
"/Temp/Untitled_1.Untitled_C"
|
||||
),
|
||||
MemberName: new StringEntity("MoveCharacterRandomLocation"),
|
||||
MemberGuid: new GuidEntity("9C3BF2E5A27C4B45825C025A224639EA"),
|
||||
}))).toBeTruthy()
|
||||
expect(value.equals(new FunctionReferenceEntity({
|
||||
MemberGuid: new GuidEntity("9C3BF2E5A27C4B45825C025A224639EA"),
|
||||
MemberName: new StringEntity("MoveCharacterRandomLocation"),
|
||||
MemberParent: new ObjectReferenceEntity(
|
||||
"/Script/Engine.BlueprintGeneratedClass",
|
||||
"/Temp/Untitled_1.Untitled_C"
|
||||
),
|
||||
}))).toBeTruthy()
|
||||
expect(value.equals(new FunctionReferenceEntity({
|
||||
MemberParent: new ObjectReferenceEntity(
|
||||
"/Script/Engine.BlueprintGeneratedClass2",
|
||||
"/Temp/Untitled_1.Untitled_C"
|
||||
),
|
||||
MemberName: new StringEntity("MoveCharacterRandomLocation"),
|
||||
MemberGuid: new GuidEntity("9C3BF2E5A27C4B45825C025A224639EA"),
|
||||
}))).toBeFalsy()
|
||||
expect(value.equals(new FunctionReferenceEntity({
|
||||
MemberParent: new ObjectReferenceEntity(
|
||||
"/Script/Engine.BlueprintGeneratedClass",
|
||||
"/Temp/Untitled_1.Untitled_C"
|
||||
),
|
||||
MemberName: new StringEntity("MoveCharacterRandomLocation2"),
|
||||
MemberGuid: new GuidEntity("9C3BF2E5A27C4B45825C025A224639EA"),
|
||||
}))).toBeFalsy()
|
||||
expect(value.equals(new FunctionReferenceEntity({
|
||||
MemberParent: new ObjectReferenceEntity(
|
||||
"/Script/Engine.BlueprintGeneratedClass",
|
||||
"/Temp/Untitled_1.Untitled_C"
|
||||
),
|
||||
MemberGuid: new GuidEntity("9C3BF2E5A27C4B45825C025A224639EA"),
|
||||
}))).toBeFalsy()
|
||||
expect(value.toString()).toEqual(s)
|
||||
expect(value.toString(true)).toEqual(
|
||||
String.raw`(MemberParent=/Script/Engine.BlueprintGeneratedClass'\"/Temp/Untitled_1.Untitled_C\"',MemberName=\"MoveCharacterRandomLocation\",MemberGuid=9C3BF2E5A27C4B45825C025A224639EA)`
|
||||
)
|
||||
}
|
||||
{
|
||||
const s = `(MemberParent=/Script/Engine.BlueprintGeneratedClass'"/Temp/Untitled_1.Untitled_C"',MemberName="InpAxisKeyEvt_MouseX_K2Node_InputAxisKeyEvent_2")`
|
||||
const value = grammar.parse(s)
|
||||
expect(value).toBeInstanceOf(FunctionReferenceEntity)
|
||||
expect(value.equals(new FunctionReferenceEntity({
|
||||
MemberParent: new ObjectReferenceEntity(
|
||||
"/Script/Engine.BlueprintGeneratedClass",
|
||||
"/Temp/Untitled_1.Untitled_C"
|
||||
),
|
||||
MemberName: new StringEntity("InpAxisKeyEvt_MouseX_K2Node_InputAxisKeyEvent_2"),
|
||||
}))).toBeTruthy()
|
||||
expect(value.equals(new FunctionReferenceEntity({
|
||||
MemberParent: new ObjectReferenceEntity(
|
||||
"/Script/Engine.BlueprintGeneratedClass",
|
||||
"/Temp/Untitled_1.Untitled_C"
|
||||
),
|
||||
MemberName: new StringEntity("InpAxisKeyEvt_MouseX_K2Node_InputAxisKeyEvent_2"),
|
||||
MemberGuid: new GuidEntity("9C3BF2E5A27C4B45825C025A224639EA"),
|
||||
}))).toBeFalsy()
|
||||
expect(value.toString()).toEqual(s)
|
||||
expect(value.toString(true)).toEqual(
|
||||
String.raw`(MemberParent=/Script/Engine.BlueprintGeneratedClass'\"/Temp/Untitled_1.Untitled_C\"',MemberName=\"InpAxisKeyEvt_MouseX_K2Node_InputAxisKeyEvent_2\")`
|
||||
)
|
||||
}
|
||||
{
|
||||
const s = `()`
|
||||
const value = grammar.parse(s)
|
||||
expect(value).toBeInstanceOf(FunctionReferenceEntity)
|
||||
expect(value.equals(new FunctionReferenceEntity())).toBeTruthy()
|
||||
expect(value.equals(new FunctionReferenceEntity({
|
||||
MemberGuid: new GuidEntity("9C3BF2E5A27C4B45825C025A224639EA")
|
||||
}))).toBeFalsy()
|
||||
expect(value.toString()).toEqual("()")
|
||||
expect(value.toString(true)).toEqual("()")
|
||||
}
|
||||
{
|
||||
const s = `(Unexpected="Hello")`
|
||||
const value = grammar.parse(s)
|
||||
expect(value).toBeInstanceOf(FunctionReferenceEntity)
|
||||
expect(value.equals(new FunctionReferenceEntity({
|
||||
Unexpected: new StringEntity("Hello")
|
||||
}))).toBeTruthy()
|
||||
expect(value.equals(new FunctionReferenceEntity())).toBeFalsy()
|
||||
expect(value.toString()).toEqual(`(Unexpected="Hello")`)
|
||||
expect(value.toString(true)).toEqual(String.raw`(Unexpected=\"Hello\")`)
|
||||
}
|
||||
})
|
||||
|
||||
test("GuidEntity", () => {
|
||||
let grammar = GuidEntity.flagInlined().grammar
|
||||
|
||||
let value = grammar.parse("0556a3ecabf648d0a5c07b2478e9dd32")
|
||||
expect(value).toBeInstanceOf(GuidEntity)
|
||||
expect(value).toEqual(new GuidEntity("0556a3ecabf648d0a5c07b2478e9dd32"))
|
||||
expect(value.equals(new GuidEntity("0556a3ecabf648d0a5c07b2478e9dd32"))).toBeTruthy()
|
||||
expect(value.equals(new (GuidEntity.withDefault().flagInlined())("0556a3ecabf648d0a5c07b2478e9dd32"))).toBeTruthy()
|
||||
expect(value.equals(new (GuidEntity.withDefault().flagInlined())("0556a3ecabf648d0a5c07b2478e9dd33"))).toBeFalsy()
|
||||
expect(value.toString()).toEqual("0556a3ecabf648d0a5c07b2478e9dd32")
|
||||
|
||||
value = grammar.parse("64023BC344E0453DBB583FAC411489BC")
|
||||
expect(value).toBeInstanceOf(GuidEntity)
|
||||
expect(value).toEqual(new GuidEntity("64023BC344E0453DBB583FAC411489BC"))
|
||||
expect(value.toString()).toEqual("64023BC344E0453DBB583FAC411489BC")
|
||||
|
||||
value = grammar.parse("6edC4a425ca948da8bC78bA52DED6C6C")
|
||||
expect(value).toBeInstanceOf(GuidEntity)
|
||||
expect(value).toEqual(new GuidEntity("6edC4a425ca948da8bC78bA52DED6C6C"))
|
||||
expect(value.toString()).toEqual("6edC4a425ca948da8bC78bA52DED6C6C")
|
||||
|
||||
{
|
||||
let value = grammar.parse("0556a3ecabf648d0a5c07b2478e9dd32")
|
||||
expect(value).toBeInstanceOf(GuidEntity)
|
||||
expect(value).toEqual(new GuidEntity("0556a3ecabf648d0a5c07b2478e9dd32"))
|
||||
expect(value.equals(new GuidEntity("0556a3ecabf648d0a5c07b2478e9dd32"))).toBeTruthy()
|
||||
expect(value.equals(new (GuidEntity.withDefault().flagInlined())("0556a3ecabf648d0a5c07b2478e9dd32"))).toBeTruthy()
|
||||
expect(value.equals(new (GuidEntity.withDefault().flagInlined())("0556a3ecabf648d0a5c07b2478e9dd33"))).toBeFalsy()
|
||||
expect(value.toString()).toEqual("0556a3ecabf648d0a5c07b2478e9dd32")
|
||||
}
|
||||
{
|
||||
const value = grammar.parse("64023BC344E0453DBB583FAC411489BC")
|
||||
expect(value).toBeInstanceOf(GuidEntity)
|
||||
expect(value).toEqual(new GuidEntity("64023BC344E0453DBB583FAC411489BC"))
|
||||
expect(value.toString()).toEqual("64023BC344E0453DBB583FAC411489BC")
|
||||
}
|
||||
{
|
||||
const value = grammar.parse("6edC4a425ca948da8bC78bA52DED6C6C")
|
||||
expect(value).toBeInstanceOf(GuidEntity)
|
||||
expect(value).toEqual(new GuidEntity("6edC4a425ca948da8bC78bA52DED6C6C"))
|
||||
expect(value.toString()).toEqual("6edC4a425ca948da8bC78bA52DED6C6C")
|
||||
}
|
||||
expect(() => grammar.parse("172087193 9B04362973544B3564FDB2C")).toThrow("Could not parse")
|
||||
expect(() => grammar.parse("E25F14F8F3E9441AB07153E7DA2BA2B")).toThrow("Could not parse")
|
||||
expect(() => grammar.parse("A78988B0097E48418C8CB87EC5A67ABF7")).toThrow("Could not parse")
|
||||
|
||||
@@ -86,13 +86,6 @@ test("equals method test", () => {
|
||||
)).toBeFalsy() // Second element is different
|
||||
})
|
||||
|
||||
test("isValueOfType method test", () => {
|
||||
expect(Utility.isValueOfType(34, Number)).toBeTruthy()
|
||||
expect(Utility.isValueOfType(new Number(34), Number)).toBeTruthy()
|
||||
expect(Utility.isValueOfType("34", String)).toBeTruthy()
|
||||
expect(Utility.isValueOfType("34", Number)).toBeFalsy()
|
||||
})
|
||||
|
||||
test("mergeArrays method test", () => {
|
||||
expect(Utility.mergeArrays(
|
||||
[],
|
||||
|
||||
Reference in New Issue
Block a user