diff --git a/dist/ueblueprint.js b/dist/ueblueprint.js index 95761ce..f765f63 100644 --- a/dist/ueblueprint.js +++ b/dist/ueblueprint.js @@ -353,13 +353,13 @@ class ObjectEntity extends Entity { Class: ObjectReferenceEntity, Name: "", bIsPureFunc: new TypeInitialization(false, false), - VariableReference: new TypeInitialization(new VariableReferenceEntity(), false), - FunctionReference: new TypeInitialization(new FunctionReferenceEntity(), false), - TargetType: new TypeInitialization(new ObjectReferenceEntity(), false), + VariableReference: new TypeInitialization(null, false, VariableReferenceEntity), + FunctionReference: new TypeInitialization(null, false, FunctionReferenceEntity), + TargetType: new TypeInitialization(null, false, ObjectReferenceEntity), NodePosX: Integer, NodePosY: Integer, NodeGuid: GuidEntity, - CustomProperties: [PinEntity$1] + CustomProperties: [new TypeInitialization(null, false, PinEntity$1)] } getAttributes() { @@ -383,7 +383,7 @@ class Grammar { 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") PathSymbol = _ => P.regex(/[0-9a-zA-Z_]+/) - ReferencePath = _ => P.seq(P.string("/"), r.PathSymbol.sepBy1(P.string(".")).tieWith(".")) + ReferencePath = r => P.seq(P.string("/"), r.PathSymbol.sepBy1(P.string(".")).tieWith(".")) .tie() .atLeast(2) .tie() @@ -513,10 +513,21 @@ class Grammar { PinEntity$1, attributeKey => Utility.objectGet(PinEntity$1.attributes, attributeKey) ) + CustomProperties = r => + P.string("CustomProperties") + .then(P.whitespace) + .then(r.Pin) + .map(pin => entity => { + /** @type {Array} */ + let properties = Utility.objectGet(entity, ["CustomProperties"], []); + properties.push(pin); + Utility.objectSet(entity, ["CustomProperties"], properties, true); + }) + Object = r => P.seqMap( P.seq(P.string("Begin"), P.whitespace, P.string("Object"), P.whitespace), P.alt( - Grammar.CreateAttributeGrammar(r, P.string("CustomProperties"), _ => ObjectEntity.attributes.CustomProperties, P.whitespace), + r.CustomProperties, Grammar.CreateAttributeGrammar(r, r.AttributeName, attributeKey => Utility.objectGet(ObjectEntity.attributes, attributeKey)) ) .sepBy1(P.whitespace), diff --git a/js/entity/ObjectEntity.js b/js/entity/ObjectEntity.js index 7f4308b..9778bdf 100644 --- a/js/entity/ObjectEntity.js +++ b/js/entity/ObjectEntity.js @@ -13,13 +13,13 @@ export default class ObjectEntity extends Entity { Class: ObjectReferenceEntity, Name: "", bIsPureFunc: new TypeInitialization(false, false), - VariableReference: new TypeInitialization(new VariableReferenceEntity(), false), - FunctionReference: new TypeInitialization(new FunctionReferenceEntity(), false), - TargetType: new TypeInitialization(new ObjectReferenceEntity(), false), - NodePosX: Integer, - NodePosY: Integer, + VariableReference: new TypeInitialization(null, false, VariableReferenceEntity), + FunctionReference: new TypeInitialization(null, false, FunctionReferenceEntity), + TargetType: new TypeInitialization(null, false, ObjectReferenceEntity), + NodePosX: 0, + NodePosY: 0, NodeGuid: GuidEntity, - CustomProperties: [PinEntity] + CustomProperties: [new TypeInitialization(null, false, PinEntity)] } getAttributes() { diff --git a/js/serialization/Grammar.js b/js/serialization/Grammar.js index 8dd20e3..9d840c6 100644 --- a/js/serialization/Grammar.js +++ b/js/serialization/Grammar.js @@ -25,7 +25,7 @@ export default class Grammar { 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") PathSymbol = _ => P.regex(/[0-9a-zA-Z_]+/) - ReferencePath = _ => P.seq(P.string("/"), r.PathSymbol.sepBy1(P.string(".")).tieWith(".")) + ReferencePath = r => P.seq(P.string("/"), r.PathSymbol.sepBy1(P.string(".")).tieWith(".")) .tie() .atLeast(2) .tie() @@ -155,10 +155,21 @@ export default class Grammar { PinEntity, attributeKey => Utility.objectGet(PinEntity.attributes, attributeKey) ) + CustomProperties = r => + P.string("CustomProperties") + .then(P.whitespace) + .then(r.Pin) + .map(pin => entity => { + /** @type {Array} */ + let properties = Utility.objectGet(entity, ["CustomProperties"], []) + properties.push(pin) + Utility.objectSet(entity, ["CustomProperties"], properties, true) + }) + Object = r => P.seqMap( P.seq(P.string("Begin"), P.whitespace, P.string("Object"), P.whitespace), P.alt( - Grammar.CreateAttributeGrammar(r, P.string("CustomProperties"), _ => ObjectEntity.attributes.CustomProperties, P.whitespace), + r.CustomProperties, Grammar.CreateAttributeGrammar(r, r.AttributeName, attributeKey => Utility.objectGet(ObjectEntity.attributes, attributeKey)) ) .sepBy1(P.whitespace), diff --git a/ueblueprint.html b/ueblueprint.html index e01184b..6aea59a 100644 --- a/ueblueprint.html +++ b/ueblueprint.html @@ -15,7 +15,18 @@
Hello