summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2014-12-30 21:18:40 -0200
committerVitor Sousa <vitorsousasilva@gmail.com>2015-01-05 15:52:27 -0200
commit4222cd3f50042452893bc24e85376f3c1b4ce748 (patch)
tree978fa3e6605e1c03bb33fcc21d1ad9e042a7e6bc /src/lib/eolian_cxx/grammar/inheritance_base_generator.hh
parent2b12114777cc9e0b7db3894f37dd71f6b5b073b4 (diff)
eolian_cxx: Fix compilation of inheritance from Eolian generated classes
Updated the code for the "inheritance helper" functions and classes to be in conformance with the new wrapper architecture. Member variable "parents" of efl::eo::eo_class struct was split in two member variables, "ancestors" and "parents", the former containing all Eo class ancestors and the later only the direct bases. Changed all required files accordingly. Check to avoid using biding string when the parameter is @out now matches any variation of "char". Add default constructor to efl::eo::concrete in order to allow it to be NULL initialized in the "inheritance helper" classes. Removed conflicting parent_set member function in the efl::eo::inherit class. Removed the "inheritance_extension_function" generator since it is no longer used.
Diffstat (limited to 'src/lib/eolian_cxx/grammar/inheritance_base_generator.hh')
-rw-r--r--src/lib/eolian_cxx/grammar/inheritance_base_generator.hh131
1 files changed, 19 insertions, 112 deletions
diff --git a/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh b/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh
index 9e10e5067d..30ee36d1bb 100644
--- a/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh
+++ b/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh
@@ -65,12 +65,8 @@ struct inheritance_operations_description
65inline std::ostream& 65inline std::ostream&
66operator<<(std::ostream& out, inheritance_operations_description const& x) 66operator<<(std::ostream& out, inheritance_operations_description const& x)
67{ 67{
68 extensions_container_type::const_iterator it, first, last;
69 std::string s; 68 std::string s;
70 69
71 first = x._cls.extensions.begin();
72 last = x._cls.extensions.end();
73
74 out << "template <typename T>" 70 out << "template <typename T>"
75 << endl << "int initialize_operation_description(::efl::eo::detail::tag<" 71 << endl << "int initialize_operation_description(::efl::eo::detail::tag<"
76 << full_name(x._cls) << ">" << endl 72 << full_name(x._cls) << ">" << endl
@@ -84,21 +80,13 @@ operator<<(std::ostream& out, inheritance_operations_description const& x)
84 out << inheritance_operation(x._cls, i); 80 out << inheritance_operation(x._cls, i);
85 } 81 }
86 82
87 out << tab(1) 83 for (std::string const& parent : x._cls.parents)
88 << "initialize_operation_description<T>(efl::eo::detail::tag<"
89 << x._cls.parent
90 << ">(), &ops["
91 << x._cls.functions.size() << "]);" << endl;
92
93 s += " + operation_description_class_size<" + x._cls.parent + ">::value";
94
95 for (it = first; it != last; ++it)
96 { 84 {
97 out << tab(1) 85 out << tab(1)
98 << "initialize_operation_description<T>(efl::eo::detail::tag<" 86 << "initialize_operation_description<T>(::efl::eo::detail::tag<::"
99 << *it << ">(), &ops[" << x._cls.functions.size() << s << "]);" << endl; 87 << parent << ">(), &ops[" << x._cls.functions.size() << s << "]);" << endl;
100 88
101 s += " + operation_description_class_size< " + *it + ">::value"; 89 s += " + operation_description_class_size<::" + parent + ">::value";
102 } 90 }
103 91
104 out << tab(1) << "return 0;" << endl 92 out << tab(1) << "return 0;" << endl
@@ -168,21 +156,16 @@ struct inheritance_base_operations_size
168inline std::ostream& 156inline std::ostream&
169operator<<(std::ostream& out, inheritance_base_operations_size const& x) 157operator<<(std::ostream& out, inheritance_base_operations_size const& x)
170{ 158{
171 extensions_container_type::const_iterator it, first = x._cls.extensions.begin();
172 extensions_container_type::const_iterator last = x._cls.extensions.end();
173 first = x._cls.extensions.begin();
174
175 out << "template<>" 159 out << "template<>"
176 << endl << "struct operation_description_class_size< " 160 << endl << "struct operation_description_class_size< "
177 << full_name(x._cls) << " >" << endl 161 << full_name(x._cls) << " >" << endl
178 << "{" << endl 162 << "{" << endl
179 << tab(1) << "static const int value = " 163 << tab(1) << "static const int value = "
180 << x._cls.functions.size() 164 << x._cls.functions.size();
181 << " + operation_description_class_size<" << class_name(x._cls.parent) << ">::value";
182 165
183 for (it = first; it != last; ++it) 166 for (std::string const& parent : x._cls.parents)
184 { 167 {
185 out << " + operation_description_class_size< " << *it << " >::value"; 168 out << " + operation_description_class_size<::" << parent << " >::value";
186 } 169 }
187 170
188 out << ";" << endl 171 out << ";" << endl
@@ -205,14 +188,14 @@ inline std::ostream&
205operator<<(std::ostream& out, inheritance_base_operations_extensions const& x) 188operator<<(std::ostream& out, inheritance_base_operations_extensions const& x)
206{ 189{
207 eo_class const& cls = x._cls; 190 eo_class const& cls = x._cls;
208 extensions_container_type::const_iterator it, first = cls.extensions.begin(); 191 ancestors_container_type::const_iterator it, first = cls.parents.begin();
209 extensions_container_type::const_iterator last = cls.extensions.end(); 192 ancestors_container_type::const_iterator last = cls.parents.end();
210 193
211 out << endl << tab(3) << ": operations< " << class_name(cls.parent) << " >::template type<T>";
212 for (it = first; it != last; ++it) 194 for (it = first; it != last; ++it)
213 { 195 {
214 out << "," << endl << tab(3) 196 out << endl
215 << "operations< " << *it 197 << tab(3) << (it == first ? ": " : ", ")
198 << "virtual operations< ::" << *it
216 << " >::template type<T>"; 199 << " >::template type<T>";
217 } 200 }
218 201
@@ -247,12 +230,12 @@ operator<<(std::ostream& out, inheritance_base_operations_function const& x)
247 if (!is_void) 230 if (!is_void)
248 out << tab(3) << func.ret.front().native << " _tmp_ret = {};" << endl; 231 out << tab(3) << func.ret.front().native << " _tmp_ret = {};" << endl;
249 232
250 out << callbacks_heap_alloc("static_cast<T*>(this)->_eo_ptr()", func.params, 3) 233 out << callbacks_heap_alloc("dynamic_cast<T*>(this)->_eo_ptr()", func.params, 3)
251 << endl; 234 << endl;
252 235
253 out << tab(3) 236 out << tab(3)
254 << "eo_do_super(static_cast<T*>(this)->_eo_ptr()," << endl 237 << "eo_do_super(dynamic_cast<T*>(this)->_eo_ptr()," << endl
255 << tab(5) << "static_cast<T*>(this)->_eo_class()," << endl 238 << tab(5) << "dynamic_cast<T*>(this)->_eo_class()," << endl
256 << tab(5) << function_call(func) << ");" << endl; 239 << tab(5) << function_call(func) << ");" << endl;
257 240
258 if (!is_void) 241 if (!is_void)
@@ -325,10 +308,10 @@ operator<<(std::ostream& out, inheritance_call_constructors const& x)
325 { 308 {
326 eo_constructor const& ctor = *it; 309 eo_constructor const& ctor = *it;
327 out << "inline void" << endl 310 out << "inline void" << endl
328 << "call_constructor(tag< " 311 << "call_constructor(::efl::eo::detail::tag< "
329 << full_name(x._cls) << " >" << endl 312 << full_name(x._cls) << " >" << endl
330 << tab(5) << ", Eo* eo, Eo_Class const* cls EINA_UNUSED," << endl 313 << tab(5) << ", Eo* eo, Eo_Class const* cls EINA_UNUSED," << endl
331 << tab(5) << "args_class<" 314 << tab(5) << "::efl::eo::detail::args_class<"
332 << full_name(x._cls) 315 << full_name(x._cls)
333 << ", ::std::tuple<" 316 << ", ::std::tuple<"
334 << parameters_types(ctor.params) 317 << parameters_types(ctor.params)
@@ -343,10 +326,10 @@ operator<<(std::ostream& out, inheritance_call_constructors const& x)
343 } 326 }
344 327
345 out << "inline void" << endl 328 out << "inline void" << endl
346 << "call_constructor(tag< " 329 << "call_constructor(::efl::eo::detail::tag< "
347 << full_name(x._cls) << " >" << endl 330 << full_name(x._cls) << " >" << endl
348 << tab(5) << ", Eo* eo, Eo_Class const* cls EINA_UNUSED," << endl 331 << tab(5) << ", Eo* eo, Eo_Class const* cls EINA_UNUSED," << endl
349 << tab(5) << "args_class<" 332 << tab(5) << "::efl::eo::detail::args_class<"
350 << full_name(x._cls) 333 << full_name(x._cls)
351 << ", ::std::tuple<::efl::eo::parent_type> > const& args)" << endl 334 << ", ::std::tuple<::efl::eo::parent_type> > const& args)" << endl
352 << "{" << endl 335 << "{" << endl
@@ -357,81 +340,6 @@ operator<<(std::ostream& out, inheritance_call_constructors const& x)
357 return out; 340 return out;
358} 341}
359 342
360struct inheritance_extension_function
361{
362 eo_function const& _func;
363 inheritance_extension_function(eo_function const& func) : _func(func) {}
364};
365
366inline std::ostream&
367operator<<(std::ostream& out, inheritance_extension_function const& x)
368{
369 out << template_parameters_declaration(x._func.params, 1);
370
371 bool is_void = function_is_void(x._func);
372 out << tab(2)
373 << reinterpret_type(x._func.ret) << " "
374 << x._func.name << "("
375 << parameters_declaration(x._func.params)
376 << ")" << endl
377 << tab(2) << "{" << endl;
378
379 if (!is_void)
380 {
381 out << tab(3) << x._func.ret.front().native << " _tmp_ret = {};" << endl;
382 }
383
384 out << callbacks_heap_alloc("static_cast<U*>(this)->_eo_ptr()", x._func.params, 2)
385 << endl;
386
387 out << tab(3) << "eo_do(static_cast<U*>(this)->_eo_ptr(), "
388 << function_call(x._func) << ");" << endl;
389
390 if (!function_is_void(x._func))
391 out << tab(4) << "return " << to_cxx(x._func.ret, "_tmp_ret") << ";" << endl;
392 out << tab(2) << "}" << endl
393 << endl;
394
395 return out;
396}
397
398struct inheritance_extension
399{
400 eo_class const& _cls;
401 inheritance_extension(eo_class const& cls) : _cls(cls) {}
402};
403
404inline std::ostream&
405operator<<(std::ostream& out, inheritance_extension const& x)
406{
407 full_name const cls(x._cls);
408 out << "template<>" << endl
409 << "struct extension_inheritance< "
410 << cls << ">" << endl
411 << "{" << endl
412 << tab(1) << "template <typename U>" << endl
413 << tab(1) << "struct type" << endl
414 << tab(1) << "{" << endl
415 << tab(2) << "operator " << cls << "() const" << endl
416 << tab(2) << "{" << endl
417 << tab(3) << "return " << cls
418 << "(eo_ref(static_cast<U const*>(this)->_eo_ptr()));" << endl
419 << tab(2) << "}" << endl
420 << endl;
421 functions_container_type::const_iterator it,
422 first = x._cls.functions.begin(),
423 last = x._cls.functions.end();
424 for (it = first; it != last; ++it)
425 {
426 out << inheritance_extension_function(*it);
427 }
428 out << events(x._cls, true);
429 out << tab(1) << "};" << endl
430 << "};" << endl
431 << endl;
432 return out;
433}
434
435struct inheritance_eo_class_getter 343struct inheritance_eo_class_getter
436{ 344{
437 eo_class const& _cls; 345 eo_class const& _cls;
@@ -460,7 +368,6 @@ eo_inheritance_detail_generator(std::ostream& out, eo_class const& cls)
460 << inheritance_base_operations_size(cls) 368 << inheritance_base_operations_size(cls)
461 << inheritance_operations_description(cls) 369 << inheritance_operations_description(cls)
462 << inheritance_call_constructors(cls) 370 << inheritance_call_constructors(cls)
463 << inheritance_extension(cls)
464 << inheritance_eo_class_getter(cls) 371 << inheritance_eo_class_getter(cls)
465 << "} } }" << endl; 372 << "} } }" << endl;
466} 373}