From 427c5885c8715b34d2fc64f8b1f1da4d7b37788f Mon Sep 17 00:00:00 2001 From: Lauro Moura Date: Thu, 10 Jan 2019 12:36:39 +0100 Subject: [PATCH] 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 --- src/bin/eolian_mono/eolian/mono/name_helpers.hh | 2 +- src/lib/eolian_cxx/grammar/klass_def.hpp | 21 +++++++++++++++------ src/tests/eolian_cxx/eolian_cxx_test_binding.cc | 14 ++++++++++++++ 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 05e1e4a..79aa5b4 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) template inline std::string klass_get_name(T const& clsname) { - return utils::to_lowercase(join_namespaces(clsname.namespaces, '_') + clsname.eolian_name + "_class_get"); + return clsname.klass_get_name; } inline 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 23303a0..f69fca2 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 std::string eolian_name; qualifier_def base_qualifier; class_type type; + std::string klass_get_name; klass_name() { } klass_name(std::vector namespaces , std::string eolian_name, qualifier_def base_qualifier - , class_type type) + , class_type type, std::string klass_get_name) : namespaces(namespaces), eolian_name(eolian_name), base_qualifier(base_qualifier) - , type(type) {} + , type(type), klass_get_name(klass_get_name) {} klass_name(Eolian_Class const* klass, qualifier_def base_qualifier) : eolian_name( ::eolian_class_short_name_get(klass)) , base_qualifier(base_qualifier) + , klass_get_name( ::eolian_class_c_get_function_name_get(klass)) { for(efl::eina::iterator namespace_iterator ( ::eolian_class_namespaces_get(klass)) , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator) @@ -1003,6 +1005,7 @@ struct klass_def std::set immediate_inherits; eina::optional parent; std::set extensions; + std::string klass_get_name; std::set parts; Eolian_Unit const* unit; @@ -1018,7 +1021,8 @@ struct klass_def && lhs.inherits == rhs.inherits && lhs.type == rhs.type && lhs.events == rhs.events - && lhs.parts == rhs.parts; + && lhs.parts == rhs.parts + && lhs.klass_get_name == rhs.klass_get_name; } friend inline bool operator!=(klass_def const& lhs, klass_def const& rhs) { @@ -1039,24 +1043,29 @@ struct klass_def , std::vector properties , std::set inherits , class_type type - , std::set immediate_inherits) + , std::set immediate_inherits + , std::string klass_get_name) : eolian_name(eolian_name), cxx_name(cxx_name), filename(filename) , documentation(documentation) , namespaces(namespaces) , functions(functions), properties(properties), inherits(inherits), type(type) , immediate_inherits(immediate_inherits) + , klass_get_name(klass_get_name) {} klass_def(std::string _eolian_name, std::string _cxx_name , std::vector _namespaces , std::vector _functions , std::vector _properties , std::set _inherits - , class_type _type, Eolian_Unit const* unit) + , class_type _type, Eolian_Unit const* unit + , std::string klass_get_name) : eolian_name(_eolian_name), cxx_name(_cxx_name) , namespaces(_namespaces) , functions(_functions), properties(_properties), inherits(_inherits), type(_type), unit(unit) + , klass_get_name(klass_get_name) {} klass_def(Eolian_Class const* klass, Eolian_Unit const* unit) : unit(unit) + , klass_get_name( ::eolian_class_c_get_function_name_get(klass)) { for(efl::eina::iterator namespace_iterator( ::eolian_class_namespaces_get(klass)) , namespace_last; namespace_iterator != namespace_last; ++namespace_iterator) @@ -1349,7 +1358,7 @@ struct struct_def inline klass_name get_klass_name(klass_def const& klass) { - return {klass.namespaces, klass.eolian_name, {qualifier_info::is_none, {}}, klass.type}; + return {klass.namespaces, klass.eolian_name, {qualifier_info::is_none, {}}, klass.type, klass.klass_get_name}; } inline 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 936687a..2215312 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) } EFL_END_TEST +EFL_START_TEST(eolian_cxx_test_cls_get) +{ + efl::eolian::eolian_init eolian_init; + efl::eolian::eolian_state eolian_state; + + klass_def cls = init_test_data("generic.eo", "Generic", eolian_state); + ck_assert_str_eq("generic_class_get", cls.klass_get_name.c_str()); + + klass_def iface = init_test_data("generic_interface.eo", "Generic_Interface", eolian_state); + ck_assert_str_eq("generic_interface_interface_get", iface.klass_get_name.c_str()); +} +EFL_END_TEST + void eolian_cxx_test_binding(TCase* tc) { @@ -321,4 +334,5 @@ eolian_cxx_test_binding(TCase* tc) tcase_add_test(tc, eolian_cxx_test_type_callback); tcase_add_test(tc, eolian_cxx_test_properties); tcase_add_test(tc, eolian_cxx_test_parent_extensions); + tcase_add_test(tc, eolian_cxx_test_cls_get); } -- 2.7.4