From c42254a24e5817c46f53261b1fd1efb832907704 Mon Sep 17 00:00:00 2001 From: Felipe Magno de Almeida Date: Fri, 18 Mar 2016 17:48:47 -0300 Subject: eolian-cxx: WIP: Remove .Base requirement --- src/Makefile_Eolian_Cxx.am | 5 +++++ src/bin/eolian_cxx/eolian_wrappers.hh | 4 ++-- src/bin/eolian_cxx/type_lookup.hh | 26 +++++++++++++++++++------- src/tests/eolian_cxx/name_name.c | 7 +++++++ src/tests/eolian_cxx/name_name.eo | 4 ++++ src/tests/eolian_cxx/name_name_cxx.cc | 6 ++++++ 6 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 src/tests/eolian_cxx/name_name.c create mode 100644 src/tests/eolian_cxx/name_name.eo create mode 100644 src/tests/eolian_cxx/name_name_cxx.cc diff --git a/src/Makefile_Eolian_Cxx.am b/src/Makefile_Eolian_Cxx.am index 89111c1681..c9da3f0b13 100644 --- a/src/Makefile_Eolian_Cxx.am +++ b/src/Makefile_Eolian_Cxx.am @@ -72,6 +72,8 @@ tests/eolian_cxx/eolian_cxx_test_callback.cc \ tests/eolian_cxx/eolian_cxx_test_address_of.cc \ tests/eolian_cxx/eolian_cxx_test_wrapper.cc \ tests/eolian_cxx/simple.c \ +tests/eolian_cxx/name_name.c \ +tests/eolian_cxx/name_name_cxx.cc \ tests/eolian_cxx/generic.c \ tests/eolian_cxx/eolian_cxx_test_inheritance.cc \ tests/eolian_cxx/eolian_cxx_test_generate.cc \ @@ -91,6 +93,9 @@ tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-b.$(OBJEXT): tests/eolian_cxx tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-c.$(OBJEXT): tests/eolian_cxx/c.eo.c tests/eolian_cxx/c.eo.h tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-d.$(OBJEXT): tests/eolian_cxx/d.eo.c tests/eolian_cxx/d.eo.h +tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-name_name.$(OBJEXT): tests/eolian_cxx/name_name.eo.c tests/eolian_cxx/name_name.eo.h +tests/eolian_cxx/tests_eolian_cxx_eolian_cxx_suite-name_name_cxx.$(OBJEXT): tests/eolian_cxx/name_name.eo.h tests/eolian_cxx/name_name.eo.hh + CLEANFILES += \ tests/eolian_cxx/callback.eo.hh \ tests/eolian_cxx/callback.eo.c \ diff --git a/src/bin/eolian_cxx/eolian_wrappers.hh b/src/bin/eolian_cxx/eolian_wrappers.hh index 0b78020188..8be5f9bec6 100644 --- a/src/bin/eolian_cxx/eolian_wrappers.hh +++ b/src/bin/eolian_cxx/eolian_wrappers.hh @@ -59,7 +59,7 @@ class_base_file(Eolian_Class const& klass) inline std::string class_name(Eolian_Class const& klass) { - return safe_lower(::eolian_class_name_get(&klass)); + return ::eolian_class_name_get(&klass); } inline std::string @@ -347,7 +347,7 @@ event_create(Eolian_Class const& klass, const Eolian_Event *event_) event.is_beta = (::eolian_event_is_beta(event_) != EINA_FALSE); event.name = normalize_spaces(name_); event.eo_name = safe_upper - (find_replace(class_full_name(klass), ".", "_") + "_EVENT_" + event.name); + (find_replace(safe_lower(class_full_name(klass)), ".", "_") + "_EVENT_" + event.name); /* FIXME: use doc api */ event.comment = safe_str(""); } diff --git a/src/bin/eolian_cxx/type_lookup.hh b/src/bin/eolian_cxx/type_lookup.hh index 7f73a5edda..a1b32204f4 100644 --- a/src/bin/eolian_cxx/type_lookup.hh +++ b/src/bin/eolian_cxx/type_lookup.hh @@ -27,14 +27,26 @@ extern const lookup_table_type type_lookup_table; inline std::string class_format_cxx(std::string const& fullname) { - std::string s = fullname; - auto found = s.find("."); - while (found != std::string::npos) + auto current = fullname.begin(), last = fullname.end(); + auto found = std::find(current, last, '.'); + std::string new_string; + while (current != last) { - s.replace(found, 1, "::"); - found = s.find("."); + if(found == last) + { + new_string.insert(new_string.end(), current, found); + current = found; + } + else + { + new_string += std::tolower(*current); + new_string.insert(new_string.end(), std::next(current), found); + new_string += "::"; + current = std::next(found); + found = std::find(current, last, '.'); + } } - return s; + return new_string; } inline bool @@ -60,7 +72,7 @@ type_from_eolian(Eolian_Type const& type) x.category = efl::eolian::eolian_type::simple_; x.is_class = true; x.binding_requires_optional = false; - x.binding = "::" + class_format_cxx(safe_lower(safe_str(::eolian_class_full_name_get(klass)))); + x.binding = "::" + class_format_cxx(safe_str(::eolian_class_full_name_get(klass))); Eina_Stringshare* klass_file = ::eolian_class_file_get(klass); if (klass_file) diff --git a/src/tests/eolian_cxx/name_name.c b/src/tests/eolian_cxx/name_name.c new file mode 100644 index 0000000000..6526c7e05d --- /dev/null +++ b/src/tests/eolian_cxx/name_name.c @@ -0,0 +1,7 @@ + +#include + +struct Name_Name_Data {}; + +#include "name_name.eo.h" +#include "name_name.eo.c" diff --git a/src/tests/eolian_cxx/name_name.eo b/src/tests/eolian_cxx/name_name.eo new file mode 100644 index 0000000000..fd88a5e8c1 --- /dev/null +++ b/src/tests/eolian_cxx/name_name.eo @@ -0,0 +1,4 @@ +class Name.Name { + legacy_prefix: null; +} + diff --git a/src/tests/eolian_cxx/name_name_cxx.cc b/src/tests/eolian_cxx/name_name_cxx.cc new file mode 100644 index 0000000000..99087548f1 --- /dev/null +++ b/src/tests/eolian_cxx/name_name_cxx.cc @@ -0,0 +1,6 @@ + +#include + +#include "name_name.eo.h" +#include "name_name.eo.hh" + -- cgit v1.2.1