From: Jean-Philippe Andre Date: Tue, 28 Nov 2017 07:21:40 +0000 (+0900) Subject: cxx: Use per-function guards in efl object X-Git-Tag: submit/sandbox/upgrade/efl120/20180319.053334~1351 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09cf28274166bdf8cccc945cbc3b4083af1f9c6c;p=platform%2Fupstream%2Fefl.git cxx: Use per-function guards in efl object This prevents generation of del(). I also removed constructor, finalize and destructor as I believe this requires special work with eo_inherit (where did this work go??). --- diff --git a/src/Makefile_Cxx.am b/src/Makefile_Cxx.am index 74ac8f7..bc9f374 100644 --- a/src/Makefile_Cxx.am +++ b/src/Makefile_Cxx.am @@ -16,7 +16,8 @@ bindings/cxx/eo_cxx/eo_wref.hh \ bindings/cxx/eo_cxx/eo_future.hh \ bindings/cxx/eo_cxx/eo_promise.hh \ bindings/cxx/eo_cxx/eo_promise_meta.hh \ -bindings/cxx/eo_cxx/eo_private.hh +bindings/cxx/eo_cxx/eo_private.hh \ +bindings/cxx/eo_cxx/efl_object_impl.hh ### Elementary C++ installed_elementarycxxmainheadersdir = $(includedir)/elementary-cxx-@VMAJ@/ diff --git a/src/bindings/cxx/eo_cxx/Eo.hh b/src/bindings/cxx/eo_cxx/Eo.hh index 771ee12..bd60f69 100644 --- a/src/bindings/cxx/eo_cxx/Eo.hh +++ b/src/bindings/cxx/eo_cxx/Eo.hh @@ -1,6 +1,8 @@ #ifndef EFL_CXX_EO_HH #define EFL_CXX_EO_HH +#include "efl_object_impl.hh" + #include #include #include @@ -10,4 +12,7 @@ #include #include +#include "efl_object.eo.hh" +#include "efl_object.eo.impl.hh" + #endif // EFL_CXX_EO_HH diff --git a/src/bindings/cxx/eo_cxx/efl_object_impl.hh b/src/bindings/cxx/eo_cxx/efl_object_impl.hh new file mode 100644 index 0000000..ce61ed6 --- /dev/null +++ b/src/bindings/cxx/eo_cxx/efl_object_impl.hh @@ -0,0 +1,23 @@ +#ifndef EFL_OBJECT_MANUAL_IMPL_HH +#define EFL_OBJECT_MANUAL_IMPL_HH + +#define EFL_OBJECT_BETA +#define EFL_OBJECT_PROTECTED + +// Skip del. Must be implemented in eo::concrete. +#define EOLIAN_CXX_EFL_DEL_DECLARATION +#define EOLIAN_CXX_EFL_DEL_IMPLEMENTATION + +// Skip constructor, destructor and finalize. +#define EOLIAN_CXX_EFL_CONSTRUCTOR_DECLARATION +#define EOLIAN_CXX_EFL_CONSTRUCTOR_IMPLEMENTATION +#define EOLIAN_CXX_EFL_DESTRUCTOR_DECLARATION +#define EOLIAN_CXX_EFL_DESTRUCTOR_IMPLEMENTATION +#define EOLIAN_CXX_EFL_FINALIZE_DECLARATION +#define EOLIAN_CXX_EFL_FINALIZE_IMPLEMENTATION + +// Skip auto_unref +#define EOLIAN_CXX_EFL_AUTO_UNREF_SET_DECLARATION +#define EOLIAN_CXX_EFL_AUTO_UNREF_SET_IMPLEMENTATION + +#endif diff --git a/src/lib/efl/Efl.hh b/src/lib/efl/Efl.hh index a7efc5f..e6473ea 100644 --- a/src/lib/efl/Efl.hh +++ b/src/lib/efl/Efl.hh @@ -1,16 +1,9 @@ #ifndef EFL_EFL_HH #define EFL_EFL_HH -#ifdef EFL_BETA_API_SUPPORT - -#define EFL_PART_IMPL_HH -#define EFL_OBJECT_BETA -#define EFL_OBJECT_PROTECTED +#include "cxx/efl_part_impl.hh" +#include #include -#include "cxx/efl_part_impl.hh" #endif -#endif - - diff --git a/src/lib/efl/cxx/efl_part_impl.hh b/src/lib/efl/cxx/efl_part_impl.hh index c1c99e7..f40292c 100644 --- a/src/lib/efl/cxx/efl_part_impl.hh +++ b/src/lib/efl/cxx/efl_part_impl.hh @@ -1,26 +1,15 @@ -//#ifndef EFL_PART_IMPL_HH -//#define EFL_PART_IMPL_HH +#ifndef EFL_PART_MANUAL_IMPL_HH +#define EFL_PART_MANUAL_IMPL_HH -namespace efl { -inline ::efl::eolian::return_traits< ::efl::Object>::type Part::part( ::efl::eolian::in_traits< ::efl::eina::string_view>::type name) const -{ - Eo *handle = ::efl_part(this->_eo_ptr(), name.c_str()); - ::efl_auto_unref_set(handle, false); - return ::efl::Object{handle}; -} -} +#define EOLIAN_CXX_EFL_PART_DECLARATION \ + ::efl::Object part(::efl::eina::string_view const& name) const; -namespace eo_cxx { -namespace efl { -inline ::efl::eolian::return_traits< ::efl::Object>::type Part::part( ::efl::eolian::in_traits< ::efl::eina::string_view>::type name) const -{ - Eo *handle = ::efl_part(this->_eo_ptr(), name.c_str()); - ::efl_auto_unref_set(handle, false); - return ::efl::Object{handle}; +#define EOLIAN_CXX_EFL_PART_IMPLEMENTATION \ +inline ::efl::Object Part::part(::efl::eina::string_view const& name) const \ +{ \ + ::Eo *handle = ::efl_part(_eo_ptr(), name.c_str()); \ + ::efl_auto_unref_set(handle, false); \ + return ::efl::Object{handle}; \ } -inline efl::Part::operator ::efl::Part() const { return *static_cast< ::efl::Part const*>(static_cast(this)); } -inline efl::Part::operator ::efl::Part&() { return *static_cast< ::efl::Part*>(static_cast(this)); } -inline efl::Part::operator ::efl::Part const&() const { return *static_cast< ::efl::Part const*>(static_cast(this)); } -} } -//#endif +#endif diff --git a/src/lib/eolian_cxx/grammar/class_definition.hpp b/src/lib/eolian_cxx/grammar/class_definition.hpp index e7bfaba..771121d 100644 --- a/src/lib/eolian_cxx/grammar/class_definition.hpp +++ b/src/lib/eolian_cxx/grammar/class_definition.hpp @@ -134,7 +134,7 @@ struct class_definition_generator << "(const_cast<" << string << " *>(this))); }\n" ).generate(sink, cls.cxx_name, context)) return false; - + for (auto&& e : cls.events) { if (e.beta) @@ -237,6 +237,7 @@ struct class_definition_generator if(!as_generator( scope_tab << "using ::efl::eo::concrete::_eo_ptr;\n" << scope_tab << "using ::efl::eo::concrete::_release;\n" << scope_tab << "using ::efl::eo::concrete::_reset;\n" + << scope_tab << "using ::efl::eo::concrete::_delete;\n" << scope_tab << "using ::efl::eo::concrete::operator bool;\n" ).generate(sink, attributes::unused, context)) return false; diff --git a/src/lib/eolian_cxx/grammar/function_declaration.hpp b/src/lib/eolian_cxx/grammar/function_declaration.hpp index 634642e..a2770ab 100644 --- a/src/lib/eolian_cxx/grammar/function_declaration.hpp +++ b/src/lib/eolian_cxx/grammar/function_declaration.hpp @@ -40,8 +40,12 @@ struct function_declaration_generator } if(f.is_beta && - !as_generator("#ifdef " << *(string << "_") << string << "_" << string << "_BETA\n") - .generate(sink, std::make_tuple(_klass_name.namespaces, _klass_name.eolian_name, suffix), add_upper_case_context(ctx))) + !as_generator("#ifdef " << *(string << "_") << string << "_BETA\n") + .generate(sink, std::make_tuple(_klass_name.namespaces, _klass_name.eolian_name), add_upper_case_context(ctx))) + return false; + if(f.is_protected && + !as_generator("#ifdef " << *(string << "_") << string << "_PROTECTED\n") + .generate(sink, std::make_tuple(_klass_name.namespaces, _klass_name.eolian_name), add_upper_case_context(ctx))) return false; if(!as_generator @@ -70,6 +74,9 @@ struct function_declaration_generator .generate(sink, f.c_name, add_upper_case_context(ctx))) return false; + if(f.is_protected && + !as_generator("#endif\n").generate(sink, attributes::unused, ctx)) + return false; if(f.is_beta && !as_generator("#endif\n").generate(sink, attributes::unused, ctx)) return false;