diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-12-05 10:47:09 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2017-12-05 15:01:45 +0900 |
commit | 8cdb3184f8a1f3e5396d953b238ce2e217f0cb1c (patch) | |
tree | bbd99d8e8616588f69360281d8291fb34fffb7e6 /src/lib/eolian_cxx | |
parent | 2b0805ddce66903c73c82047772f695b70c3b810 (diff) |
cxx: Fix compilation after merge
This resolves a few issues and brings back the experimental features.
Also, disable some of the ugliest experiments:
- manual function overrides,
- define APIs only in eo_cxx namespace
Some APIs are generated behind EFL_CXXPERIMENT (eg. event_name_cb_add or
some weak pointer stuff). I believe they are useful but would like to
make sure there are no serious drawbacks with generating those.
Diffstat (limited to 'src/lib/eolian_cxx')
-rw-r--r-- | src/lib/eolian_cxx/grammar/class_definition.hpp | 37 | ||||
-rw-r--r-- | src/lib/eolian_cxx/grammar/context.hpp | 2 | ||||
-rw-r--r-- | src/lib/eolian_cxx/grammar/function_declaration.hpp | 4 | ||||
-rw-r--r-- | src/lib/eolian_cxx/grammar/function_definition.hpp | 4 | ||||
-rw-r--r-- | src/lib/eolian_cxx/grammar/generator.hpp | 1 | ||||
-rw-r--r-- | src/lib/eolian_cxx/grammar/klass_def.hpp | 8 | ||||
-rw-r--r-- | src/lib/eolian_cxx/grammar/parameter.hpp | 10 | ||||
-rw-r--r-- | src/lib/eolian_cxx/grammar/part_declaration.hpp | 3 | ||||
-rw-r--r-- | src/lib/eolian_cxx/grammar/part_implementation.hpp | 3 | ||||
-rw-r--r-- | src/lib/eolian_cxx/grammar/type_function_declaration.hpp | 5 |
10 files changed, 49 insertions, 28 deletions
diff --git a/src/lib/eolian_cxx/grammar/class_definition.hpp b/src/lib/eolian_cxx/grammar/class_definition.hpp index 771121d8ee..b282f71bf9 100644 --- a/src/lib/eolian_cxx/grammar/class_definition.hpp +++ b/src/lib/eolian_cxx/grammar/class_definition.hpp | |||
@@ -208,26 +208,17 @@ struct class_definition_generator | |||
208 | if(!as_generator(scope_tab << "/// @endcond\n").generate(sink, attributes::unused, context)) return false; | 208 | if(!as_generator(scope_tab << "/// @endcond\n").generate(sink, attributes::unused, context)) return false; |
209 | 209 | ||
210 | // EXPERIMENTAL: Parts | 210 | // EXPERIMENTAL: Parts |
211 | if(!as_generator("#ifdef EFL_CXXPERIMENTAL\n").generate(sink, attributes::unused, context)) return false; | 211 | if (!cls.parts.empty()) |
212 | if(!as_generator(*(scope_tab << part_declaration << ";\n")) | 212 | { |
213 | .generate(sink, cls.parts, context)) return false; | 213 | if(!as_generator("#ifdef EFL_CXXPERIMENTAL\n").generate(sink, attributes::unused, context)) return false; |
214 | if(!as_generator("#endif \n").generate(sink, attributes::unused, context)) return false; | 214 | if(!as_generator(*(scope_tab << part_declaration << ";\n")) |
215 | .generate(sink, cls.parts, context)) return false; | ||
216 | if(!as_generator("#endif \n").generate(sink, attributes::unused, context)) return false; | ||
217 | } | ||
215 | 218 | ||
216 | if(!as_generator( scope_tab << "::efl::eo::wref<" << string << "> _get_wref() const { " | 219 | if(!as_generator( scope_tab << "::efl::eo::wref<" << string << "> _get_wref() const { " |
217 | "return ::efl::eo::wref<" << string << ">(*this); }\n" | 220 | "return ::efl::eo::wref<" << string << ">(*this); }\n" |
218 | ).generate(sink, std::make_tuple(cls.cxx_name, cls.cxx_name), context)) return false; | 221 | ).generate(sink, std::make_tuple(cls.cxx_name, cls.cxx_name), context)) return false; |
219 | |||
220 | // EXPERIMENTAL: wref and implicit conversion to Eo* | ||
221 | if(!as_generator("#ifdef EFL_CXXPERIMENTAL\n").generate(sink, attributes::unused, context)) return false; | ||
222 | // For easy wref, operator-> in wref needs to also return a pointer type | ||
223 | if(!as_generator( scope_tab << "const " << string << "* operator->() const { return this; }\n" | ||
224 | ).generate(sink, std::make_tuple(cls.cxx_name, cls.cxx_name), context)) return false; | ||
225 | if(!as_generator( scope_tab << string << "* operator->() { return this; }\n" | ||
226 | ).generate(sink, std::make_tuple(cls.cxx_name, cls.cxx_name), context)) return false; | ||
227 | // For easy interfacing with C: no need to use _eo_ptr() | ||
228 | if(!as_generator( scope_tab << "operator Eo*() const { return _eo_ptr(); }\n" | ||
229 | ).generate(sink, attributes::unused, context)) return false; | ||
230 | if(!as_generator("#endif \n").generate(sink, attributes::unused, context)) return false; | ||
231 | 222 | ||
232 | // eo_concrete | 223 | // eo_concrete |
233 | if(!as_generator( scope_tab << "::efl::eo::concrete const& _get_concrete() const { return *this; }\n" | 224 | if(!as_generator( scope_tab << "::efl::eo::concrete const& _get_concrete() const { return *this; }\n" |
@@ -241,6 +232,18 @@ struct class_definition_generator | |||
241 | << scope_tab << "using ::efl::eo::concrete::operator bool;\n" | 232 | << scope_tab << "using ::efl::eo::concrete::operator bool;\n" |
242 | ).generate(sink, attributes::unused, context)) return false; | 233 | ).generate(sink, attributes::unused, context)) return false; |
243 | 234 | ||
235 | // EXPERIMENTAL: wref and implicit conversion to Eo* | ||
236 | if(!as_generator("#ifdef EFL_CXXPERIMENTAL\n").generate(sink, attributes::unused, context)) return false; | ||
237 | // For easy wref, operator-> in wref needs to also return a pointer type | ||
238 | if(!as_generator( scope_tab << "const " << string << "* operator->() const { return this; }\n" | ||
239 | ).generate(sink, std::make_tuple(cls.cxx_name, cls.cxx_name), context)) return false; | ||
240 | if(!as_generator( scope_tab << string << "* operator->() { return this; }\n" | ||
241 | ).generate(sink, std::make_tuple(cls.cxx_name, cls.cxx_name), context)) return false; | ||
242 | // For easy interfacing with C: no need to use _eo_ptr() | ||
243 | if(!as_generator( scope_tab << "operator Eo*() const { return _eo_ptr(); }\n" | ||
244 | ).generate(sink, attributes::unused, context)) return false; | ||
245 | if(!as_generator("#endif \n").generate(sink, attributes::unused, context)) return false; | ||
246 | |||
244 | if(!as_generator( scope_tab << "friend bool operator==(" << string << " const& lhs, " << string << " const& rhs)\n" | 247 | if(!as_generator( scope_tab << "friend bool operator==(" << string << " const& lhs, " << string << " const& rhs)\n" |
245 | << scope_tab << "{ return lhs._get_concrete() == rhs._get_concrete(); }\n" | 248 | << scope_tab << "{ return lhs._get_concrete() == rhs._get_concrete(); }\n" |
246 | << scope_tab << "friend bool operator!=(" << string << " const& lhs, " << string << " const& rhs)\n" | 249 | << scope_tab << "friend bool operator!=(" << string << " const& lhs, " << string << " const& rhs)\n" |
diff --git a/src/lib/eolian_cxx/grammar/context.hpp b/src/lib/eolian_cxx/grammar/context.hpp index 79e54178e0..e4839200bc 100644 --- a/src/lib/eolian_cxx/grammar/context.hpp +++ b/src/lib/eolian_cxx/grammar/context.hpp | |||
@@ -56,7 +56,7 @@ Tag const& context_find_tag(context_cons<OtherTag, Tail> const& context | |||
56 | } | 56 | } |
57 | 57 | ||
58 | template <typename Tag, typename OtherTag, typename Tail> | 58 | template <typename Tag, typename OtherTag, typename Tail> |
59 | Tag const& context_find_tag(context_null const& context) | 59 | Tag const& context_find_tag(context_null const&) |
60 | { | 60 | { |
61 | throw std::logic_error("Context for generation not available"); | 61 | throw std::logic_error("Context for generation not available"); |
62 | } | 62 | } |
diff --git a/src/lib/eolian_cxx/grammar/function_declaration.hpp b/src/lib/eolian_cxx/grammar/function_declaration.hpp index a2770abf18..f30f7569dc 100644 --- a/src/lib/eolian_cxx/grammar/function_declaration.hpp +++ b/src/lib/eolian_cxx/grammar/function_declaration.hpp | |||
@@ -48,10 +48,12 @@ struct function_declaration_generator | |||
48 | .generate(sink, std::make_tuple(_klass_name.namespaces, _klass_name.eolian_name), add_upper_case_context(ctx))) | 48 | .generate(sink, std::make_tuple(_klass_name.namespaces, _klass_name.eolian_name), add_upper_case_context(ctx))) |
49 | return false; | 49 | return false; |
50 | 50 | ||
51 | #ifdef USE_EOCXX_MANUAL_OVERRIDES | ||
51 | if(!as_generator | 52 | if(!as_generator |
52 | ("#ifndef EOLIAN_CXX_" << string << "_DECLARATION\n") | 53 | ("#ifndef EOLIAN_CXX_" << string << "_DECLARATION\n") |
53 | .generate(sink, f.c_name, add_upper_case_context(ctx))) | 54 | .generate(sink, f.c_name, add_upper_case_context(ctx))) |
54 | return false; | 55 | return false; |
56 | #endif | ||
55 | 57 | ||
56 | std::string template_statement(f.template_statement()); | 58 | std::string template_statement(f.template_statement()); |
57 | if (!template_statement.empty() && | 59 | if (!template_statement.empty() && |
@@ -68,11 +70,13 @@ struct function_declaration_generator | |||
68 | .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), ctx)) | 70 | .generate(sink, std::make_tuple(f.return_type, escape_keyword(f.name), f.parameters), ctx)) |
69 | return false; | 71 | return false; |
70 | 72 | ||
73 | #ifdef USE_EOCXX_MANUAL_OVERRIDES | ||
71 | if(!as_generator | 74 | if(!as_generator |
72 | ("#else\n" << scope_tab << "EOLIAN_CXX_" << string << "_DECLARATION\n" | 75 | ("#else\n" << scope_tab << "EOLIAN_CXX_" << string << "_DECLARATION\n" |
73 | "#endif\n") | 76 | "#endif\n") |
74 | .generate(sink, f.c_name, add_upper_case_context(ctx))) | 77 | .generate(sink, f.c_name, add_upper_case_context(ctx))) |
75 | return false; | 78 | return false; |
79 | #endif | ||
76 | 80 | ||
77 | if(f.is_protected && | 81 | if(f.is_protected && |
78 | !as_generator("#endif\n").generate(sink, attributes::unused, ctx)) | 82 | !as_generator("#endif\n").generate(sink, attributes::unused, ctx)) |
diff --git a/src/lib/eolian_cxx/grammar/function_definition.hpp b/src/lib/eolian_cxx/grammar/function_definition.hpp index 46df876b33..3161b76041 100644 --- a/src/lib/eolian_cxx/grammar/function_definition.hpp +++ b/src/lib/eolian_cxx/grammar/function_definition.hpp | |||
@@ -54,10 +54,12 @@ struct function_definition_generator | |||
54 | .generate(sink, std::make_tuple(_klass_name.namespaces, _klass_name.eolian_name), add_upper_case_context(ctx))) | 54 | .generate(sink, std::make_tuple(_klass_name.namespaces, _klass_name.eolian_name), add_upper_case_context(ctx))) |
55 | return false; | 55 | return false; |
56 | 56 | ||
57 | #ifdef USE_EOCXX_MANUAL_OVERRIDES | ||
57 | if(!as_generator | 58 | if(!as_generator |
58 | ("#ifndef EOLIAN_CXX_" << string << "_IMPLEMENTATION\n") | 59 | ("#ifndef EOLIAN_CXX_" << string << "_IMPLEMENTATION\n") |
59 | .generate(sink, f.c_name, add_upper_case_context(ctx))) | 60 | .generate(sink, f.c_name, add_upper_case_context(ctx))) |
60 | return false; | 61 | return false; |
62 | #endif | ||
61 | 63 | ||
62 | std::string template_statement(f.template_statement()); | 64 | std::string template_statement(f.template_statement()); |
63 | if (!template_statement.empty() && | 65 | if (!template_statement.empty() && |
@@ -166,11 +168,13 @@ struct function_definition_generator | |||
166 | if(!as_generator("}\n").generate(sink, attributes::unused, ctx)) | 168 | if(!as_generator("}\n").generate(sink, attributes::unused, ctx)) |
167 | return false; | 169 | return false; |
168 | 170 | ||
171 | #ifdef USE_EOCXX_MANUAL_OVERRIDES | ||
169 | if(!as_generator | 172 | if(!as_generator |
170 | ("#else\n" << scope_tab << "EOLIAN_CXX_" << string << "_IMPLEMENTATION\n" | 173 | ("#else\n" << scope_tab << "EOLIAN_CXX_" << string << "_IMPLEMENTATION\n" |
171 | "#endif\n") | 174 | "#endif\n") |
172 | .generate(sink, f.c_name, add_upper_case_context(ctx))) | 175 | .generate(sink, f.c_name, add_upper_case_context(ctx))) |
173 | return false; | 176 | return false; |
177 | #endif | ||
174 | 178 | ||
175 | if(f.is_beta && | 179 | if(f.is_beta && |
176 | !as_generator("#endif\n").generate(sink, attributes::unused, ctx)) | 180 | !as_generator("#endif\n").generate(sink, attributes::unused, ctx)) |
diff --git a/src/lib/eolian_cxx/grammar/generator.hpp b/src/lib/eolian_cxx/grammar/generator.hpp index 10e96c7c13..6d0be7e4f1 100644 --- a/src/lib/eolian_cxx/grammar/generator.hpp +++ b/src/lib/eolian_cxx/grammar/generator.hpp | |||
@@ -5,6 +5,7 @@ | |||
5 | 5 | ||
6 | // EXPERIMENTAL | 6 | // EXPERIMENTAL |
7 | //#define USE_EOCXX_INHERIT_ONLY | 7 | //#define USE_EOCXX_INHERIT_ONLY |
8 | //#define USE_EOCXX_MANUAL_OVERRIDES | ||
8 | 9 | ||
9 | namespace efl { namespace eolian { namespace grammar { | 10 | namespace efl { namespace eolian { namespace grammar { |
10 | 11 | ||
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp index b2aae1bbef..1cb5ecfba0 100644 --- a/src/lib/eolian_cxx/grammar/klass_def.hpp +++ b/src/lib/eolian_cxx/grammar/klass_def.hpp | |||
@@ -458,17 +458,15 @@ struct function_def | |||
458 | return !(lhs == rhs); | 458 | return !(lhs == rhs); |
459 | } | 459 | } |
460 | function_def() = default; | 460 | function_def() = default; |
461 | function_def(type_def return_type, std::string name, std::vector<parameter_def> parameters | ||
462 | , std::string c_name, std::string filename, bool is_beta) | ||
463 | : return_type(return_type), name(name), parameters(parameters), c_name(c_name), filename(filename), is_beta(is_beta) {} | ||
464 | function_def(type_def _return_type, std::string const& _name, | 461 | function_def(type_def _return_type, std::string const& _name, |
465 | std::vector<parameter_def> const& _parameters, | 462 | std::vector<parameter_def> const& _parameters, |
466 | std::string const& _c_name, | 463 | std::string const& _c_name, |
464 | std::string _filename, | ||
467 | bool _is_beta = false, | 465 | bool _is_beta = false, |
468 | bool _is_protected = false, | 466 | bool _is_protected = false, |
469 | bool _is_function_pointer = false) | 467 | bool _is_function_pointer = false) |
470 | : return_type(_return_type), name(_name), parameters(_parameters), | 468 | : return_type(_return_type), name(_name), parameters(_parameters), |
471 | c_name(_c_name), is_beta(_is_beta), is_protected(_is_protected), | 469 | c_name(_c_name), filename(_filename), is_beta(_is_beta), is_protected(_is_protected), |
472 | is_function_pointer(_is_function_pointer) {} | 470 | is_function_pointer(_is_function_pointer) {} |
473 | 471 | ||
474 | function_def( ::Eolian_Function const* function, Eolian_Function_Type type, Eolian_Unit const* unit) | 472 | function_def( ::Eolian_Function const* function, Eolian_Function_Type type, Eolian_Unit const* unit) |
@@ -572,7 +570,7 @@ struct function_def | |||
572 | char typenam[2] = { 0, }; | 570 | char typenam[2] = { 0, }; |
573 | typenam[0] = template_typename++; | 571 | typenam[0] = template_typename++; |
574 | std::string statement = "auto fw = new ::efl::eolian::function_wrapper<"; | 572 | std::string statement = "auto fw = new ::efl::eolian::function_wrapper<"; |
575 | statement += param.c_type + ", " + typenam + ">(" + param.param_name + ");"; | 573 | statement += param.type.c_type + ", " + typenam + ">(" + param.param_name + ");"; |
576 | statements.push_back(statement); | 574 | statements.push_back(statement); |
577 | } | 575 | } |
578 | } | 576 | } |
diff --git a/src/lib/eolian_cxx/grammar/parameter.hpp b/src/lib/eolian_cxx/grammar/parameter.hpp index 5d8d3aef5c..68f5450dd1 100644 --- a/src/lib/eolian_cxx/grammar/parameter.hpp +++ b/src/lib/eolian_cxx/grammar/parameter.hpp | |||
@@ -78,12 +78,20 @@ struct parameter_as_argument_generator | |||
78 | template <typename OutputIterator, typename Context> | 78 | template <typename OutputIterator, typename Context> |
79 | bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const | 79 | bool generate(OutputIterator sink, attributes::parameter_def const& param, Context const& context) const |
80 | { | 80 | { |
81 | return as_generator(parameter_type << "(" << string << ")").generate(sink, std::make_tuple(param, param.param_name), context); | 81 | attributes::parameter_def param_copy = param; |
82 | if (param.direction == attributes::parameter_direction::in) | ||
83 | param_copy.direction = attributes::parameter_direction::out; | ||
84 | else if (param.direction == attributes::parameter_direction::out) | ||
85 | param_copy.direction = attributes::parameter_direction::in; | ||
86 | return as_generator(parameter_type << "(" << string << ")") | ||
87 | .generate(sink, std::make_tuple(param_copy, param_copy.param_name), context); | ||
82 | } | 88 | } |
83 | }; | 89 | }; |
84 | 90 | ||
85 | template <> | 91 | template <> |
86 | struct is_eager_generator<parameter_as_argument_generator> : std::true_type {}; | 92 | struct is_eager_generator<parameter_as_argument_generator> : std::true_type {}; |
93 | template <> | ||
94 | struct is_generator<parameter_as_argument_generator> : std::true_type {}; | ||
87 | namespace type_traits { | 95 | namespace type_traits { |
88 | template <> | 96 | template <> |
89 | struct attributes_needed<parameter_as_argument_generator> : std::integral_constant<int, 1> {}; | 97 | struct attributes_needed<parameter_as_argument_generator> : std::integral_constant<int, 1> {}; |
diff --git a/src/lib/eolian_cxx/grammar/part_declaration.hpp b/src/lib/eolian_cxx/grammar/part_declaration.hpp index 04258c4020..30646fcbae 100644 --- a/src/lib/eolian_cxx/grammar/part_declaration.hpp +++ b/src/lib/eolian_cxx/grammar/part_declaration.hpp | |||
@@ -31,7 +31,8 @@ struct part_declaration_generator | |||
31 | 31 | ||
32 | template <> | 32 | template <> |
33 | struct is_eager_generator<part_declaration_generator> : std::true_type {}; | 33 | struct is_eager_generator<part_declaration_generator> : std::true_type {}; |
34 | 34 | template <> | |
35 | struct is_generator<part_declaration_generator> : std::true_type {}; | ||
35 | namespace type_traits { | 36 | namespace type_traits { |
36 | template <> | 37 | template <> |
37 | struct attributes_needed<part_declaration_generator> : std::integral_constant<int, 1> {}; | 38 | struct attributes_needed<part_declaration_generator> : std::integral_constant<int, 1> {}; |
diff --git a/src/lib/eolian_cxx/grammar/part_implementation.hpp b/src/lib/eolian_cxx/grammar/part_implementation.hpp index cee2fc7fa8..692ebca7c1 100644 --- a/src/lib/eolian_cxx/grammar/part_implementation.hpp +++ b/src/lib/eolian_cxx/grammar/part_implementation.hpp | |||
@@ -53,7 +53,8 @@ private: | |||
53 | 53 | ||
54 | template <> | 54 | template <> |
55 | struct is_eager_generator<part_implementation_generator> : std::true_type {}; | 55 | struct is_eager_generator<part_implementation_generator> : std::true_type {}; |
56 | 56 | template <> | |
57 | struct is_generator<part_implementation_generator> : std::true_type {}; | ||
57 | namespace type_traits { | 58 | namespace type_traits { |
58 | template <> | 59 | template <> |
59 | struct attributes_needed<part_implementation_generator> : std::integral_constant<int, 1> {}; | 60 | struct attributes_needed<part_implementation_generator> : std::integral_constant<int, 1> {}; |
diff --git a/src/lib/eolian_cxx/grammar/type_function_declaration.hpp b/src/lib/eolian_cxx/grammar/type_function_declaration.hpp index eccedf8f4a..93ebe45940 100644 --- a/src/lib/eolian_cxx/grammar/type_function_declaration.hpp +++ b/src/lib/eolian_cxx/grammar/type_function_declaration.hpp | |||
@@ -56,7 +56,7 @@ struct type_function_declaration_generator { | |||
56 | 56 | ||
57 | std::vector<std::string> c_args; | 57 | std::vector<std::string> c_args; |
58 | for (auto itr : f.parameters) | 58 | for (auto itr : f.parameters) |
59 | c_args.push_back(", " + itr.c_type + " " + itr.param_name); | 59 | c_args.push_back(", " + itr.type.c_type + " " + itr.param_name); |
60 | if (!as_generator( | 60 | if (!as_generator( |
61 | scope_tab << "static " << string << " caller(void *cxx_call_data" | 61 | scope_tab << "static " << string << " caller(void *cxx_call_data" |
62 | << *(string) << ") {\n" | 62 | << *(string) << ") {\n" |
@@ -102,7 +102,8 @@ struct type_function_declaration_generator { | |||
102 | 102 | ||
103 | template <> | 103 | template <> |
104 | struct is_eager_generator<type_function_declaration_generator> : std::true_type {}; | 104 | struct is_eager_generator<type_function_declaration_generator> : std::true_type {}; |
105 | 105 | template <> | |
106 | struct is_generator<type_function_declaration_generator> : std::true_type {}; | ||
106 | namespace type_traits { | 107 | namespace type_traits { |
107 | template <> | 108 | template <> |
108 | struct attributes_needed<type_function_declaration_generator> : std::integral_constant<int, 1> {}; | 109 | struct attributes_needed<type_function_declaration_generator> : std::integral_constant<int, 1> {}; |