mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-03 23:55:04 +08:00
Entities semplification
* Entities semplification WIP * Bug fixes after entity semplification * Fix object serialization
This commit is contained in:
@@ -175,6 +175,7 @@ export default class Grammar {
|
||||
)
|
||||
} else if (type instanceof MirroredEntity) {
|
||||
return this.grammarFor(type.type.attributes[type.key])
|
||||
.map(() => new MirroredEntity(type.type, type.key, type.getter))
|
||||
} else if (attribute?.constructor === Object) {
|
||||
result = this.grammarFor(undefined, type)
|
||||
} else {
|
||||
@@ -454,9 +455,7 @@ export default class Grammar {
|
||||
static naturalNumberEntity = P.lazy(() => this.naturalNumber.map(v => new NaturalNumberEntity(v)))
|
||||
|
||||
static noneReferenceEntity = P.lazy(() =>
|
||||
P.string("None").map(() =>
|
||||
new ObjectReferenceEntity({ type: "None", path: "" })
|
||||
)
|
||||
P.string("None").map(() => ObjectReferenceEntity.createNoneInstance())
|
||||
)
|
||||
|
||||
static typeReferenceEntity = P.lazy(() =>
|
||||
|
||||
@@ -77,7 +77,7 @@ export default class ObjectSerializer extends Serializer {
|
||||
)
|
||||
}
|
||||
let result = indentation + "Begin Object"
|
||||
+ (entity.Class.type || entity.Class.path ? ` Class=${this.doWriteValue(entity.Class, insideString)}` : "")
|
||||
+ (entity.Class?.type || entity.Class?.path ? ` Class=${this.doWriteValue(entity.Class, insideString)}` : "")
|
||||
+ (entity.Name ? ` Name=${this.doWriteValue(entity.Name, insideString)}` : "")
|
||||
+ "\n"
|
||||
+ super.doWrite(
|
||||
|
||||
@@ -82,10 +82,7 @@ export default class Serializer {
|
||||
) {
|
||||
let result = ""
|
||||
const attributes = IEntity.getAttributes(entity)
|
||||
const keys = Utility.mergeArrays(
|
||||
Object.keys(attributes),
|
||||
Object.keys(entity)
|
||||
)
|
||||
const keys = Object.keys(entity)
|
||||
let first = true
|
||||
for (const key of keys) {
|
||||
const value = entity[key]
|
||||
@@ -147,14 +144,9 @@ export default class Serializer {
|
||||
}
|
||||
|
||||
showProperty(entity, key) {
|
||||
const attributes = /** @type {EntityConstructor} */(this.entityType).attributes
|
||||
const attribute = attributes[key]
|
||||
const value = entity[key]
|
||||
if (attribute?.constructor === Object) {
|
||||
if (attribute.ignored) {
|
||||
return false
|
||||
}
|
||||
return !Utility.equals(attribute.default, value) || attribute.showDefault
|
||||
const attribute = /** @type {EntityConstructor} */(this.entityType).attributes[key]
|
||||
if (attribute?.constructor === Object && attribute.ignored) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user