q66 pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=cc3809d295707ede041f36f92e19042f9c644f55
commit cc3809d295707ede041f36f92e19042f9c644f55 Author: Daniel Kolesa <d.kol...@samsung.com> Date: Fri Jun 20 21:11:21 2014 +0100 eolian_cxx: support API deduplication like the main generator --- src/bin/eolian_cxx/convert.cc | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/bin/eolian_cxx/convert.cc b/src/bin/eolian_cxx/convert.cc index 0b37ba0..c33953a 100644 --- a/src/bin/eolian_cxx/convert.cc +++ b/src/bin/eolian_cxx/convert.cc @@ -15,6 +15,35 @@ #include "comments.hh" static std::string +_dedup_func_name(const std::string &classn, const std::string &funcn) +{ + size_t last_p = classn.rfind('_'); + size_t func_p = funcn.find('_'); + std::string ret; + size_t len; + + if (last_p == std::string::npos) last_p = 0; + else last_p++; + if (func_p == std::string::npos) len = funcn.size(); + else len = func_p; + + if ((classn.size() - last_p) != len + || classn.compare(last_p, len, funcn, 0, len)) + { + ret += classn; + ret += '_'; + ret += funcn; + return ret; + } + + if (last_p) + ret += classn.substr(0, last_p); + + ret += funcn; + return ret; +} + +static std::string _resolve_param_type(Eolian_Function_Parameter id, bool is_get) { Eolian_Parameter_Dir dir; @@ -81,7 +110,7 @@ _get_properties(const Eolian_Class klass) efl::eolian::eo_function getter; getter.type = efl::eolian::eo_function::regular_; getter.name = name + "_get"; - getter.impl = (prefix != "" ? prefix : cxx_classname) + "_" + getter.name; + getter.impl = _dedup_func_name((prefix != "" ? prefix : cxx_classname), getter.name); std::string ret = safe_str (eolian_function_return_type_get(property, EOLIAN_PROP_GET)); if (ret == "") ret = "void"; @@ -126,7 +155,7 @@ _get_properties(const Eolian_Class klass) efl::eolian::eo_function setter; setter.type = efl::eolian::eo_function::regular_; setter.name = name + "_set"; - setter.impl = (prefix != "" ? prefix : cxx_classname) + "_" + setter.name; + setter.impl = _dedup_func_name((prefix != "" ? prefix : cxx_classname), setter.name); setter.params = params; setter.ret = safe_str(eolian_function_return_type_get (property, EOLIAN_PROP_SET)); @@ -214,8 +243,8 @@ convert_eolian_constructors(efl::eolian::eo_class& cls, const Eolian_Class klass { Eolian_Function eolian_constructor = static_cast<Eolian_Function>(curr); efl::eolian::eo_constructor constructor; - constructor.name = (prefix != "" ? prefix : cls.name) + "_" + safe_str - (eolian_function_name_get(eolian_constructor)); + constructor.name = _dedup_func_name((prefix != "" ? prefix : cls.name), + safe_str(eolian_function_name_get(eolian_constructor))); constructor.params = _get_params (eolian_parameters_list_get(eolian_constructor)); constructor.comment = detail::eolian_constructor_comment @@ -240,7 +269,7 @@ convert_eolian_functions(efl::eolian::eo_class& cls, const Eolian_Class klass) // XXX Eolian only provides regular methods so far function.type = efl::eolian::eo_function::regular_; function.name = safe_str(eolian_function_name_get(eolian_function)); - function.impl = ( prefix != "" ? prefix : cls.name ) + "_" + function.name; + function.impl = _dedup_func_name((prefix != "" ? prefix : cls.name), function.name); function.ret = safe_str(eolian_function_return_type_get (eolian_function, EOLIAN_METHOD)); if(function.ret == "") function.ret = "void"; --