summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2016-03-09 15:46:19 -0300
committerVitor Sousa <vitorsousasilva@gmail.com>2016-03-09 15:46:19 -0300
commit48f62ad686d11c97ec62b1ba528262edf39cafbf (patch)
treea00ca3c622b01df549db52dfe841ddc799b67773
parentd2fba6c5959f82f35984167131d3b67207780f48 (diff)
cxx: Migrate C++ binding to the new eo_add syntax
-rw-r--r--src/bindings/eo_cxx/eo_inherit.hh3
-rw-r--r--src/bindings/eo_cxx/eo_ops.hh3
-rw-r--r--src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh7
-rw-r--r--src/tests/eina_cxx/eina_cxx_test_accessor.cc18
-rw-r--r--src/tests/eina_cxx/eina_cxx_test_ptrarray.cc54
-rw-r--r--src/tests/eina_cxx/eina_cxx_test_ptrlist.cc50
6 files changed, 76 insertions, 59 deletions
diff --git a/src/bindings/eo_cxx/eo_inherit.hh b/src/bindings/eo_cxx/eo_inherit.hh
index 9639e33e4a..1d3d3125ff 100644
--- a/src/bindings/eo_cxx/eo_inherit.hh
+++ b/src/bindings/eo_cxx/eo_inherit.hh
@@ -83,9 +83,10 @@ struct inherit
83 /// 83 ///
84 template<typename... Args> 84 template<typename... Args>
85 inherit(efl::eo::parent_type _p, Args&& ... args) 85 inherit(efl::eo::parent_type _p, Args&& ... args)
86 : _eo_cls(nullptr), _eo_raw(nullptr)
86 { 87 {
87 _eo_cls = detail::create_class<D, E...> (eina::make_index_sequence<sizeof...(E)>()); 88 _eo_cls = detail::create_class<D, E...> (eina::make_index_sequence<sizeof...(E)>());
88 _eo_raw = eo_add_ref(_eo_cls, _p._eo_raw, detail::inherit_constructor(eoid, this), ::efl::eolian::call_ctors(eoid, args...)); 89 eo_add_ref(&_eo_raw, _eo_cls, _p._eo_raw, detail::inherit_constructor(_eo_raw, this), ::efl::eolian::call_ctors(_eo_raw, args...));
89 ::efl::eolian::register_ev_del_free_callback(_eo_raw, args...); 90 ::efl::eolian::register_ev_del_free_callback(_eo_raw, args...);
90 } 91 }
91 92
diff --git a/src/bindings/eo_cxx/eo_ops.hh b/src/bindings/eo_cxx/eo_ops.hh
index 46a33c77dc..9aecf61880 100644
--- a/src/bindings/eo_cxx/eo_ops.hh
+++ b/src/bindings/eo_cxx/eo_ops.hh
@@ -54,7 +54,8 @@ isa(Eo *obj, Eo_Class *klass)
54inline Eo* 54inline Eo*
55add(Eo_Class *klass, Eo *parent = NULL) 55add(Eo_Class *klass, Eo *parent = NULL)
56{ 56{
57 Eo *eo = eo_add_ref(klass, parent); 57 Eo *eo = nullptr;
58 eo_add_ref(&eo, klass, parent);
58 return eo; 59 return eo;
59} 60}
60 61
diff --git a/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh b/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh
index 2a7091ad02..9fde23aa92 100644
--- a/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh
+++ b/src/lib/eolian_cxx/grammar/eo_class_constructors_generator.hh
@@ -577,13 +577,14 @@ operator<<(std::ostream& out, function_call_constructor_methods const& x)
577 577
578 out << ")" << endl 578 out << ")" << endl
579 << tab(1) << "{" << endl 579 << tab(1) << "{" << endl
580 << tab(2) << "Eo* _ret_eo = eo_add_ref(" << x._cls.eo_name << ", _p._eo_raw"; 580 << tab(2) << "Eo* _ret_eo = nullptr;" << endl
581 << tab(2) << "eo_add_ref(&_ret_eo, " << x._cls.eo_name << ", _p._eo_raw";
581 for (it = first; it != last; ++it) 582 for (it = first; it != last; ++it)
582 { 583 {
583 out << ", _c" << (it-first) << "(eoid)"; 584 out << ", _c" << (it-first) << "(_ret_eo)";
584 } 585 }
585 if (!x._cls.optional_constructors.empty()) 586 if (!x._cls.optional_constructors.empty())
586 out << ", ::efl::eolian::call_ctors(eoid, _opts...)"; 587 out << ", ::efl::eolian::call_ctors(_ret_eo, _opts...)";
587 out << ");" << endl << endl; 588 out << ");" << endl << endl;
588 589
589 for (it = first; it != last; ++it) 590 for (it = first; it != last; ++it)
diff --git a/src/tests/eina_cxx/eina_cxx_test_accessor.cc b/src/tests/eina_cxx/eina_cxx_test_accessor.cc
index 9737f0d383..47cb62b7d9 100644
--- a/src/tests/eina_cxx/eina_cxx_test_accessor.cc
+++ b/src/tests/eina_cxx/eina_cxx_test_accessor.cc
@@ -43,10 +43,11 @@ START_TEST(eina_cxx_eo_accessor_indexing)
43 43
44 efl::eina::list<wrapper> list; 44 efl::eina::list<wrapper> list;
45 45
46 wrapper const w1(eo_add(SIMPLE_CLASS, NULL)); 46 Eo* eoptr = nullptr;
47 wrapper const w2(eo_add(SIMPLE_CLASS, NULL)); 47 wrapper const w1(eo_add(&eoptr, SIMPLE_CLASS, NULL));
48 wrapper const w3(eo_add(SIMPLE_CLASS, NULL)); 48 wrapper const w2(eo_add(&eoptr, SIMPLE_CLASS, NULL));
49 wrapper const w4(eo_add(SIMPLE_CLASS, NULL)); 49 wrapper const w3(eo_add(&eoptr, SIMPLE_CLASS, NULL));
50 wrapper const w4(eo_add(&eoptr, SIMPLE_CLASS, NULL));
50 51
51 list.push_back(w1); 52 list.push_back(w1);
52 list.push_back(w2); 53 list.push_back(w2);
@@ -97,10 +98,11 @@ START_TEST(eina_cxx_eo_accessor_iterator)
97 98
98 efl::eina::list<wrapper> list; 99 efl::eina::list<wrapper> list;
99 100
100 wrapper const w1(eo_add(SIMPLE_CLASS, NULL)); 101 Eo* eoptr = nullptr;
101 wrapper const w2(eo_add(SIMPLE_CLASS, NULL)); 102 wrapper const w1(eo_add(&eoptr, SIMPLE_CLASS, NULL));
102 wrapper const w3(eo_add(SIMPLE_CLASS, NULL)); 103 wrapper const w2(eo_add(&eoptr, SIMPLE_CLASS, NULL));
103 wrapper const w4(eo_add(SIMPLE_CLASS, NULL)); 104 wrapper const w3(eo_add(&eoptr, SIMPLE_CLASS, NULL));
105 wrapper const w4(eo_add(&eoptr, SIMPLE_CLASS, NULL));
104 106
105 list.push_back(w1); 107 list.push_back(w1);
106 list.push_back(w2); 108 list.push_back(w2);
diff --git a/src/tests/eina_cxx/eina_cxx_test_ptrarray.cc b/src/tests/eina_cxx/eina_cxx_test_ptrarray.cc
index 6b2f6271d8..4b7fce3572 100644
--- a/src/tests/eina_cxx/eina_cxx_test_ptrarray.cc
+++ b/src/tests/eina_cxx/eina_cxx_test_ptrarray.cc
@@ -26,9 +26,10 @@ START_TEST(eina_cxx_ptrarray_push_back)
26 int result[] = {5, 10, 15}; 26 int result[] = {5, 10, 15};
27 int rresult[] = {15, 10, 5}; 27 int rresult[] = {15, 10, 5};
28 28
29 wrapper const w1(eo_add(SIMPLE_CLASS, NULL)); 29 Eo* eoptr = nullptr;
30 wrapper const w2(eo_add(SIMPLE_CLASS, NULL)); 30 wrapper const w1(eo_add(&eoptr, SIMPLE_CLASS, NULL));
31 wrapper const w3(eo_add(SIMPLE_CLASS, NULL)); 31 wrapper const w2(eo_add(&eoptr, SIMPLE_CLASS, NULL));
32 wrapper const w3(eo_add(&eoptr, SIMPLE_CLASS, NULL));
32 33
33 { 34 {
34 efl::eina::ptr_array<int> array; 35 efl::eina::ptr_array<int> array;
@@ -102,9 +103,10 @@ START_TEST(eina_cxx_ptrarray_pop_back)
102 ck_assert(std::equal(array.rbegin(), array.rend(), rresult)); 103 ck_assert(std::equal(array.rbegin(), array.rend(), rresult));
103 } 104 }
104 { 105 {
105 wrapper const w1(eo_add(SIMPLE_CLASS, NULL)); 106 Eo* eoptr = nullptr;
106 wrapper const w2(eo_add(SIMPLE_CLASS, NULL)); 107 wrapper const w1(eo_add(&eoptr, SIMPLE_CLASS, NULL));
107 wrapper const w3(eo_add(SIMPLE_CLASS, NULL)); 108 wrapper const w2(eo_add(&eoptr, SIMPLE_CLASS, NULL));
109 wrapper const w3(eo_add(&eoptr, SIMPLE_CLASS, NULL));
108 110
109 efl::eina::array<wrapper> array; 111 efl::eina::array<wrapper> array;
110 112
@@ -197,11 +199,12 @@ START_TEST(eina_cxx_ptrarray_insert)
197 ck_assert(std::equal(array.begin(), array.end(), array4.begin())); 199 ck_assert(std::equal(array.begin(), array.end(), array4.begin()));
198 } 200 }
199 { 201 {
200 wrapper const w0(eo_add(SIMPLE_CLASS, NULL)); 202 Eo* eoptr = nullptr;
201 wrapper const w1(eo_add(SIMPLE_CLASS, NULL)); 203 wrapper const w0(eo_add(&eoptr, SIMPLE_CLASS, NULL));
202 wrapper const w2(eo_add(SIMPLE_CLASS, NULL)); 204 wrapper const w1(eo_add(&eoptr, SIMPLE_CLASS, NULL));
203 wrapper const w3(eo_add(SIMPLE_CLASS, NULL)); 205 wrapper const w2(eo_add(&eoptr, SIMPLE_CLASS, NULL));
204 wrapper const w4(eo_add(SIMPLE_CLASS, NULL)); 206 wrapper const w3(eo_add(&eoptr, SIMPLE_CLASS, NULL));
207 wrapper const w4(eo_add(&eoptr, SIMPLE_CLASS, NULL));
205 208
206 efl::eina::array<wrapper> array; 209 efl::eina::array<wrapper> array;
207 ck_assert(std::distance(array.begin(), array.end()) == 0u); 210 ck_assert(std::distance(array.begin(), array.end()) == 0u);
@@ -277,7 +280,8 @@ START_TEST(eina_cxx_ptrarray_constructors)
277 efl::eina::eina_init eina_init; 280 efl::eina::eina_init eina_init;
278 efl::eo::eo_init eo_init; 281 efl::eo::eo_init eo_init;
279 282
280 wrapper const w1(eo_add(SIMPLE_CLASS, NULL)); 283 Eo* eoptr = nullptr;
284 wrapper const w1(eo_add(&eoptr, SIMPLE_CLASS, NULL));
281 285
282 { 286 {
283 efl::eina::ptr_array<int> array1; 287 efl::eina::ptr_array<int> array1;
@@ -356,12 +360,13 @@ START_TEST(eina_cxx_ptrarray_erase)
356 ck_assert(array1.back() == 25); 360 ck_assert(array1.back() == 25);
357 } 361 }
358 { 362 {
359 wrapper const w1(eo_add(SIMPLE_CLASS, NULL)); 363 Eo* eoptr = nullptr;
360 wrapper const w2(eo_add(SIMPLE_CLASS, NULL)); 364 wrapper const w1(eo_add(&eoptr, SIMPLE_CLASS, NULL));
361 wrapper const w3(eo_add(SIMPLE_CLASS, NULL)); 365 wrapper const w2(eo_add(&eoptr, SIMPLE_CLASS, NULL));
362 wrapper const w4(eo_add(SIMPLE_CLASS, NULL)); 366 wrapper const w3(eo_add(&eoptr, SIMPLE_CLASS, NULL));
363 wrapper const w5(eo_add(SIMPLE_CLASS, NULL)); 367 wrapper const w4(eo_add(&eoptr, SIMPLE_CLASS, NULL));
364 wrapper const w6(eo_add(SIMPLE_CLASS, NULL)); 368 wrapper const w5(eo_add(&eoptr, SIMPLE_CLASS, NULL));
369 wrapper const w6(eo_add(&eoptr, SIMPLE_CLASS, NULL));
365 370
366 efl::eina::array<wrapper> array1; 371 efl::eina::array<wrapper> array1;
367 372
@@ -437,12 +442,13 @@ START_TEST(eina_cxx_ptrarray_range)
437 } 442 }
438 443
439 { 444 {
440 wrapper const w1(eo_add(SIMPLE_CLASS, NULL)); 445 Eo* eoptr = nullptr;
441 wrapper const w2(eo_add(SIMPLE_CLASS, NULL)); 446 wrapper const w1(eo_add(&eoptr, SIMPLE_CLASS, NULL));
442 wrapper const w3(eo_add(SIMPLE_CLASS, NULL)); 447 wrapper const w2(eo_add(&eoptr, SIMPLE_CLASS, NULL));
443 wrapper const w4(eo_add(SIMPLE_CLASS, NULL)); 448 wrapper const w3(eo_add(&eoptr, SIMPLE_CLASS, NULL));
444 wrapper const w5(eo_add(SIMPLE_CLASS, NULL)); 449 wrapper const w4(eo_add(&eoptr, SIMPLE_CLASS, NULL));
445 wrapper const w6(eo_add(SIMPLE_CLASS, NULL)); 450 wrapper const w5(eo_add(&eoptr, SIMPLE_CLASS, NULL));
451 wrapper const w6(eo_add(&eoptr, SIMPLE_CLASS, NULL));
446 452
447 efl::eina::array<wrapper> array; 453 efl::eina::array<wrapper> array;
448 array.push_back(w1); 454 array.push_back(w1);
diff --git a/src/tests/eina_cxx/eina_cxx_test_ptrlist.cc b/src/tests/eina_cxx/eina_cxx_test_ptrlist.cc
index 039ef971bc..2c10263424 100644
--- a/src/tests/eina_cxx/eina_cxx_test_ptrlist.cc
+++ b/src/tests/eina_cxx/eina_cxx_test_ptrlist.cc
@@ -28,9 +28,10 @@ START_TEST(eina_cxx_ptrlist_push_back)
28 int result[] = {5, 10, 15}; 28 int result[] = {5, 10, 15};
29 int rresult[] = {15, 10, 5}; 29 int rresult[] = {15, 10, 5};
30 30
31 wrapper const w1(eo_add(SIMPLE_CLASS, NULL)); 31 Eo* eoptr = nullptr;
32 wrapper const w2(eo_add(SIMPLE_CLASS, NULL)); 32 wrapper const w1(eo_add(&eoptr, SIMPLE_CLASS, NULL));
33 wrapper const w3(eo_add(SIMPLE_CLASS, NULL)); 33 wrapper const w2(eo_add(&eoptr, SIMPLE_CLASS, NULL));
34 wrapper const w3(eo_add(&eoptr, SIMPLE_CLASS, NULL));
34 35
35 { 36 {
36 efl::eina::ptr_list<int> list; 37 efl::eina::ptr_list<int> list;
@@ -77,9 +78,10 @@ START_TEST(eina_cxx_ptrlist_pop_back)
77 int result[] = {5, 10}; 78 int result[] = {5, 10};
78 int rresult[] = {10, 5}; 79 int rresult[] = {10, 5};
79 80
80 wrapper const w1(eo_add(SIMPLE_CLASS, NULL)); 81 Eo* eoptr = nullptr;
81 wrapper const w2(eo_add(SIMPLE_CLASS, NULL)); 82 wrapper const w1(eo_add(&eoptr, SIMPLE_CLASS, NULL));
82 wrapper const w3(eo_add(SIMPLE_CLASS, NULL)); 83 wrapper const w2(eo_add(&eoptr, SIMPLE_CLASS, NULL));
84 wrapper const w3(eo_add(&eoptr, SIMPLE_CLASS, NULL));
83 85
84 { 86 {
85 efl::eina::ptr_list<int> list; 87 efl::eina::ptr_list<int> list;
@@ -143,9 +145,10 @@ START_TEST(eina_cxx_ptrlist_push_front)
143 ck_assert(std::equal(list.rbegin(), list.rend(), rresult)); 145 ck_assert(std::equal(list.rbegin(), list.rend(), rresult));
144 } 146 }
145 { 147 {
146 wrapper const w1(eo_add(SIMPLE_CLASS, NULL)); 148 Eo* eoptr = nullptr;
147 wrapper const w2(eo_add(SIMPLE_CLASS, NULL)); 149 wrapper const w1(eo_add(&eoptr, SIMPLE_CLASS, NULL));
148 wrapper const w3(eo_add(SIMPLE_CLASS, NULL)); 150 wrapper const w2(eo_add(&eoptr, SIMPLE_CLASS, NULL));
151 wrapper const w3(eo_add(&eoptr, SIMPLE_CLASS, NULL));
149 152
150 efl::eina::list<wrapper> list; 153 efl::eina::list<wrapper> list;
151 154
@@ -171,9 +174,10 @@ START_TEST(eina_cxx_ptrlist_pop_front)
171 int result[] = {10, 5}; 174 int result[] = {10, 5};
172 int rresult[] = {5, 10}; 175 int rresult[] = {5, 10};
173 176
174 wrapper const w1(eo_add(SIMPLE_CLASS, NULL)); 177 Eo* eoptr = nullptr;
175 wrapper const w2(eo_add(SIMPLE_CLASS, NULL)); 178 wrapper const w1(eo_add(&eoptr, SIMPLE_CLASS, NULL));
176 wrapper const w3(eo_add(SIMPLE_CLASS, NULL)); 179 wrapper const w2(eo_add(&eoptr, SIMPLE_CLASS, NULL));
180 wrapper const w3(eo_add(&eoptr, SIMPLE_CLASS, NULL));
177 181
178 { 182 {
179 efl::eina::ptr_list<int> list; 183 efl::eina::ptr_list<int> list;
@@ -273,11 +277,12 @@ START_TEST(eina_cxx_ptrlist_insert)
273 ck_assert(std::equal(list.begin(), list.end(), list4.begin())); 277 ck_assert(std::equal(list.begin(), list.end(), list4.begin()));
274 } 278 }
275 { 279 {
276 wrapper const w0(eo_add(SIMPLE_CLASS, NULL)); 280 Eo* eoptr = nullptr;
277 wrapper const w1(eo_add(SIMPLE_CLASS, NULL)); 281 wrapper const w0(eo_add(&eoptr, SIMPLE_CLASS, NULL));
278 wrapper const w2(eo_add(SIMPLE_CLASS, NULL)); 282 wrapper const w1(eo_add(&eoptr, SIMPLE_CLASS, NULL));
279 wrapper const w3(eo_add(SIMPLE_CLASS, NULL)); 283 wrapper const w2(eo_add(&eoptr, SIMPLE_CLASS, NULL));
280 wrapper const w4(eo_add(SIMPLE_CLASS, NULL)); 284 wrapper const w3(eo_add(&eoptr, SIMPLE_CLASS, NULL));
285 wrapper const w4(eo_add(&eoptr, SIMPLE_CLASS, NULL));
281 286
282 efl::eina::list<wrapper> list; 287 efl::eina::list<wrapper> list;
283 288
@@ -366,11 +371,12 @@ START_TEST(eina_cxx_ptrlist_constructors)
366 ck_assert(list2 == list4); 371 ck_assert(list2 == list4);
367 } 372 }
368 { 373 {
369 wrapper const w0(eo_add(SIMPLE_CLASS, NULL)); 374 Eo* eoptr = nullptr;
370 wrapper const w1(eo_add(SIMPLE_CLASS, NULL)); 375 wrapper const w0(eo_add(&eoptr, SIMPLE_CLASS, NULL));
371 wrapper const w2(eo_add(SIMPLE_CLASS, NULL)); 376 wrapper const w1(eo_add(&eoptr, SIMPLE_CLASS, NULL));
372 wrapper const w3(eo_add(SIMPLE_CLASS, NULL)); 377 wrapper const w2(eo_add(&eoptr, SIMPLE_CLASS, NULL));
373 wrapper const w4(eo_add(SIMPLE_CLASS, NULL)); 378 wrapper const w3(eo_add(&eoptr, SIMPLE_CLASS, NULL));
379 wrapper const w4(eo_add(&eoptr, SIMPLE_CLASS, NULL));
374 380
375 efl::eina::list<wrapper> list1; 381 efl::eina::list<wrapper> list1;
376 ck_assert(list1.empty()); 382 ck_assert(list1.empty());