Commit graph

1380 commits

Author SHA1 Message Date
6fa54411b3 improved log msg
..because actually we don't know if the intention is
to drop those waste elements -- and for sure this
discarding of waste does not happen through the
invocation logged here; rather it happens by
abandoning the scope
2016-06-09 01:21:06 +02:00
37cfdbb7e1 better name for nested handle type 2016-06-09 01:18:21 +02:00
ef27c09fa2 round-up and document the attribute binding and test 2016-06-09 01:10:52 +02:00
b5ab5df929 supply implementation, basically working already
so this test case is more or less finished,
just needs some more polishing and documentation
2016-06-05 17:26:48 +02:00
6eff16f21c supply missing implementation
standard case of attribute binding, i.e.
the setter invocation is fully functional now.
2016-06-05 16:31:29 +02:00
1ae3c1991d second round of this test implemented
...which mostly just is either ignoring the
operations or indicating failure on attempt to
'reorder' attributes (which don't have any notion of 'ordering')
2016-06-04 15:08:10 +02:00
76b898b602 amend the design and then implement the two concrete setter/mutator cases
overall, the structure of this implementation is still rather confusing,
yet any alternatives seem even less convincing

- if we want to avoid the delegation to base-class, we'd have
  to duplicate several functions and the combined class would
  handle two distinct concerns.
- any attempt to handle the IDs more "symmetrically" seems to
  create additional problems on one side or the other
2016-06-04 14:20:59 +02:00
ee99c405fd Reorganise implementation into base class + overlay
...as preparation for implementing the two flavours of
binding attributes either via  a setter lambda or via
creation of a nested mutator.
2016-05-29 03:01:27 +02:00
e5bbcb27d8 identify attributes through an EntryID (including type hash)
this also supersedes and removes the initial implementation
draft for attribute binding with the 'setAttribute' API
The elementary part of diff application incl. setting
new attribute values works by now.
2016-05-28 03:41:03 +02:00
5dbe877318 Library: add option to bypass the sanitising in EntryID
While in general it is fine to clean-up any entity IDs
to be US-ASCII alphanumerics (plus some allowed interpunction),
the GenNodes and also keys in object-bindings for diff are
considerd internal interfaces, assuming that any passed
ID symbol is already sanitised and checked. So the
sanitise operation can be skipped. This changeset
adds the same option directly to lib::EntryID,
allowing to create an EntryID that matches
a similar GenNode's (hash) ID.
2016-05-28 03:21:04 +02:00
16086caf42 explicit error message
...turns out that inclusion of format-string.hpp
is almost irrelevant, since diff/record.hpp already
includes even format-util.hpp
2016-05-28 01:49:03 +02:00
201b6542f2 API change to allow to detect missing attribute binding
The way we build this attribute binding, there is no single
entity to handle all attribute bindings. Thus the only way
to detect a missing binding is when none of the binding layers
was able to handle a given INS verb
2016-05-28 01:17:45 +02:00
4073cdf797 first part of the implementation of attribute binding
...the simple checks and direct assignment.
Passes compiler, but test fails where it shouldn't
2016-05-27 03:33:56 +02:00
34f6d38919 WIP: implant outline of the implementation
...again by overriding all TreeMutator operations
2016-05-27 02:08:29 +02:00
06102b74ad rename test (no change) 2016-05-26 02:16:34 +02:00
4571d3fb0f introduce new mutation primitive as pointed out by preceding analysis
to summarise, it turned out that it is impossible to
provide an airtight 'emptySrc' implementation when binding
to object fields -- so we distinguish into positive and
negative tests, allowing to loosen the sanity check
only for the latter ones when binding to object fields.
2016-05-24 23:43:55 +02:00
b47b4c3f94 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...
2016-05-24 21:34:08 +02:00
72f9b4edb1 Analysis continued: inner contradictions of object field vs attribute
...after re-reading my own documentation, it occured to me that
we need to draw a border line and thus decide, what not to support
2016-05-21 17:55:48 +02:00
d3869d2280 Design/Analysis: Attribute TreeMutator binding
how can ordinary object fields be treated as "Attributes"
and thus tied into the Diff framework defined thus far.
This turns out to be really tricky, even questionable
2016-04-30 00:26:19 +02:00
835c43027d add support for Ref::THIS (questionable, #996)
while simple to add into the implementation, this whole feature
seems rather qestionable to me now, thus I've added a Ticket
to be revisited later.

In a nutshell, right here, when implementing the binding layer
for STL collections, it is easy to enable the framework to treat
Ref::THIS properly, but the *actual implementation* will necessarily
be offloaded onto each and every concrete binding implementation.
Thus client code would have to add support for an rather obscure
shortcut within the Diff language. The only way to avoid this
would be to change the semantics of the "match"-lambda: if this
binding would rather be a back-translation of implementation data
into GenNode::ID values, then we'd be able to implement Ref::THIS
natively. But such an approach looks like a way inferiour deisgn
to me; having delegated the meaning of a "match" to the client
seems like an asset, since it is both natural and opens a lot
of flexibility, without adding complexity.

For that reason I tend to avoid that shortcut now, in the hope
to be able to drop it entirely from the language
2016-04-18 01:21:38 +02:00
7bbfb4bc68 implement nested mutation of sub structures
...basically this worked right away and was easy to put together.
However, when considering how many components, indirections and
nested lambdas are working together here, I feel a bit dizzy...

:-/
2016-04-17 04:51:19 +02:00
69c63045e6 DOC: constituting elements of the TreeMutator
write down a first draft for a definiton section,
to describe the fundamental parts involved, when
applying a diff message onto implementation defined
data structures

After a break of tree weeks, I found it difficult to find may way
amidst all those various levels of abstraction. In addition to this
definition, we'll probably also need a high level overview of the
whole diff system operation.
2016-04-17 03:53:10 +02:00
8167fbff77 implement fast-forward and assignment to value
...all of this implementation boils down to slightly adjusting
the code written for the test-mutation-target. Insofar it pays off now
having implemented this diagnostic and demonstration first.

Moreover I'm implementing this basic scheme of "diff application"
roughly the fourth time, thus things kindof fall into place now.
What's really hard is all those layers of abstraction in between.

Lesson learned (after being off for three weeks, due to LAC and
other obligations): I really need to document the meaning of the
closures, and I need to document the "abstract operational semantics"
of diff application, otherwise no one will be able to provide
the correct closures.
2016-04-17 01:07:07 +02:00
7f42b9b7e7 draft third round of mutation operations to be implemented
...now about opening a sub mutator within a nested scope
2016-04-16 02:20:23 +02:00
54fb335a9c allow to "peek" into an embedded Record's type field
while I still keep my stance not to allow reflection and
switch-on-type, access to the internal / semantic type of
an embedded record seems a valid compromise to allow
to deal with collections of object-like children
of mixed kind.

Indirectly (and quite intentional) this also opens a loophole
to detect if a given GenNode might constitute a nested scope,
but with the for the actual nested element indeed to cary
a type symbol. Effectively this limits the use of this shortcut
to situations where the handling context does have some pre-established
knowledge about what types *might* be expected. This is precisely
the kind of constraint I intend to uphold: I do not want the
false notion of "total flexibility", as is conveyed by introspection.
2016-04-16 00:48:15 +02:00
ad6d348d8f make TreeMutator noncopyable to prevent dangling references
since we're moving elements around to apply the diff,
dangerous situation might arise in case anyone takes a copy
of the mutator. Thus we effectively limit the possible
usage pattern and only allow to build an anonymous
TreeMutator subclass through the Builder-DSL.

The concrete "onion layers" of the TreeMutator are now limited
- to be created by the chaining operations of the Builder DSl
- to be moved into target location, retaining ownership.
2016-03-26 02:01:31 +01:00
f9f2a225c3 implement content reordering mutation primitives
and cover result in test.
This also demonstrates that it is possible to install
a specific lambda on each usage
2016-03-26 01:22:40 +01:00
c49dd04b44 address an insidious dangling reference
I still feel somewhat queasy with this whole situation!
We need to return the product of the DSL/Builder by value,
but we also want to swap away the current contents before
starting the mutation, and we do not want a stateful lifecycle
for the mutator implementation. Which means, we need to swap
right at construction, and then we copy -- TADAAA!

Thus I'm going for the solution to disallow copying of the
mutator, yet to allow moving, and to change the builder
to move its product into place. Probably should even push
this policy up into the base class (TreeMutator) to set
everyone straight.

Looks like this didn't show up with the test dummy implementation
just because in this case the src buffer also lived within th
TestMutationTarget, which is assumed to sit where it is, so
effectively we moved around only pointers.
2016-03-26 00:48:38 +01:00
d98fde5b0e better verification in test
...actually iterate the populated collection
and verify each element in order. Also verify
and document the mutator's storage requirements
2016-03-25 23:12:54 +01:00
e84844142f implement inserting of new elements 2016-03-25 22:43:11 +01:00
91bf75d54a spelling in comments 2016-03-25 21:40:30 +01:00
fb1857423e implement mutation start and lifecycle
the whole implementation will very much be based on
my experiences with the TestMutationTarget and TestWireTap.
Insofar it was a good idea to implement this test dummy first,
as a prototype. Basically what emerges here is a standard pattern
how to implement a tree mutator:

- the TreeMutator will be a one-way-off "throwaway" object.
- its lifecylce starts with sucking away the previous contents
- consuming the diff moves contents back in place
- thus the mutator always attaches onto a target by reference
  and needs the ability to manipulate the target
2016-03-25 20:46:48 +01:00
1bf0753854 mark where function signature helpers should be refactored (#994) 2016-03-25 19:58:09 +01:00
e698a3800b verify signatures of binding lambdas
the collection binding can be configured with various
lambdas to supply the basic building blocks of the generated binding.

Since we allow picking up basically anything (functors,
function pointers, function objects, lamdas), and since
we speculate on inlining optimisation of lambdas, we can not
enforce a specific signature in the builder functions.

But at least we can static_assert on the effective signature
at the point where we're generating the actual binding configuration
2016-03-25 02:51:56 +01:00
7b6713bcab extend lamda-signature-extracting metafunction to several arguments 2016-03-25 02:25:51 +01:00
2098e69981 move metafunction to GenNode
because this is something of wider usage potential.
It allows us to detect if a type in question can be
placed within a GenNode
2016-03-24 21:32:56 +01:00
92d4e87ab9 raise a runtime error when unable to generate a sensible default collection binding
we can't generate a static assertion so easily here.
Problem is, when forming this type, we don't know if
the user will override and provide a custom binding
in some chained call within the nested DSL.

Might still be able to come up with some clever trick,
like e.g. returing an unsuitable marker type from these
dummy default implementations and then, later on, when
actually building the collection binding, to detect
those marker types and rise a static assert at that point.
This would at least give us a better error message,
and in theory, it should always be possible to
detect this kind of misuse at compile time
2016-03-24 17:44:58 +01:00
3b116fe6ef find a way to pick a default implementation for collection binding
...through the use of partial specialisation and SFINAE.
There are some rather specific (yet expectedly not uncommon) cases,
where we'd be able to provide a sensible default for the
- match predicate
- new element constructor
of the binding. While in all other cases, the user
has to provide an explicit implementation for these
crucial building blocks anyway.
2016-03-24 17:33:28 +01:00
4e6fd86c8d variant: change the method to check for suitable payload type
the reason is also to enable usage as metafunction,
to disable specialisations for some type which could
never live within a variant record in question
2016-03-24 17:33:28 +01:00
cb2a95627d WIP: specify first example binding...
...but does not compile, since all of the fallback functions
will be instantiated, even while in fact we're overriding them
right away with something that *can* be compiled.

this prompts me to reconsider and question the basic approach
with closures for binding, while in fact what I am doing here
is to implement an ABC.
2016-03-24 17:32:30 +01:00
df8ca071a8 first outline of test and aggregate initialisation problem
- the test will use some really private data types,
  valid only within the scope of the test function.

- invoking the builder for real got me into problems
  with the aggregate initialisation I'd used.
  Maybe it's the function pointers? Anyway, working
  around that by definint a telescope ctor
2016-03-19 16:47:40 +01:00
b4fb767109 default/fallback configuration for the collection binding
when setting up a binding to child elements within a STL collection,
all the variable elements are preconfigured to a more or less
disabled and inactive state.
2016-03-19 01:24:11 +01:00
c909a67388 reorg: split, trim down and comment 2016-03-18 20:52:35 +01:00
08657bf199 reorg: split off implementation details
the concern is for the structure of the builder to be
incomprehensible and completely buried within the
implementation details of the various binding layers
2016-03-18 20:03:27 +01:00
1b24453f5b set up the full builder definition chain 2016-03-18 19:35:48 +01:00
5579e9c86f draft a way to configure the binding to a STL collection
this is the most relevant binding layer for TreeMutator,
enabling to transform and mutate child elements managed
within a STL collection.
2016-03-18 00:31:04 +01:00
3646c5df72 rearrange logic to allow for chaining / layering
most of the mutation primitives return bool(true)
when /any/ layer or part of the TreeMuator was able
to cope with the diff verb.

This is based on the assumption to configure the
TreeMutator in such a way that at most one facility
will actually handle and apply a given verb. That is,
we'll assume that the TreeMutator acutally wraps and
adapts *one* custom data structure, to which the
diff has to be applied.

The TestWireTap is special, insofar it indeed targets
a *second* data structure, albeit not a "real" one,
just a dest and diagnostics dummy.
2016-03-12 01:01:26 +01:00
9ef32e0d62 complete dummy/proof-of-concept implementation of TreeMutator primitives
the first part of the unit test (now passing)
is able to demonstrate the full set of diff operations
just by binding to a TestMutationTarget.

Now, after verifying the design of those primmitive operations,
we can now proceed with bindings to "real" data structures
2016-03-11 21:30:25 +01:00
b0c6ba0777 switch implementation of TestMutationTarget to storing full GenNodes
when implementing the assignment and mutation primitives
it became clear that the original approach of just storing
a log or string rendered elements does not work: for
assignment, we need to locate an element by ID
2016-03-11 17:39:25 +01:00
1016d792b9 implement accept_until for the test-dummy 2016-03-10 20:53:36 +01:00