summaryrefslogtreecommitdiff
path: root/src/bin/eolian_cxx
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2014-11-11 20:37:47 -0200
committerVitor Sousa <vitorsousasilva@gmail.com>2015-01-05 15:52:27 -0200
commit132abc353454a2653b5b2b40d6de5f1689323a37 (patch)
tree2184e0c8361e0da179cf72c1071d2e6be4af9af7 /src/bin/eolian_cxx
parented8ce801cb56644c12b395797c3f9e22a508811f (diff)
eolian_cxx: Fix Eolian C++ generated wrapper inconsistencies
In convert.cc: Reading functions instead of implements to convert the Eolian_Class. It avoids creation of methods that do not belong to the class, in special it avoids calling the default constructor twice in the generated code. No longer generating one constructor in the C++ wrapper for each eolian class constructor, since the correct behavior demands that all constructor should be called. Now the wrappers have "constructor methods" that must be called when creating a new object. Updated test cases and examples to match the new interface. Some class constructors and some test cases have to be removed since they were based on the wrong assumption that constructors are mutually exclusive. Created new generators for forwarding parameters and for looping over the relevant parameters to the C++ wrapper executing a generic lambda. Added a TODO comment regarding the call of constructor methods of all base classes. Currently there is no base type with constructors, so this situation should be discussed more. Added a TODO comment regarding the way callback parameters are being processed.
Diffstat (limited to 'src/bin/eolian_cxx')
-rw-r--r--src/bin/eolian_cxx/convert.cc72
1 files changed, 39 insertions, 33 deletions
diff --git a/src/bin/eolian_cxx/convert.cc b/src/bin/eolian_cxx/convert.cc
index 4e68b87f1c..acb2c78a1e 100644
--- a/src/bin/eolian_cxx/convert.cc
+++ b/src/bin/eolian_cxx/convert.cc
@@ -205,45 +205,23 @@ convert_eolian_class_new(Eolian_Class const& klass)
205} 205}
206 206
207void 207void
208convert_eolian_implements(efl::eolian::eo_class& cls, Eolian_Class const& klass) 208convert_eolian_functions(efl::eolian::eo_class& cls, Eolian_Class const& klass)
209{ 209{
210 efl::eina::iterator<const Eolian_Implement> itr = implements_get(klass); 210 for(efl::eina::iterator<const Eolian_Function> first ( ::eolian_class_functions_get(&klass, EOLIAN_METHOD))
211 efl::eina::iterator<const Eolian_Implement> end; 211 , last; first != last; ++first)
212
213 while (itr != end)
214 { 212 {
215 const Eolian_Implement impl = *itr; 213 Eolian_Function const& func = *first;
216 assert(!!implement_function(impl)); 214 Eolian_Function_Type const func_type = function_op_type(func);
217 assert(!!implement_class(impl));
218 Eolian_Function const& func = *implement_function(impl);
219 Eolian_Class const& icls = *implement_class(impl);
220 215
221 if (implement_is_property_get(impl)) 216 if (function_is_constructor(klass, func))
222 {
223 cls.functions.push_back
224 (_convert_property_get_to_function(icls, func));
225 }
226 else if (implement_is_property_set(impl))
227 {
228 cls.functions.push_back
229 (_convert_property_set_to_function(icls, func));
230 }
231 else if (function_op_type(func) == eolian_cxx::property.value)
232 {
233 cls.functions.push_back
234 (_convert_property_get_to_function(icls, func));
235 cls.functions.push_back
236 (_convert_property_set_to_function(icls, func));
237 }
238 else if (function_is_constructor(klass, func))
239 { 217 {
240 cls.constructors.push_back({ 218 cls.constructors.push_back({
241 function_impl(func), 219 function_impl(func),
242 _convert_eolian_parameters(func), 220 _convert_eolian_parameters(func),
243 convert_comments_function(icls, func) 221 convert_comments_function(klass, func)
244 }); 222 });
245 } 223 }
246 else if (implement_is_visible(impl)) 224 else if (function_is_visible(func, func_type))
247 { 225 {
248 cls.functions.push_back({ 226 cls.functions.push_back({
249 function_type(func), 227 function_type(func),
@@ -251,10 +229,38 @@ convert_eolian_implements(efl::eolian::eo_class& cls, Eolian_Class const& klass)
251 function_impl(func), 229 function_impl(func),
252 function_return_type(func), 230 function_return_type(func),
253 _convert_eolian_parameters(func), 231 _convert_eolian_parameters(func),
254 convert_comments_function(icls, func, eolian_cxx::method) 232 convert_comments_function(klass, func, eolian_cxx::method)
255 }); 233 });
256 } 234 }
257 ++itr; 235 }
236 for(efl::eina::iterator<const Eolian_Function> first ( ::eolian_class_functions_get(&klass, EOLIAN_PROPERTY))
237 , last; first != last; ++first)
238 {
239 Eolian_Function const& func = *first;
240 Eolian_Function_Type t = ::eolian_function_type_get(&func);
241
242 if(t == EOLIAN_PROP_GET)
243 {
244 cls.functions.push_back
245 (_convert_property_get_to_function(klass, func));
246 }
247 else if(t == EOLIAN_PROP_SET)
248 {
249 cls.functions.push_back
250 (_convert_property_set_to_function(klass, func));
251 }
252 else if(t == EOLIAN_PROPERTY)
253 {
254 cls.functions.push_back
255 (_convert_property_get_to_function(klass, func));
256 cls.functions.push_back
257 (_convert_property_set_to_function(klass, func));
258 }
259 else
260 {
261 std::cerr << "Error: Inconsistent type for Eolian function \'" << ::eolian_function_name_get(&func) << "\'." << std::endl;
262 throw std::runtime_error("Invalid Eolian function type");
263 }
258 } 264 }
259} 265}
260 266
@@ -263,7 +269,7 @@ convert_eolian_class(const Eolian_Class& klass)
263{ 269{
264 efl::eolian::eo_class cls(eolian_cxx::convert_eolian_class_new(klass)); 270 efl::eolian::eo_class cls(eolian_cxx::convert_eolian_class_new(klass));
265 eolian_cxx::convert_eolian_inheritances(cls, klass); 271 eolian_cxx::convert_eolian_inheritances(cls, klass);
266 eolian_cxx::convert_eolian_implements(cls, klass); 272 eolian_cxx::convert_eolian_functions(cls, klass);
267 eolian_cxx::convert_eolian_events(cls, klass); 273 eolian_cxx::convert_eolian_events(cls, klass);
268 efl::eolian::eo_class_validate(cls); 274 efl::eolian::eo_class_validate(cls);
269 return cls; 275 return cls;