summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx/grammar/klass_def.hpp
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-01-28 16:20:02 +0900
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-01-28 16:23:07 +0900
commitc03f272becfab7c7eefeba49b9da99f75afa5976 (patch)
tree3f9d7fc532bb7e9bf9c97c7de01c0aa908aad078 /src/lib/eolian_cxx/grammar/klass_def.hpp
parent95e31dbc4a7b1e967eeabcf5ef838fcb60c654da (diff)
eolian-cxx: Add constructor_def
Summary: To be used generating argument-aware constructors in C#. Reviewers: felipealmeida, vitor.sousa Reviewed By: felipealmeida Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7794
Diffstat (limited to '')
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index fc9d09519a..5fb0dbb8f3 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -988,6 +988,42 @@ struct part_def
988 , documentation(::eolian_part_documentation_get(part)) {} 988 , documentation(::eolian_part_documentation_get(part)) {}
989}; 989};
990 990
991struct constructor_def
992{
993 std::string name;
994 klass_name klass;
995 function_def function;
996 bool is_optional;
997 bool is_ctor_param;
998
999 friend inline bool operator==(constructor_def const& lhs, constructor_def const& rhs)
1000 {
1001 return lhs.name == rhs.name
1002 && lhs.klass == rhs.klass
1003 && lhs.function == rhs.function
1004 && lhs.is_optional == rhs.is_optional
1005 && lhs.is_ctor_param == rhs.is_ctor_param;
1006 }
1007
1008 friend inline bool operator!=(constructor_def const& lhs, constructor_def const& rhs)
1009 {
1010 return !(lhs == rhs);
1011 }
1012
1013 constructor_def(Eolian_Constructor const* constructor, Eolian_Unit const* unit)
1014 : name(::eolian_constructor_name_get(constructor))
1015 , klass(::eolian_constructor_class_get(constructor), {})
1016 , is_optional(::eolian_constructor_is_optional(constructor))
1017 , is_ctor_param(::eolian_constructor_is_ctor_param(constructor))
1018 {
1019 Eolian_Function const* eo_function = ::eolian_constructor_function_get(constructor);
1020 Eolian_Function_Type eo_func_type = ::eolian_function_type_get(eo_function);
1021 if (eo_func_type == ::EOLIAN_PROPERTY)
1022 eo_func_type = ::EOLIAN_PROP_SET;
1023 function = function_def(eo_function, eo_func_type, NULL, unit);
1024 }
1025};
1026
991inline Eolian_Class const* get_klass(klass_name const& klass_name_, Eolian_Unit const* unit); 1027inline Eolian_Class const* get_klass(klass_name const& klass_name_, Eolian_Unit const* unit);
992 1028
993struct klass_def 1029struct klass_def
@@ -999,6 +1035,7 @@ struct klass_def
999 std::vector<std::string> namespaces; 1035 std::vector<std::string> namespaces;
1000 std::vector<function_def> functions; 1036 std::vector<function_def> functions;
1001 std::vector<property_def> properties; 1037 std::vector<property_def> properties;
1038 std::vector<constructor_def> constructors;
1002 std::set<klass_name, compare_klass_name_by_name> inherits; 1039 std::set<klass_name, compare_klass_name_by_name> inherits;
1003 class_type type; 1040 class_type type;
1004 std::vector<event_def> events; 1041 std::vector<event_def> events;
@@ -1197,6 +1234,10 @@ struct klass_def
1197 } catch(std::exception const&) {} 1234 } catch(std::exception const&) {}
1198 } 1235 }
1199 1236
1237 for(efl::eina::iterator<Eolian_Constructor const> constructor_iterator(::eolian_class_constructors_get(klass))
1238 , constructor_last; constructor_iterator != constructor_last; ++constructor_iterator)
1239 constructors.push_back({&*constructor_iterator, unit});
1240
1200 documentation = eolian_class_documentation_get(klass); 1241 documentation = eolian_class_documentation_get(klass);
1201 } 1242 }
1202 1243
@@ -1248,6 +1289,22 @@ struct klass_def
1248 1289
1249 return ret; 1290 return ret;
1250 } 1291 }
1292
1293 std::vector<constructor_def> get_all_constructors() const
1294 {
1295 std::vector<constructor_def> ret;
1296
1297 std::copy(constructors.cbegin(), constructors.cend(), std::back_inserter(ret));
1298
1299 for (auto inherit : inherits)
1300 {
1301 klass_def klass(get_klass(inherit, unit), unit);
1302 std::copy(klass.constructors.cbegin(), klass.constructors.cend(),
1303 std::back_inserter(ret));
1304 }
1305
1306 return ret;
1307 }
1251}; 1308};
1252 1309
1253struct value_def 1310struct value_def