Integer => IntegerEntity, No more primitive

This commit is contained in:
barsdeveloper
2021-11-23 21:01:07 +01:00
parent 6a3e2cc36f
commit c774886a2e
8 changed files with 52 additions and 85 deletions

View File

@@ -1,6 +1,6 @@
import FunctionReferenceEntity from "../entity/FunctionReferenceEntity"
import GuidEntity from "../entity/GuidEntity"
import Integer from "../entity/primitive/Integer"
import IntegerEntity from "../entity/IntegerEntity"
import LocalizedTextEntity from "../entity/LocalizedTextEntity"
import ObjectEntity from "../entity/ObjectEntity"
import ObjectReferenceEntity from "../entity/ObjectReferenceEntity"
@@ -21,7 +21,7 @@ export default class Grammar {
None = _ => P.string("None").map(_ => new ObjectReferenceEntity({ type: "None", path: "" })).desc("none")
Boolean = _ => P.alt(P.string("True"), P.string("False")).map(v => v === "True" ? true : false).desc("either True or False")
Number = _ => P.regex(/[0-9]+(?:\.[0-9]+)?/).map(Number).desc("a number")
Integer = _ => P.regex(/[0-9]+/).map(v => new Integer(v)).desc("an integer")
Integer = _ => P.regex(/[0-9]+/).map(v => new IntegerEntity({ value: v })).desc("an integer")
String = _ => P.regex(/(?:[^"\\]|\\")*/).wrap(P.string('"'), P.string('"')).desc('string (with possibility to escape the quote using \")')
Word = _ => P.regex(/[a-zA-Z]+/).desc("a word")
Guid = _ => P.regex(/[0-9a-zA-Z]{32}/).map(v => new GuidEntity({ value: v })).desc("32 digit hexadecimal (accepts all the letters for safety) value")
@@ -76,7 +76,7 @@ export default class Grammar {
return r.Boolean
case Number:
return r.Number
case Integer:
case IntegerEntity:
return r.Integer
case String:
return r.String

View File

@@ -1,7 +1,6 @@
import Entity from "../entity/Entity"
import Grammar from "./Grammar"
import Parsimmon from "parsimmon"
import Primitive from "../entity/primitive/Primitive"
import SerializerFactory from "./SerializerFactory"
import TypeInitialization from "../entity/TypeInitialization"
import Utility from "../Utility"
@@ -41,9 +40,6 @@ export default class Serializer {
if (value instanceof Entity) {
return serialize(value)
}
if (value instanceof Primitive) {
return value.toString()
}
}
subWrite(key, object) {