From 8d01882ed5b53b73829ff5c804ac926d8d56b0fb Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Mon, 4 Jul 2022 12:03:28 -0500 Subject: [PATCH] [nostalgia/core] Update TypeStore::loadDescriptor to take type version --- ...tte => net.drinkingtea.nostalgia.core.Palette;1} | 3 ++- ...drinkingtea.nostalgia.core.TileSheet.SubSheet;1} | 5 ++++- ...t => net.drinkingtea.nostalgia.core.TileSheet;2} | 3 ++- ...s.Data => net.drinkingtea.ox.FileAddress.Data;1} | 3 ++- ...FileAddress => net.drinkingtea.ox.FileAddress;1} | 3 ++- src/nostalgia/core/typestore.cpp | 13 +++++++++++++ src/nostalgia/core/typestore.hpp | 9 +-------- 7 files changed, 26 insertions(+), 13 deletions(-) rename sample_project/.nostalgia/type_descriptors/{net.drinkingtea.nostalgia.core.Palette => net.drinkingtea.nostalgia.core.Palette;1} (66%) rename sample_project/.nostalgia/type_descriptors/{net.drinkingtea.nostalgia.core.TileSheet.SubSheet => net.drinkingtea.nostalgia.core.TileSheet.SubSheet;1} (87%) rename sample_project/.nostalgia/type_descriptors/{net.drinkingtea.nostalgia.core.TileSheet => net.drinkingtea.nostalgia.core.TileSheet;2} (81%) rename sample_project/.nostalgia/type_descriptors/{net.drinkingtea.ox.FileAddress.Data => net.drinkingtea.ox.FileAddress.Data;1} (79%) rename sample_project/.nostalgia/type_descriptors/{net.drinkingtea.ox.FileAddress => net.drinkingtea.ox.FileAddress;1} (77%) diff --git a/sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.Palette b/sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.Palette;1 similarity index 66% rename from sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.Palette rename to sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.Palette;1 index 62ffcff7..8da37a24 100644 --- a/sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.Palette +++ b/sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.Palette;1 @@ -7,5 +7,6 @@ O1;net.drinkingtea.ox.DescriptorType;2;{ } ], "primitiveType" : 5, - "typeName" : "net.drinkingtea.nostalgia.core.Palette" + "typeName" : "net.drinkingtea.nostalgia.core.Palette", + "typeVersion" : 1 } diff --git a/sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.TileSheet.SubSheet b/sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.TileSheet.SubSheet;1 similarity index 87% rename from sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.TileSheet.SubSheet rename to sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.TileSheet.SubSheet;1 index c785adca..c165d2b0 100644 --- a/sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.TileSheet.SubSheet +++ b/sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.TileSheet.SubSheet;1 @@ -15,13 +15,16 @@ O1;net.drinkingtea.ox.DescriptorType;2;{ }, { "fieldName" : "subsheets", + "subscriptLevels" : 1, "typeName" : "net.drinkingtea.nostalgia.core.TileSheet.SubSheet" }, { "fieldName" : "pixels", + "subscriptLevels" : 1, "typeName" : "B:uint8_t" } ], "primitiveType" : 5, - "typeName" : "net.drinkingtea.nostalgia.core.TileSheet.SubSheet" + "typeName" : "net.drinkingtea.nostalgia.core.TileSheet.SubSheet", + "typeVersion" : 1 } diff --git a/sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.TileSheet b/sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.TileSheet;2 similarity index 81% rename from sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.TileSheet rename to sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.TileSheet;2 index 6029cbda..918307ea 100644 --- a/sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.TileSheet +++ b/sample_project/.nostalgia/type_descriptors/net.drinkingtea.nostalgia.core.TileSheet;2 @@ -15,5 +15,6 @@ O1;net.drinkingtea.ox.DescriptorType;2;{ } ], "primitiveType" : 5, - "typeName" : "net.drinkingtea.nostalgia.core.TileSheet" + "typeName" : "net.drinkingtea.nostalgia.core.TileSheet", + "typeVersion" : 2 } diff --git a/sample_project/.nostalgia/type_descriptors/net.drinkingtea.ox.FileAddress.Data b/sample_project/.nostalgia/type_descriptors/net.drinkingtea.ox.FileAddress.Data;1 similarity index 79% rename from sample_project/.nostalgia/type_descriptors/net.drinkingtea.ox.FileAddress.Data rename to sample_project/.nostalgia/type_descriptors/net.drinkingtea.ox.FileAddress.Data;1 index 35a5bc88..8c1f9ccf 100644 --- a/sample_project/.nostalgia/type_descriptors/net.drinkingtea.ox.FileAddress.Data +++ b/sample_project/.nostalgia/type_descriptors/net.drinkingtea.ox.FileAddress.Data;1 @@ -15,5 +15,6 @@ O1;net.drinkingtea.ox.DescriptorType;2;{ } ], "primitiveType" : 6, - "typeName" : "net.drinkingtea.ox.FileAddress.Data" + "typeName" : "net.drinkingtea.ox.FileAddress.Data", + "typeVersion" : 1 } diff --git a/sample_project/.nostalgia/type_descriptors/net.drinkingtea.ox.FileAddress b/sample_project/.nostalgia/type_descriptors/net.drinkingtea.ox.FileAddress;1 similarity index 77% rename from sample_project/.nostalgia/type_descriptors/net.drinkingtea.ox.FileAddress rename to sample_project/.nostalgia/type_descriptors/net.drinkingtea.ox.FileAddress;1 index 0a310c0c..5c9b634d 100644 --- a/sample_project/.nostalgia/type_descriptors/net.drinkingtea.ox.FileAddress +++ b/sample_project/.nostalgia/type_descriptors/net.drinkingtea.ox.FileAddress;1 @@ -11,5 +11,6 @@ O1;net.drinkingtea.ox.DescriptorType;2;{ } ], "primitiveType" : 5, - "typeName" : "net.drinkingtea.ox.FileAddress" + "typeName" : "net.drinkingtea.ox.FileAddress", + "typeVersion" : 1 } diff --git a/src/nostalgia/core/typestore.cpp b/src/nostalgia/core/typestore.cpp index 21a9329e..e45823a9 100644 --- a/src/nostalgia/core/typestore.cpp +++ b/src/nostalgia/core/typestore.cpp @@ -3,3 +3,16 @@ */ #include "typestore.hpp" + +namespace nostalgia::core { + +ox::Result> TypeStore::loadDescriptor(const ox::String &name, int version) noexcept { + constexpr auto descPath = "/.nostalgia/type_descriptors"; + auto path = ox::sfmt("{}/{};{}", descPath, name, version); + oxRequire(buff, m_fs->read(path)); + auto dt = ox::make_unique(); + oxReturnError(ox::readClaw(buff, dt.get())); + return dt; +} + +} \ No newline at end of file diff --git a/src/nostalgia/core/typestore.hpp b/src/nostalgia/core/typestore.hpp index 07b299fc..70956b82 100644 --- a/src/nostalgia/core/typestore.hpp +++ b/src/nostalgia/core/typestore.hpp @@ -20,14 +20,7 @@ class TypeStore: public ox::TypeStore { } protected: - ox::Result> loadDescriptor(const ox::String &name) noexcept override { - constexpr auto descPath = "/.nostalgia/type_descriptors"; - auto path = ox::sfmt("{}/{}", descPath, name); - oxRequire(buff, m_fs->read(path)); - auto dt = ox::make_unique(); - oxReturnError(ox::readClaw(buff, dt.get())); - return dt; - } + ox::Result> loadDescriptor(const ox::String &name, int version) noexcept override; }; }