This commit is contained in:
barsdeveloper
2024-05-21 15:44:56 +02:00
parent a5813d0b4d
commit 31a07b992d
4 changed files with 19 additions and 26 deletions

17
dist/ueblueprint.js vendored
View File

@@ -2457,7 +2457,7 @@ class Parsernostrum {
} }
/** /**
* @template {[Parsernostrum<any>, Parsernostrum<any>, ...Parsernostrum<any>[]]} P * @template {Parsernostrum<any>[]} P
* @param {P} parsers * @param {P} parsers
* @returns {Parsernostrum<AlternativeParser<UnwrapParser<P>>>} * @returns {Parsernostrum<AlternativeParser<UnwrapParser<P>>>}
*/ */
@@ -4476,10 +4476,10 @@ class ObjectReferenceEntity extends IEntity {
).map(([_full, type, ...path]) => new this({ type, path: path.find(v => v), _full })) ).map(([_full, type, ...path]) => new this({ type, path: path.find(v => v), _full }))
static fullReferenceSerializedGrammar = Parsernostrum.regArray( static fullReferenceSerializedGrammar = Parsernostrum.regArray(
new RegExp( new RegExp(
"(" + this.typeReference.getParser().regexp.source + ")" '"(' + Grammar.Regex.InsideString.source + "?)"
+ `'(` + Grammar.Regex.InsideSingleQuotedString.source + `)'` + "(?:'(" + Grammar.Regex.InsideSingleQuotedString.source + `?)')?"`
) )
).map(([_full, type, ...path]) => new this({ type, path: path.find(v => v), _full })) ).map(([_full, type, path]) => new this({ type, path, _full }))
static typeReferenceGrammar = this.typeReference.map(v => new this({ type: v, path: "", _full: v })) static typeReferenceGrammar = this.typeReference.map(v => new this({ type: v, path: "", _full: v }))
static grammar = this.createGrammar() static grammar = this.createGrammar()
@@ -4499,14 +4499,7 @@ class ObjectReferenceEntity extends IEntity {
static createGrammar() { static createGrammar() {
return Parsernostrum.alt( return Parsernostrum.alt(
Parsernostrum.seq( this.fullReferenceSerializedGrammar,
Parsernostrum.str('"'),
Parsernostrum.alt(
this.fullReferenceSerializedGrammar,
this.typeReferenceGrammar,
),
Parsernostrum.str('"'),
).map(([_0, objectReference, _1]) => (objectReference._full = `"${objectReference._full}"`, objectReference)),
this.fullReferenceGrammar, this.fullReferenceGrammar,
this.typeReferenceGrammar, this.typeReferenceGrammar,
) )

File diff suppressed because one or more lines are too long

View File

@@ -37,10 +37,10 @@ export default class ObjectReferenceEntity extends IEntity {
).map(([_full, type, ...path]) => new this({ type, path: path.find(v => v), _full })) ).map(([_full, type, ...path]) => new this({ type, path: path.find(v => v), _full }))
static fullReferenceSerializedGrammar = Parsernostrum.regArray( static fullReferenceSerializedGrammar = Parsernostrum.regArray(
new RegExp( new RegExp(
"(" + this.typeReference.getParser().regexp.source + ")" '"(' + Grammar.Regex.InsideString.source + "?)"
+ `'(` + Grammar.Regex.InsideSingleQuotedString.source + `)'` + "(?:'(" + Grammar.Regex.InsideSingleQuotedString.source + `?)')?"`
) )
).map(([_full, type, ...path]) => new this({ type, path: path.find(v => v), _full })) ).map(([_full, type, path]) => new this({ type, path, _full }))
static typeReferenceGrammar = this.typeReference.map(v => new this({ type: v, path: "", _full: v })) static typeReferenceGrammar = this.typeReference.map(v => new this({ type: v, path: "", _full: v }))
static grammar = this.createGrammar() static grammar = this.createGrammar()
@@ -60,14 +60,7 @@ export default class ObjectReferenceEntity extends IEntity {
static createGrammar() { static createGrammar() {
return Parsernostrum.alt( return Parsernostrum.alt(
Parsernostrum.seq( this.fullReferenceSerializedGrammar,
Parsernostrum.str('"'),
Parsernostrum.alt(
this.fullReferenceSerializedGrammar,
this.typeReferenceGrammar,
),
Parsernostrum.str('"'),
).map(([_0, objectReference, _1]) => (objectReference._full = `"${objectReference._full}"`, objectReference)),
this.fullReferenceGrammar, this.fullReferenceGrammar,
this.typeReferenceGrammar, this.typeReferenceGrammar,
) )

View File

@@ -370,6 +370,13 @@ test("ObjectReferenceEntity", () => {
path: "/Script/Engine.GameModeBase", path: "/Script/Engine.GameModeBase",
}) })
expect(serializer.write(reference)).toBe(`/Script/CoreUObject.Class'"/Script/Engine.GameModeBase"'`) expect(serializer.write(reference)).toBe(`/Script/CoreUObject.Class'"/Script/Engine.GameModeBase"'`)
reference = serializer.read(`"/Game/_YukiritoLib/Textures/T_紫色渐变01.T_紫色渐变01"`)
expect(reference).toBeInstanceOf(ObjectReferenceEntity)
expect(reference).toMatchObject({
type: "/Game/_YukiritoLib/Textures/T_紫色渐变01.T_紫色渐变01",
path: "",
})
}) })
test("PinEntity", () => { test("PinEntity", () => {