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 /src/lib | |
parent | 2dd1e59a4cf77d29232c8b592990eb6db9846657 (diff) |
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.
Diffstat (limited to 'src/lib')
-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 | |||
33 | "struct " << string << " {\n" | 33 | "struct " << string << " {\n" |
34 | ).generate(sink, cls.cxx_name, context)) return false; | 34 | ).generate(sink, cls.cxx_name, context)) return false; |
35 | 35 | ||
36 | if(!as_generator(*(scope_tab << function_declaration)) | 36 | if(!as_generator(*(scope_tab << function_declaration(get_klass_name(cls)))) |
37 | .generate(sink, cls.functions, context)) return false; | 37 | .generate(sink, cls.functions, context)) return false; |
38 | 38 | ||
39 | // static Efl_Class const* _eo_class(); | 39 | // 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 | |||
87 | // << scope_tab << scope_tab << ": ::efl::eo::concrete( ::efl::eo::do_eo_add( ::efl::eo::concrete{nullptr}, f)) {}\n" | 87 | // << scope_tab << scope_tab << ": ::efl::eo::concrete( ::efl::eo::do_eo_add( ::efl::eo::concrete{nullptr}, f)) {}\n" |
88 | ).generate(sink, attributes::make_infinite_tuple(cls.cxx_name), context)) return false; | 88 | ).generate(sink, attributes::make_infinite_tuple(cls.cxx_name), context)) return false; |
89 | 89 | ||
90 | if(!as_generator(*(scope_tab << function_declaration)) | 90 | if(!as_generator(*(scope_tab << function_declaration(get_klass_name(cls)))) |
91 | .generate(sink, cls.functions, context)) return false; | 91 | .generate(sink, cls.functions, context)) return false; |
92 | 92 | ||
93 | // static Efl_Class const* _eo_class(); | 93 | // 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 @@ | |||
4 | #include "grammar/generator.hpp" | 4 | #include "grammar/generator.hpp" |
5 | #include "grammar/klass_def.hpp" | 5 | #include "grammar/klass_def.hpp" |
6 | 6 | ||
7 | #include "grammar/string.hpp" | ||
7 | #include "grammar/indentation.hpp" | 8 | #include "grammar/indentation.hpp" |
8 | #include "grammar/list.hpp" | 9 | #include "grammar/list.hpp" |
9 | #include "grammar/alternative.hpp" | 10 | #include "grammar/alternative.hpp" |
@@ -15,13 +16,43 @@ namespace efl { namespace eolian { namespace grammar { | |||
15 | 16 | ||
16 | struct function_declaration_generator | 17 | struct function_declaration_generator |
17 | { | 18 | { |
18 | template <typename OutputIterator, typename Context> | 19 | function_declaration_generator(attributes::klass_name const& name) |
19 | bool generate(OutputIterator sink, attributes::function_def const& f, Context const& context) const | 20 | : _klass_name(name) |
20 | { | 21 | {} |
21 | return as_generator | 22 | |
22 | ("::efl::eolian::return_traits<" << grammar::type(true) << ">::type " << string << "(" << (parameter % ", ") << ") const;\n") | 23 | template <typename OutputIterator, typename Context> |
23 | .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), context); | 24 | bool generate(OutputIterator sink, attributes::function_def const& f, Context const& ctx) const |
24 | } | 25 | { |
26 | std::string suffix; | ||
27 | switch(_klass_name.type) | ||
28 | { | ||
29 | case attributes::class_type::regular: | ||
30 | case attributes::class_type::abstract_: | ||
31 | suffix = "CLASS"; | ||
32 | break; | ||
33 | case attributes::class_type::mixin: | ||
34 | suffix = "MIXIN"; | ||
35 | break; | ||
36 | case attributes::class_type::interface_: | ||
37 | suffix = "INTERFACE"; | ||
38 | break; | ||
39 | } | ||
40 | |||
41 | if(f.is_beta && | ||
42 | !as_generator("#ifdef " << *(string << "_") << string << "_" << string << "_BETA\n") | ||
43 | .generate(sink, std::make_tuple(_klass_name.namespaces, _klass_name.eolian_name, suffix), add_upper_case_context(ctx))) | ||
44 | return false; | ||
45 | if(!as_generator | ||
46 | ("::efl::eolian::return_traits<" << grammar::type(true) << ">::type " << string << "(" << (parameter % ", ") << ") const;\n") | ||
47 | .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), ctx)) | ||
48 | return false; | ||
49 | if(f.is_beta && | ||
50 | !as_generator("#endif\n").generate(sink, attributes::unused, ctx)) | ||
51 | return false; | ||
52 | return true; | ||
53 | } | ||
54 | |||
55 | attributes::klass_name _klass_name; | ||
25 | }; | 56 | }; |
26 | 57 | ||
27 | template <> | 58 | template <> |
@@ -31,8 +62,14 @@ namespace type_traits { | |||
31 | template <> | 62 | template <> |
32 | struct attributes_needed<function_declaration_generator> : std::integral_constant<int, 1> {}; | 63 | struct attributes_needed<function_declaration_generator> : std::integral_constant<int, 1> {}; |
33 | } | 64 | } |
34 | 65 | ||
35 | function_declaration_generator const function_declaration = {}; | 66 | struct function_declaration_terminal |
67 | { | ||
68 | function_declaration_generator operator()(attributes::klass_name name) const | ||
69 | { | ||
70 | return function_declaration_generator{name}; | ||
71 | } | ||
72 | } const function_declaration = {}; | ||
36 | 73 | ||
37 | } } } | 74 | } } } |
38 | 75 | ||