summaryrefslogtreecommitdiff
path: root/src/bin/eolian_cxx
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2014-06-27 14:47:40 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2014-06-30 17:20:39 +0100
commit7b54a0101c607cc92d299bf1662c36d6ccc5b6f3 (patch)
tree3a642784c2c71605dcc0f64cfae1fd2de74281a4 /src/bin/eolian_cxx
parentba362d350fe29ae5526a6a67e5cb26575233139b (diff)
eolian: new type API
This new API supports function pointer types, multiple type subtypes, const attribute without parsing the name string, own attribute for any partial type and more. This commit also updates the C and C++ generators so that they compile and generate correct code. @feature
Diffstat (limited to 'src/bin/eolian_cxx')
-rw-r--r--src/bin/eolian_cxx/comments.cc6
-rw-r--r--src/bin/eolian_cxx/convert.cc28
2 files changed, 25 insertions, 9 deletions
diff --git a/src/bin/eolian_cxx/comments.cc b/src/bin/eolian_cxx/comments.cc
index d82f2b424c..32eec8bcda 100644
--- a/src/bin/eolian_cxx/comments.cc
+++ b/src/bin/eolian_cxx/comments.cc
@@ -60,8 +60,12 @@ static std::string
60_comment_return(Eolian_Function function, 60_comment_return(Eolian_Function function,
61 Eolian_Function_Type rettype) 61 Eolian_Function_Type rettype)
62{ 62{
63 Eolian_Type rettypet = eolian_function_return_type_get(function, rettype);
64 const char *rettypes = NULL;
65 if (rettypet) rettypes = eolian_type_c_type_get(rettypet);
63 std::string doc = ""; 66 std::string doc = "";
64 std::string ret = safe_str(eolian_function_return_type_get(function, rettype)); 67 std::string ret = safe_str(rettypes);
68 if (rettypes) eina_stringshare_del(rettypes);
65 std::string comment = safe_str(eolian_function_return_comment_get(function, rettype)); 69 std::string comment = safe_str(eolian_function_return_comment_get(function, rettype));
66 if (ret != "void" && ret != "" && comment != "") 70 if (ret != "void" && ret != "" && comment != "")
67 { 71 {
diff --git a/src/bin/eolian_cxx/convert.cc b/src/bin/eolian_cxx/convert.cc
index dfb7272d6d..b915ed82b7 100644
--- a/src/bin/eolian_cxx/convert.cc
+++ b/src/bin/eolian_cxx/convert.cc
@@ -27,13 +27,16 @@ static std::string
27_resolve_param_type(Eolian_Function_Parameter id, bool is_get) 27_resolve_param_type(Eolian_Function_Parameter id, bool is_get)
28{ 28{
29 Eolian_Parameter_Dir dir; 29 Eolian_Parameter_Dir dir;
30 const char *type; 30 Eolian_Type typet;
31 const char *type = NULL;
31 bool is_const; 32 bool is_const;
32 std::string res; 33 std::string res;
33 34
34 eolian_parameter_information_get(id, &dir, &type, NULL, NULL); 35 eolian_parameter_information_get(id, &dir, &typet, NULL, NULL);
36 if (typet) type = eolian_type_c_type_get(typet);
35 is_const = eolian_parameter_const_attribute_get(id, is_get); 37 is_const = eolian_parameter_const_attribute_get(id, is_get);
36 res = safe_str(type); 38 res = safe_str(type);
39 eina_stringshare_del(type);
37 assert(res != ""); 40 assert(res != "");
38 if (is_const) res = std::string("const ") + res; 41 if (is_const) res = std::string("const ") + res;
39 if (dir == EOLIAN_OUT_PARAM || dir == EOLIAN_INOUT_PARAM) res += "*"; 42 if (dir == EOLIAN_OUT_PARAM || dir == EOLIAN_INOUT_PARAM) res += "*";
@@ -91,8 +94,11 @@ _get_properties(const Eolian_Class klass)
91 getter.type = efl::eolian::eo_function::regular_; 94 getter.type = efl::eolian::eo_function::regular_;
92 getter.name = name + "_get"; 95 getter.name = name + "_get";
93 getter.impl = _dedup_func_name(property, (prefix != "" ? prefix : cxx_classname)) + "_get"; 96 getter.impl = _dedup_func_name(property, (prefix != "" ? prefix : cxx_classname)) + "_get";
94 std::string ret = safe_str 97 Eolian_Type tp = eolian_function_return_type_get(property, EOLIAN_PROP_GET);
95 (eolian_function_return_type_get(property, EOLIAN_PROP_GET)); 98 const char *tps = NULL;
99 if (tp) tps = eolian_type_c_type_get(tp);
100 std::string ret = safe_str(tps);
101 if (tps) eina_stringshare_del(tps);
96 if (ret == "") ret = "void"; 102 if (ret == "") ret = "void";
97 103
98 // if the getter has a single parameter and void return 104 // if the getter has a single parameter and void return
@@ -137,8 +143,11 @@ _get_properties(const Eolian_Class klass)
137 setter.name = name + "_set"; 143 setter.name = name + "_set";
138 setter.impl = _dedup_func_name(property, (prefix != "" ? prefix : cxx_classname)) + "_set"; 144 setter.impl = _dedup_func_name(property, (prefix != "" ? prefix : cxx_classname)) + "_set";
139 setter.params = params; 145 setter.params = params;
140 setter.ret = safe_str(eolian_function_return_type_get 146 Eolian_Type tp = eolian_function_return_type_get(property, EOLIAN_PROP_SET);
141 (property, EOLIAN_PROP_SET)); 147 const char *tps = NULL;
148 if (tp) tps = eolian_type_c_type_get(tp);
149 setter.ret = safe_str(tps);
150 if (tps) eina_stringshare_del(tps);
142 if (setter.ret == "") setter.ret = "void"; 151 if (setter.ret == "") setter.ret = "void";
143 setter.comment = detail::eolian_property_setter_comment(property); 152 setter.comment = detail::eolian_property_setter_comment(property);
144 container.push_back(setter); 153 container.push_back(setter);
@@ -250,8 +259,11 @@ convert_eolian_functions(efl::eolian::eo_class& cls, const Eolian_Class klass)
250 function.type = efl::eolian::eo_function::regular_; 259 function.type = efl::eolian::eo_function::regular_;
251 function.name = safe_str(eolian_function_name_get(eolian_function)); 260 function.name = safe_str(eolian_function_name_get(eolian_function));
252 function.impl = _dedup_func_name(eolian_function, (prefix != "" ? prefix : cls.name)); 261 function.impl = _dedup_func_name(eolian_function, (prefix != "" ? prefix : cls.name));
253 function.ret = safe_str(eolian_function_return_type_get 262 Eolian_Type tp = eolian_function_return_type_get(eolian_function, EOLIAN_METHOD);
254 (eolian_function, EOLIAN_METHOD)); 263 const char *tps = NULL;
264 if (tp) tps = eolian_type_c_type_get(tp);
265 function.ret = safe_str(tps);
266 if (tps) eina_stringshare_del(tps);
255 if(function.ret == "") function.ret = "void"; 267 if(function.ret == "") function.ret = "void";
256 function.params = _get_params(eolian_parameters_list_get(eolian_function)); 268 function.params = _get_params(eolian_parameters_list_get(eolian_function));
257 function.comment = detail::eolian_function_comment(eolian_function); 269 function.comment = detail::eolian_function_comment(eolian_function);