diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-11-01 21:59:17 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-11-07 09:57:24 +0900 |
commit | 3f64dcc521ce6709beb9355cca31a99a940c18be (patch) | |
tree | 854e540d8c16a5d0b045222b7b79d6f1a8560fb0 | |
parent | 2dd1e59a4cf77d29232c8b592990eb6db9846657 (diff) | |
download | efl-3f64dcc521ce6709beb9355cca31a99a940c18be.tar.gz |
cxx: Place beta API declarations behind ifdef
NOTE: protected APIs are placed behind ifdef as well in the
implementation file. This makes sense since the define is required for
the C code to compile, but this isn't what @protected means.
-rw-r--r-- | src/lib/eolian_cxx/grammar/base_class_definition.hpp | 2 | ||||
-rw-r--r-- | src/lib/eolian_cxx/grammar/class_definition.hpp | 2 | ||||
-rw-r--r-- | src/lib/eolian_cxx/grammar/function_declaration.hpp | 55 |
3 files changed, 48 insertions, 11 deletions
diff --git a/src/lib/eolian_cxx/grammar/base_class_definition.hpp b/src/lib/eolian_cxx/grammar/base_class_definition.hpp index bb5adde1cc..5a4a219529 100644 --- a/src/lib/eolian_cxx/grammar/base_class_definition.hpp +++ b/src/lib/eolian_cxx/grammar/base_class_definition.hpp @@ -33,7 +33,7 @@ struct base_class_definition_generator "struct " << string << " {\n" ).generate(sink, cls.cxx_name, context)) return false; - if(!as_generator(*(scope_tab << function_declaration)) + if(!as_generator(*(scope_tab << function_declaration(get_klass_name(cls)))) .generate(sink, cls.functions, context)) return false; // static Efl_Class const* _eo_class(); diff --git a/src/lib/eolian_cxx/grammar/class_definition.hpp b/src/lib/eolian_cxx/grammar/class_definition.hpp index 326ef23578..15ef86d371 100644 --- a/src/lib/eolian_cxx/grammar/class_definition.hpp +++ b/src/lib/eolian_cxx/grammar/class_definition.hpp @@ -87,7 +87,7 @@ 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; - if(!as_generator(*(scope_tab << function_declaration)) + if(!as_generator(*(scope_tab << function_declaration(get_klass_name(cls)))) .generate(sink, cls.functions, context)) return false; // static Efl_Class const* _eo_class(); diff --git a/src/lib/eolian_cxx/grammar/function_declaration.hpp b/src/lib/eolian_cxx/grammar/function_declaration.hpp index 6e124dfd38..431b4a21da 100644 --- a/src/lib/eolian_cxx/grammar/function_declaration.hpp +++ b/src/lib/eolian_cxx/grammar/function_declaration.hpp @@ -4,6 +4,7 @@ #include "grammar/generator.hpp" #include "grammar/klass_def.hpp" +#include "grammar/string.hpp" #include "grammar/indentation.hpp" #include "grammar/list.hpp" #include "grammar/alternative.hpp" @@ -15,13 +16,43 @@ namespace efl { namespace eolian { namespace grammar { struct function_declaration_generator { - template <typename OutputIterator, typename Context> - bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const - { - return as_generator - ("::efl::eolian::return_traits<" << grammar::type(true) << ">::type " << string << "(" << (parameter % ", ") << ") const;\n") - .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), context); - } + function_declaration_generator(attributes::klass_name const& name) + : _klass_name(name) + {} + + template <typename OutputIterator, typename Context> + bool generate(OutputIterator sink, attributes::function_def const& f, Context const& ctx) const + { + std::string suffix; + switch(_klass_name.type) + { + case attributes::class_type::regular: + case attributes::class_type::abstract_: + suffix = "CLASS"; + break; + case attributes::class_type::mixin: + suffix = "MIXIN"; + break; + case attributes::class_type::interface_: + suffix = "INTERFACE"; + break; + } + + 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))) + return false; + if(!as_generator + ("::efl::eolian::return_traits<" << grammar::type(true) << ">::type " << string << "(" << (parameter % ", ") << ") const;\n") + .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), ctx)) + return false; + if(f.is_beta && + !as_generator("#endif\n").generate(sink, attributes::unused, ctx)) + return false; + return true; + } + + attributes::klass_name _klass_name; }; template <> @@ -31,8 +62,14 @@ namespace type_traits { template <> struct attributes_needed<function_declaration_generator> : std::integral_constant<int, 1> {}; } - -function_declaration_generator const function_declaration = {}; + +struct function_declaration_terminal +{ + function_declaration_generator operator()(attributes::klass_name name) const + { + return function_declaration_generator{name}; + } +} const function_declaration = {}; } } } |