summaryrefslogtreecommitdiff
path: root/src/bin/eolian_cxx
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-06-20 21:11:21 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2014-06-20 21:11:21 +0100
commitcc3809d295707ede041f36f92e19042f9c644f55 (patch)
tree340b32c9cdacf904529e3b957d3baac903bf6684 /src/bin/eolian_cxx
parent43e23492033614096dda88aedc482d0d7c2d0546 (diff)
eolian_cxx: support API deduplication like the main generator
Diffstat (limited to 'src/bin/eolian_cxx')
-rw-r--r--src/bin/eolian_cxx/convert.cc39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/bin/eolian_cxx/convert.cc b/src/bin/eolian_cxx/convert.cc
index 0b37ba011f..c33953a658 100644
--- a/src/bin/eolian_cxx/convert.cc
+++ b/src/bin/eolian_cxx/convert.cc
@@ -15,6 +15,35 @@
15#include "comments.hh" 15#include "comments.hh"
16 16
17static std::string 17static std::string
18_dedup_func_name(const std::string &classn, const std::string &funcn)
19{
20 size_t last_p = classn.rfind('_');
21 size_t func_p = funcn.find('_');
22 std::string ret;
23 size_t len;
24
25 if (last_p == std::string::npos) last_p = 0;
26 else last_p++;
27 if (func_p == std::string::npos) len = funcn.size();
28 else len = func_p;
29
30 if ((classn.size() - last_p) != len
31 || classn.compare(last_p, len, funcn, 0, len))
32 {
33 ret += classn;
34 ret += '_';
35 ret += funcn;
36 return ret;
37 }
38
39 if (last_p)
40 ret += classn.substr(0, last_p);
41
42 ret += funcn;
43 return ret;
44}
45
46static std::string
18_resolve_param_type(Eolian_Function_Parameter id, bool is_get) 47_resolve_param_type(Eolian_Function_Parameter id, bool is_get)
19{ 48{
20 Eolian_Parameter_Dir dir; 49 Eolian_Parameter_Dir dir;
@@ -81,7 +110,7 @@ _get_properties(const Eolian_Class klass)
81 efl::eolian::eo_function getter; 110 efl::eolian::eo_function getter;
82 getter.type = efl::eolian::eo_function::regular_; 111 getter.type = efl::eolian::eo_function::regular_;
83 getter.name = name + "_get"; 112 getter.name = name + "_get";
84 getter.impl = (prefix != "" ? prefix : cxx_classname) + "_" + getter.name; 113 getter.impl = _dedup_func_name((prefix != "" ? prefix : cxx_classname), getter.name);
85 std::string ret = safe_str 114 std::string ret = safe_str
86 (eolian_function_return_type_get(property, EOLIAN_PROP_GET)); 115 (eolian_function_return_type_get(property, EOLIAN_PROP_GET));
87 if (ret == "") ret = "void"; 116 if (ret == "") ret = "void";
@@ -126,7 +155,7 @@ _get_properties(const Eolian_Class klass)
126 efl::eolian::eo_function setter; 155 efl::eolian::eo_function setter;
127 setter.type = efl::eolian::eo_function::regular_; 156 setter.type = efl::eolian::eo_function::regular_;
128 setter.name = name + "_set"; 157 setter.name = name + "_set";
129 setter.impl = (prefix != "" ? prefix : cxx_classname) + "_" + setter.name; 158 setter.impl = _dedup_func_name((prefix != "" ? prefix : cxx_classname), setter.name);
130 setter.params = params; 159 setter.params = params;
131 setter.ret = safe_str(eolian_function_return_type_get 160 setter.ret = safe_str(eolian_function_return_type_get
132 (property, EOLIAN_PROP_SET)); 161 (property, EOLIAN_PROP_SET));
@@ -214,8 +243,8 @@ convert_eolian_constructors(efl::eolian::eo_class& cls, const Eolian_Class klass
214 { 243 {
215 Eolian_Function eolian_constructor = static_cast<Eolian_Function>(curr); 244 Eolian_Function eolian_constructor = static_cast<Eolian_Function>(curr);
216 efl::eolian::eo_constructor constructor; 245 efl::eolian::eo_constructor constructor;
217 constructor.name = (prefix != "" ? prefix : cls.name) + "_" + safe_str 246 constructor.name = _dedup_func_name((prefix != "" ? prefix : cls.name),
218 (eolian_function_name_get(eolian_constructor)); 247 safe_str(eolian_function_name_get(eolian_constructor)));
219 constructor.params = _get_params 248 constructor.params = _get_params
220 (eolian_parameters_list_get(eolian_constructor)); 249 (eolian_parameters_list_get(eolian_constructor));
221 constructor.comment = detail::eolian_constructor_comment 250 constructor.comment = detail::eolian_constructor_comment
@@ -240,7 +269,7 @@ convert_eolian_functions(efl::eolian::eo_class& cls, const Eolian_Class klass)
240 // XXX Eolian only provides regular methods so far 269 // XXX Eolian only provides regular methods so far
241 function.type = efl::eolian::eo_function::regular_; 270 function.type = efl::eolian::eo_function::regular_;
242 function.name = safe_str(eolian_function_name_get(eolian_function)); 271 function.name = safe_str(eolian_function_name_get(eolian_function));
243 function.impl = ( prefix != "" ? prefix : cls.name ) + "_" + function.name; 272 function.impl = _dedup_func_name((prefix != "" ? prefix : cls.name), function.name);
244 function.ret = safe_str(eolian_function_return_type_get 273 function.ret = safe_str(eolian_function_return_type_get
245 (eolian_function, EOLIAN_METHOD)); 274 (eolian_function, EOLIAN_METHOD));
246 if(function.ret == "") function.ret = "void"; 275 if(function.ret == "") function.ret = "void";