Several serialization and deserialization fixes

This commit is contained in:
barsdeveloper
2023-04-15 12:20:53 +02:00
parent d10589f0bd
commit baf40a9094
17 changed files with 366 additions and 149 deletions

View File

@@ -26,7 +26,7 @@ describe("Entity initialization", () => {
Entity2,
new Serializer(
Entity2,
v => `{\n${v}\n}`,
(entity, v) => `{\n${v}\n}`,
"\n",
false,
": ",
@@ -37,7 +37,7 @@ describe("Entity initialization", () => {
Entity1,
new Serializer(
Entity1,
v => `Entity1(${v})`,
(entity, v) => `Entity1(${v})`,
", ",
false,
"=",
@@ -147,7 +147,7 @@ describe("Entity initialization", () => {
Entity3,
new Serializer(
Entity3,
v => `[[\n${v}\n]]`,
(entity, v) => `[[\n${v}\n]]`,
"\n",
false,
": ",
@@ -158,7 +158,7 @@ describe("Entity initialization", () => {
Entity1,
new Serializer(
Entity1,
v => `Entity1(${v})`,
(entity, v) => `Entity1(${v})`,
", ",
false,
"=",
@@ -287,7 +287,7 @@ describe("Entity initialization", () => {
Entity4,
new Serializer(
Entity4,
v => `Begin\n${v}\nEnd`,
(entity, v) => `Begin\n${v}\nEnd`,
"\n",
false,
" => ",

View File

@@ -6,40 +6,72 @@ const tests = [
{
name: "ROS Change Element",
value: String.raw`
Begin Object Class=/Script/BlueprintGraph.K2Node_CustomEvent Name="K2Node_CustomEvent_13465"
Begin Object Class=/Script/Engine.EdGraphPin_Deprecated Name="EdGraphPin_2859957"
Begin Object Class=K2Node_CallFunction Name="K2Node_CallFunction_131095"
NodePosX=-5024
NodePosY=-1888
NodeGuid=CC44F0434996CC21484572A242E1F72D
Begin Object Class=EdGraphPin Name="EdGraphPin_3991113"
End Object
Begin Object Class=/Script/Engine.EdGraphPin_Deprecated Name="EdGraphPin_2859956"
Begin Object Class=EdGraphPin Name="EdGraphPin_3991114"
End Object
Begin Object Class=/Script/Engine.EdGraphPin_Deprecated Name="EdGraphPin_2859955"
Begin Object Class=EdGraphPin Name="EdGraphPin_3991115"
End Object
Begin Object Name="EdGraphPin_2859957"
PinName="Element"
Direction=EGPD_Output
PinType=(PinCategory="int")
LinkedTo(0)=None
LinkedTo(1)=None
Begin Object Class=EdGraphPin Name="EdGraphPin_3991116"
End Object
Begin Object Name="EdGraphPin_2859956"
Begin Object Class=EdGraphPin Name="EdGraphPin_3991117"
End Object
Begin Object Class=EdGraphPin Name="EdGraphPin_3991118"
End Object
FunctionReference=(MemberParentClass=Class'/Script/ShooterGame.ShooterGameMode',MemberName="GetFloatOptionIni")
Pins(0)=EdGraphPin'EdGraphPin_3991113'
Pins(1)=EdGraphPin'EdGraphPin_3991114'
Pins(2)=EdGraphPin'EdGraphPin_3991115'
Pins(3)=EdGraphPin'EdGraphPin_3991116'
Pins(4)=EdGraphPin'EdGraphPin_3991117'
Pins(5)=EdGraphPin'EdGraphPin_3991118'
ErrorType=1
ErrorMsg="Error This blueprint (self) is not a ShooterGameMode, therefore \' Target \' must have a connection\nError This blueprint (self) is not a ShooterGameMode, therefore \' Target \' must have a connection"
Begin Object Name="EdGraphPin_3991113"
PinName="execute"
PinType=(PinCategory="exec")
LinkedTo(0)=EdGraphPin'"K2Node_CallFunction_113214.EdGraphPin_3991579"'
End Object
Begin Object Name="EdGraphPin_3991114"
PinName="then"
Direction=EGPD_Output
PinType=(PinCategory="exec")
LinkedTo(0)=None
LinkedTo(0)=EdGraphPin'"K2Node_IfThenElse_7680.EdGraphPin_3991155"'
End Object
Begin Object Name="EdGraphPin_2859955"
PinName="OutputDelegate"
Begin Object Name="EdGraphPin_3991115"
PinName="self"
PinFriendlyName="Target"
PinToolTip="Target\nShooter Game Mode Reference"
PinType=(PinCategory="object",PinSubCategoryObject=Class'/Script/ShooterGame.ShooterGameMode')
LinkedTo(0)=EdGraphPin'"K2Node_DynamicCast_2126.EdGraphPin_3990988"'
End Object
Begin Object Name="EdGraphPin_3991116"
PinName="Section"
PinToolTip="Section\nString"
PinType=(PinCategory="string")
DefaultValue="CrazysDinosStats"
End Object
Begin Object Name="EdGraphPin_3991117"
PinName="OptionName"
PinToolTip="Option Name\nString"
PinType=(PinCategory="string")
DefaultValue="DinoStamina"
End Object
Begin Object Name="EdGraphPin_3991118"
PinName="ReturnValue"
PinToolTip="Return Value\nFloat"
Direction=EGPD_Output
PinType=(PinCategory="delegate")
PinType=(PinCategory="float")
DefaultValue="0.0"
AutogeneratedDefaultValue="0.0"
LinkedTo(0)=EdGraphPin'"K2Node_CallFunction_131096.EdGraphPin_3991132"'
LinkedTo(1)=EdGraphPin'"K2Node_CallFunction_131097.EdGraphPin_3991144"'
LinkedTo(2)=EdGraphPin'"K2Node_VariableSet_21447.EdGraphPin_3992243"'
End Object
CustomFunctionName="ROS Change Element"
FunctionFlags=2097344
NodePosX=-3696
NodePosY=-128
ErrorType=1
NodeGuid=A7AFBC3557734BFDA0D1E917569CA6A1
CustomProperties Pin (PinId=989B6502AF0240A28DE51122C9F3F5D7,PinName="OutputDelegate",Direction="EGPD_Output",PinType.PinCategory="delegate",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(MemberParent=/Script/Engine.BlueprintGeneratedClass'"/Temp/Untitled_1.Untitled_1_C"',MemberName="ROS Change Element",MemberGuid=A7AFBC3557734BFDA0D1E917569CA6A1),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=385BD405C63F4EC5B7D55D902D37A6CE,PinName="then",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties UserDefinedPin ()
End Object
`,
pins: 2,

View File

@@ -92,7 +92,6 @@ describe("Serializer", () => {
context("KeyBindingEntity", () => {
let serializer = SerializerFactory.getSerializer(KeyBindingEntity)
it("Parses A", () =>
expect(serializer.read("A"))
.to.be.instanceOf(KeyBindingEntity)
@@ -115,6 +114,36 @@ describe("Serializer", () => {
)
})
context("ObjectReferenceEntity", () => {
let serializer = SerializerFactory.getSerializer(ObjectReferenceEntity)
it("Parses Class", () =>
expect(serializer.read("Class"))
.to.be.instanceOf(ObjectReferenceEntity)
.and.to.deep.contain({ type: "Class", path: "" })
)
it("Parses Class'/Script/ShooterGame.ShooterGameMode'", () =>
expect(serializer.read(`Class'/Script/ShooterGame.ShooterGameMode'`))
.to.be.instanceOf(ObjectReferenceEntity)
.and.to.deep.contain({ type: "Class", path: "/Script/ShooterGame.ShooterGameMode" })
)
it(`Parses EdGraphPin'"K2Node_DynamicCast_2126.EdGraphPin_3990988"'`, () =>
expect(serializer.read(`EdGraphPin'"K2Node_DynamicCast_2126.EdGraphPin_3990988"'`))
.to.be.instanceOf(ObjectReferenceEntity)
.and.to.deep.contain({ type: "EdGraphPin", path: "K2Node_DynamicCast_2126.EdGraphPin_3990988" })
)
it(`Parses /Script/Engine.EdGraph'"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N"'`, () =>
expect(serializer.read(`/Script/Engine.EdGraph'"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N"'`))
.to.be.instanceOf(ObjectReferenceEntity)
.and.to.deep.contain({ type: "/Script/Engine.EdGraph", path: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N" })
)
it(`Parses Function'"/Game/Mods/CrazyDinos/ElementalDragon/CDElementalDragon_Character_BP.SKEL_CDElementalDragon_Character_BP_C:ROS Change Element"'`, () =>
expect(serializer.read(`Function'"/Game/Mods/CrazyDinos/ElementalDragon/CDElementalDragon_Character_BP.SKEL_CDElementalDragon_Character_BP_C:ROS Change Element"'`))
.to.be.instanceOf(ObjectReferenceEntity)
.and.to.deep.contain({ type: "Function", path: "/Game/Mods/CrazyDinos/ElementalDragon/CDElementalDragon_Character_BP.SKEL_CDElementalDragon_Character_BP_C:ROS Change Element" })
)
})
context("GuidEntity", () => {
let serializer = SerializerFactory.getSerializer(GuidEntity)
@@ -308,11 +337,6 @@ describe("Serializer", () => {
expect(parser.parse(`Class'"/Script/Engine.KismetSystemLibrary"'`).value.constructor)
.equals(ObjectReferenceEntity)
)
it("Parses ObjectReferenceEntity 2", () =>
expect(parser.parse(`Function'"/Game/Mods/CrazyDinos/ElementalDragon/CDElementalDragon_Character_BP.SKEL_CDElementalDragon_Character_BP_C:ROS Change Element"'`)
.value.constructor)
.equals(ObjectReferenceEntity)
)
it("Parses Numbers array", () =>
expect(parser.parse("(1,2,3,4,5,6,7,8,9)").value).to.be.deep.equal([1, 2, 3, 4, 5, 6, 7, 8, 9])
)