From e698a3800b97569a2944bd857ed895d616d293cd Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 25 Mar 2016 02:51:56 +0100 Subject: [PATCH] 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 --- .../diff/tree-mutator-collection-binding.hpp | 13 ++++- .../diff/tree-manipulation-binding-test.cpp | 6 +- wiki/thinkPad.ichthyo.mm | 56 ++++++++++++++++++- 3 files changed, 68 insertions(+), 7 deletions(-) diff --git a/src/lib/diff/tree-mutator-collection-binding.hpp b/src/lib/diff/tree-mutator-collection-binding.hpp index b9cc8ca40..505ed3567 100644 --- a/src/lib/diff/tree-mutator-collection-binding.hpp +++ b/src/lib/diff/tree-mutator-collection-binding.hpp @@ -60,6 +60,9 @@ using lib::meta::Strip; using lib::diff::GenNode; +#define ASSERT_VALID_SIGNATURE(_FUN_, _SIG_) \ + static_assert (has_Sig<_FUN_, _SIG_>::value, "Function " STRINGIFY(_FUN_) " unsuitable, expected signature: " STRINGIFY(_SIG_)); + /** * Attach to collection: Concrete binding setup. * This record holds all the actual binding and closures @@ -83,6 +86,12 @@ { using Coll = typename Strip::TypeReferred; using Elm = typename Coll::value_type; + + ASSERT_VALID_SIGNATURE (MAT, bool(GenNode const& spec, Elm const& elm)) + ASSERT_VALID_SIGNATURE (CTR, Elm (GenNode const&)) + ASSERT_VALID_SIGNATURE (SEL, bool(GenNode const&)) + ASSERT_VALID_SIGNATURE (ASS, bool(Elm&, GenNode const&)) + ASSERT_VALID_SIGNATURE (MUT, bool(Elm&, TreeMutator::MutatorBuffer)) Coll& collection; @@ -445,13 +454,13 @@ } static bool - disable_assignment (GenNode const&) + disable_assignment (Elm&, GenNode const&) { return false; } static bool - disable_childMutation (GenNode const&, TreeMutator::MutatorBuffer) + disable_childMutation (Elm&, TreeMutator::MutatorBuffer) { return false; } diff --git a/tests/library/diff/tree-manipulation-binding-test.cpp b/tests/library/diff/tree-manipulation-binding-test.cpp index 268b154ed..235771b41 100644 --- a/tests/library/diff/tree-manipulation-binding-test.cpp +++ b/tests/library/diff/tree-manipulation-binding-test.cpp @@ -308,10 +308,10 @@ namespace test{ { cout << "match? "< - + + + @@ -2442,6 +2444,54 @@ + + + + + + + +

+ der Builder in der nested DSL generiert einen sonderbar falschen "this"-Typ, +

+

+ genauer gesagt, eine TYPID die falsch ist. +

+

+ Und zwar kommt es da zum "Übersprechen" von einem Typ-Parameter in den anderen. +

+

+ Im Besonderen hab ich beobachtet, daß, wenn man auf den 3.Typparameter ein Lambda gibt, +

+

+ dann auf dem 4. oder 5. Typparameter der bisherige /alte Typ des 3.Typparameters auftaucht, +

+

+ u.U auch eingeschachtelt als ein Argument. +

+

+ +

+

+ Habe mich aber davon überzeugt, daß die eigentlichen Typ-Parameter in Ordnung sind. +

+

+ Und zwar habe ich das verifiziert +

+
    +
  • + durch Ausgeben der Typen im Konstruktor (mithilfe meiner typeStr<TY>() +
  • +
  • + durch Einbauen einer Static-Assertion mit Signatur-Match +
  • +
+ + +
+ +
+
@@ -2509,7 +2559,9 @@ - + + +