summaryrefslogtreecommitdiff
path: root/src/bin/eolian_cxx
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2014-05-22 17:24:50 +0300
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-05-26 13:56:06 +0300
commit62082548bc2210e8ebe1cf59127634e00b5ad30f (patch)
tree1698cf9a65395407987d62fbb6fce3c295c51f85 /src/bin/eolian_cxx
parent1401ce36b6d8a40270641a5094dbf098ed6858c1 (diff)
Eolian: modify API to allow future scalability
Until now, the functions giving access to class information were taking the class name as parameter. Except the fact that we needed to search into a hash table for the internal class structure, no flexibility is possible. This change consists in modifying most of the APIs using the class name with a new Eolian_Class type and adapt the code of the C and C++ generators accordingly.
Diffstat (limited to 'src/bin/eolian_cxx')
-rw-r--r--src/bin/eolian_cxx/comments.cc4
-rw-r--r--src/bin/eolian_cxx/comments.hh2
-rw-r--r--src/bin/eolian_cxx/convert.cc64
-rw-r--r--src/bin/eolian_cxx/eolian_cxx.cc11
4 files changed, 42 insertions, 39 deletions
diff --git a/src/bin/eolian_cxx/comments.cc b/src/bin/eolian_cxx/comments.cc
index afe725f300..d82f2b424c 100644
--- a/src/bin/eolian_cxx/comments.cc
+++ b/src/bin/eolian_cxx/comments.cc
@@ -73,9 +73,9 @@ _comment_return(Eolian_Function function,
73namespace detail { 73namespace detail {
74 74
75std::string 75std::string
76eolian_class_comment(const char *classname) 76eolian_class_comment(const Eolian_Class kls)
77{ 77{
78 return safe_str(eolian_class_description_get(classname)); 78 return safe_str(eolian_class_description_get(kls));
79} 79}
80 80
81std::string 81std::string
diff --git a/src/bin/eolian_cxx/comments.hh b/src/bin/eolian_cxx/comments.hh
index 3aaf7562ce..c8378bc689 100644
--- a/src/bin/eolian_cxx/comments.hh
+++ b/src/bin/eolian_cxx/comments.hh
@@ -14,7 +14,7 @@ extern "C"
14 14
15namespace detail { 15namespace detail {
16 16
17std::string eolian_class_comment(const char *classname); 17std::string eolian_class_comment(const Eolian_Class kls);
18 18
19std::string eolian_constructor_comment(Eolian_Function constructor); 19std::string eolian_constructor_comment(Eolian_Function constructor);
20 20
diff --git a/src/bin/eolian_cxx/convert.cc b/src/bin/eolian_cxx/convert.cc
index 8827899014..4a4215c763 100644
--- a/src/bin/eolian_cxx/convert.cc
+++ b/src/bin/eolian_cxx/convert.cc
@@ -55,20 +55,20 @@ _get_params(const Eina_List *eolian_params, bool is_get = false)
55} 55}
56 56
57static efl::eolian::functions_container_type 57static efl::eolian::functions_container_type
58_get_properties(const char *classname) 58_get_properties(const Eolian_Class klass)
59{ 59{
60 efl::eolian::functions_container_type container; 60 efl::eolian::functions_container_type container;
61 61
62 std::string cxx_classname = classname; 62 std::string cxx_classname = eolian_class_name_get(klass);
63 std::transform(cxx_classname.begin(), cxx_classname.end(), 63 std::transform(cxx_classname.begin(), cxx_classname.end(),
64 cxx_classname.begin(), ::tolower); 64 cxx_classname.begin(), ::tolower);
65 65
66 const Eina_List *properties; 66 const Eina_List *properties;
67 properties = eolian_class_functions_list_get(classname, EOLIAN_PROPERTY); 67 properties = eolian_class_functions_list_get(klass, EOLIAN_PROPERTY);
68 68
69 const Eina_List *it; 69 const Eina_List *it;
70 void *curr; 70 void *curr;
71 std::string prefix(safe_str(eolian_class_eo_prefix_get(classname))); 71 std::string prefix(safe_str(eolian_class_eo_prefix_get(klass)));
72 EINA_LIST_FOREACH (properties, it, curr) 72 EINA_LIST_FOREACH (properties, it, curr)
73 { 73 {
74 Eolian_Function property = static_cast<Eolian_Function>(curr); 74 Eolian_Function property = static_cast<Eolian_Function>(curr);
@@ -142,9 +142,9 @@ _get_properties(const char *classname)
142namespace detail { 142namespace detail {
143 143
144void 144void
145convert_eolian_inheritances(efl::eolian::eo_class& cls, const char *classname) 145convert_eolian_inheritances(efl::eolian::eo_class& cls, const Eolian_Class klass)
146{ 146{
147 const Eina_List *inheritances = eolian_class_inherits_list_get(classname); 147 const Eina_List *inheritances = eolian_class_inherits_list_get(klass);
148 const Eina_List *it; 148 const Eina_List *it;
149 void *curr; 149 void *curr;
150 150
@@ -174,25 +174,26 @@ convert_eolian_inheritances(efl::eolian::eo_class& cls, const char *classname)
174} 174}
175 175
176void 176void
177convert_eolian_implements(efl::eolian::eo_class& cls, const char *classname) 177convert_eolian_implements(efl::eolian::eo_class& cls, const Eolian_Class klass)
178{ 178{
179 const Eina_List *it; 179 const Eina_List *it;
180 std::string prefix(safe_str(eolian_class_eo_prefix_get(classname))); 180 std::string prefix(safe_str(eolian_class_eo_prefix_get(klass)));
181 void *impl_desc_; 181 void *impl_desc_;
182 EINA_LIST_FOREACH(eolian_class_implements_list_get(classname), it, impl_desc_) 182 EINA_LIST_FOREACH(eolian_class_implements_list_get(klass), it, impl_desc_)
183 { 183 {
184 Eolian_Implement impl_desc = static_cast<Eolian_Implement>(impl_desc_); 184 Eolian_Implement impl_desc = static_cast<Eolian_Implement>(impl_desc_);
185 const char *impl_class; 185 const char *impl_classname;
186 const char *func_name; 186 const char *func_name;
187 Eolian_Function_Type func_type; 187 Eolian_Function_Type func_type;
188 eolian_implement_information_get 188 eolian_implement_information_get
189 (impl_desc, &impl_class, &func_name, &func_type); 189 (impl_desc, &impl_classname, &func_name, &func_type);
190 if (func_type == EOLIAN_CTOR) 190 if (func_type == EOLIAN_CTOR)
191 { 191 {
192 efl::eolian::eo_constructor constructor; 192 efl::eolian::eo_constructor constructor;
193 Eolian_Class impl_class = eolian_class_find_by_name(impl_classname);
193 Eolian_Function eolian_constructor = 194 Eolian_Function eolian_constructor =
194 eolian_class_function_find_by_name(impl_class, func_name, func_type); 195 eolian_class_function_find_by_name(impl_class, func_name, func_type);
195 std::string parent = safe_str(impl_class); 196 std::string parent = safe_str(impl_classname);
196 if(parent == "Eo_Base") parent = "eo"; 197 if(parent == "Eo_Base") parent = "eo";
197 else std::transform(parent.begin(), parent.end(), parent.begin(), ::tolower); 198 else std::transform(parent.begin(), parent.end(), parent.begin(), ::tolower);
198 constructor.name = parent + "_" + safe_str(func_name); 199 constructor.name = parent + "_" + safe_str(func_name);
@@ -206,13 +207,13 @@ convert_eolian_implements(efl::eolian::eo_class& cls, const char *classname)
206} 207}
207 208
208void 209void
209convert_eolian_constructors(efl::eolian::eo_class& cls, const char *classname) 210convert_eolian_constructors(efl::eolian::eo_class& cls, const Eolian_Class klass)
210{ 211{
211 const Eina_List *it; 212 const Eina_List *it;
212 void *curr; 213 void *curr;
213 std::string prefix(safe_str(eolian_class_eo_prefix_get(classname))); 214 std::string prefix(safe_str(eolian_class_eo_prefix_get(klass)));
214 const Eina_List *constructors = 215 const Eina_List *constructors =
215 eolian_class_functions_list_get(classname, EOLIAN_CTOR); 216 eolian_class_functions_list_get(klass, EOLIAN_CTOR);
216 EINA_LIST_FOREACH (constructors, it, curr) 217 EINA_LIST_FOREACH (constructors, it, curr)
217 { 218 {
218 Eolian_Function eolian_constructor = static_cast<Eolian_Function>(curr); 219 Eolian_Function eolian_constructor = static_cast<Eolian_Function>(curr);
@@ -228,18 +229,18 @@ convert_eolian_constructors(efl::eolian::eo_class& cls, const char *classname)
228} 229}
229 230
230void 231void
231convert_eolian_functions(efl::eolian::eo_class& cls, const char *classname) 232convert_eolian_functions(efl::eolian::eo_class& cls, const Eolian_Class klass)
232{ 233{
233 const Eina_List *it; 234 const Eina_List *it;
234 void *curr; 235 void *curr;
235 236
236 const Eina_List *eolian_functions = 237 const Eina_List *eolian_functions =
237 eolian_class_functions_list_get(classname, EOLIAN_METHOD); 238 eolian_class_functions_list_get(klass, EOLIAN_METHOD);
238 EINA_LIST_FOREACH (eolian_functions, it, curr) 239 EINA_LIST_FOREACH (eolian_functions, it, curr)
239 { 240 {
240 efl::eolian::eo_function function; 241 efl::eolian::eo_function function;
241 Eolian_Function eolian_function = static_cast<Eolian_Function>(curr); 242 Eolian_Function eolian_function = static_cast<Eolian_Function>(curr);
242 std::string prefix(safe_str(eolian_class_eo_prefix_get(classname))); 243 std::string prefix(safe_str(eolian_class_eo_prefix_get(klass)));
243 // XXX Eolian only provides regular methods so far 244 // XXX Eolian only provides regular methods so far
244 function.type = efl::eolian::eo_function::regular_; 245 function.type = efl::eolian::eo_function::regular_;
245 function.name = safe_str(eolian_function_name_get(eolian_function)); 246 function.name = safe_str(eolian_function_name_get(eolian_function));
@@ -254,29 +255,29 @@ convert_eolian_functions(efl::eolian::eo_class& cls, const char *classname)
254} 255}
255 256
256void 257void
257convert_eolian_properties(efl::eolian::eo_class& cls, const char *classname) 258convert_eolian_properties(efl::eolian::eo_class& cls, const Eolian_Class klass)
258{ 259{
259 efl::eolian::functions_container_type properties = _get_properties(classname); 260 efl::eolian::functions_container_type properties = _get_properties(klass);
260 cls.functions.insert(cls.functions.end(), properties.begin(), properties.end()); 261 cls.functions.insert(cls.functions.end(), properties.begin(), properties.end());
261} 262}
262 263
263} // namespace detail { 264} // namespace detail {
264 265
265efl::eolian::eo_class 266efl::eolian::eo_class
266_cxx_new(const char *classname) 267_cxx_new(const Eolian_Class klass)
267{ 268{
268 using namespace efl::eolian; 269 using namespace efl::eolian;
269 eo_class cls; 270 eo_class cls;
270 Eolian_Class_Type cls_type = ::eolian_class_type_get(classname); 271 Eolian_Class_Type cls_type = ::eolian_class_type_get(klass);
271 if (cls_type == EOLIAN_CLASS_REGULAR) cls.type = eo_class::regular_; 272 if (cls_type == EOLIAN_CLASS_REGULAR) cls.type = eo_class::regular_;
272 else if (cls_type == EOLIAN_CLASS_ABSTRACT) cls.type = eo_class::regular_noninst_; 273 else if (cls_type == EOLIAN_CLASS_ABSTRACT) cls.type = eo_class::regular_noninst_;
273 else if (cls_type == EOLIAN_CLASS_MIXIN) cls.type = eo_class::mixin_; 274 else if (cls_type == EOLIAN_CLASS_MIXIN) cls.type = eo_class::mixin_;
274 else if (cls_type == EOLIAN_CLASS_INTERFACE) cls.type = eo_class::interface_; 275 else if (cls_type == EOLIAN_CLASS_INTERFACE) cls.type = eo_class::interface_;
275 else { assert(false); } 276 else { assert(false); }
276 std::string prefix(safe_str(eolian_class_eo_prefix_get(classname))); 277 std::string prefix(safe_str(eolian_class_eo_prefix_get(klass)));
277 cls.name = classname; 278 cls.name = eolian_class_name_get(klass);
278 cls.eo_name = (prefix != "" ? prefix : cls.name) + "_CLASS"; 279 cls.eo_name = (prefix != "" ? prefix : cls.name) + "_CLASS";
279 cls.comment = detail::eolian_class_comment(classname); 280 cls.comment = detail::eolian_class_comment(klass);
280 std::transform(cls.name.begin(), cls.name.end(), cls.name.begin(), ::tolower); 281 std::transform(cls.name.begin(), cls.name.end(), cls.name.begin(), ::tolower);
281 std::transform(cls.eo_name.begin(), cls.eo_name.end(), cls.eo_name.begin(), ::toupper); 282 std::transform(cls.eo_name.begin(), cls.eo_name.end(), cls.eo_name.begin(), ::toupper);
282 return cls; 283 return cls;
@@ -285,11 +286,12 @@ _cxx_new(const char *classname)
285efl::eolian::eo_class 286efl::eolian::eo_class
286c_to_cxx(const char *classname) 287c_to_cxx(const char *classname)
287{ 288{
288 efl::eolian::eo_class cls(_cxx_new(classname)); 289 Eolian_Class klass = eolian_class_find_by_name(classname);
289 detail::convert_eolian_inheritances(cls, classname); 290 efl::eolian::eo_class cls(_cxx_new(klass));
290 detail::convert_eolian_implements(cls, classname); 291 detail::convert_eolian_inheritances(cls, klass);
291 detail::convert_eolian_constructors(cls, classname); 292 detail::convert_eolian_implements(cls, klass);
292 detail::convert_eolian_functions(cls, classname); 293 detail::convert_eolian_constructors(cls, klass);
293 detail::convert_eolian_properties(cls, classname); 294 detail::convert_eolian_functions(cls, klass);
295 detail::convert_eolian_properties(cls, klass);
294 return cls; 296 return cls;
295} 297}
diff --git a/src/bin/eolian_cxx/eolian_cxx.cc b/src/bin/eolian_cxx/eolian_cxx.cc
index d3e194d15c..e58ea6399d 100644
--- a/src/bin/eolian_cxx/eolian_cxx.cc
+++ b/src/bin/eolian_cxx/eolian_cxx.cc
@@ -84,9 +84,9 @@ _guess_classname_from_sources(::options_type& opts)
84{ 84{
85 for (auto filename : opts.in_srcs) 85 for (auto filename : opts.in_srcs)
86 { 86 {
87 if (const char *cls = eolian_class_find_by_file(filename.c_str())) 87 if (Eolian_Class klass = eolian_class_find_by_file(filename.c_str()))
88 { 88 {
89 return cls; 89 return eolian_class_name_get(klass);
90 } 90 }
91 } 91 }
92 return ""; 92 return "";
@@ -119,16 +119,17 @@ _resolve_includes(std::string const& classname)
119 efl::eolian::eo_generator_options gen_opts; 119 efl::eolian::eo_generator_options gen_opts;
120 120
121 std::string cls_name = classname; 121 std::string cls_name = classname;
122 Eolian_Class klass = eolian_class_find_by_name(classname.c_str());
122 std::transform(cls_name.begin(), cls_name.end(), cls_name.begin(), ::tolower); 123 std::transform(cls_name.begin(), cls_name.end(), cls_name.begin(), ::tolower);
123 124
124 std::string eo_file = safe_str(eolian_class_file_get(classname.c_str())); 125 std::string eo_file = safe_str(eolian_class_file_get(klass));
125 gen_opts.c_headers.push_back(get_filename_info(eo_file).first + ".h"); 126 gen_opts.c_headers.push_back(get_filename_info(eo_file).first + ".h");
126 127
127 void *cur = NULL; 128 void *cur = NULL;
128 const Eina_List *itr, *inheritances = eolian_class_inherits_list_get(classname.c_str()); 129 const Eina_List *itr, *inheritances = eolian_class_inherits_list_get(klass);
129 EINA_LIST_FOREACH(inheritances, itr, cur) 130 EINA_LIST_FOREACH(inheritances, itr, cur)
130 { 131 {
131 const char *ext = static_cast<const char*>(cur); 132 Eolian_Class ext = eolian_class_find_by_name(static_cast<const char*>(cur));
132 std::string eo_parent_file = safe_str(eolian_class_file_get(ext)); 133 std::string eo_parent_file = safe_str(eolian_class_file_get(ext));
133 if (!eo_parent_file.empty()) 134 if (!eo_parent_file.empty())
134 { 135 {