From b47b4c3f9489f49cac0220bda35c468b856efaab Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 24 May 2016 21:34:08 +0200 Subject: [PATCH] flip logic of emptySrc -> hasSrc ..as concluded from the preceding analysis. NOTE this entails a semantical change, since this predicate is now only meant to be indicative, not conclusive remarks: the actual implementation of the diff application process as bound via the TreeMutator remains yet to be written... --- src/lib/diff/test-mutation-target.hpp | 6 +-- src/lib/diff/tree-diff-mutator-binding.hpp | 2 +- .../diff/tree-mutator-collection-binding.hpp | 4 +- src/lib/diff/tree-mutator.hpp | 4 +- .../diff/tree-manipulation-binding-test.cpp | 24 +++++----- wiki/renderengine.html | 6 +-- wiki/thinkPad.ichthyo.mm | 48 ++++++++++++++++--- 7 files changed, 64 insertions(+), 30 deletions(-) diff --git a/src/lib/diff/test-mutation-target.hpp b/src/lib/diff/test-mutation-target.hpp index eeb091f72..afa23e23f 100644 --- a/src/lib/diff/test-mutation-target.hpp +++ b/src/lib/diff/test-mutation-target.hpp @@ -402,10 +402,10 @@ namespace diff{ } virtual bool - emptySrc () override + hasSrc () override { - return !pos_ - and PAR::emptySrc(); + return pos_ + or PAR::hasSrc(); } /** ensure the next recorded source element diff --git a/src/lib/diff/tree-diff-mutator-binding.hpp b/src/lib/diff/tree-diff-mutator-binding.hpp index f32c3f972..652e24389 100644 --- a/src/lib/diff/tree-diff-mutator-binding.hpp +++ b/src/lib/diff/tree-diff-mutator-binding.hpp @@ -131,7 +131,7 @@ namespace diff{ Mutator& out() { return scopes_.top().target; } Content& src() { return scopes_.top().content; } Iter& srcPos() { return scopes_.top().content.pos; } - bool endOfData() { return srcPos() == src().end(); } + bool endOfData() { return srcPos() == src().end(); } /////TODO split into an actual scope end check and an non-null check Rec& alteredRec() { return out(); } diff --git a/src/lib/diff/tree-mutator-collection-binding.hpp b/src/lib/diff/tree-mutator-collection-binding.hpp index 5fd7eaab3..99fb71567 100644 --- a/src/lib/diff/tree-mutator-collection-binding.hpp +++ b/src/lib/diff/tree-mutator-collection-binding.hpp @@ -225,9 +225,9 @@ } virtual bool - emptySrc () override + hasSrc () override { - return !pos_; + return pos_; } /** ensure the next recorded source element diff --git a/src/lib/diff/tree-mutator.hpp b/src/lib/diff/tree-mutator.hpp index a9204f5ee..4db462a78 100644 --- a/src/lib/diff/tree-mutator.hpp +++ b/src/lib/diff/tree-mutator.hpp @@ -201,9 +201,9 @@ namespace diff{ /* ==== operation API ==== */ virtual bool - emptySrc () + hasSrc () { - return true; + return false; // do nothing by default } diff --git a/tests/library/diff/tree-manipulation-binding-test.cpp b/tests/library/diff/tree-manipulation-binding-test.cpp index 26eb07074..9fa91a08b 100644 --- a/tests/library/diff/tree-manipulation-binding-test.cpp +++ b/tests/library/diff/tree-manipulation-binding-test.cpp @@ -123,7 +123,7 @@ namespace test{ .attachDummy (target); CHECK (isnil (target)); - CHECK (mutator.emptySrc()); + CHECK (not mutator.hasSrc()); mutator.injectNew (ATTRIB1); CHECK (!isnil (target)); @@ -159,7 +159,7 @@ namespace test{ .before("attachMutator")); CHECK (isnil (target)); // the "visible" new content is still void - CHECK (not mutator2.emptySrc()); // content was moved into hidden "src" buffer + CHECK (mutator2.hasSrc()); // content was moved into hidden "src" buffer CHECK (target.showSrcBuffer() == "α = 1, γ = 3.45, γ = 3.45, b, b, 78:56:34.012"); CHECK (mutator2.matchSrc (ATTRIB1)); // current head element of src "matches" the given spec @@ -173,32 +173,32 @@ namespace test{ CHECK (mutator2.acceptSrc (ATTRIB1)); // now pick and accept this src element // acceptSrc CHECK (target.showContent() == "γ = 3.45, α = 1"); - CHECK (not mutator2.emptySrc()); // next we have to clean up waste + CHECK (mutator2.hasSrc()); // next we have to clean up waste mutator2.skipSrc(); // left behind by the findSrc() operation // skipSrc CHECK (target.showContent() == "γ = 3.45, α = 1"); mutator2.injectNew (ATTRIB2); // injectNew - CHECK (not mutator2.emptySrc()); + CHECK (mutator2.hasSrc()); CHECK (mutator2.matchSrc (ATTRIB3)); CHECK (mutator2.acceptSrc (ATTRIB3)); // acceptSrc CHECK (target.showContent() == "γ = 3.45, α = 1, β = 2, γ = 3.45"); // now proceeding with the children. // NOTE: the TestWireTap / TestMutationTarget does not enforce the attribute / children distinction! - CHECK (not mutator2.emptySrc()); + CHECK (mutator2.hasSrc()); CHECK (mutator2.matchSrc (CHILD_B)); // first child waiting in src is CHILD_B mutator2.skipSrc(); // ...which will be skipped (and thus discarded) // skipSrc mutator2.injectNew (SUB_NODE); // inject a new nested sub-structure here // injectNew CHECK (mutator2.matchSrc (CHILD_B)); // yet another B-child is waiting CHECK (not mutator2.findSrc (CHILD_A)); // unsuccessful find operation won't do anything - CHECK (not mutator2.emptySrc()); + CHECK (mutator2.hasSrc()); CHECK (mutator2.matchSrc (CHILD_B)); // child B still waiting, unaffected CHECK (not mutator2.acceptSrc (CHILD_T)); // refusing to accept/pick a non matching element CHECK (mutator2.matchSrc (CHILD_B)); // child B still patiently waiting, unaffected CHECK (mutator2.acceptSrc (CHILD_B)); // acceptSrc CHECK (mutator2.matchSrc (CHILD_T)); CHECK (mutator2.acceptSrc (CHILD_T)); // acceptSrc - CHECK (mutator2.emptySrc()); // source contents exhausted + CHECK (not mutator2.hasSrc()); // source contents exhausted CHECK (not mutator2.acceptSrc (CHILD_T)); CHECK (target.verify("attachMutator") .beforeEvent("injectNew","78:56:34.012") @@ -249,7 +249,7 @@ namespace test{ TreeMutator::MutatorBuffer placementHandle(subMutatorBuffer); CHECK (mutator3.mutateChild (SUB_NODE, placementHandle)); - CHECK (subMutatorBuffer->emptySrc()); // ...this is all we can do here + CHECK (not subMutatorBuffer->hasSrc()); // ...this is all we can do here // the real implementation would instead find a suitable // sub-mutator within this buffer and recurse into that. @@ -336,7 +336,7 @@ namespace test{ // --- first round: populate the collection --- CHECK (isnil (target)); - CHECK (mutator1.emptySrc()); + CHECK (not mutator1.hasSrc()); mutator1.injectNew (ATTRIB1); CHECK (!isnil (target)); @@ -412,14 +412,14 @@ namespace test{ mutator2.injectNew (SUB_NODE); // inject a nested sub-structure (implementation defined) // injectNew CHECK (mutator2.matchSrc (CHILD_B)); // yet another B-child is waiting CHECK (not mutator2.findSrc (CHILD_A)); // unsuccessful find operation won't do anything - CHECK (not mutator2.emptySrc()); + CHECK (mutator2.hasSrc()); CHECK (mutator2.matchSrc (CHILD_B)); // child B still waiting, unaffected CHECK (not mutator2.acceptSrc (CHILD_T)); // refusing to accept/pick a non matching element CHECK (mutator2.matchSrc (CHILD_B)); // child B still patiently waiting, unaffected CHECK (mutator2.acceptSrc (CHILD_B)); // acceptSrc CHECK (mutator2.matchSrc (CHILD_T)); CHECK (mutator2.acceptSrc (CHILD_T)); // acceptSrc - CHECK (mutator2.emptySrc()); // source contents exhausted + CHECK (not mutator2.hasSrc()); // source contents exhausted CHECK (not mutator2.acceptSrc (CHILD_T)); // ...anything beyond is NOP // verify reordered shape @@ -516,7 +516,7 @@ namespace test{ CHECK (mutator3.mutateChild (SUB_NODE, placementHandle)); CHECK (isnil (subScopes[SUB_NODE.idi])); // ...this is where the nested mutator is expected to work on - CHECK (subMutatorBuffer->emptySrc()); + CHECK (not subMutatorBuffer->hasSrc()); // now use the Mutator *interface* to talk to the nested mutator... // This code might be confusing, because in fact we're playing two roles here! diff --git a/wiki/renderengine.html b/wiki/renderengine.html index b2bef561d..9ce6c4cd2 100644 --- a/wiki/renderengine.html +++ b/wiki/renderengine.html @@ -8214,7 +8214,7 @@ On receiving the terms of this "diff language", it is possible to gene i.e. a ''unified diff'' or the ''predicate notation'' used above to describe the list diffing algorithm, just by accumulating changes. -
+
The TreeMutator is an intermediary to translate a generic structure pattern into heterogeneous local invocation sequences.
 within the [[diff framework|TreeDiffModel]], this is a crucial joint, since here the abstract, generic, ~DOM-like ExternalTreeDescription meeds opaque, local and undisclosed data structures.
 
@@ -8275,8 +8275,8 @@ the building blocks, from which such a diff application can be combined, are emb
 :''none'' given. If diff application fails, data is possibly partially transformed, partially in the old state buffer. Thus data is //corrupted.//
 ;old sequence position
 :during diff application, the old state sequence is traversed once. There is an implicit position.
-;operation {{{emptySrc}}}
-:determine if the old state sequence is empty, i.e. there are no further elements waiting from the old state sequence
+;operation {{{hasSrc}}}
+:determine if there are further elements waiting from the old state sequence (to be either picked in the new sequence or discarded)
 ;operation {{{skipSrc}}}
 :skip the next element in the old state sequence, effectively dropping it into obsolescence
 ;operation {{{injectNew}}}
diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm
index f334236b9..c4c98db67 100644
--- a/wiki/thinkPad.ichthyo.mm
+++ b/wiki/thinkPad.ichthyo.mm
@@ -609,7 +609,7 @@
 
 
 
-
+
 
 
 
@@ -972,9 +972,9 @@
 
 
 
-
+
 
-
+
 
 
 
@@ -3140,9 +3140,30 @@
     

- + - + + + + + + + + + + + + +

+ rationale: object fields are hard wired, +

+

+ thus always available +

+ + +
+
@@ -3387,9 +3408,22 @@
- + + + + - + + + + + + + + + + +