Skip to content

Commit

Permalink
drop code for handling undefines
Browse files Browse the repository at this point in the history
Since 0.12 dropped support for undefines, we can remove the code to
support it as well.
  • Loading branch information
dcbaker committed Sep 25, 2024
1 parent f33b7af commit 556aeac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
12 changes: 3 additions & 9 deletions src/cps/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,11 @@ namespace cps::loader {

} // namespace

Define::Define(std::string name_) : name{std::move(name_)}, value{}, define{true} {};
Define::Define(std::string name_, std::string value_)
: name{std::move(name_)}, value{std::move(value_)}, define{true} {};
Define::Define(std::string name_, bool define_) : name{std::move(name_)}, value{}, define{define_} {};

bool Define::is_undefine() const { return !define; }

bool Define::is_define() const { return define && value.empty(); }
Define::Define(std::string name_) : name{std::move(name_)}, value{std::nullopt} {};
Define::Define(std::string name_, std::string value_) : name{std::move(name_)}, value{std::move(value_)} {};

std::string Define::get_name() const { return name; }
std::string Define::get_value() const { return value; }
std::optional<std::string> Define::get_value() const { return value; }

Configuration::Configuration() = default;
Configuration::Configuration(LangValues cflags) : compile_flags{std::move(cflags)} {};
Expand Down
8 changes: 2 additions & 6 deletions src/cps/loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,13 @@ namespace cps::loader {
public:
Define(std::string name);
Define(std::string name, std::string value);
Define(std::string name, bool define);

bool is_undefine() const;
bool is_define() const;
std::string get_name() const;
std::string get_value() const;
std::optional<std::string> get_value() const;

private:
std::string name;
std::string value;
bool define;
std::optional<std::string> value;
};

using LangValues = std::unordered_map<KnownLanguages, std::vector<std::string>>;
Expand Down
8 changes: 3 additions & 5 deletions src/cps/printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ namespace cps::printer {
if (auto && f = r.definitions.find(loader::KnownLanguages::c);
f != r.definitions.end() && !f->second.empty()) {
auto && transformer = [](auto && d) {
if (d.is_define()) {
return fmt::format("-D{}", d.get_name());
} else if (d.is_undefine()) {
return fmt::format("-U{}", d.get_name());
if (auto && v = d.get_value()) {
return fmt::format("-D{}={}", d.get_name(), v.value());
} else {
return fmt::format("-D{}={}", d.get_name(), d.get_value());
return fmt::format("-D{}", d.get_name());
}
};
args.reserve(args.size() + f->second.size());
Expand Down

0 comments on commit 556aeac

Please sign in to comment.