cxx: Only use eo_cxx:: for methods
authorJean-Philippe Andre <jp.andre@samsung.com>
Wed, 22 Nov 2017 11:16:21 +0000 (20:16 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Tue, 5 Dec 2017 01:14:03 +0000 (10:14 +0900)
Add an experimental (disabled) macro to only generate functions inside
the eo_cxx equivalent of a class, instead of inside both the eo_cxx and
the normal class definition.

I guess the duplicated definition had something to do with doxygen, but
I'm not sure this is quite necessary as doc will be generated with
custom scripts.

src/lib/eolian_cxx/grammar/class_definition.hpp
src/lib/eolian_cxx/grammar/class_implementation.hpp
src/lib/eolian_cxx/grammar/generator.hpp

index a60e18d..e326c9d 100644 (file)
@@ -27,15 +27,21 @@ struct class_definition_generator
      auto open_namespace = *("namespace " << string << " { ") << "\n";
      if(!as_generator(open_namespace).generate(sink, cpp_namespaces, add_lower_case_context(context))) return false;
 
-     if(!as_generator
-        (
-         "struct " << string << " : private ::efl::eo::concrete"
-         )
+#ifdef USE_EOCXX_INHERIT_ONLY
+     if(!as_generator("struct " << string << " : private ::efl::eo::concrete\n"
+                      << scope_tab << ", ::eo_cxx"
+                      << *("::" << lower_case[string]) << "::" << string)
+           .generate(sink, std::make_tuple(cls.cxx_name, attributes::cpp_namespaces(cls.namespaces), cls.cxx_name), context))
+       return false;
+#else
+     if(!as_generator("struct " << string << " : private ::efl::eo::concrete")
         .generate(sink, cls.cxx_name, context))
        return false;
+#endif
+
      for(auto&& i : cls.inherits)
        {
-         if(!as_generator("\n" << scope_tab << ", EO_CXX_INHERIT(" << *(" ::" << lower_case[string]) << "::" << string << ")")
+         if(!as_generator("\n" << scope_tab << ", EO_CXX_INHERIT(" << *("::" << lower_case[string]) << "::" << string << ")")
             .generate(sink, std::make_tuple(attributes::cpp_namespaces(i.namespaces), i.eolian_name), context))
            return false;
        }
@@ -89,8 +95,10 @@ struct class_definition_generator
          // << scope_tab << scope_tab << ": ::efl::eo::concrete( ::efl::eo::do_eo_add( ::efl::eo::concrete{nullptr}, f)) {}\n"
         ).generate(sink, attributes::make_infinite_tuple(cls.cxx_name), context)) return false;
      
+#ifndef USE_EOCXX_INHERIT_ONLY
      if(!as_generator(*(scope_tab << function_declaration(get_klass_name(cls))))
         .generate(sink, cls.functions, context)) return false;
+#endif
                                              
      // static Efl_Class const* _eo_class();
      std::string suffix;
index 0731e3d..b2578b5 100644 (file)
@@ -27,12 +27,14 @@ struct class_implementation_generator
      auto class_name = *(lit("::") << lower_case[string]) << "::" << string;
      return as_generator
        (
+#ifndef USE_EOCXX_INHERIT_ONLY
         (namespaces
          [*function_definition(get_klass_name(cls))]
          << "\n"
        )).generate(sink, std::make_tuple(cls.namespaces, cls.functions), ctx)
        && as_generator
        (
+#endif
         attribute_reorder<0, 1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3>
         (
          "namespace eo_cxx {\n"
index 130ee68..10e96c7 100644 (file)
@@ -3,6 +3,9 @@
 
 #include <type_traits>
 
+// EXPERIMENTAL
+//#define USE_EOCXX_INHERIT_ONLY
+
 namespace efl { namespace eolian { namespace grammar {
 
 template <typename T, typename Enable = void>