]> git.tdb.fi Git - builder.git/commitdiff
Use std::function instead of sigc::slot in BooleanEvaluator
authorMikko Rasa <tdb@tdb.fi>
Mon, 19 Dec 2022 18:54:29 +0000 (20:54 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 19 Dec 2022 19:00:14 +0000 (21:00 +0200)
source/booleanevaluator.cpp
source/booleanevaluator.h
source/conditionalloader.cpp

index 01037415d2bf36ee9d012f59840e5463151b1cf9..074956a7a29b4cfddca039b1506eaaf30bf5dabb 100644 (file)
@@ -5,8 +5,8 @@ using namespace std;
 
 /* I'd rather have overloads with different slots, but that creates an
 ambiguity because slots have template constructors. */
-BooleanEvaluator::BooleanEvaluator(const Slot &s, bool allow_compare):
-       slot(s),
+BooleanEvaluator::BooleanEvaluator(const Function &f, bool allow_compare):
+       func(f),
        ops(allow_compare ? "&|!=^" : "&|!")
 { }
 
@@ -31,7 +31,7 @@ bool BooleanEvaluator::evaluate(const string &str)
                                        op_stack.pop_back();
                                        string var = var_stack.back();
                                        var_stack.pop_back();
-                                       bool value = (slot(var, &buf) == (op=='='));
+                                       bool value = (func(var, &buf) == (op=='='));
                                        value_stack.push_back(value);
                                }
                                else
@@ -81,7 +81,7 @@ bool BooleanEvaluator::pop_value()
        {
                string var = var_stack.back();
                var_stack.pop_back();
-               return slot(var, 0);
+               return func(var, 0);
        }
        else if(!value_stack.empty())
        {
index 08ed432665bd48fd6822e2215b53b3adc2d3d6ca..7c2af6f1a0f9cbeb8d99d546c89d50172520e5a4 100644 (file)
@@ -1,17 +1,17 @@
 #ifndef BOOLEANEVALUATOR_H_
 #define BOOLEANEVALUATOR_H_
 
+#include <functional>
 #include <string>
 #include <vector>
-#include <sigc++/slot.h>
 
 class BooleanEvaluator
 {
 public:
-       typedef sigc::slot<bool, const std::string &, const std::string *> Slot;
+       using Function = std::function<bool(const std::string &, const std::string *)>;
 
 private:
-       Slot slot;
+       Function func;
        std::string ops;
        std::vector<std::string> var_stack;
        std::vector<unsigned char> value_stack;
@@ -19,7 +19,7 @@ private:
        bool last_was_op;
 
 public:
-       BooleanEvaluator(const Slot &, bool = true);
+       BooleanEvaluator(const Function &, bool = true);
 
        bool evaluate(const std::string &);
 private:
index 43e613b737d263b1e84469ccc7a0af8ed072d105..731c5594c312a1d9cd18cd985c325f7806f1bc96 100644 (file)
@@ -16,7 +16,8 @@ ArchitectureConditional::ArchitectureConditional(const Builder &b, const string
 
 void ArchitectureConditional::if_arch(const string &cond)
 {
-       BooleanEvaluator eval(sigc::hide<1>(sigc::mem_fun(&builder.get_current_arch(), &Architecture::match_name)), false);
+       const Architecture &arch = builder.get_current_arch();
+       BooleanEvaluator eval([&arch](const string &value, const string *){ return arch.match_name(value); }, false);
        bool match = eval.evaluate(cond);
        builder.get_logger().log("configure", format("%s: arch %s %smatched", log_prefix, cond, (match ? "" : "not ")));
        if(match)
@@ -33,7 +34,7 @@ FeatureConditional::FeatureConditional(const SourcePackage &p, const string &l):
 
 void FeatureConditional::if_feature(const string &cond)
 {
-       BooleanEvaluator eval(sigc::mem_fun(&package, &SourcePackage::match_feature));
+       BooleanEvaluator eval([this](const string &feat, const string *value){ return package.match_feature(feat, value); });
        bool match = eval.evaluate(cond);
        package.get_builder().get_logger().log("configure", format("%s: feature %s %smatched", log_prefix, cond, (match ? "" : "not ")));
        if(match)