Grammar refactoring

* Grammar refactoring WIP

* ISerializer.grammar

* Fixing various bugs in the grammar

* Small touch that improoves performance

* Fix unknown values grammar

* Various fixes

* Serialization refactoring to drop suboject logic

* Details fixed

* Entity attributes initialization refactoring

* JSDoc error fixed

* Rename value key to default

* Remove useless default

* Revert string keys
This commit is contained in:
barsdeveloper
2023-04-01 19:55:16 +02:00
committed by GitHub
parent b235d63348
commit bb24486303
44 changed files with 6395 additions and 6248 deletions

View File

@@ -1,11 +1,11 @@
import BoolPinTemplate from "../template/pin/BoolPinTemplate.js"
import ElementFactory from "./ElementFactory.js"
import ExecPinTemplate from "../template/pin/ExecPinTemplate.js"
import Grammar from "../serialization/Grammar.js"
import GuidEntity from "../entity/GuidEntity.js"
import IElement from "./IElement.js"
import Int64PinTemplate from "../template/pin/Int64PinTemplate.js"
import IntPinTemplate from "../template/pin/IntPinTemplate.js"
import ISerializer from "../serialization/ISerializer.js"
import LinearColorEntity from "../entity/LinearColorEntity.js"
import LinearColorPinTemplate from "../template/pin/LinearColorPinTemplate.js"
import NamePinTemplate from "../template/pin/NamePinTemplate.js"
@@ -27,6 +27,10 @@ import VectorPinTemplate from "../template/pin/VectorPinTemplate.js"
* @typedef {import("lit").CSSResult} CSSResult
* @typedef {typeof PinElement} PinElementConstructor
*/
/**
* @template T
* @typedef {import("parsimmon").Success<T>} Success
*/
/**
* @template {AnyValue} T
@@ -54,7 +58,7 @@ export default class PinElement extends IElement {
type: GuidEntity,
converter: {
fromAttribute: (value, type) => value
? ISerializer.grammar.Guid.parse(value).value
? /** @type {Success<GuidEntity>} */(Grammar.guidEntity.parse(value)).value
: null,
toAttribute: (value, type) => value?.toString(),
},
@@ -75,7 +79,7 @@ export default class PinElement extends IElement {
type: LinearColorEntity,
converter: {
fromAttribute: (value, type) => value
? ISerializer.grammar.LinearColorFromAnyColor.parse(value).value
? /** @type {Success<LinearColorEntity>} */(Grammar.linearColorFromAnyFormat.parse(value)).value
: null,
toAttribute: (value, type) => value ? Utility.printLinearColor(value) : null,
},
@@ -107,7 +111,7 @@ export default class PinElement extends IElement {
* @return {new () => PinTemplate}
*/
static getTypeTemplate(pinEntity) {
if (pinEntity.PinType.bIsReference && !pinEntity.PinType.bIsConst) {
if (pinEntity.PinType$bIsReference && !pinEntity.PinType$bIsConst) {
return PinElement.#inputPinTemplates["MUTABLE_REFERENCE"]
}
if (pinEntity.getType() === "exec") {