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& 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(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 struct operation_description_class_size; -template <> struct operation_description_class_size< ::eo::base> : std::integral_constant {}; +template <> struct operation_description_class_size< ::eo::Base> : std::integral_constant {}; /// @internal /// @@ -136,7 +136,7 @@ namespace detail { template struct operations; template <> -struct operations< ::eo::base> { template struct type {}; }; +struct operations< ::eo::Base> { template struct type {}; }; /// @internal /// @@ -165,7 +165,7 @@ struct Inherit_Private_Data namespace efl { namespace eo { namespace detail { template -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 +#include #include #include 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 list; + efl::eina::list 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 iterator = list.ibegin() + efl::eina::iterator 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 #endif +#include + #include #include #include @@ -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 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 +: efl::eo::inherit { 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 + +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 + +#include "name_name.eo.h" +#include "name_name.eo.hh" +