From 93365f861854aa32294babbb6da080e976efa8ce Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 20 Aug 2012 09:52:05 +0200 Subject: [PATCH] Added: #1440 Unparser for DllDirectory --HG-- branch : build_pipeline_v3 --- code/nel/tools/pipeline/max/class_data.cpp | 10 +++++ code/nel/tools/pipeline/max/class_data.h | 2 + .../tools/pipeline/max/class_directory_3.cpp | 10 +++++ .../tools/pipeline/max/class_directory_3.h | 2 + code/nel/tools/pipeline/max/config.cpp | 30 +++++++++++++ code/nel/tools/pipeline/max/config.h | 6 +++ code/nel/tools/pipeline/max/dll_directory.cpp | 44 +++++++++++++++++-- code/nel/tools/pipeline/max/dll_directory.h | 3 +- code/nel/tools/pipeline/max/scene.cpp | 15 +++++++ code/nel/tools/pipeline/max/scene.h | 3 ++ .../nel/tools/pipeline/max/storage_object.cpp | 11 +++++ code/nel/tools/pipeline/max/storage_object.h | 2 + code/nel/tools/pipeline/max_dump/main.cpp | 4 ++ 13 files changed, 138 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/pipeline/max/class_data.cpp b/code/nel/tools/pipeline/max/class_data.cpp index c8dfc5b01..dae0a4b6d 100644 --- a/code/nel/tools/pipeline/max/class_data.cpp +++ b/code/nel/tools/pipeline/max/class_data.cpp @@ -75,6 +75,11 @@ void CClassData::build(uint16 version) CStorageContainer::build(version); } +void CClassData::disown() +{ + CStorageContainer::disown(); +} + IStorageObject *CClassData::createChunkById(uint16 id, bool container) { if (container) @@ -122,6 +127,11 @@ void CClassDataEntry::build(uint16 version) CStorageContainer::build(version); } +void CClassDataEntry::disown() +{ + CStorageContainer::disown(); +} + IStorageObject *CClassDataEntry::createChunkById(uint16 id, bool container) { if (!container) diff --git a/code/nel/tools/pipeline/max/class_data.h b/code/nel/tools/pipeline/max/class_data.h index 4d729ec7c..3e7b6a354 100644 --- a/code/nel/tools/pipeline/max/class_data.h +++ b/code/nel/tools/pipeline/max/class_data.h @@ -58,6 +58,7 @@ public: virtual void toString(std::ostream &ostream, const std::string &pad = ""); virtual void parse(uint16 version, TParseLevel level); virtual void build(uint16 version); + virtual void disown(); protected: virtual IStorageObject *createChunkById(uint16 id, bool container); @@ -81,6 +82,7 @@ public: virtual void toString(std::ostream &ostream, const std::string &pad = ""); virtual void parse(uint16 version, TParseLevel level); virtual void build(uint16 version); + virtual void disown(); protected: virtual IStorageObject *createChunkById(uint16 id, bool container); diff --git a/code/nel/tools/pipeline/max/class_directory_3.cpp b/code/nel/tools/pipeline/max/class_directory_3.cpp index 840bb1abf..b90c52ec2 100644 --- a/code/nel/tools/pipeline/max/class_directory_3.cpp +++ b/code/nel/tools/pipeline/max/class_directory_3.cpp @@ -75,6 +75,11 @@ void CClassDirectory3::build(uint16 version) CStorageContainer::build(version); } +void CClassDirectory3::disown() +{ + CStorageContainer::disown(); +} + IStorageObject *CClassDirectory3::createChunkById(uint16 id, bool container) { if (container) @@ -122,6 +127,11 @@ void CClassEntry::build(uint16 version) CStorageContainer::build(version); } +void CClassEntry::disown() +{ + CStorageContainer::disown(); +} + IStorageObject *CClassEntry::createChunkById(uint16 id, bool container) { if (!container) diff --git a/code/nel/tools/pipeline/max/class_directory_3.h b/code/nel/tools/pipeline/max/class_directory_3.h index 425cbecbd..b052af8a0 100644 --- a/code/nel/tools/pipeline/max/class_directory_3.h +++ b/code/nel/tools/pipeline/max/class_directory_3.h @@ -58,6 +58,7 @@ public: virtual void toString(std::ostream &ostream, const std::string &pad = ""); virtual void parse(uint16 version, TParseLevel level); virtual void build(uint16 version); + virtual void disown(); protected: virtual IStorageObject *createChunkById(uint16 id, bool container); @@ -81,6 +82,7 @@ public: virtual void toString(std::ostream &ostream, const std::string &pad = ""); virtual void parse(uint16 version, TParseLevel level); virtual void build(uint16 version); + virtual void disown(); protected: virtual IStorageObject *createChunkById(uint16 id, bool container); diff --git a/code/nel/tools/pipeline/max/config.cpp b/code/nel/tools/pipeline/max/config.cpp index f0dae74f4..8aef081cc 100644 --- a/code/nel/tools/pipeline/max/config.cpp +++ b/code/nel/tools/pipeline/max/config.cpp @@ -76,6 +76,11 @@ void CConfig::build(uint16 version) CStorageContainer::build(version); } +void CConfig::disown() +{ + CStorageContainer::disown(); +} + IStorageObject *CConfig::createChunkById(uint16 id, bool container) { if (container) @@ -133,6 +138,11 @@ void CConfig20a0::build(uint16 version) CStorageContainer::build(version); } +void CConfig20a0::disown() +{ + CStorageContainer::disown(); +} + IStorageObject *CConfig20a0::createChunkById(uint16 id, bool container) { if (container) @@ -188,6 +198,11 @@ void CConfig20a0Entry::build(uint16 version) CStorageContainer::build(version); } +void CConfig20a0Entry::disown() +{ + CStorageContainer::disown(); +} + IStorageObject *CConfig20a0Entry::createChunkById(uint16 id, bool container) { if (container) @@ -270,6 +285,11 @@ void CConfigScript::build(uint16 version) CStorageContainer::build(version); } +void CConfigScript::disown() +{ + CStorageContainer::disown(); +} + IStorageObject *CConfigScript::createChunkById(uint16 id, bool container) { if (container) @@ -317,6 +337,11 @@ void CConfigScriptEntry::build(uint16 version) CStorageContainer::build(version); } +void CConfigScriptEntry::disown() +{ + CStorageContainer::disown(); +} + IStorageObject *CConfigScriptEntry::createChunkById(uint16 id, bool container) { if (container) @@ -405,6 +430,11 @@ void CConfigScriptMetaContainer::build(uint16 version) CStorageContainer::build(version); } +void CConfigScriptMetaContainer::disown() +{ + CStorageContainer::disown(); +} + IStorageObject *CConfigScriptMetaContainer::createChunkById(uint16 id, bool container) { if (container) diff --git a/code/nel/tools/pipeline/max/config.h b/code/nel/tools/pipeline/max/config.h index 7d94b04bc..f8a78a906 100644 --- a/code/nel/tools/pipeline/max/config.h +++ b/code/nel/tools/pipeline/max/config.h @@ -58,6 +58,7 @@ public: virtual void toString(std::ostream &ostream, const std::string &pad = ""); virtual void parse(uint16 version, TParseLevel level); virtual void build(uint16 version); + virtual void disown(); protected: virtual IStorageObject *createChunkById(uint16 id, bool container); @@ -81,6 +82,7 @@ public: virtual void toString(std::ostream &ostream, const std::string &pad = ""); virtual void parse(uint16 version, TParseLevel level); virtual void build(uint16 version); + virtual void disown(); protected: virtual IStorageObject *createChunkById(uint16 id, bool container); @@ -104,6 +106,7 @@ public: virtual void toString(std::ostream &ostream, const std::string &pad = ""); virtual void parse(uint16 version, TParseLevel level); virtual void build(uint16 version); + virtual void disown(); protected: virtual IStorageObject *createChunkById(uint16 id, bool container); @@ -127,6 +130,7 @@ public: virtual void toString(std::ostream &ostream, const std::string &pad = ""); virtual void parse(uint16 version, TParseLevel level); virtual void build(uint16 version); + virtual void disown(); protected: virtual IStorageObject *createChunkById(uint16 id, bool container); @@ -150,6 +154,7 @@ public: virtual void toString(std::ostream &ostream, const std::string &pad = ""); virtual void parse(uint16 version, TParseLevel level); virtual void build(uint16 version); + virtual void disown(); protected: virtual IStorageObject *createChunkById(uint16 id, bool container); @@ -197,6 +202,7 @@ public: virtual void toString(std::ostream &ostream, const std::string &pad = ""); virtual void parse(uint16 version, TParseLevel level); virtual void build(uint16 version); + virtual void disown(); protected: virtual IStorageObject *createChunkById(uint16 id, bool container); diff --git a/code/nel/tools/pipeline/max/dll_directory.cpp b/code/nel/tools/pipeline/max/dll_directory.cpp index ea962dcd0..432cdd4b5 100644 --- a/code/nel/tools/pipeline/max/dll_directory.cpp +++ b/code/nel/tools/pipeline/max/dll_directory.cpp @@ -72,7 +72,7 @@ void CDllDirectory::toString(std::ostream &ostream, const std::string &pad) uint16 id = it->first; switch (id) { - case 0x2038: + case 0x2038: // DllEntry { uint subi = 0; for (std::vector::iterator subit = m_Entries.begin(), subend = m_Entries.end(); subit != subend; ++subit) @@ -109,7 +109,6 @@ void CDllDirectory::parse(uint16 version, TParseLevel level) CStorageContainer::parse(version, level); // Initialize - m_ParseVersion = version; uint16 lastCached = 0xFFFF; bool parsedDllEntry = false; @@ -144,13 +143,44 @@ void CDllDirectory::parse(uint16 version, TParseLevel level) void CDllDirectory::build(uint16 version) { - // TODO: Set up the Chunks list, when (CDllEntry::ID, NULL) is found write out all of the entries. + // Ensure parsed + nlassert(!ChunksOwnsPointers); + + // Initialize + Chunks.clear(); + + // Set up the Chunks list, when (CDllEntry::ID, NULL) is found write out all of the entries. + for (TStorageObjectContainer::iterator it = m_ChunkCache.begin(), end = m_ChunkCache.end(); it != end; ++it) + { + uint16 id = it->first; + switch (id) + { + case 0x2038: // DllEntry + for (std::vector::iterator subit = m_Entries.begin(), subend = m_Entries.end(); subit != subend; ++subit) + Chunks.push_back(TStorageObjectWithId(id, (*subit))); + break; + default: + Chunks.push_back(*it); + break; + } + } + // Build the entries last CStorageContainer::build(version); // NOTE: Ownership remains with m_ChunkCache and m_Entries } +void CDllDirectory::disown() +{ + CStorageContainer::disown(); + m_ChunkCache.clear(); + m_Entries.clear(); + + // Ownership goes back to Chunks + ChunksOwnsPointers = true; +} + const CDllEntry *CDllDirectory::get(std::vector::size_type idx) const { return m_Entries[idx]; @@ -227,6 +257,14 @@ void CDllEntry::build(uint16 version) // CStorageContainer::build(version); } +void CDllEntry::disown() +{ + // CStorageContainer::disown(); + m_DllDescription = NULL; + m_DllFilename = NULL; + nlassert(ChunksOwnsPointers); +} + IStorageObject *CDllEntry::createChunkById(uint16 id, bool container) { if (!container) diff --git a/code/nel/tools/pipeline/max/dll_directory.h b/code/nel/tools/pipeline/max/dll_directory.h index 3cce7619c..1b03f3e10 100644 --- a/code/nel/tools/pipeline/max/dll_directory.h +++ b/code/nel/tools/pipeline/max/dll_directory.h @@ -60,6 +60,7 @@ public: virtual void toString(std::ostream &ostream, const std::string &pad = ""); virtual void parse(uint16 version, TParseLevel level); virtual void build(uint16 version); + virtual void disown(); // public const CDllEntry *get(std::vector::size_type idx) const; @@ -68,7 +69,6 @@ protected: virtual IStorageObject *createChunkById(uint16 id, bool container); private: - uint16 m_ParseVersion; TStorageObjectContainer m_ChunkCache; std::vector m_Entries; @@ -91,6 +91,7 @@ public: virtual void toString(std::ostream &ostream, const std::string &pad = ""); virtual void parse(uint16 version, TParseLevel level); virtual void build(uint16 version); + virtual void disown(); const ucstring &dllDescription() { return m_DllDescription->Value; } const ucstring &dllFilename() { return m_DllFilename->Value; } diff --git a/code/nel/tools/pipeline/max/scene.cpp b/code/nel/tools/pipeline/max/scene.cpp index 92f77bf10..9a6a24fcc 100644 --- a/code/nel/tools/pipeline/max/scene.cpp +++ b/code/nel/tools/pipeline/max/scene.cpp @@ -76,6 +76,11 @@ void CScene::build(uint16 version) CStorageContainer::build(version); } +void CScene::disown() +{ + CStorageContainer::disown(); +} + IStorageObject *CScene::createChunkById(uint16 id, bool container) { if (container) @@ -120,6 +125,11 @@ void CSceneClassContainer::build(uint16 version) CStorageContainer::build(version); } +void CSceneClassContainer::disown() +{ + CStorageContainer::disown(); +} + IStorageObject *CSceneClassContainer::createChunkById(uint16 id, bool container) { if (container) @@ -165,6 +175,11 @@ void CSceneClass::build(uint16 version) CStorageContainer::build(version); } +void CSceneClass::disown() +{ + CStorageContainer::disown(); +} + IStorageObject *CSceneClass::createChunkById(uint16 id, bool container) { return CStorageContainer::createChunkById(id, container); diff --git a/code/nel/tools/pipeline/max/scene.h b/code/nel/tools/pipeline/max/scene.h index 83ccfed8f..1ab5958dd 100644 --- a/code/nel/tools/pipeline/max/scene.h +++ b/code/nel/tools/pipeline/max/scene.h @@ -61,6 +61,7 @@ public: virtual void toString(std::ostream &ostream, const std::string &pad = ""); virtual void parse(uint16 version, TParseLevel level); virtual void build(uint16 version); + virtual void disown(); protected: virtual IStorageObject *createChunkById(uint16 id, bool container); @@ -84,6 +85,7 @@ public: virtual void toString(std::ostream &ostream, const std::string &pad = ""); virtual void parse(uint16 version, TParseLevel level); virtual void build(uint16 version); + virtual void disown(); protected: virtual IStorageObject *createChunkById(uint16 id, bool container); @@ -109,6 +111,7 @@ public: virtual void toString(std::ostream &ostream, const std::string &pad = ""); virtual void parse(uint16 version, TParseLevel level); virtual void build(uint16 version); + virtual void disown(); // static const static const ucchar *DisplayName; diff --git a/code/nel/tools/pipeline/max/storage_object.cpp b/code/nel/tools/pipeline/max/storage_object.cpp index a133b7262..22278a862 100644 --- a/code/nel/tools/pipeline/max/storage_object.cpp +++ b/code/nel/tools/pipeline/max/storage_object.cpp @@ -191,6 +191,17 @@ void CStorageContainer::build(uint16 version) } } +void CStorageContainer::disown() +{ + for (TStorageObjectContainer::const_iterator it = Chunks.begin(), end = Chunks.end(); it != end; ++it) + { + if (it->second->isContainer()) + { + static_cast(it->second)->disown(); + } + } +} + bool CStorageContainer::isContainer() const { return true; diff --git a/code/nel/tools/pipeline/max/storage_object.h b/code/nel/tools/pipeline/max/storage_object.h index 5e9d25b08..03b1f775c 100644 --- a/code/nel/tools/pipeline/max/storage_object.h +++ b/code/nel/tools/pipeline/max/storage_object.h @@ -122,6 +122,8 @@ public: virtual void parse(uint16 version, TParseLevel level); // Build the storage structure needed to store the parsed data back virtual void build(uint16 version); + // Give ownership of the chunks back to the Chunks, must build first + virtual void disown(); public: // should be protected but that doesn't compile, nice c++! // inherited diff --git a/code/nel/tools/pipeline/max_dump/main.cpp b/code/nel/tools/pipeline/max_dump/main.cpp index 1edac2b17..1d2949efc 100644 --- a/code/nel/tools/pipeline/max_dump/main.cpp +++ b/code/nel/tools/pipeline/max_dump/main.cpp @@ -88,6 +88,10 @@ int main(int argc, char **argv) dllDirectory.parse(PIPELINE::MAX::VersionUnknown, PIPELINE::MAX::PARSE_INTERNAL); dllDirectory.toString(std::cout); std::cout << "\n"; + dllDirectory.build(PIPELINE::MAX::VersionUnknown); + dllDirectory.disown(); + dllDirectory.toString(std::cout); + std::cout << "\n"; /*