cxx: Use per-function guards in efl object
authorJean-Philippe Andre <jp.andre@samsung.com>
Tue, 28 Nov 2017 07:21:40 +0000 (16:21 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Tue, 5 Dec 2017 06:01:45 +0000 (15:01 +0900)
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??).

src/Makefile_Cxx.am
src/bindings/cxx/eo_cxx/Eo.hh
src/bindings/cxx/eo_cxx/efl_object_impl.hh [new file with mode: 0644]
src/lib/efl/Efl.hh
src/lib/efl/cxx/efl_part_impl.hh
src/lib/eolian_cxx/grammar/class_definition.hpp
src/lib/eolian_cxx/grammar/function_declaration.hpp

index 74ac8f7..bc9f374 100644 (file)
@@ -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@/
index 771ee12..bd60f69 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef EFL_CXX_EO_HH
 #define EFL_CXX_EO_HH
 
+#include "efl_object_impl.hh"
+
 #include <eo_concrete.hh>
 #include <eo_init.hh>
 #include <eo_wref.hh>
@@ -10,4 +12,7 @@
 #include <eo_cxx_interop.hh>
 #include <eo_event.hh>
 
+#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 (file)
index 0000000..ce61ed6
--- /dev/null
@@ -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
index a7efc5f..e6473ea 100644 (file)
@@ -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 <Eo.hh>
 #include <Efl.eo.hh>
-#include "cxx/efl_part_impl.hh"
 
 #endif
-#endif
-
-
index c1c99e7..f40292c 100644 (file)
@@ -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<void const*>(this)); }
-inline efl::Part::operator ::efl::Part&() { return *static_cast< ::efl::Part*>(static_cast<void*>(this)); }
-inline efl::Part::operator ::efl::Part const&() const { return *static_cast< ::efl::Part const*>(static_cast<void const*>(this)); }
-} }
 
-//#endif
+#endif
index e7bfaba..771121d 100644 (file)
@@ -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;
 
index 634642e..a2770ab 100644 (file)
@@ -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;