summaryrefslogtreecommitdiff
path: root/src/bin/eolian_cxx
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2014-07-23 10:24:59 +0300
committerDaniel Kolesa <d.kolesa@samsung.com>2014-07-23 13:45:25 +0100
commit0efeeaf1c0dbfdb921eee7f50c15c73da0e16f22 (patch)
treee5e1edaf1458dfb823444163181416bbfcac26a6 /src/bin/eolian_cxx
parent356d10fbeefd3f79f3cc848ed266d33e04ac7238 (diff)
Eolian: modify APIs to return iterators instead of lists.
The change affects the C and the C++ generators.
Diffstat (limited to 'src/bin/eolian_cxx')
-rw-r--r--src/bin/eolian_cxx/convert.cc67
-rw-r--r--src/bin/eolian_cxx/convert_comments.cc6
-rw-r--r--src/bin/eolian_cxx/eolian_cxx.cc5
-rw-r--r--src/bin/eolian_cxx/eolian_wrappers.hh16
4 files changed, 50 insertions, 44 deletions
diff --git a/src/bin/eolian_cxx/convert.cc b/src/bin/eolian_cxx/convert.cc
index 5597725cd3..0da515c347 100644
--- a/src/bin/eolian_cxx/convert.cc
+++ b/src/bin/eolian_cxx/convert.cc
@@ -23,16 +23,15 @@ namespace eolian_cxx {
23extern efl::eina::log_domain domain; 23extern efl::eina::log_domain domain;
24 24
25static efl::eolian::parameters_container_type 25static efl::eolian::parameters_container_type
26convert_eolian_parameters(Eina_List const* parameters, 26convert_eolian_parameters(Eina_Iterator *parameters,
27 Eolian_Function_Type func_type) 27 Eolian_Function_Type func_type)
28{ 28{
29 if (parameters == NULL) return {}; 29 if (parameters == NULL) return {};
30 assert(func_type != EOLIAN_PROPERTY); 30 assert(func_type != EOLIAN_PROPERTY);
31 31
32 const Eina_List *it;
33 void *curr; 32 void *curr;
34 efl::eolian::parameters_container_type list; 33 efl::eolian::parameters_container_type list;
35 EINA_LIST_FOREACH (parameters, it, curr) 34 EINA_ITERATOR_FOREACH(parameters, curr)
36 { 35 {
37 const Eolian_Function_Parameter *id = 36 const Eolian_Function_Parameter *id =
38 (static_cast<const Eolian_Function_Parameter*>(curr)); 37 (static_cast<const Eolian_Function_Parameter*>(curr));
@@ -42,6 +41,7 @@ convert_eolian_parameters(Eina_List const* parameters,
42 parameter_name(*id) 41 parameter_name(*id)
43 }); 42 });
44 } 43 }
44 eina_iterator_free(parameters);
45 return list; 45 return list;
46} 46}
47 47
@@ -53,13 +53,13 @@ convert_eolian_parameters(Eolian_Function const& func, getter_t func_type)
53} 53}
54 54
55static efl::eolian::parameters_container_type 55static efl::eolian::parameters_container_type
56convert_eolian_parameters(Eina_List const* parameters, getter_t func_type) 56convert_eolian_parameters(Eina_Iterator *parameters, getter_t func_type)
57{ 57{
58 return convert_eolian_parameters(parameters, func_type.value); 58 return convert_eolian_parameters(parameters, func_type.value);
59} 59}
60 60
61static efl::eolian::parameters_container_type 61static efl::eolian::parameters_container_type
62convert_eolian_parameters(Eina_List const* parameters, setter_t func_type) 62convert_eolian_parameters(Eina_Iterator *parameters, setter_t func_type)
63{ 63{
64 return convert_eolian_parameters(parameters, func_type.value); 64 return convert_eolian_parameters(parameters, func_type.value);
65} 65}
@@ -77,12 +77,11 @@ convert_eolian_property_to_functions(Eolian_Class const& klass)
77{ 77{
78 efl::eolian::functions_container_type container; 78 efl::eolian::functions_container_type container;
79 std::string cxx_classname = safe_lower(class_name(klass)); 79 std::string cxx_classname = safe_lower(class_name(klass));
80 const Eina_List *properties = 80 Eina_Iterator *properties =
81 ::eolian_class_functions_list_get(&klass, EOLIAN_PROPERTY); // XXX 81 ::eolian_class_functions_list_get(&klass, EOLIAN_PROPERTY); // XXX
82 const Eina_List *it;
83 void *curr; 82 void *curr;
84 std::string prefix(class_prefix(klass)); 83 std::string prefix(class_prefix(klass));
85 EINA_LIST_FOREACH (properties, it, curr) 84 EINA_ITERATOR_FOREACH(properties, curr)
86 { 85 {
87 Eolian_Function *prop_ = static_cast<Eolian_Function*>(curr); 86 Eolian_Function *prop_ = static_cast<Eolian_Function*>(curr);
88 if (property_is_getter(*prop_)) 87 if (property_is_getter(*prop_))
@@ -137,22 +136,30 @@ convert_eolian_property_to_functions(Eolian_Class const& klass)
137 } 136 }
138 if (property_is_setter(*prop_)) 137 if (property_is_setter(*prop_))
139 { 138 {
140 const Eina_List *keys_ = eolian_property_keys_list_get(prop_);
141 const Eina_List *args_ = eolian_parameters_list_get(prop_);
142 Eina_List *params_ = eina_list_merge(eina_list_clone(keys_), eina_list_clone(args_));
143 efl::eolian::parameters_container_type params =
144 convert_eolian_parameters(params_, eolian_cxx::setter);
145 eina_list_free(params_);
146 efl::eolian::eo_function set_; 139 efl::eolian::eo_function set_;
147 set_.type = efl::eolian::eo_function::regular_; 140 set_.type = efl::eolian::eo_function::regular_;
148 set_.name = function_name(*prop_) + "_set"; 141 set_.name = function_name(*prop_) + "_set";
149 set_.impl = function_impl(*prop_, prefix) + "_set"; 142 set_.impl = function_impl(*prop_, prefix) + "_set";
143 efl::eolian::parameters_container_type keys =
144 convert_eolian_parameters(::eolian_property_keys_list_get(prop_),
145 eolian_cxx::setter);
146 efl::eolian::parameters_container_type params =
147 convert_eolian_parameters(::eolian_parameters_list_get(prop_),
148 eolian_cxx::setter);
150 set_.params = params; 149 set_.params = params;
150 if (!keys.empty())
151 {
152 keys.reserve(keys.size() + set_.params.size());
153 keys.insert(keys.end(), set_.params.begin(),
154 set_.params.end());
155 set_.params = keys;
156 }
151 set_.ret = function_return_type(*prop_, eolian_cxx::setter); 157 set_.ret = function_return_type(*prop_, eolian_cxx::setter);
152 set_.comment = convert_comments_function(*prop_, eolian_cxx::setter); 158 set_.comment = convert_comments_function(*prop_, eolian_cxx::setter);
153 container.push_back(set_); 159 container.push_back(set_);
154 } 160 }
155 } 161 }
162 eina_iterator_free(properties);
156 return container; 163 return container;
157} 164}
158 165
@@ -167,42 +174,39 @@ std::string get_class_name(std::string const& name)
167void 174void
168convert_eolian_inheritances(efl::eolian::eo_class& cls, Eolian_Class const& klass) 175convert_eolian_inheritances(efl::eolian::eo_class& cls, Eolian_Class const& klass)
169{ 176{
170 const Eina_List *inheritances = 177 Eina_Iterator *inheritances =
171 ::eolian_class_inherits_list_get(&klass); 178 ::eolian_class_inherits_list_get(&klass);
172 const Eina_List *it;
173 void *curr; 179 void *curr;
174 180
175 if (eina_list_count(inheritances) == 0 181 if (!eina_iterator_next(inheritances, &curr) || !curr)
176 || eina_list_data_get(inheritances) == NULL)
177 { 182 {
178 cls.parent = "efl::eo::base"; 183 cls.parent = "efl::eo::base";
184 eina_iterator_free(inheritances);
179 return; 185 return;
180 } 186 }
181 else 187 else
182 { 188 {
183 // First element is the parent 189 // First element is the parent
184 const char *ptr = static_cast<const char*> 190 const char *ptr = static_cast<const char*>(curr);
185 (eina_list_data_get(inheritances));
186 cls.parent = get_class_name(class_format_cxx(safe_lower(ptr))); 191 cls.parent = get_class_name(class_format_cxx(safe_lower(ptr)));
187 192
188 inheritances = eina_list_next(inheritances); 193 EINA_ITERATOR_FOREACH(inheritances, curr)
189
190 EINA_LIST_FOREACH (inheritances, it, curr)
191 { 194 {
192 std::string extension = safe_lower(static_cast<const char*>(curr)); 195 std::string extension = safe_lower(static_cast<const char*>(curr));
193 cls.extensions.push_back(get_class_name(class_format_cxx(extension))); 196 cls.extensions.push_back(get_class_name(class_format_cxx(extension)));
194 } 197 }
195 } 198 }
199 eina_iterator_free(inheritances);
196} 200}
197 201
198void 202void
199convert_eolian_implements(efl::eolian::eo_class& cls, Eolian_Class const& klass) 203convert_eolian_implements(efl::eolian::eo_class& cls, Eolian_Class const& klass)
200{ 204{
201 const Eina_List *it;
202 std::string prefix(class_prefix(klass)); 205 std::string prefix(class_prefix(klass));
206 Eina_Iterator *itr = ::eolian_class_implements_list_get(&klass);
203 void *impl_desc_; 207 void *impl_desc_;
204 208
205 EINA_LIST_FOREACH(::eolian_class_implements_list_get(&klass), it, impl_desc_) 209 EINA_ITERATOR_FOREACH(itr, impl_desc_)
206 { 210 {
207 const Eolian_Implement *impl_desc = static_cast<Eolian_Implement*>(impl_desc_); 211 const Eolian_Implement *impl_desc = static_cast<Eolian_Implement*>(impl_desc_);
208 const Eolian_Class *impl_class; 212 const Eolian_Class *impl_class;
@@ -221,17 +225,17 @@ convert_eolian_implements(efl::eolian::eo_class& cls, Eolian_Class const& klass)
221 cls.constructors.push_back(constructor); 225 cls.constructors.push_back(constructor);
222 } 226 }
223 } 227 }
228 eina_iterator_free(itr);
224} 229}
225 230
226void 231void
227convert_eolian_constructors(efl::eolian::eo_class& cls, Eolian_Class const& klass) 232convert_eolian_constructors(efl::eolian::eo_class& cls, Eolian_Class const& klass)
228{ 233{
229 const Eina_List *it;
230 void *curr; 234 void *curr;
231 std::string prefix(class_prefix(klass)); 235 std::string prefix(class_prefix(klass));
232 const Eina_List *constructors = 236 Eina_Iterator *constructors =
233 ::eolian_class_functions_list_get(&klass, EOLIAN_CTOR); 237 ::eolian_class_functions_list_get(&klass, EOLIAN_CTOR);
234 EINA_LIST_FOREACH (constructors, it, curr) 238 EINA_ITERATOR_FOREACH(constructors, curr)
235 { 239 {
236 Eolian_Function *eo_constructor = static_cast<Eolian_Function*>(curr); 240 Eolian_Function *eo_constructor = static_cast<Eolian_Function*>(curr);
237 efl::eolian::eo_constructor constructor; 241 efl::eolian::eo_constructor constructor;
@@ -240,17 +244,17 @@ convert_eolian_constructors(efl::eolian::eo_class& cls, Eolian_Class const& klas
240 constructor.comment = convert_comments_function(*eo_constructor, eolian_cxx::ctor); 244 constructor.comment = convert_comments_function(*eo_constructor, eolian_cxx::ctor);
241 cls.constructors.push_back(constructor); 245 cls.constructors.push_back(constructor);
242 } 246 }
247 eina_iterator_free(constructors);
243} 248}
244 249
245void 250void
246convert_eolian_functions(efl::eolian::eo_class& cls, Eolian_Class const& klass) 251convert_eolian_functions(efl::eolian::eo_class& cls, Eolian_Class const& klass)
247{ 252{
248 const Eina_List *it;
249 void *curr; 253 void *curr;
250 254
251 const Eina_List *eolian_functions = 255 Eina_Iterator *eolian_functions =
252 ::eolian_class_functions_list_get(&klass, EOLIAN_METHOD); 256 ::eolian_class_functions_list_get(&klass, EOLIAN_METHOD);
253 EINA_LIST_FOREACH (eolian_functions, it, curr) 257 EINA_ITERATOR_FOREACH(eolian_functions, curr)
254 { 258 {
255 efl::eolian::eo_function func_; 259 efl::eolian::eo_function func_;
256 Eolian_Function *eol_func = static_cast<Eolian_Function*>(curr); 260 Eolian_Function *eol_func = static_cast<Eolian_Function*>(curr);
@@ -263,6 +267,7 @@ convert_eolian_functions(efl::eolian::eo_class& cls, Eolian_Class const& klass)
263 func_.comment = convert_comments_function(*eol_func, eolian_cxx::method); 267 func_.comment = convert_comments_function(*eol_func, eolian_cxx::method);
264 cls.functions.push_back(func_); 268 cls.functions.push_back(func_);
265 } 269 }
270 eina_iterator_free(eolian_functions);
266} 271}
267 272
268void 273void
diff --git a/src/bin/eolian_cxx/convert_comments.cc b/src/bin/eolian_cxx/convert_comments.cc
index 51ce698c0e..0242eefa8f 100644
--- a/src/bin/eolian_cxx/convert_comments.cc
+++ b/src/bin/eolian_cxx/convert_comments.cc
@@ -27,16 +27,16 @@ _comment_parameter(Eolian_Function_Parameter *param)
27} 27}
28 28
29static std::string 29static std::string
30_comment_parameters_list(const Eina_List *params) 30_comment_parameters_list(Eina_Iterator *params)
31{ 31{
32 std::string doc = ""; 32 std::string doc = "";
33 const Eina_List *it;
34 void *curr; 33 void *curr;
35 EINA_LIST_FOREACH (params, it, curr) 34 EINA_ITERATOR_FOREACH(params, curr)
36 { 35 {
37 doc += _comment_parameter 36 doc += _comment_parameter
38 (static_cast<Eolian_Function_Parameter*>(curr)) + "\n"; 37 (static_cast<Eolian_Function_Parameter*>(curr)) + "\n";
39 } 38 }
39 eina_iterator_free(params);
40 return doc; 40 return doc;
41} 41}
42 42
diff --git a/src/bin/eolian_cxx/eolian_cxx.cc b/src/bin/eolian_cxx/eolian_cxx.cc
index d68548ce89..e01948d0d0 100644
--- a/src/bin/eolian_cxx/eolian_cxx.cc
+++ b/src/bin/eolian_cxx/eolian_cxx.cc
@@ -94,8 +94,8 @@ generator_options(const Eolian_Class& klass)
94 gen_opts.c_headers.push_back(class_base_file(klass) + ".h"); 94 gen_opts.c_headers.push_back(class_base_file(klass) + ".h");
95 95
96 void *cur = NULL; 96 void *cur = NULL;
97 const Eina_List *itr, *inheritances = ::eolian_class_inherits_list_get(&klass); 97 Eina_Iterator *inheritances = ::eolian_class_inherits_list_get(&klass);
98 EINA_LIST_FOREACH(inheritances, itr, cur) 98 EINA_ITERATOR_FOREACH(inheritances, cur)
99 { 99 {
100 const Eolian_Class *ext = ::eolian_class_find_by_name(static_cast<const char*>(cur)); 100 const Eolian_Class *ext = ::eolian_class_find_by_name(static_cast<const char*>(cur));
101 std::string eo_parent_file = class_base_file(*ext); 101 std::string eo_parent_file = class_base_file(*ext);
@@ -117,6 +117,7 @@ generator_options(const Eolian_Class& klass)
117 << std::endl; 117 << std::endl;
118 } 118 }
119 } 119 }
120 eina_iterator_free(inheritances);
120 return gen_opts; 121 return gen_opts;
121} 122}
122 123
diff --git a/src/bin/eolian_cxx/eolian_wrappers.hh b/src/bin/eolian_cxx/eolian_wrappers.hh
index db1bdaabc6..132c7f750e 100644
--- a/src/bin/eolian_cxx/eolian_wrappers.hh
+++ b/src/bin/eolian_cxx/eolian_wrappers.hh
@@ -137,20 +137,20 @@ inline std::string
137class_namespace_full(Eolian_Class const& klass) 137class_namespace_full(Eolian_Class const& klass)
138{ 138{
139 std::string s; 139 std::string s;
140 const Eina_List* list = 140 Eina_Iterator* itr = ::eolian_class_namespaces_list_get(&klass);
141 ::eolian_class_namespaces_list_get(&klass), *itr;
142 void* name; 141 void* name;
143 EINA_LIST_FOREACH(list, itr, name) 142 EINA_ITERATOR_FOREACH(itr, name)
144 { 143 {
145 s += static_cast<const char*>(name); 144 s += static_cast<const char*>(name);
146 s += "::"; 145 s += "::";
147 } 146 }
147 eina_iterator_free(itr);
148 if (s.size() >= 2) 148 if (s.size() >= 2)
149 s = s.substr(0, s.size()-2); 149 s = s.substr(0, s.size()-2);
150 return safe_lower(s); 150 return safe_lower(s);
151} 151}
152 152
153inline efl::eina::range_ptr_list<const Eolian_Class> 153inline efl::eina::iterator<const Eolian_Class>
154class_list_all() 154class_list_all()
155{ 155{
156 return ::eolian_all_classes_list_get(); 156 return ::eolian_all_classes_list_get();
@@ -344,13 +344,13 @@ inline efl::eolian::events_container_type
344event_list(Eolian_Class const& klass) 344event_list(Eolian_Class const& klass)
345{ 345{
346 efl::eolian::events_container_type events; 346 efl::eolian::events_container_type events;
347 const Eina_List* list = ::eolian_class_events_list_get(&klass); 347 Eina_Iterator *itr = ::eolian_class_events_list_get(&klass);
348 unsigned int length = eina_list_count(list); 348 Eolian_Event *e;
349 for (unsigned int i = 0; i < length; ++i) 349 EINA_ITERATOR_FOREACH(itr, e)
350 { 350 {
351 Eolian_Event *e = static_cast<Eolian_Event*>(eina_list_nth(list, i));
352 events.push_back(event_create(klass, e)); 351 events.push_back(event_create(klass, e));
353 } 352 }
353 eina_iterator_free(itr);
354 return events; 354 return events;
355} 355}
356 356