summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx/grammar/klass_def.hpp
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-03-11 13:02:51 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-03-11 14:41:01 -0300
commit2a003420f83134331c8b404df1905cba538cfad6 (patch)
tree4d2ce96ed345346e1dc8a150c4350c839c224beb /src/lib/eolian_cxx/grammar/klass_def.hpp
parent2331ae3692507b7f0b49328293579cd6ef8b5909 (diff)
eolian-cxx: Add beta information to *_def
Summary: Fixes T7732 Reviewers: cedric, felipealmeida, vitor.sousa, bu5hm4n Reviewed By: vitor.sousa Subscribers: #reviewers, #committers Tags: #efl Maniphest Tasks: T7732 Differential Revision: https://phab.enlightenment.org/D8267
Diffstat (limited to '')
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index 42b720d05d..c014ee8a88 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -153,6 +153,7 @@ struct klass_name
153 qualifier_def base_qualifier; 153 qualifier_def base_qualifier;
154 class_type type; 154 class_type type;
155 std::string klass_get_name; 155 std::string klass_get_name;
156 bool is_beta;
156 157
157 friend inline std::ostream& operator<<(std::ostream& s, klass_name const& name) 158 friend inline std::ostream& operator<<(std::ostream& s, klass_name const& name)
158 { 159 {
@@ -167,13 +168,14 @@ struct klass_name
167 168
168 klass_name(std::vector<std::string> namespaces 169 klass_name(std::vector<std::string> namespaces
169 , std::string eolian_name, qualifier_def base_qualifier 170 , std::string eolian_name, qualifier_def base_qualifier
170 , class_type type, std::string klass_get_name) 171 , class_type type, std::string klass_get_name, bool is_beta)
171 : namespaces(namespaces), eolian_name(eolian_name), base_qualifier(base_qualifier) 172 : namespaces(namespaces), eolian_name(eolian_name), base_qualifier(base_qualifier)
172 , type(type), klass_get_name(klass_get_name) {} 173 , type(type), klass_get_name(klass_get_name), is_beta(is_beta) {}
173 klass_name(Eolian_Class const* klass, qualifier_def base_qualifier) 174 klass_name(Eolian_Class const* klass, qualifier_def base_qualifier)
174 : eolian_name( ::eolian_class_short_name_get(klass)) 175 : eolian_name( ::eolian_class_short_name_get(klass))
175 , base_qualifier(base_qualifier) 176 , base_qualifier(base_qualifier)
176 , klass_get_name( ::eolian_class_c_get_function_name_get(klass)) 177 , klass_get_name( ::eolian_class_c_get_function_name_get(klass))
178 , is_beta(::eolian_object_is_beta(EOLIAN_OBJECT(klass)))
177 { 179 {
178 for(efl::eina::iterator<const char> namespace_iterator ( ::eolian_class_namespaces_get(klass)) 180 for(efl::eina::iterator<const char> namespace_iterator ( ::eolian_class_namespaces_get(klass))
179 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator) 181 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator)
@@ -364,6 +366,8 @@ inline bool operator!=(complex_type_def const& lhs, complex_type_def const& rhs)
364 return !(lhs == rhs); 366 return !(lhs == rhs);
365} 367}
366 368
369// type_def represents a type where it is used, like a method parameter or a struc field, in contrast to more
370// specifict types like struct_def, class_def, function_def, which represents a declaration of a type.
367struct type_def 371struct type_def
368{ 372{
369 typedef eina::variant<klass_name, regular_type_def, complex_type_def> variant_type; 373 typedef eina::variant<klass_name, regular_type_def, complex_type_def> variant_type;
@@ -371,6 +375,7 @@ struct type_def
371 std::string c_type; 375 std::string c_type;
372 bool has_own; 376 bool has_own;
373 bool is_ptr; 377 bool is_ptr;
378 bool is_beta;
374 379
375 type_def() = default; 380 type_def() = default;
376 type_def(variant_type original_type, std::string c_type, bool has_own) 381 type_def(variant_type original_type, std::string c_type, bool has_own)
@@ -427,6 +432,9 @@ inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* uni
427 Eolian_Type const* stp = eolian_type_base_type_get(eolian_type); 432 Eolian_Type const* stp = eolian_type_base_type_get(eolian_type);
428 has_own = !!::eolian_type_is_owned(eolian_type); 433 has_own = !!::eolian_type_is_owned(eolian_type);
429 is_ptr = !!::eolian_type_is_ptr(eolian_type); 434 is_ptr = !!::eolian_type_is_ptr(eolian_type);
435
436 Eolian_Typedecl const* decl = eolian_type_typedecl_get(eolian_type);
437 is_beta = decl && eolian_object_is_beta(EOLIAN_OBJECT(decl));
430 switch( ::eolian_type_type_get(eolian_type)) 438 switch( ::eolian_type_type_get(eolian_type))
431 { 439 {
432 case EOLIAN_TYPE_VOID: 440 case EOLIAN_TYPE_VOID:
@@ -764,9 +772,11 @@ struct function_def
764 filename = eolian_object_file_get((const Eolian_Object *)eolian_klass); 772 filename = eolian_object_file_get((const Eolian_Object *)eolian_klass);
765 klass = klass_name(eolian_klass, 773 klass = klass_name(eolian_klass,
766 {attributes::qualifier_info::is_none, std::string()}); 774 {attributes::qualifier_info::is_none, std::string()});
775 is_beta = eolian_function_is_beta(function) || klass.is_beta;
767 } 776 }
768 else 777 else
769 { 778 {
779 is_beta = tp && eolian_object_is_beta(EOLIAN_OBJECT(tp));
770 filename = ""; 780 filename = "";
771 781
772 if (tp) 782 if (tp)
@@ -777,7 +787,6 @@ struct function_def
777 namespaces.push_back(&*ns_iterator); 787 namespaces.push_back(&*ns_iterator);
778 } 788 }
779 } 789 }
780 is_beta = eolian_function_is_beta(function);
781 is_protected = eolian_function_scope_get(function, type) == EOLIAN_SCOPE_PROTECTED; 790 is_protected = eolian_function_scope_get(function, type) == EOLIAN_SCOPE_PROTECTED;
782 is_static = eolian_function_is_class(function); 791 is_static = eolian_function_is_class(function);
783 792
@@ -1174,6 +1183,7 @@ struct klass_def
1174 eina::optional<klass_name> parent; 1183 eina::optional<klass_name> parent;
1175 std::set<klass_name, compare_klass_name_by_name> extensions; 1184 std::set<klass_name, compare_klass_name_by_name> extensions;
1176 std::string klass_get_name; 1185 std::string klass_get_name;
1186 bool is_beta;
1177 1187
1178 std::set<part_def> parts; 1188 std::set<part_def> parts;
1179 Eolian_Unit const* unit; 1189 Eolian_Unit const* unit;
@@ -1190,7 +1200,8 @@ struct klass_def
1190 && lhs.type == rhs.type 1200 && lhs.type == rhs.type
1191 && lhs.events == rhs.events 1201 && lhs.events == rhs.events
1192 && lhs.parts == rhs.parts 1202 && lhs.parts == rhs.parts
1193 && lhs.klass_get_name == rhs.klass_get_name; 1203 && lhs.klass_get_name == rhs.klass_get_name
1204 && lhs.is_beta == rhs.is_beta;
1194 } 1205 }
1195 friend inline bool operator!=(klass_def const& lhs, klass_def const& rhs) 1206 friend inline bool operator!=(klass_def const& lhs, klass_def const& rhs)
1196 { 1207 {
@@ -1212,13 +1223,15 @@ struct klass_def
1212 , std::set<klass_name, compare_klass_name_by_name> inherits 1223 , std::set<klass_name, compare_klass_name_by_name> inherits
1213 , class_type type 1224 , class_type type
1214 , std::set<klass_name, compare_klass_name_by_name> immediate_inherits 1225 , std::set<klass_name, compare_klass_name_by_name> immediate_inherits
1215 , std::string klass_get_name) 1226 , std::string klass_get_name
1227 , bool is_beta)
1216 : eolian_name(eolian_name), cxx_name(cxx_name), filename(filename) 1228 : eolian_name(eolian_name), cxx_name(cxx_name), filename(filename)
1217 , documentation(documentation) 1229 , documentation(documentation)
1218 , namespaces(namespaces) 1230 , namespaces(namespaces)
1219 , functions(functions), properties(properties), inherits(inherits), type(type) 1231 , functions(functions), properties(properties), inherits(inherits), type(type)
1220 , immediate_inherits(immediate_inherits) 1232 , immediate_inherits(immediate_inherits)
1221 , klass_get_name(klass_get_name) 1233 , klass_get_name(klass_get_name)
1234 , is_beta(is_beta)
1222 {} 1235 {}
1223 klass_def(std::string _eolian_name, std::string _cxx_name 1236 klass_def(std::string _eolian_name, std::string _cxx_name
1224 , std::vector<std::string> _namespaces 1237 , std::vector<std::string> _namespaces
@@ -1226,14 +1239,16 @@ struct klass_def
1226 , std::vector<property_def> _properties 1239 , std::vector<property_def> _properties
1227 , std::set<klass_name, compare_klass_name_by_name> _inherits 1240 , std::set<klass_name, compare_klass_name_by_name> _inherits
1228 , class_type _type, Eolian_Unit const* unit 1241 , class_type _type, Eolian_Unit const* unit
1229 , std::string klass_get_name) 1242 , std::string klass_get_name
1243 , bool is_beta)
1230 : eolian_name(_eolian_name), cxx_name(_cxx_name) 1244 : eolian_name(_eolian_name), cxx_name(_cxx_name)
1231 , namespaces(_namespaces) 1245 , namespaces(_namespaces)
1232 , functions(_functions), properties(_properties), inherits(_inherits), type(_type) 1246 , functions(_functions), properties(_properties), inherits(_inherits), type(_type)
1233 , klass_get_name(klass_get_name), unit(unit) 1247 , klass_get_name(klass_get_name), is_beta(is_beta), unit(unit)
1234 {} 1248 {}
1235 klass_def(Eolian_Class const* klass, Eolian_Unit const* unit) 1249 klass_def(Eolian_Class const* klass, Eolian_Unit const* unit)
1236 : klass_get_name( ::eolian_class_c_get_function_name_get(klass)) 1250 : klass_get_name( ::eolian_class_c_get_function_name_get(klass))
1251 , is_beta(::eolian_class_is_beta(klass))
1237 , unit(unit) 1252 , unit(unit)
1238 { 1253 {
1239 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_class_namespaces_get(klass)) 1254 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_class_namespaces_get(klass))
@@ -1519,6 +1534,7 @@ struct struct_def
1519 std::string cxx_name; 1534 std::string cxx_name;
1520 std::vector<std::string> namespaces; 1535 std::vector<std::string> namespaces;
1521 std::vector<struct_field_def> fields; 1536 std::vector<struct_field_def> fields;
1537 bool is_beta;
1522 documentation_def documentation; 1538 documentation_def documentation;
1523 1539
1524 struct_def(Eolian_Typedecl const* struct_obj, Eolian_Unit const* unit) 1540 struct_def(Eolian_Typedecl const* struct_obj, Eolian_Unit const* unit)
@@ -1537,13 +1553,15 @@ struct struct_def
1537 this->fields.push_back(field_def); 1553 this->fields.push_back(field_def);
1538 } 1554 }
1539 1555
1556 is_beta = eolian_object_is_beta(EOLIAN_OBJECT(struct_obj));
1557
1540 documentation = ::eolian_typedecl_documentation_get(struct_obj); 1558 documentation = ::eolian_typedecl_documentation_get(struct_obj);
1541 } 1559 }
1542}; 1560};
1543 1561
1544inline klass_name get_klass_name(klass_def const& klass) 1562inline klass_name get_klass_name(klass_def const& klass)
1545{ 1563{
1546 return {klass.namespaces, klass.eolian_name, {qualifier_info::is_none, {}}, klass.type, klass.klass_get_name}; 1564 return {klass.namespaces, klass.eolian_name, {qualifier_info::is_none, {}}, klass.type, klass.klass_get_name, klass.is_beta};
1547} 1565}
1548 1566
1549inline Eolian_Class const* get_klass(klass_name const& klass_name_, Eolian_Unit const* unit) 1567inline Eolian_Class const* get_klass(klass_name const& klass_name_, Eolian_Unit const* unit)