mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:28:17 +08:00
Filterable attributes, Int64 entity
This commit is contained in:
@@ -3,6 +3,7 @@ import ByteEntity from "../entity/ByteEntity"
|
||||
import FunctionReferenceEntity from "../entity/FunctionReferenceEntity"
|
||||
import GuidEntity from "../entity/GuidEntity"
|
||||
import IdentifierEntity from "../entity/IdentifierEntity"
|
||||
import Integer64Entity from "../entity/Integer64Entity"
|
||||
import IntegerEntity from "../entity/IntegerEntity"
|
||||
import InvariantTextEntity from "../entity/InvariantTextEntity"
|
||||
import KeyBindingEntity from "../entity/KeyBindingEntity"
|
||||
@@ -66,6 +67,8 @@ export default class Grammar {
|
||||
return result
|
||||
}
|
||||
switch (attribute) {
|
||||
case BigInt:
|
||||
return r.BigInt
|
||||
case Boolean:
|
||||
return r.Boolean
|
||||
case ByteEntity:
|
||||
@@ -76,6 +79,8 @@ export default class Grammar {
|
||||
return r.Guid
|
||||
case IdentifierEntity:
|
||||
return r.Identifier
|
||||
case Integer64Entity:
|
||||
return r.Integer64
|
||||
case IntegerEntity:
|
||||
return r.Integer
|
||||
case InvariantTextEntity:
|
||||
@@ -217,6 +222,9 @@ export default class Grammar {
|
||||
/** @param {Grammar} r */
|
||||
Number = r => P.regex(/[-\+]?[0-9]+(?:\.[0-9]+)?/).map(Number).desc("a number")
|
||||
|
||||
/** @param {Grammar} r */
|
||||
BigInt = r => P.regex(/[\-\+]?[0-9]+/).map(v => BigInt(v)).desc("a big integer")
|
||||
|
||||
/** @param {Grammar} r */
|
||||
RealNumber = r => P.regex(/[-\+]?[0-9]+\.[0-9]+/).map(Number).desc("a number written as real")
|
||||
|
||||
@@ -244,6 +252,9 @@ export default class Grammar {
|
||||
/** @param {Grammar} r */
|
||||
None = r => P.string("None").map(() => new ObjectReferenceEntity({ type: "None", path: "" })).desc("none")
|
||||
|
||||
/** @param {Grammar} r */
|
||||
Integer64 = r => r.BigInt.map(v => new Integer64Entity(v)).desc("an integer64")
|
||||
|
||||
/** @param {Grammar} r */
|
||||
Integer = r => P.regex(/[\-\+]?[0-9]+/).map(v => new IntegerEntity(v)).desc("an integer")
|
||||
|
||||
|
||||
@@ -93,10 +93,10 @@ export default class ISerializer {
|
||||
const attributes = /** @type {EntityConstructor} */(object.constructor).attributes
|
||||
const keys = attributes
|
||||
? Utility.mergeArrays(
|
||||
Object.getOwnPropertyNames(attributes),
|
||||
Object.getOwnPropertyNames(object)
|
||||
Object.keys(attributes),
|
||||
Object.keys(object)
|
||||
)
|
||||
: Object.getOwnPropertyNames(object)
|
||||
: Object.keys(object)
|
||||
for (const property of keys) {
|
||||
fullKey[last] = property
|
||||
const value = object[property]
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import ByteEntity from "../entity/ByteEntity"
|
||||
import CustomSerializer from "./CustomSerializer"
|
||||
import FunctionReferenceEntity from "../entity/FunctionReferenceEntity"
|
||||
import GeneralSerializer from "./GeneralSerializer"
|
||||
import GuidEntity from "../entity/GuidEntity"
|
||||
import IdentifierEntity from "../entity/IdentifierEntity"
|
||||
import Integer64Entity from "../entity/Integer64Entity"
|
||||
import IntegerEntity from "../entity/IntegerEntity"
|
||||
import InvariantTextEntity from "../entity/InvariantTextEntity"
|
||||
import KeyBindingEntity from "../entity/KeyBindingEntity"
|
||||
@@ -61,6 +63,11 @@ export default function initializeSerializerFactory() {
|
||||
)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
BigInt,
|
||||
new ToStringSerializer(BigInt)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
Boolean,
|
||||
new CustomSerializer(
|
||||
@@ -76,6 +83,11 @@ export default function initializeSerializerFactory() {
|
||||
)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
ByteEntity,
|
||||
new ToStringSerializer(ByteEntity)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
FunctionReferenceEntity,
|
||||
new GeneralSerializer(bracketsWrapped, FunctionReferenceEntity)
|
||||
@@ -91,6 +103,11 @@ export default function initializeSerializerFactory() {
|
||||
new ToStringSerializer(IdentifierEntity)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
Integer64Entity,
|
||||
new ToStringSerializer(Integer64Entity)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
IntegerEntity,
|
||||
new ToStringSerializer(IntegerEntity)
|
||||
@@ -123,11 +140,7 @@ export default function initializeSerializerFactory() {
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
Number,
|
||||
new CustomSerializer(
|
||||
/** @param {Number} value */
|
||||
value => value.toString(),
|
||||
Number
|
||||
)
|
||||
new ToStringSerializer(Number)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
|
||||
Reference in New Issue
Block a user