summaryrefslogtreecommitdiff
path: root/src/examples/eolian_cxx
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2014-11-11 20:37:47 -0200
committerVitor Sousa <vitorsousasilva@gmail.com>2015-01-05 15:52:27 -0200
commit132abc353454a2653b5b2b40d6de5f1689323a37 (patch)
tree2184e0c8361e0da179cf72c1071d2e6be4af9af7 /src/examples/eolian_cxx
parented8ce801cb56644c12b395797c3f9e22a508811f (diff)
eolian_cxx: Fix Eolian C++ generated wrapper inconsistencies
In convert.cc: Reading functions instead of implements to convert the Eolian_Class. It avoids creation of methods that do not belong to the class, in special it avoids calling the default constructor twice in the generated code. No longer generating one constructor in the C++ wrapper for each eolian class constructor, since the correct behavior demands that all constructor should be called. Now the wrappers have "constructor methods" that must be called when creating a new object. Updated test cases and examples to match the new interface. Some class constructors and some test cases have to be removed since they were based on the wrong assumption that constructors are mutually exclusive. Created new generators for forwarding parameters and for looping over the relevant parameters to the C++ wrapper executing a generic lambda. Added a TODO comment regarding the call of constructor methods of all base classes. Currently there is no base type with constructors, so this situation should be discussed more. Added a TODO comment regarding the way callback parameters are being processed.
Diffstat (limited to 'src/examples/eolian_cxx')
-rw-r--r--src/examples/eolian_cxx/colourable.c18
-rw-r--r--src/examples/eolian_cxx/colourable.eo10
-rw-r--r--src/examples/eolian_cxx/colourable_cxx.cc12
-rw-r--r--src/examples/eolian_cxx/colourable_stub.h1
-rw-r--r--src/examples/eolian_cxx/eolian_cxx_callbacks_01.cc27
-rw-r--r--src/examples/eolian_cxx/eolian_cxx_inherit_01.cc7
-rw-r--r--src/examples/eolian_cxx/eolian_cxx_simple_01.cc8
-rw-r--r--src/examples/eolian_cxx/eolian_cxx_simple_01_cxx_impl.cc8
8 files changed, 28 insertions, 63 deletions
diff --git a/src/examples/eolian_cxx/colourable.c b/src/examples/eolian_cxx/colourable.c
index a677f64..1c7ff5e 100644
--- a/src/examples/eolian_cxx/colourable.c
+++ b/src/examples/eolian_cxx/colourable.c
@@ -51,24 +51,6 @@ _colourable_eo_base_destructor(Eo *obj, Colourable_Data *self EINA_UNUSED)
51} 51}
52 52
53void 53void
54_colourable_rgb_composite_constructor(Eo *obj, Colourable_Data *self, int r, int g, int b)
55{
56 if(!_colourable_impl_logdomain)
57 {
58 _colourable_impl_logdomain
59 = eina_log_domain_register("colourable", EINA_COLOR_BLUE);
60 }
61 self->r = r;
62 self->g = g;
63 self->b = b;
64 DBG("_colourable_rgb_composite_constructor(0x%2.x, %0x2.x, %0x2.x)\n",
65 (unsigned int)self->r,
66 (unsigned int)self->g,
67 (unsigned int)self->b);
68 eo_do_super(obj, MY_CLASS, eo_constructor());
69}
70
71void
72_colourable_rgb_24bits_constructor(Eo *obj, Colourable_Data *self, int rgb) 54_colourable_rgb_24bits_constructor(Eo *obj, Colourable_Data *self, int rgb)
73{ 55{
74 if(!_colourable_impl_logdomain) 56 if(!_colourable_impl_logdomain)
diff --git a/src/examples/eolian_cxx/colourable.eo b/src/examples/eolian_cxx/colourable.eo
index e0b011b..3693818 100644
--- a/src/examples/eolian_cxx/colourable.eo
+++ b/src/examples/eolian_cxx/colourable.eo
@@ -4,15 +4,6 @@ class Colourable (Eo.Base)
4 legacy_prefix: legacy; 4 legacy_prefix: legacy;
5 data: Colourable_Data; 5 data: Colourable_Data;
6 methods { 6 methods {
7 rgb_composite_constructor {
8 /*@ Composite RGB Constructor. */
9 legacy: null;
10 params {
11 @in int r; /*@ The red component. */
12 @in int g; /*@ The green component. */
13 @in int b; /*@ The blue component. */
14 }
15 }
16 rgb_24bits_constructor { 7 rgb_24bits_constructor {
17 /*@ RGB Constructor. */ 8 /*@ RGB Constructor. */
18 legacy: null; 9 legacy: null;
@@ -60,7 +51,6 @@ class Colourable (Eo.Base)
60 Eo.Base.destructor; 51 Eo.Base.destructor;
61 } 52 }
62 constructors { 53 constructors {
63 .rgb_composite_constructor;
64 .rgb_24bits_constructor; 54 .rgb_24bits_constructor;
65 } 55 }
66 events { 56 events {
diff --git a/src/examples/eolian_cxx/colourable_cxx.cc b/src/examples/eolian_cxx/colourable_cxx.cc
index 4d9ef78..bd4fa46 100644
--- a/src/examples/eolian_cxx/colourable_cxx.cc
+++ b/src/examples/eolian_cxx/colourable_cxx.cc
@@ -35,18 +35,6 @@ _colourable_eo_base_destructor(Eo *obj, Colourable_Data *self EINA_UNUSED)
35} 35}
36 36
37void 37void
38_colourable_rgb_composite_constructor(Eo *obj, Colourable_Data *self, int r, int g, int b)
39{
40 EINA_CXX_DOM_LOG_DBG(domain) << std::showbase << std::hex
41 << __func__ << " [ (r, g, b) = ("
42 << r << ", " << g << ", " << b << ") ]" << std::endl;
43 self->r = r;
44 self->g = g;
45 self->b = b;
46 eo_do_super(obj, MY_CLASS, eo_constructor());
47}
48
49void
50_colourable_rgb_24bits_constructor(Eo *obj, Colourable_Data *self, int rgb) 38_colourable_rgb_24bits_constructor(Eo *obj, Colourable_Data *self, int rgb)
51{ 39{
52 EINA_CXX_DOM_LOG_DBG(domain) << std::showbase << std::hex 40 EINA_CXX_DOM_LOG_DBG(domain) << std::showbase << std::hex
diff --git a/src/examples/eolian_cxx/colourable_stub.h b/src/examples/eolian_cxx/colourable_stub.h
index ae3ac94..f6d758c 100644
--- a/src/examples/eolian_cxx/colourable_stub.h
+++ b/src/examples/eolian_cxx/colourable_stub.h
@@ -15,7 +15,6 @@ typedef struct _Colourable_Data Colourable_Data;
15 15
16void _colourable_eo_base_constructor(Eo *obj, Colourable_Data *self); 16void _colourable_eo_base_constructor(Eo *obj, Colourable_Data *self);
17void _colourable_eo_base_destructor(Eo *obj, Colourable_Data *self); 17void _colourable_eo_base_destructor(Eo *obj, Colourable_Data *self);
18void _colourable_rgb_composite_constructor(Eo *obj, Colourable_Data *self, int r, int g, int b);
19void _colourable_rgb_24bits_constructor(Eo *obj, Colourable_Data *self, int rgb); 18void _colourable_rgb_24bits_constructor(Eo *obj, Colourable_Data *self, int rgb);
20void _colourable_print_colour(Eo *obj, Colourable_Data *self); 19void _colourable_print_colour(Eo *obj, Colourable_Data *self);
21void _colourable_print_colour(Eo *obj, Colourable_Data *self); 20void _colourable_print_colour(Eo *obj, Colourable_Data *self);
diff --git a/src/examples/eolian_cxx/eolian_cxx_callbacks_01.cc b/src/examples/eolian_cxx/eolian_cxx_callbacks_01.cc
index 2c64784..8c41c0e 100644
--- a/src/examples/eolian_cxx/eolian_cxx_callbacks_01.cc
+++ b/src/examples/eolian_cxx/eolian_cxx_callbacks_01.cc
@@ -27,20 +27,21 @@ void
27example_callbacks() 27example_callbacks()
28{ 28{
29 int count = 0; 29 int count = 0;
30 efl::ecore::poller poller 30 efl::ecore::poller poller(
31 (ECORE_POLLER_CORE, 1, 31 poller.ecore_poller_constructor(ECORE_POLLER_CORE, 1,
32 [&count, &poller] 32 [&count, &poller]
33 { 33 {
34 if (++count == 5) 34 if (++count == 5)
35 { 35 {
36 std::cout << std::endl; 36 std::cout << std::endl;
37 ecore_main_loop_quit(); 37 ecore_main_loop_quit();
38 return false; 38 return false;
39 } 39 }
40 poller.interval_set(2*poller.interval_get()); 40 poller.interval_set(2*poller.interval_get());
41 std::cout << "."<< std::flush; 41 std::cout << "." << std::flush;
42 return true; 42 return true;
43 }); 43 })
44 );
44 ::ecore_main_loop_begin(); 45 ::ecore_main_loop_begin();
45} 46}
46 47
diff --git a/src/examples/eolian_cxx/eolian_cxx_inherit_01.cc b/src/examples/eolian_cxx/eolian_cxx_inherit_01.cc
index b3fe196..b258f05 100644
--- a/src/examples/eolian_cxx/eolian_cxx_inherit_01.cc
+++ b/src/examples/eolian_cxx/eolian_cxx_inherit_01.cc
@@ -16,10 +16,6 @@ using namespace efl;
16struct ColourableCircle 16struct ColourableCircle
17 : efl::eo::inherit<ColourableCircle, ::colourable> 17 : efl::eo::inherit<ColourableCircle, ::colourable>
18{ 18{
19 ColourableCircle(int r, int g, int b)
20 : inherit_base(r, g, b)
21 {}
22
23 ColourableCircle(int rgb) 19 ColourableCircle(int rgb)
24 : inherit_base(efl::eo::args<::colourable>(rgb)) 20 : inherit_base(efl::eo::args<::colourable>(rgb))
25 {} 21 {}
@@ -52,7 +48,8 @@ main()
52 efl::eo::eo_init init; 48 efl::eo::eo_init init;
53 eina_log_domain_level_set("colourable", EINA_LOG_LEVEL_DBG); 49 eina_log_domain_level_set("colourable", EINA_LOG_LEVEL_DBG);
54 50
55 ColourableCircle obj1(0xc0, 0xff, 0xee); 51 ColourableCircle obj1(0x0);
52 obj1.composite_colour_set(0xc0, 0xff, 0xee);
56 53
57 ColourableCircle obj2(0xc0ffee); 54 ColourableCircle obj2(0xc0ffee);
58 int r, g, b; 55 int r, g, b;
diff --git a/src/examples/eolian_cxx/eolian_cxx_simple_01.cc b/src/examples/eolian_cxx/eolian_cxx_simple_01.cc
index c64a93c..47b98cb 100644
--- a/src/examples/eolian_cxx/eolian_cxx_simple_01.cc
+++ b/src/examples/eolian_cxx/eolian_cxx_simple_01.cc
@@ -18,11 +18,15 @@ main()
18 eina_log_domain_level_set("colourablesquare", EINA_LOG_LEVEL_DBG); 18 eina_log_domain_level_set("colourablesquare", EINA_LOG_LEVEL_DBG);
19 19
20 int r, g, b; 20 int r, g, b;
21 ::colourable obj1(0x123456); 21 ::colourable obj1(
22 obj1.colourable_rgb_24bits_constructor(0x123456)
23 );
22 obj1.colour_set(0xc0ffee); 24 obj1.colour_set(0xc0ffee);
23 obj1.composite_colour_get(&r, &g, &b); 25 obj1.composite_colour_get(&r, &g, &b);
24 26
25 ::colourablesquare obj2(10); 27 ::colourablesquare obj2(
28 obj2.colourablesquare_size_constructor(10)
29 );
26 obj2.composite_colour_set(r, g, b); 30 obj2.composite_colour_set(r, g, b);
27 obj2.size_set(11); 31 obj2.size_set(11);
28 assert(obj1.colour_get() == obj2.colour_get()); 32 assert(obj1.colour_get() == obj2.colour_get());
diff --git a/src/examples/eolian_cxx/eolian_cxx_simple_01_cxx_impl.cc b/src/examples/eolian_cxx/eolian_cxx_simple_01_cxx_impl.cc
index 0a35f93..1120978 100644
--- a/src/examples/eolian_cxx/eolian_cxx_simple_01_cxx_impl.cc
+++ b/src/examples/eolian_cxx/eolian_cxx_simple_01_cxx_impl.cc
@@ -18,11 +18,15 @@ main()
18 eina_log_domain_level_set("colourablesquare", EINA_LOG_LEVEL_DBG); 18 eina_log_domain_level_set("colourablesquare", EINA_LOG_LEVEL_DBG);
19 19
20 int r, g, b; 20 int r, g, b;
21 ::colourable obj1(0x123456); 21 ::colourable obj1(
22 obj1.colourable_rgb_24bits_constructor(0x123456)
23 );
22 obj1.colour_set(0xc0ffee); 24 obj1.colour_set(0xc0ffee);
23 obj1.composite_colour_get(&r, &g, &b); 25 obj1.composite_colour_get(&r, &g, &b);
24 26
25 ::colourablesquare obj2(0x123456); 27 ::colourablesquare obj2(
28 obj2.colourablesquare_size_constructor(0x123456)
29 );
26 obj2.composite_colour_set(r, g, b); 30 obj2.composite_colour_set(r, g, b);
27 obj2.size_set(11); 31 obj2.size_set(11);
28 assert(obj1.colour_get() == obj2.colour_get()); 32 assert(obj1.colour_get() == obj2.colour_get());