summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-03-18 17:48:47 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-04-21 18:31:53 -0300
commit535a069a2312acc7b217f8150e6c0cfc469fd5f2 (patch)
tree213555fc38de227241adba4b68b7d51a309b2ee1
parent5c87f2762fca7b4adc8940e1d77a4fdc6a214562 (diff)
downloadefl-535a069a2312acc7b217f8150e6c0cfc469fd5f2.tar.gz
eolian-cxx: Remove .Base requirement
Remove requirement that class can't have the same name as another class's namespace.
-rw-r--r--src/Makefile_Eolian_Cxx.am5
-rw-r--r--src/bin/eolian_cxx/convert.cc6
-rw-r--r--src/bin/eolian_cxx/eolian_wrappers.hh4
-rw-r--r--src/bin/eolian_cxx/type_lookup.hh46
-rw-r--r--src/bindings/eo_cxx/eo_private.hh8
-rw-r--r--src/tests/ecore_audio_cxx/cxx_compile_test.cc1
-rw-r--r--src/tests/eina_cxx/eina_cxx_test_iterator.cc14
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_address_of.cc12
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_binding.cc4
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_callback.cc10
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_inheritance.cc4
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_wrapper.cc2
-rw-r--r--src/tests/eolian_cxx/name_name.c8
-rw-r--r--src/tests/eolian_cxx/name_name.eo4
-rw-r--r--src/tests/eolian_cxx/name_name_cxx.cc6
15 files changed, 94 insertions, 40 deletions
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/convert.cc b/src/bin/eolian_cxx/convert.cc
index 1b42e66799..97e88c9171 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 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..57d7c940b6 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 5f1448a582..ec4d92cd5b 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 dfc4cd6425..2f1421efd9 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 3fe4c9d2d1..493fa9a944 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 9a1283be6c..f73de98f97 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 4a189bb058..b705e67732 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 6ffaf50590..c22141307f 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 9804a80359..8af557a2c5 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 bf794a7eb7..3441a8975b 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 0000000000..50b65d9ee8
--- /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 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 <Eo.h>
+
+#include "name_name.eo.h"
+#include "name_name.eo.hh"
+