mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-27 10:44:43 +08:00
Type system fixes
This commit is contained in:
@@ -20,8 +20,7 @@ export default class GeneralSerializer extends ISerializer {
|
||||
let grammar = Grammar.getGrammarForType(ISerializer.grammar, this.entityType)
|
||||
const parseResult = grammar.parse(value)
|
||||
if (!parseResult.status) {
|
||||
console.error("Error when trying to parse the entity " + this.entityType.prototype.constructor.name)
|
||||
return parseResult
|
||||
throw new Error(`Error when trying to parse the entity ${this.entityType.prototype.constructor.name}.`)
|
||||
}
|
||||
return parseResult.value
|
||||
}
|
||||
|
||||
@@ -102,7 +102,8 @@ export default class Grammar {
|
||||
let result = new entityType()
|
||||
attributes.forEach(attributeSetter => attributeSetter(result))
|
||||
return result
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
/* --- General --- */
|
||||
|
||||
@@ -194,7 +195,8 @@ export default class Grammar {
|
||||
r.String,
|
||||
r.Guid,
|
||||
r.Reference,
|
||||
r.LocalizedText)
|
||||
r.LocalizedText
|
||||
)
|
||||
|
||||
PinReference = r => P.seqMap(
|
||||
r.PathSymbol, // Goes into objectNAme
|
||||
@@ -239,9 +241,9 @@ export default class Grammar {
|
||||
.sepBy1(P.whitespace),
|
||||
P.seq(r.MultilineWhitespace, P.string("End"), P.whitespace, P.string("Object")),
|
||||
(_, attributes, __) => {
|
||||
let result = new ObjectEntity()
|
||||
attributes.forEach(attributeSetter => attributeSetter(result))
|
||||
return result
|
||||
let values = {}
|
||||
attributes.forEach(attributeSetter => attributeSetter(values))
|
||||
return new ObjectEntity(values)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -25,8 +25,7 @@ export default class ObjectSerializer extends ISerializer {
|
||||
read(value) {
|
||||
const parseResult = ISerializer.grammar.Object.parse(value)
|
||||
if (!parseResult.status) {
|
||||
console.error("Error when trying to parse the object.")
|
||||
return parseResult
|
||||
throw new Error("Error when trying to parse the object.")
|
||||
}
|
||||
return parseResult.value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user