summaryrefslogtreecommitdiff
path: root/src/bin/eolian_cxx
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2015-03-26 11:48:09 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2015-04-14 01:06:57 -0300
commitce36f0be936f218d87055cf21b643ab327f07853 (patch)
treefde18f8d5e3e33b57583ba321e61e7f4a07de224 /src/bin/eolian_cxx
parent72604d49574dba6d540d631895facbbc9b12bb2f (diff)
eolain_cxx: Fix C++ support for new Eolian features
Added optional constructor methods for C++ Eolian wrappers. Changed the interface of wrappers' main constructors. If there are optional constructor methods they should be passed as variadic template argument at the end of the constructor. To support variadic template arguments, the optional "parent" parameter is now the first parameter and there is another constructor without the "parent" parameter. Checking for @optinal and @nullable attributes instead of @nonull. Now @nonull is the default, and eina::optional is only used when @optional or @nullable attribute is specified. The names of constructor methods no longer have the class name prefixed. Added unit tests for checking the binding of optional constructors. Added new .eo file to be used in the test. Changed the generated documentation of constructors. Changed the efl::eo::inherit accordingly, to address these new features. Now the constructor methods should be explicit called in the efl::eo::inherit constructor, which will receive them via variadic template arguments. Added another constructor to efl::eo::inherit for passing the parent object. Updated some tests and examples to follow the new interface. Removed some code that is no longer necessary. Also, fix Eolian C++ support for constructing properties. fix assertion when parsing constructing properties. Now if a property is a constructing property eolian_cxx will generate a constructor method that have the property name (without the "_set" suffix).
Diffstat (limited to 'src/bin/eolian_cxx')
-rw-r--r--src/bin/eolian_cxx/convert.cc68
-rw-r--r--src/bin/eolian_cxx/eolian_wrappers.hh6
2 files changed, 48 insertions, 26 deletions
diff --git a/src/bin/eolian_cxx/convert.cc b/src/bin/eolian_cxx/convert.cc
index 22ee22f0e5..4d03c8f775 100644
--- a/src/bin/eolian_cxx/convert.cc
+++ b/src/bin/eolian_cxx/convert.cc
@@ -212,6 +212,20 @@ _convert_property_get_to_function(Eolian_Class const& klass,
212 return get_; 212 return get_;
213} 213}
214 214
215static efl::eolian::eo_function
216_convert_function(Eolian_Class const& klass, Eolian_Function const& func)
217{
218 return {
219 function_type(func),
220 function_scope(func),
221 function_name(func),
222 function_impl(func),
223 function_return_type(func),
224 _convert_eolian_parameters(func),
225 convert_comments_function(klass, func, eolian_cxx::method)
226 };
227}
228
215 229
216void 230void
217convert_eolian_inheritances(efl::eolian::eo_class& cls, Eolian_Class const& klass) 231convert_eolian_inheritances(efl::eolian::eo_class& cls, Eolian_Class const& klass)
@@ -276,32 +290,42 @@ convert_eolian_functions(efl::eolian::eo_class& cls, Eolian_Class const& klass)
276 , last; first != last; ++first) 290 , last; first != last; ++first)
277 { 291 {
278 Eolian_Function const& func = *first; 292 Eolian_Function const& func = *first;
279 Eolian_Function_Type const func_type = function_op_type(func);
280
281 if (!function_is_visible(func, func_type))
282 continue;
283 293
284 if (function_is_constructor(klass, func)) 294 if (function_is_visible(func, function_op_type(func)) &&
295 !function_is_constructor(klass, func))
285 { 296 {
286 cls.constructors.push_back({ 297 cls.functions.push_back(_convert_function(klass, func));
287 function_impl(func),
288 _convert_eolian_parameters(func),
289 convert_comments_function(klass, func)
290 });
291 }
292 else
293 {
294 cls.functions.push_back({
295 function_type(func),
296 function_scope(func),
297 function_name(func),
298 function_impl(func),
299 function_return_type(func),
300 _convert_eolian_parameters(func),
301 convert_comments_function(klass, func, eolian_cxx::method)
302 });
303 } 298 }
304 } 299 }
300 if (class_eo_name(klass) != "EO_BASE_CLASS")
301 for(efl::eina::iterator<const Eolian_Constructor> first ( ::eolian_class_constructors_get(&klass))
302 , last; first != last; ++first)
303 {
304 Eolian_Constructor const& ctor = *first;
305 Eolian_Function const& func = *(::eolian_constructor_function_get(&ctor));
306
307 efl::eolian::eo_function f;
308 if (::eolian_function_type_get(&func) != EOLIAN_PROPERTY)
309 f = _convert_function(klass, func);
310 else
311 f = _convert_property_set_to_function(klass, func);
312
313
314 (::eolian_constructor_is_optional(&ctor) ?
315 cls.optional_constructors :
316 cls.constructors
317 ).push_back({
318 function_name(func),
319 f.impl,
320 f.params,
321 f.comment
322 });
323 }
324
325 cls.all_constructors = cls.constructors;
326 cls.all_constructors.insert(cls.all_constructors.end(),
327 cls.optional_constructors.begin(), cls.optional_constructors.end());
328
305 for(efl::eina::iterator<const Eolian_Function> first ( ::eolian_class_functions_get(&klass, EOLIAN_PROPERTY)) 329 for(efl::eina::iterator<const Eolian_Function> first ( ::eolian_class_functions_get(&klass, EOLIAN_PROPERTY))
306 , last; first != last; ++first) 330 , last; first != last; ++first)
307 { 331 {
diff --git a/src/bin/eolian_cxx/eolian_wrappers.hh b/src/bin/eolian_cxx/eolian_wrappers.hh
index 5cad7976c0..5b6579ed34 100644
--- a/src/bin/eolian_cxx/eolian_wrappers.hh
+++ b/src/bin/eolian_cxx/eolian_wrappers.hh
@@ -375,10 +375,8 @@ parameter_type(Eolian_Function_Parameter const& parameter,
375 if (!type.front().binding.empty()) 375 if (!type.front().binding.empty())
376 type.front().binding.insert(0, "const "); 376 type.front().binding.insert(0, "const ");
377 } 377 }
378 if (::eolian_parameter_is_nonull(&parameter)) 378 type.is_optional = ::eolian_parameter_is_optional(&parameter) ||
379 { 379 ::eolian_parameter_is_nullable(&parameter);
380 type.is_nonull = true;
381 }
382 return type; 380 return type;
383} 381}
384 382