summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-01-10 12:36:39 +0100
committerXavi Artigas <xavierartigas@yahoo.es>2019-01-10 12:47:58 +0100
commita5b338ded3d8de06baceaacc515b14342db050d1 (patch)
tree971822673f7b86f64139e6959909b08b5092e3da
parent2ce974475450701e81adf350ea9e1fdea75e32bb (diff)
cxx: Add class get name attribute.
Summary: C# generator was mistakenly reimplementing it assuming everything was *_class_get. Test Plan: run cxx/csharp tests Reviewers: felipealmeida, cedric, segfaultxavi Reviewed By: segfaultxavi Subscribers: segfaultxavi, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7522
-rw-r--r--src/bin/eolian_mono/eolian/mono/name_helpers.hh2
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp21
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_binding.cc14
3 files changed, 30 insertions, 7 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/name_helpers.hh b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
index 05e1e4a7ac..79aa5b47ae 100644
--- a/src/bin/eolian_mono/eolian/mono/name_helpers.hh
+++ b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
@@ -368,7 +368,7 @@ inline std::string klass_full_native_inherit_name(T const& klass)
368template<typename T> 368template<typename T>
369inline std::string klass_get_name(T const& clsname) 369inline std::string klass_get_name(T const& clsname)
370{ 370{
371 return utils::to_lowercase(join_namespaces(clsname.namespaces, '_') + clsname.eolian_name + "_class_get"); 371 return clsname.klass_get_name;
372} 372}
373 373
374inline std::string klass_get_full_name(attributes::klass_name const& clsname) 374inline std::string klass_get_full_name(attributes::klass_name const& clsname)
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp
index 23303a0202..f69fca29d3 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -106,18 +106,20 @@ struct klass_name
106 std::string eolian_name; 106 std::string eolian_name;
107 qualifier_def base_qualifier; 107 qualifier_def base_qualifier;
108 class_type type; 108 class_type type;
109 std::string klass_get_name;
109 110
110 klass_name() { 111 klass_name() {
111 } 112 }
112 113
113 klass_name(std::vector<std::string> namespaces 114 klass_name(std::vector<std::string> namespaces
114 , std::string eolian_name, qualifier_def base_qualifier 115 , std::string eolian_name, qualifier_def base_qualifier
115 , class_type type) 116 , class_type type, std::string klass_get_name)
116 : namespaces(namespaces), eolian_name(eolian_name), base_qualifier(base_qualifier) 117 : namespaces(namespaces), eolian_name(eolian_name), base_qualifier(base_qualifier)
117 , type(type) {} 118 , type(type), klass_get_name(klass_get_name) {}
118 klass_name(Eolian_Class const* klass, qualifier_def base_qualifier) 119 klass_name(Eolian_Class const* klass, qualifier_def base_qualifier)
119 : eolian_name( ::eolian_class_short_name_get(klass)) 120 : eolian_name( ::eolian_class_short_name_get(klass))
120 , base_qualifier(base_qualifier) 121 , base_qualifier(base_qualifier)
122 , klass_get_name( ::eolian_class_c_get_function_name_get(klass))
121 { 123 {
122 for(efl::eina::iterator<const char> namespace_iterator ( ::eolian_class_namespaces_get(klass)) 124 for(efl::eina::iterator<const char> namespace_iterator ( ::eolian_class_namespaces_get(klass))
123 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator) 125 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator)
@@ -1003,6 +1005,7 @@ struct klass_def
1003 std::set<klass_name, compare_klass_name_by_name> immediate_inherits; 1005 std::set<klass_name, compare_klass_name_by_name> immediate_inherits;
1004 eina::optional<klass_name> parent; 1006 eina::optional<klass_name> parent;
1005 std::set<klass_name, compare_klass_name_by_name> extensions; 1007 std::set<klass_name, compare_klass_name_by_name> extensions;
1008 std::string klass_get_name;
1006 1009
1007 std::set<part_def> parts; 1010 std::set<part_def> parts;
1008 Eolian_Unit const* unit; 1011 Eolian_Unit const* unit;
@@ -1018,7 +1021,8 @@ struct klass_def
1018 && lhs.inherits == rhs.inherits 1021 && lhs.inherits == rhs.inherits
1019 && lhs.type == rhs.type 1022 && lhs.type == rhs.type
1020 && lhs.events == rhs.events 1023 && lhs.events == rhs.events
1021 && lhs.parts == rhs.parts; 1024 && lhs.parts == rhs.parts
1025 && lhs.klass_get_name == rhs.klass_get_name;
1022 } 1026 }
1023 friend inline bool operator!=(klass_def const& lhs, klass_def const& rhs) 1027 friend inline bool operator!=(klass_def const& lhs, klass_def const& rhs)
1024 { 1028 {
@@ -1039,24 +1043,29 @@ struct klass_def
1039 , std::vector<property_def> properties 1043 , std::vector<property_def> properties
1040 , std::set<klass_name, compare_klass_name_by_name> inherits 1044 , std::set<klass_name, compare_klass_name_by_name> inherits
1041 , class_type type 1045 , class_type type
1042 , std::set<klass_name, compare_klass_name_by_name> immediate_inherits) 1046 , std::set<klass_name, compare_klass_name_by_name> immediate_inherits
1047 , std::string klass_get_name)
1043 : eolian_name(eolian_name), cxx_name(cxx_name), filename(filename) 1048 : eolian_name(eolian_name), cxx_name(cxx_name), filename(filename)
1044 , documentation(documentation) 1049 , documentation(documentation)
1045 , namespaces(namespaces) 1050 , namespaces(namespaces)
1046 , functions(functions), properties(properties), inherits(inherits), type(type) 1051 , functions(functions), properties(properties), inherits(inherits), type(type)
1047 , immediate_inherits(immediate_inherits) 1052 , immediate_inherits(immediate_inherits)
1053 , klass_get_name(klass_get_name)
1048 {} 1054 {}
1049 klass_def(std::string _eolian_name, std::string _cxx_name 1055 klass_def(std::string _eolian_name, std::string _cxx_name
1050 , std::vector<std::string> _namespaces 1056 , std::vector<std::string> _namespaces
1051 , std::vector<function_def> _functions 1057 , std::vector<function_def> _functions
1052 , std::vector<property_def> _properties 1058 , std::vector<property_def> _properties
1053 , std::set<klass_name, compare_klass_name_by_name> _inherits 1059 , std::set<klass_name, compare_klass_name_by_name> _inherits
1054 , class_type _type, Eolian_Unit const* unit) 1060 , class_type _type, Eolian_Unit const* unit
1061 , std::string klass_get_name)
1055 : eolian_name(_eolian_name), cxx_name(_cxx_name) 1062 : eolian_name(_eolian_name), cxx_name(_cxx_name)
1056 , namespaces(_namespaces) 1063 , namespaces(_namespaces)
1057 , functions(_functions), properties(_properties), inherits(_inherits), type(_type), unit(unit) 1064 , functions(_functions), properties(_properties), inherits(_inherits), type(_type), unit(unit)
1065 , klass_get_name(klass_get_name)
1058 {} 1066 {}
1059 klass_def(Eolian_Class const* klass, Eolian_Unit const* unit) : unit(unit) 1067 klass_def(Eolian_Class const* klass, Eolian_Unit const* unit) : unit(unit)
1068 , klass_get_name( ::eolian_class_c_get_function_name_get(klass))
1060 { 1069 {
1061 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_class_namespaces_get(klass)) 1070 for(efl::eina::iterator<const char> namespace_iterator( ::eolian_class_namespaces_get(klass))
1062 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator) 1071 , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator)
@@ -1349,7 +1358,7 @@ struct struct_def
1349 1358
1350inline klass_name get_klass_name(klass_def const& klass) 1359inline klass_name get_klass_name(klass_def const& klass)
1351{ 1360{
1352 return {klass.namespaces, klass.eolian_name, {qualifier_info::is_none, {}}, klass.type}; 1361 return {klass.namespaces, klass.eolian_name, {qualifier_info::is_none, {}}, klass.type, klass.klass_get_name};
1353} 1362}
1354 1363
1355inline Eolian_Class const* get_klass(klass_name const& klass_name_, Eolian_Unit const* unit) 1364inline Eolian_Class const* get_klass(klass_name const& klass_name_, Eolian_Unit const* unit)
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_binding.cc b/src/tests/eolian_cxx/eolian_cxx_test_binding.cc
index 936687a288..2215312f18 100644
--- a/src/tests/eolian_cxx/eolian_cxx_test_binding.cc
+++ b/src/tests/eolian_cxx/eolian_cxx_test_binding.cc
@@ -309,6 +309,19 @@ EFL_START_TEST(eolian_cxx_test_parent_extensions)
309} 309}
310EFL_END_TEST 310EFL_END_TEST
311 311
312EFL_START_TEST(eolian_cxx_test_cls_get)
313{
314 efl::eolian::eolian_init eolian_init;
315 efl::eolian::eolian_state eolian_state;
316
317 klass_def cls = init_test_data("generic.eo", "Generic", eolian_state);
318 ck_assert_str_eq("generic_class_get", cls.klass_get_name.c_str());
319
320 klass_def iface = init_test_data("generic_interface.eo", "Generic_Interface", eolian_state);
321 ck_assert_str_eq("generic_interface_interface_get", iface.klass_get_name.c_str());
322}
323EFL_END_TEST
324
312void 325void
313eolian_cxx_test_binding(TCase* tc) 326eolian_cxx_test_binding(TCase* tc)
314{ 327{
@@ -321,4 +334,5 @@ eolian_cxx_test_binding(TCase* tc)
321 tcase_add_test(tc, eolian_cxx_test_type_callback); 334 tcase_add_test(tc, eolian_cxx_test_type_callback);
322 tcase_add_test(tc, eolian_cxx_test_properties); 335 tcase_add_test(tc, eolian_cxx_test_properties);
323 tcase_add_test(tc, eolian_cxx_test_parent_extensions); 336 tcase_add_test(tc, eolian_cxx_test_parent_extensions);
337 tcase_add_test(tc, eolian_cxx_test_cls_get);
324} 338}