diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-11-22 20:46:26 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-12-05 10:14:03 +0900 |
commit | 03af836332b6b80975a402c865542fccf2f56de1 (patch) | |
tree | 0cd428e5a650bccb071a34edc747d4bc1e7821f3 | |
parent | 4fdc5fd0b20bf9c56248858fb31aa02cad306e77 (diff) | |
download | efl-03af836332b6b80975a402c865542fccf2f56de1.tar.gz |
cxx: Use set for forward classes
This avoids duplication. Not very important as there are FWD_GUARD
macros anyway.
-rw-r--r-- | src/bin/eolian_cxx/eolian_cxx.cc | 10 | ||||
-rw-r--r-- | src/lib/eolian_cxx/grammar/klass_def.hpp | 6 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/bin/eolian_cxx/eolian_cxx.cc b/src/bin/eolian_cxx/eolian_cxx.cc index 29c81d32d7..2df5b9ae2d 100644 --- a/src/bin/eolian_cxx/eolian_cxx.cc +++ b/src/bin/eolian_cxx/eolian_cxx.cc @@ -74,7 +74,7 @@ generate(const Eolian_Class* klass, eolian_cxx::options_type const& opts, efl::eolian::grammar::attributes::klass_def klass_def(klass, opts.unit); std::vector<efl::eolian::grammar::attributes::klass_def> klasses{klass_def}; - std::vector<efl::eolian::grammar::attributes::klass_def> forward_klasses{}; + std::set<efl::eolian::grammar::attributes::klass_def> forward_klasses{}; std::set<std::string> c_headers; std::set<std::string> cpp_headers; @@ -90,8 +90,7 @@ generate(const Eolian_Class* klass, eolian_cxx::options_type const& opts, c_headers.insert(eolian_class_file_get(klass2) + std::string(".h")); cpp_headers.insert(eolian_class_file_get(klass2) + std::string(".hh")); efl::eolian::grammar::attributes::klass_def cls{klass2, opts.unit}; - if(std::find(forward_klasses.begin(), forward_klasses.end(), cls) == forward_klasses.end()) - forward_klasses.push_back(cls); + forward_klasses.insert(cls); }; auto complex_function = [&] (efl::eolian::grammar::attributes::complex_type_def const& complex) @@ -123,8 +122,7 @@ generate(const Eolian_Class* klass, eolian_cxx::options_type const& opts, c_headers.insert(eolian_class_file_get(inherit) + std::string(".h")); cpp_headers.insert(eolian_class_file_get(inherit) + std::string(".hh")); efl::eolian::grammar::attributes::klass_def klass3{inherit, opts.unit}; - if(std::find(forward_klasses.begin(), forward_klasses.end(), klass3) == forward_klasses.end()) - forward_klasses.push_back(klass3); + forward_klasses.insert(klass3); klass_function(inherit); } @@ -157,7 +155,7 @@ generate(const Eolian_Class* klass, eolian_cxx::options_type const& opts, std::tuple<std::string, std::set<std::string>&, std::set<std::string>& , std::string const& , std::vector<efl::eolian::grammar::attributes::klass_def>& - , std::vector<efl::eolian::grammar::attributes::klass_def>& + , std::set<efl::eolian::grammar::attributes::klass_def> const& , std::vector<efl::eolian::grammar::attributes::klass_def>& , std::vector<efl::eolian::grammar::attributes::klass_def>& > attributes diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp index f7b12af578..739390ddc6 100644 --- a/src/lib/eolian_cxx/grammar/klass_def.hpp +++ b/src/lib/eolian_cxx/grammar/klass_def.hpp @@ -719,6 +719,12 @@ struct klass_def { return !(lhs == rhs); } + friend inline bool operator<(klass_def const& lhs, klass_def const& rhs) + { + return lhs.eolian_name < rhs.eolian_name + || lhs.cxx_name < rhs.cxx_name + || lhs.namespaces < rhs.namespaces; + } klass_def(std::string eolian_name, std::string cxx_name, std::string filename , std::vector<std::string> namespaces |