From 1b6a87324d051e012efa79636455e8a8c383f9d4 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Thu, 25 Aug 2016 18:42:51 +0200 Subject: [PATCH] implement value assignment through TreeMutator --- src/lib/diff/tree-diff-mutator-binding.cpp | 38 ++++--------------- .../diff/tree-mutator-collection-binding.hpp | 6 +-- wiki/thinkPad.ichthyo.mm | 9 +++-- 3 files changed, 15 insertions(+), 38 deletions(-) diff --git a/src/lib/diff/tree-diff-mutator-binding.cpp b/src/lib/diff/tree-diff-mutator-binding.cpp index bc6e5a7c1..305476f17 100644 --- a/src/lib/diff/tree-diff-mutator-binding.cpp +++ b/src/lib/diff/tree-diff-mutator-binding.cpp @@ -259,8 +259,8 @@ namespace diff{ void TreeDiffMutatorBinding::__failMismatch (GenNode const& spec, Literal oper) { - throw error::State(_Fmt("Unable to %s element %s. Current target binding " - "did not match as expected") % oper % spec + throw error::State(_Fmt("Unable to %s element %s. Current shape of target " + "data does not match expectations") % oper % spec , LUMIERA_ERROR_DIFF_CONFLICT); } @@ -273,36 +273,13 @@ namespace diff{ void TreeDiffMutatorBinding::__expect_valid_parent_scope (GenNode::ID const& idi) { - + if (0 == scopeManger_->depth()) + throw error::Fatal(_Fmt("Diff application floundered after leaving scope %s; " + "unbalanced nested scopes, diff attempts to pop root.") % idi.getSym() + , LUMIERA_ERROR_DIFF_CONFLICT); } - /* == Forwarding: mutation primitives == */ - - bool - TreeDiffMutatorBinding::matchSrc (GenNode const& n) - { - UNIMPLEMENTED("ensure the next source element matches with given spec"); - } - - void - TreeDiffMutatorBinding::assignElm (GenNode const& n) - { - UNIMPLEMENTED("locate already accepted element and assign given new payload"); - } - - void - TreeDiffMutatorBinding::open_subScope (GenNode const& n) - { - UNIMPLEMENTED("locate already accepted element and open recursive sub-scope for mutation"); - } - - void - TreeDiffMutatorBinding::close_subScope() - { - UNIMPLEMENTED("finish and leave sub scope and return to invoking parent scope"); - } - /* == Implementation of the list diff application primitives == */ @@ -364,7 +341,8 @@ namespace diff{ void TreeDiffMutatorBinding::set (GenNode const& n) { - assignElm (n); + if (not treeMutator_->assignElm(n)) + __failMismatch (n, "assign"); } /** open nested scope to apply diff to child object */ diff --git a/src/lib/diff/tree-mutator-collection-binding.hpp b/src/lib/diff/tree-mutator-collection-binding.hpp index 079f92188..d1d207073 100644 --- a/src/lib/diff/tree-mutator-collection-binding.hpp +++ b/src/lib/diff/tree-mutator-collection-binding.hpp @@ -327,8 +327,7 @@ if (binding_.isApplicable(spec)) { Iter target_found = binding_.locate (spec); - return target_found? binding_.assign (*target_found, spec) - : false; + return target_found and binding_.assign (*target_found, spec); } else return PAR::assignElm (spec); @@ -342,8 +341,7 @@ if (binding_.isApplicable(spec)) { Iter target_found = binding_.locate (spec); - return target_found? binding_.openSub (*target_found, spec.idi, targetBuff) - : false; + return target_found and binding_.openSub (*target_found, spec.idi, targetBuff); } else return PAR::mutateChild (spec, targetBuff); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 931891972..174cbe735 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -4243,7 +4243,7 @@ - + @@ -4514,7 +4514,7 @@ - + @@ -4537,7 +4537,7 @@ - + @@ -4656,7 +4656,7 @@ - + @@ -4828,6 +4828,7 @@ +