From a787c3cc07b8ddcc3288091a9d1b9e0eb06582bc Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Wed, 22 Nov 2017 20:16:21 +0900 Subject: [PATCH] cxx: Only use eo_cxx:: for methods 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. --- .../eolian_cxx/grammar/class_definition.hpp | 18 +++++++++++++----- .../grammar/class_implementation.hpp | 2 ++ src/lib/eolian_cxx/grammar/generator.hpp | 3 +++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/lib/eolian_cxx/grammar/class_definition.hpp b/src/lib/eolian_cxx/grammar/class_definition.hpp index a60e18dedf..e326c9d0e3 100644 --- a/src/lib/eolian_cxx/grammar/class_definition.hpp +++ b/src/lib/eolian_cxx/grammar/class_definition.hpp @@ -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; diff --git a/src/lib/eolian_cxx/grammar/class_implementation.hpp b/src/lib/eolian_cxx/grammar/class_implementation.hpp index 0731e3d591..b2578b5bf2 100644 --- a/src/lib/eolian_cxx/grammar/class_implementation.hpp +++ b/src/lib/eolian_cxx/grammar/class_implementation.hpp @@ -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" diff --git a/src/lib/eolian_cxx/grammar/generator.hpp b/src/lib/eolian_cxx/grammar/generator.hpp index 130ee6859c..10e96c7c13 100644 --- a/src/lib/eolian_cxx/grammar/generator.hpp +++ b/src/lib/eolian_cxx/grammar/generator.hpp @@ -3,6 +3,9 @@ #include +// EXPERIMENTAL +//#define USE_EOCXX_INHERIT_ONLY + namespace efl { namespace eolian { namespace grammar { template