summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2015-05-12 11:45:16 -0300
committerVitor Sousa <vitorsousasilva@gmail.com>2015-05-12 11:45:54 -0300
commitc27c2c15d5196df7905628d737a6f50ce6a0f3fa (patch)
treebf05f9ccf989c4beaa898a0c70573322ecc51d9d
parent6e7ab244f7609f4655e683c2df829a9e9e461d60 (diff)
eolian_cxx: Fix @beta on generated bindings for C++devs/vitorsousa/beta_error_eoliancxx
-rw-r--r--src/bin/eolian_cxx/convert.cc3
-rw-r--r--src/bin/eolian_cxx/eolian_wrappers.hh7
-rw-r--r--src/lib/eolian_cxx/eo_types.hh2
-rw-r--r--src/lib/eolian_cxx/grammar/eo_class_scope_guard_generator.hh4
-rw-r--r--src/lib/eolian_cxx/grammar/inheritance_base_generator.hh100
5 files changed, 63 insertions, 53 deletions
diff --git a/src/bin/eolian_cxx/convert.cc b/src/bin/eolian_cxx/convert.cc
index 4d03c8f775..4f92b97d41 100644
--- a/src/bin/eolian_cxx/convert.cc
+++ b/src/bin/eolian_cxx/convert.cc
@@ -142,6 +142,7 @@ _convert_property_set_to_function(Eolian_Class const& klass,
142 { 142 {
143 efl::eolian::eo_function::regular_, 143 efl::eolian::eo_function::regular_,
144 function_scope(prop_), 144 function_scope(prop_),
145 function_is_beta(prop_),
145 function_name(prop_) + "_set", 146 function_name(prop_) + "_set",
146 function_impl(prop_) + "_set", 147 function_impl(prop_) + "_set",
147 function_return_type(prop_, eolian_cxx::setter), 148 function_return_type(prop_, eolian_cxx::setter),
@@ -170,6 +171,7 @@ _convert_property_get_to_function(Eolian_Class const& klass,
170 { 171 {
171 efl::eolian::eo_function::regular_, 172 efl::eolian::eo_function::regular_,
172 function_scope(prop_), 173 function_scope(prop_),
174 function_is_beta(prop_),
173 function_name(prop_) + "_get", 175 function_name(prop_) + "_get",
174 function_impl(prop_) + "_get", 176 function_impl(prop_) + "_get",
175 function_return_type(prop_, eolian_cxx::getter), 177 function_return_type(prop_, eolian_cxx::getter),
@@ -218,6 +220,7 @@ _convert_function(Eolian_Class const& klass, Eolian_Function const& func)
218 return { 220 return {
219 function_type(func), 221 function_type(func),
220 function_scope(func), 222 function_scope(func),
223 function_is_beta(func),
221 function_name(func), 224 function_name(func),
222 function_impl(func), 225 function_impl(func),
223 function_return_type(func), 226 function_return_type(func),
diff --git a/src/bin/eolian_cxx/eolian_wrappers.hh b/src/bin/eolian_cxx/eolian_wrappers.hh
index 5b6579ed34..0dd9890d68 100644
--- a/src/bin/eolian_cxx/eolian_wrappers.hh
+++ b/src/bin/eolian_cxx/eolian_wrappers.hh
@@ -204,6 +204,12 @@ function_is_constructor(Eolian_Class const& cls, Eolian_Function const& func)
204 return ::eolian_function_is_constructor(&func, &cls); 204 return ::eolian_function_is_constructor(&func, &cls);
205} 205}
206 206
207inline bool
208function_is_beta(Eolian_Function const& func)
209{
210 return ::eolian_function_is_beta(&func);
211}
212
207inline efl::eolian::eolian_scope 213inline efl::eolian::eolian_scope
208function_scope(Eolian_Function const& func) 214function_scope(Eolian_Function const& func)
209{ 215{
@@ -403,6 +409,7 @@ event_create(Eolian_Class const& klass, const Eolian_Event *event_)
403 std::transform(name_.begin(), name_.end(), name_.begin(), 409 std::transform(name_.begin(), name_.end(), name_.begin(),
404 [](int c) { return c != ',' ? c : '_'; }); 410 [](int c) { return c != ',' ? c : '_'; });
405 event.scope = eolian_scope_cxx(::eolian_event_scope_get(event_)); 411 event.scope = eolian_scope_cxx(::eolian_event_scope_get(event_));
412 event.is_beta = (::eolian_event_is_beta(event_) != EINA_FALSE);
406 event.name = normalize_spaces(name_); 413 event.name = normalize_spaces(name_);
407 event.eo_name = safe_upper 414 event.eo_name = safe_upper
408 (find_replace(class_full_name(klass), ".", "_") + "_EVENT_" + event.name); 415 (find_replace(class_full_name(klass), ".", "_") + "_EVENT_" + event.name);
diff --git a/src/lib/eolian_cxx/eo_types.hh b/src/lib/eolian_cxx/eo_types.hh
index 843c2fab55..431ba050f8 100644
--- a/src/lib/eolian_cxx/eo_types.hh
+++ b/src/lib/eolian_cxx/eo_types.hh
@@ -285,6 +285,7 @@ struct eo_function
285 }; 285 };
286 eo_function_type type; 286 eo_function_type type;
287 eolian_scope scope; 287 eolian_scope scope;
288 bool is_beta;
288 std::string name; 289 std::string name;
289 std::string impl; 290 std::string impl;
290 eolian_type_instance ret; 291 eolian_type_instance ret;
@@ -297,6 +298,7 @@ struct eo_event
297 eo_event() : scope(eolian_scope::public_) {} 298 eo_event() : scope(eolian_scope::public_) {}
298 299
299 eolian_scope scope; 300 eolian_scope scope;
301 bool is_beta;
300 std::string name; 302 std::string name;
301 std::string eo_name; 303 std::string eo_name;
302 //parameters_container_type params; // XXX desirable. 304 //parameters_container_type params; // XXX desirable.
diff --git a/src/lib/eolian_cxx/grammar/eo_class_scope_guard_generator.hh b/src/lib/eolian_cxx/grammar/eo_class_scope_guard_generator.hh
index 9d545c33b3..5915c38beb 100644
--- a/src/lib/eolian_cxx/grammar/eo_class_scope_guard_generator.hh
+++ b/src/lib/eolian_cxx/grammar/eo_class_scope_guard_generator.hh
@@ -29,6 +29,8 @@ operator<<(std::ostream& out, _scope_guard_head<T> const& x)
29 assert(x._e.scope != eolian_scope::private_); 29 assert(x._e.scope != eolian_scope::private_);
30 if (x._e.scope == eolian_scope::protected_) 30 if (x._e.scope == eolian_scope::protected_)
31 out << "#ifdef " << name_upper(x._cls) << "_PROTECTED" << endl; 31 out << "#ifdef " << name_upper(x._cls) << "_PROTECTED" << endl;
32 if (x._e.is_beta)
33 out << "#ifdef " << name_upper(x._cls) << "_BETA" << endl;
32 return out; 34 return out;
33} 35}
34 36
@@ -53,6 +55,8 @@ operator<<(std::ostream& out, _scope_guard_tail<T> const& x)
53{ 55{
54 if (x._e.scope == eolian_scope::protected_) 56 if (x._e.scope == eolian_scope::protected_)
55 out << "#endif" << endl; 57 out << "#endif" << endl;
58 if (x._e.is_beta)
59 out << "#endif" << endl;
56 return out; 60 return out;
57} 61}
58 62
diff --git a/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh b/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh
index e134729aa4..ed993f0fc8 100644
--- a/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh
+++ b/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh
@@ -31,26 +31,27 @@ struct inheritance_operation
31{ 31{
32 eo_class const& _cls; 32 eo_class const& _cls;
33 eo_function const& _func; 33 eo_function const& _func;
34 functions_container_type::size_type _idx; 34 inheritance_operation(eo_class const& cls, eo_function const& func)
35 inheritance_operation(eo_class const& cls, eo_function const& func, functions_container_type::size_type idx) 35 : _cls(cls), _func(func)
36 : _cls(cls), _func(func), _idx(idx)
37 {} 36 {}
38}; 37};
39 38
40inline std::ostream& 39inline std::ostream&
41operator<<(std::ostream& out, inheritance_operation const& x) 40operator<<(std::ostream& out, inheritance_operation const& x)
42{ 41{
43 assert(x._idx < x._cls.functions.size());
44 eo_function const& func = x._func; 42 eo_function const& func = x._func;
45 out << tab(1) 43 out << scope_guard_head(x._cls, func)
46 << "ops[" << x._idx << "].func = reinterpret_cast<void*>(& ::" 44 << tab(1)
45 << "ops[i].func = reinterpret_cast<void*>(& ::"
47 << _ns_as_prefix(x._cls) << "_" 46 << _ns_as_prefix(x._cls) << "_"
48 << x._cls.name << "_" << func.name << "_wrapper<T>);" << endl 47 << x._cls.name << "_" << func.name << "_wrapper<T>);" << endl
49 << tab(1) << "ops[" << x._idx << "].api_func = reinterpret_cast<void*>(& ::" 48 << tab(1) << "ops[i].api_func = reinterpret_cast<void*>(& ::"
50 << func.impl << ");" << endl 49 << func.impl << ");" << endl
51 << tab(1) << "ops[" << x._idx << "].op = EO_OP_OVERRIDE;" << endl 50 << tab(1) << "ops[i].op = EO_OP_OVERRIDE;" << endl
52 << tab(1) << "ops[" << x._idx << "].op_type = EO_OP_TYPE_REGULAR;" << endl // XXX class ops 51 << tab(1) << "ops[i].op_type = EO_OP_TYPE_REGULAR;" << endl // XXX class ops
53 << tab(1) << "ops[" << x._idx << "].doc = NULL;" << endl 52 << tab(1) << "ops[i].doc = NULL;" << endl
53 << tab(1) << "++i;" << endl
54 << scope_guard_tail(x._cls, func)
54 << endl; 55 << endl;
55 return out; 56 return out;
56} 57}
@@ -74,23 +75,13 @@ operator<<(std::ostream& out, inheritance_operations_description const& x)
74 << tab(11) 75 << tab(11)
75 << ", Eo_Op_Description* ops)" << endl 76 << ", Eo_Op_Description* ops)" << endl
76 << "{" << endl 77 << "{" << endl
78 << tab(1) << "int i = 0;" << endl
79 << tab(1) << "(void)i;" << endl
77 << tab(1) << "(void)ops;" << endl; 80 << tab(1) << "(void)ops;" << endl;
78 81
79 auto funcs = x._cls.functions; 82 for (auto const& f : x._cls.functions)
80 auto part = std::stable_partition(funcs.begin(), funcs.end(), [](eo_function const& f){ return f.scope == eolian_scope::public_; });
81
82 functions_container_type::size_type op_idx = 0;
83 for (auto it = funcs.begin(); it != part; ++it, ++op_idx)
84 { 83 {
85 out << inheritance_operation(x._cls, *it, op_idx); 84 out << inheritance_operation(x._cls, f);
86 }
87
88 if (part != funcs.end())
89 {
90 out << scope_guard_head(x._cls, *part);
91 for (auto it = part; it != funcs.end(); ++it, ++op_idx)
92 out << inheritance_operation(x._cls, *it, op_idx);
93 out << scope_guard_tail(x._cls, *part);
94 } 85 }
95 86
96 for (std::string const& parent : x._cls.parents) 87 for (std::string const& parent : x._cls.parents)
@@ -167,25 +158,50 @@ operator<<(std::ostream& out, inheritance_wrappers const& x)
167struct inheritance_base_operations_size 158struct inheritance_base_operations_size
168{ 159{
169 eo_class const& _cls; 160 eo_class const& _cls;
170 functions_container_type const& _funcs; 161 inheritance_base_operations_size(eo_class const& cls)
171 inheritance_base_operations_size(eo_class const& cls, functions_container_type const& funcs) 162 : _cls(cls)
172 : _cls(cls), _funcs(funcs)
173 {} 163 {}
174}; 164};
175 165
176inline std::ostream& 166inline std::ostream&
177operator<<(std::ostream& out, inheritance_base_operations_size const& x) 167operator<<(std::ostream& out, inheritance_base_operations_size const& x)
178{ 168{
169 int pcted = 0;
170 int beta = 0;
171 int pcted_beta = 0;
172
173 auto funcs = x._cls.functions;
174
175 for (auto const& f : funcs)
176 {
177 if (f.is_beta && f.scope != eolian_scope::public_)
178 ++pcted_beta;
179 if (f.scope != eolian_scope::public_)
180 ++pcted;
181 if (f.is_beta)
182 ++beta;
183 }
184 auto all = funcs.size();
185
179 out << "template<>" 186 out << "template<>"
180 << endl << "struct operation_description_class_size< " 187 << endl << "struct operation_description_class_size< "
181 << full_name(x._cls) << " >" << endl 188 << full_name(x._cls) << " >" << endl
182 << "{" << endl 189 << "{" << endl
183 << tab(1) << "static constexpr int value = " 190 << tab(1) << "static constexpr int value = " << endl
184 << x._funcs.size(); 191 << "#if defined(" << name_upper(x._cls) << "_PROTECTED)"
192 << " && defined(" << name_upper(x._cls) << "_BETA)" << endl
193 << tab(2) << all << endl
194 << "#elif defined(" << name_upper(x._cls) << "_PROTECTED)" << endl
195 << tab(2) << (all - beta) << endl
196 << "#elif defined(" << name_upper(x._cls) << "_BETA)" << endl
197 << tab(2) << (all - pcted) << endl
198 << "#else" << endl
199 << tab(2) << (all + pcted_beta - beta - pcted) << endl
200 << "#endif" << endl;
185 201
186 for (std::string const& parent : x._cls.parents) 202 for (std::string const& parent : x._cls.parents)
187 { 203 {
188 out << " + operation_description_class_size<::" << parent << " >::value"; 204 out << tab(2) << "+ operation_description_class_size<::" << parent << " >::value";
189 } 205 }
190 206
191 out << ";" << endl 207 out << ";" << endl
@@ -195,28 +211,6 @@ operator<<(std::ostream& out, inheritance_base_operations_size const& x)
195 return out; 211 return out;
196} 212}
197 213
198struct inheritance_base_operations_size_scopes
199{
200 eo_class const& _cls;
201 inheritance_base_operations_size_scopes(eo_class const& cls)
202 : _cls(cls)
203 {}
204};
205
206inline std::ostream&
207operator<<(std::ostream& out, inheritance_base_operations_size_scopes const& x)
208{
209 auto funcs = x._cls.functions;
210 auto part = std::stable_partition(funcs.begin(), funcs.end(), [](eo_function const& f){ return f.scope == eolian_scope::public_; });
211
212 out << "#ifdef " << name_upper(x._cls) << "_PROTECTED" << endl
213 << inheritance_base_operations_size(x._cls, funcs)
214 << "#else" << endl
215 << inheritance_base_operations_size(x._cls, {funcs.begin(), part})
216 << "#endif" << endl << endl;
217 return out;
218}
219
220struct inheritance_base_operations_extensions 214struct inheritance_base_operations_extensions
221{ 215{
222 eo_class const& _cls; 216 eo_class const& _cls;
@@ -341,7 +335,7 @@ eo_inheritance_detail_generator(std::ostream& out, eo_class const& cls)
341 out << inheritance_wrappers(cls) 335 out << inheritance_wrappers(cls)
342 << "namespace efl { namespace eo { namespace detail {" << endl << endl 336 << "namespace efl { namespace eo { namespace detail {" << endl << endl
343 << inheritance_base_operations(cls) << endl 337 << inheritance_base_operations(cls) << endl
344 << inheritance_base_operations_size_scopes(cls) 338 << inheritance_base_operations_size(cls)
345 << inheritance_operations_description(cls) 339 << inheritance_operations_description(cls)
346 << inheritance_eo_class_getter(cls) 340 << inheritance_eo_class_getter(cls)
347 << "} } }" << endl; 341 << "} } }" << endl;