felipealmeida pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=535a069a2312acc7b217f8150e6c0cfc469fd5f2

commit 535a069a2312acc7b217f8150e6c0cfc469fd5f2
Author: Felipe Magno de Almeida <fel...@expertisesolutions.com.br>
Date:   Fri Mar 18 17:48:47 2016 -0300

    eolian-cxx: Remove .Base requirement
    
    Remove requirement that class can't have the same name as another
    class's namespace.
---
 src/Makefile_Eolian_Cxx.am                         |  5 +++
 src/bin/eolian_cxx/convert.cc                      |  6 ++-
 src/bin/eolian_cxx/eolian_wrappers.hh              |  4 +-
 src/bin/eolian_cxx/type_lookup.hh                  | 46 +++++++++++++++++-----
 src/bindings/eo_cxx/eo_private.hh                  |  8 ++--
 src/tests/ecore_audio_cxx/cxx_compile_test.cc      |  1 +
 src/tests/eina_cxx/eina_cxx_test_iterator.cc       | 14 +++----
 src/tests/eolian_cxx/eolian_cxx_test_address_of.cc | 12 +++---
 src/tests/eolian_cxx/eolian_cxx_test_binding.cc    |  4 +-
 src/tests/eolian_cxx/eolian_cxx_test_callback.cc   | 10 ++---
 .../eolian_cxx/eolian_cxx_test_inheritance.cc      |  4 +-
 src/tests/eolian_cxx/eolian_cxx_test_wrapper.cc    |  2 +-
 src/tests/eolian_cxx/name_name.c                   |  8 ++++
 src/tests/eolian_cxx/name_name.eo                  |  4 ++
 src/tests/eolian_cxx/name_name_cxx.cc              |  6 +++
 15 files changed, 94 insertions(+), 40 deletions(-)

diff --git a/src/Makefile_Eolian_Cxx.am b/src/Makefile_Eolian_Cxx.am
index 89111c1..c9da3f0 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/convert.cc b/src/bin/eolian_cxx/convert.cc
index 1b42e66..97e88c9 100644
--- a/src/bin/eolian_cxx/convert.cc
+++ b/src/bin/eolian_cxx/convert.cc
@@ -38,7 +38,7 @@ add_ancestor_recursive(const char* klass_name, 
std::set<std::string>& ancestor)
         return;
      }
 
-   ancestor.insert(class_format_cxx(safe_lower(klass_name)));
+   ancestor.insert(class_format_cxx(safe_str(klass_name)));
 
    Eina_Iterator* inheritances = ::eolian_class_inherits_get(klass);
    void* curr = 0;
@@ -236,7 +236,7 @@ convert_eolian_inheritances(efl::eolian::eo_class& cls, 
Eolian_Class const& klas
    EINA_ITERATOR_FOREACH(inheritances, curr)
      {
         const char* klass_name = static_cast<const char*>(curr);
-        cls.parents.push_back(class_format_cxx(safe_lower(klass_name)));
+        cls.parents.push_back(class_format_cxx(safe_str(klass_name)));
         add_ancestor_recursive(klass_name, ancestors);
      }
    eina_iterator_free(inheritances);
@@ -275,6 +275,8 @@ convert_eolian_class_new(Eolian_Class const& klass)
    cls.type = class_type(klass);
    cls.name = class_name(klass);
    cls.name_space = class_namespace_full(klass);
+   if(cls.name_space.empty())
+     cls.name_space = "nonamespace";
    cls.eo_name = class_eo_name(klass);
    cls.comment = convert_comments_class(klass);
    return cls;
diff --git a/src/bin/eolian_cxx/eolian_wrappers.hh 
b/src/bin/eolian_cxx/eolian_wrappers.hh
index 0b78020..8be5f9b 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 7f73a5e..57d7c94 100644
--- a/src/bin/eolian_cxx/type_lookup.hh
+++ b/src/bin/eolian_cxx/type_lookup.hh
@@ -27,14 +27,30 @@ 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)
-     {
-        s.replace(found, 1, "::");
-        found = s.find(".");
-     }
-   return s;
+   auto current = fullname.begin(), last = fullname.end();
+   auto found = std::find(current, last, '.');
+   std::string new_string;
+   if(found == last)
+     new_string = "nonamespace::" + fullname;
+   else
+     while (current != last)
+       {
+          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 = safe_lower(new_string);
+               new_string += "::";
+               current = std::next(found);
+               found = std::find(current, last, '.');
+            }
+       }
+   return new_string;
 }
 
 inline bool
@@ -60,7 +76,16 @@ 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)));
+                  x.native = "::";
+                  x.native += safe_str( ::eolian_class_full_name_get(klass));
+                  std::replace(x.native.begin(), x.native.end(), '.', '_');
+
+                  if( ::eolian_type_is_const(base_type))
+                    x.native += " const";
+                  
+                  x.native += '*';
+                  
 
                   Eina_Stringshare* klass_file = 
::eolian_class_file_get(klass);
                   if (klass_file)
@@ -69,7 +94,8 @@ type_from_eolian(Eolian_Type const& type)
           }
      }
 
