diff --git a/src/lib/diff/tree-diff-application.hpp b/src/lib/diff/tree-diff-application.hpp index 2112ee5c8..2e8794471 100644 --- a/src/lib/diff/tree-diff-application.hpp +++ b/src/lib/diff/tree-diff-application.hpp @@ -155,12 +155,13 @@ namespace diff{ Scopes scopes_; - void + TreeMutator* buildMutator (DiffMutable& targetBinding) { scopes_.clear(); TreeMutator::Handle buffHandle = scopes_.openScope(); targetBinding.buildMutator (buffHandle); + return buffHandle.get(); } public: diff --git a/src/lib/diff/tree-diff-mutator-binding.cpp b/src/lib/diff/tree-diff-mutator-binding.cpp index 305476f17..a92461a20 100644 --- a/src/lib/diff/tree-diff-mutator-binding.cpp +++ b/src/lib/diff/tree-diff-mutator-binding.cpp @@ -267,7 +267,11 @@ namespace diff{ void TreeDiffMutatorBinding::__expect_end_of_scope (GenNode::ID const& idi) { - + if (not treeMutator_->completeScope()) + throw error::State(_Fmt("Diff application floundered in nested scope %s; " + "unexpected extra elements found when diff " + "should have settled everything.") % idi.getSym() + , LUMIERA_ERROR_DIFF_CONFLICT); } void @@ -349,24 +353,22 @@ namespace diff{ void TreeDiffMutatorBinding::mut (GenNode const& n) { - open_subScope (n); + TreeMutator::Handle buffHandle = scopeManger_->openScope(); + if (not treeMutator_->mutateChild(n, buffHandle)) + __failMismatch (n, "enter nested scope"); -#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #992 - Rec const& childRecord = child.data.get(); - TRACE (diff, "tree-diff: ENTER scope %s", cStr(childRecord)); -#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #992 + TRACE (diff, "tree-diff: ENTER scope %s", cStr(n.idi)); + treeMutator_ = buffHandle.get(); } /** finish and leave child object scope, return to parent */ void TreeDiffMutatorBinding::emu (GenNode const& n) { -#if false /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #992 - TRACE (diff, "tree-diff: LEAVE scope %s", cStr(describeScope())); -#endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////UNIMPLEMENTED :: TICKET #992 + TRACE (diff, "tree-diff: LEAVE scope %s", cStr(n.idi)); __expect_end_of_scope (n.idi); - close_subScope(); + treeMutator_ = &scopeManger_->closeScope(); __expect_valid_parent_scope (n.idi); } diff --git a/src/lib/diff/tree-diff-mutator-binding.hpp b/src/lib/diff/tree-diff-mutator-binding.hpp index e581a2b05..e07c5cc67 100644 --- a/src/lib/diff/tree-diff-mutator-binding.hpp +++ b/src/lib/diff/tree-diff-mutator-binding.hpp @@ -289,14 +289,6 @@ namespace diff{ - /* == Forwarding: mutation primitives == */ - - bool matchSrc (GenNode const& n); - void assignElm (GenNode const& n); - void open_subScope (GenNode const& n); - void close_subScope(); - - /* == Implementation of the list diff application primitives == */ diff --git a/src/lib/diff/tree-mutator.hpp b/src/lib/diff/tree-mutator.hpp index 2803c2417..8546e70ce 100644 --- a/src/lib/diff/tree-mutator.hpp +++ b/src/lib/diff/tree-mutator.hpp @@ -154,6 +154,14 @@ namespace lib { { return sizeof(SUB) <= maxSiz_; } + + BA* + get() const + { + ENSURE (buffer_); + BA& bufferContent = **static_cast*> (buffer_); + return &bufferContent; + } }; /////////////////////////////TODO move over into opaque-holder.hpp namespace diff{ @@ -286,7 +294,7 @@ namespace diff{ * and build a suitable sub-mutator for this element * into the provided target buffer * @throw error::Fatal when buffer is insufficient - * @return false when unable to locate the target */ + * @return `false` when unable to locate the target */ virtual bool mutateChild (GenNode const&, Handle) { diff --git a/tests/library/diff/diff-virtualised-application-test.cpp b/tests/library/diff/diff-virtualised-application-test.cpp index 02ce37a3c..d29f16a64 100644 --- a/tests/library/diff/diff-virtualised-application-test.cpp +++ b/tests/library/diff/diff-virtualised-application-test.cpp @@ -79,7 +79,7 @@ namespace test{ */ class Opaque { - idi::EntryID key_; + idi::BareEntryID key_; string type_ = Rec::TYPE_NIL; int alpha_ = -1; @@ -92,11 +92,13 @@ namespace test{ vector nestedData_; public: - Opaque() { } + Opaque() + : key_(idi::EntryID()) + { } explicit Opaque (string keyID) - : key_(keyID) + : key_(idi::EntryID(keyID)) { } explicit @@ -132,14 +134,15 @@ namespace test{ operator string() const { - return _Fmt{"%s (α:%d β:%s γ:%7.5f δ:%s\n......|nested:%s\n......|data:%s\n )"} + return _Fmt{"%s__(α:%d β:%s γ:%7.5f δ:%s\n......|nested:%s\n......|data:%s\n )__END_%s"} % identity() % alpha_ % beta_ % gamma_ % delta_ - % join (nestedObj_, "\n........|") + % join (nestedObj_, "\n......|") % join (nestedData_) + % identity() ; } @@ -347,7 +350,7 @@ namespace test{ // TODO verify results cout << "after...II"<