-   x.native = normalize_spaces(safe_str(::eolian_type_c_type_get(&type)));
+   if(x.native.empty())
+     x.native = normalize_spaces(safe_str(::eolian_type_c_type_get(&type)));
    x.is_own = ::eolian_type_is_own(&type);
    x.is_const = ::eolian_type_is_const(&type);
    return x;
diff --git a/src/bindings/eo_cxx/eo_private.hh 
b/src/bindings/eo_cxx/eo_private.hh
index 5f1448a..ec4d92c 100644
--- a/src/bindings/eo_cxx/eo_private.hh
+++ b/src/bindings/eo_cxx/eo_private.hh
@@ -9,7 +9,7 @@
 #include "eo_ops.hh"
 
 namespace eo { 
-struct base;
+struct Base;
 }
 
 namespace efl { namespace eo { namespace detail {
@@ -89,7 +89,7 @@ Eo_Class const* do_eo_class_new(Eo_Class_Description& 
class_desc)
 }
 
 template <typename T> struct operation_description_class_size;
-template <> struct operation_description_class_size< ::eo::base> : 
std::integral_constant<std::size_t, 0u> {};
+template <> struct operation_description_class_size< ::eo::Base> : 
std::integral_constant<std::size_t, 0u> {};
 
 /// @internal
 ///
@@ -136,7 +136,7 @@ namespace detail {
 template <typename T> struct operations;
 
 template <>
-struct operations< ::eo::base> { template <typename T> struct type {}; };
+struct operations< ::eo::Base> { template <typename T> struct type {}; };
   
 /// @internal
 ///
@@ -165,7 +165,7 @@ struct Inherit_Private_Data
 
 namespace efl { namespace eo { namespace detail {
 template <typename T>
-int initialize_operation_description(efl::eo::detail::tag< ::eo::base>
+int initialize_operation_description(efl::eo::detail::tag< ::eo::Base>
                                  , Eo_Op_Description* ops)
 {
    (void)ops;
diff --git a/src/tests/ecore_audio_cxx/cxx_compile_test.cc 
b/src/tests/ecore_audio_cxx/cxx_compile_test.cc
index dfc4cd6..2f1421e 100644
--- a/src/tests/ecore_audio_cxx/cxx_compile_test.cc
+++ b/src/tests/ecore_audio_cxx/cxx_compile_test.cc
@@ -3,6 +3,7 @@
 #endif
 
 #include <Ecore_Audio.h>
+#include <ecore_audio.eo.h>
 #include <Ecore_Audio.hh>
 
 #include <iostream>
diff --git a/src/tests/eina_cxx/eina_cxx_test_iterator.cc 
b/src/tests/eina_cxx/eina_cxx_test_iterator.cc
index 3fe4c9d..493fa9a 100644
--- a/src/tests/eina_cxx/eina_cxx_test_iterator.cc
+++ b/src/tests/eina_cxx/eina_cxx_test_iterator.cc
@@ -37,22 +37,22 @@ START_TEST(eina_cxx_eo_iterator_equal)
   efl::eina::eina_init eina_init;
   efl::eo::eo_init eo_init;
 
-  efl::eina::list<simple> list;
+  efl::eina::list<nonamespace::Simple> list;
 
-  simple const w1;
-  simple const w2;
-  simple const w3;
-  simple const w4;
+  nonamespace::Simple const w1;
+  nonamespace::Simple const w2;
+  nonamespace::Simple const w3;
+  nonamespace::Simple const w4;
 
   list.push_back(w1);
   list.push_back(w2);
   list.push_back(w3);
   list.push_back(w4);
 
-  efl::eina::iterator<simple> iterator = list.ibegin()
+  efl::eina::iterator<nonamespace::Simple> iterator = list.ibegin()
     , last_iterator = list.iend();
 
-  simple const result[] = {w1, w2, w3, w4};
+  nonamespace::Simple const result[] = {w1, w2, w3, w4};
 
   ck_assert(std::equal(iterator, last_iterator, result));
 }
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_address_of.cc 
b/src/tests/eolian_cxx/eolian_cxx_test_address_of.cc
index 9a1283b..f73de98 100644
--- a/src/tests/eolian_cxx/eolian_cxx_test_address_of.cc
+++ b/src/tests/eolian_cxx/eolian_cxx_test_address_of.cc
@@ -2,6 +2,8 @@
 # include <config.h>
 #endif
 
+#include <Eo.hh>
+
 #include <a.eo.hh>
 #include <b.eo.hh>
 #include <c.eo.hh>
@@ -13,12 +15,12 @@ START_TEST(eolian_cxx_test_addess_of_conversions)
 {
    efl::eo::eo_init init;
 
-   d d_obj;
+   nonamespace::D d_obj;
 
-   a* a_ptr = &d_obj;
-   b* b_ptr = &d_obj;
-   c* c_ptr = &d_obj;
-   d* d_ptr = &d_obj;
+   nonamespace::A* a_ptr = &d_obj;
+   nonamespace::B* b_ptr = &d_obj;
+   nonamespace::C* c_ptr = &d_obj;
+   nonamespace::D* d_ptr = &d_obj;
 
    fail_unless(a_ptr == (void*) b_ptr);
    fail_unless(a_ptr == (void*) c_ptr);
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_binding.cc 
b/src/tests/eolian_cxx/eolian_cxx_test_binding.cc
index 4a189bb..b705e67 100644
--- a/src/tests/eolian_cxx/eolian_cxx_test_binding.cc
+++ b/src/tests/eolian_cxx/eolian_cxx_test_binding.cc
@@ -12,7 +12,7 @@ START_TEST(eolian_cxx_test_binding_constructor_only_required)
 
   bool called1 = false;
 
-  generic g(
+  nonamespace::Generic g(
     g.required_ctor_a(1),
     g.required_ctor_b(std::bind([&called1] { called1 = true; }))
   );
@@ -32,7 +32,7 @@ START_TEST(eolian_cxx_test_binding_constructor_all_optionals)
   bool called1 = false;
   bool called2 = false;
 
-  generic g(
+  nonamespace::Generic g(
     g.required_ctor_a(2),
     g.required_ctor_b(std::bind([&called1] { called1 = true; })),
     g.optional_ctor_a(3),
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_callback.cc 
b/src/tests/eolian_cxx/eolian_cxx_test_callback.cc
index 6ffaf50..c221413 100644
--- a/src/tests/eolian_cxx/eolian_cxx_test_callback.cc
+++ b/src/tests/eolian_cxx/eolian_cxx_test_callback.cc
@@ -20,7 +20,7 @@ START_TEST(eolian_cxx_test_callback_method)
 {
   efl::eo::eo_init i;
 
-  callback c;
+  nonamespace::Callback c;
 
   bool called1 = false, called2 = false;
 
@@ -36,7 +36,7 @@ START_TEST(eolian_cxx_test_callback_event_add)
 {
   efl::eo::eo_init i;
 
-  callback c;
+  nonamespace::Callback c;
 
   bool called1 = false, called2 = false;
 
@@ -53,7 +53,7 @@ START_TEST(eolian_cxx_test_callback_event_del)
 {
   efl::eo::eo_init i;
 
-  callback c;
+  nonamespace::Callback c;
 
   int called1 = 0, called2 = 0, called3 = 0, called4 = 0;
 
@@ -119,7 +119,7 @@ START_TEST(eolian_cxx_test_global_callback)
 
   bool called = false;
 
-  callback::test_global_callbacks(std::bind([&called] { called = true; }));
+  nonamespace::Callback::test_global_callbacks(std::bind([&called] { called = 
true; }));
 
   fail_if(!called);
 }
@@ -128,7 +128,7 @@ END_TEST
 START_TEST(eolian_cxx_test_disconnect_inside_callback)
 {
   efl::eo::eo_init i;
-  callback c;
+  nonamespace::Callback c;
 
   std::vector<long> capture_me;
   int times_called = 0;
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_inheritance.cc 
b/src/tests/eolian_cxx/eolian_cxx_test_inheritance.cc
index 9804a80..8af557a 100644
--- a/src/tests/eolian_cxx/eolian_cxx_test_inheritance.cc
+++ b/src/tests/eolian_cxx/eolian_cxx_test_inheritance.cc
@@ -10,7 +10,7 @@
 #include "eolian_cxx_suite.h"
 
 struct bar
-: efl::eo::inherit<bar, simple>
+: efl::eo::inherit<bar, nonamespace::Simple>
 {
   bar()
     : inherit_base(efl::eo::parent = nullptr)
@@ -23,7 +23,7 @@ struct bar
   }
 };
 
-void foo(simple is)
+void foo(nonamespace::Simple is)
 {
    fail_if(is.simple_get());
 }
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_wrapper.cc 
b/src/tests/eolian_cxx/eolian_cxx_test_wrapper.cc
index bf794a7..3441a89 100644
--- a/src/tests/eolian_cxx/eolian_cxx_test_wrapper.cc
+++ b/src/tests/eolian_cxx/eolian_cxx_test_wrapper.cc
@@ -14,7 +14,7 @@ START_TEST(eolian_cxx_test_wrapper_size)
   efl::eo::eo_init init;
 
   ::efl::eo::concrete b(nullptr);
-  ::callback c;
+  ::nonamespace::Callback c;
 
   fail_if(sizeof(b) != sizeof(Eo*));
   fail_if(sizeof(b) != sizeof(c));
diff --git a/src/tests/eolian_cxx/name_name.c b/src/tests/eolian_cxx/name_name.c
new file mode 100644
index 0000000..50b65d9
--- /dev/null
+++ b/src/tests/eolian_cxx/name_name.c
@@ -0,0 +1,8 @@
+
+#include <Eo.h>
+
+struct Name_Name_Data {};
+typedef struct Name_Name_Data 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 0000000..fd88a5e
--- /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 0000000..9908754
--- /dev/null
+++ b/src/tests/eolian_cxx/name_name_cxx.cc
@@ -0,0 +1,6 @@
+
+#include <Eo.h>
+
+#include "name_name.eo.h"
+#include "name_name.eo.hh"
+

-- 


Reply via email to