summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-06-06 02:54:36 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-06-06 02:54:36 -0300
commit2a3d7860dbc11458425e162cd69ee399e9025251 (patch)
tree84c5b21b644c4cf8806a8eee07b4ed81922c92b4 /src/tests
parent4d1b3191d94fcc70472552b1bb554984a9cb0288 (diff)
eolian-cxx: Rewrite to accomodate new features of the C++ binding
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/eolian_cxx/callback.c56
-rw-r--r--src/tests/eolian_cxx/callback.eo36
-rw-r--r--src/tests/eolian_cxx/complex.c5
-rw-r--r--src/tests/eolian_cxx/complex.eo80
-rw-r--r--src/tests/eolian_cxx/complex_cxx.cc22
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_suite.cc1
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_suite.h1
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_binding.cc172
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_callback.cc184
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_generate.cc60
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_inheritance.cc56
-rw-r--r--src/tests/eolian_cxx/eolian_cxx_test_wrapper.cc4
-rw-r--r--src/tests/eolian_cxx/generic.c89
-rw-r--r--src/tests/eolian_cxx/generic.eo64
-rw-r--r--src/tests/eolian_cxx/name1_name2_type_generation.c240
-rw-r--r--src/tests/eolian_cxx/name1_name2_type_generation.eo220
-rw-r--r--src/tests/eolian_cxx/name_name_cxx.cc4
17 files changed, 943 insertions, 351 deletions
diff --git a/src/tests/eolian_cxx/callback.c b/src/tests/eolian_cxx/callback.c
deleted file mode 100644
index aee32370cb..0000000000
--- a/src/tests/eolian_cxx/callback.c
+++ /dev/null
@@ -1,56 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6
7#include <Eo.h>
8#include <Ecore.h>
9
10#include "callback.eo.h"
11
12struct _Callback_Data
13{
14 int callbacks;
15};
16typedef struct _Callback_Data Callback_Data;
17
18#define MY_CLASS CALLBACK_CLASS
19
20static Eina_Bool _callback_callback_added(void* data EINA_UNUSED, Eo_Event const* event)
21{
22 Callback_Data* pd = event->info;
23 ++pd->callbacks;
24 eo_event_callback_call(event->object, CALLBACK_EVENT_CALL_ON_ADD, &pd->callbacks);
25 return EINA_TRUE;
26}
27
28static Eo *_callback_eo_base_constructor(Eo *obj, Callback_Data *pd EINA_UNUSED)
29{
30 pd->callbacks = 0;
31 obj = eo_constructor(eo_super(obj, MY_CLASS));
32
33 eo_event_callback_priority_add(obj, EO_EVENT_CALLBACK_ADD, EO_CALLBACK_PRIORITY_DEFAULT
34 , &_callback_callback_added, pd);
35
36 return obj;
37}
38
39static void _callback_onecallback(Eo *obj EINA_UNUSED, Callback_Data *pd EINA_UNUSED, Ecore_Cb cb, void *data)
40{
41 cb(data);
42}
43
44static void _callback_twocallback(Eo *obj EINA_UNUSED, Callback_Data *pd EINA_UNUSED, Ecore_Cb cb, void *data
45 , Ecore_Cb cb2 EINA_UNUSED)
46{
47 cb(data);
48}
49
50static void _callback_test_global_callbacks(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED
51 , Ecore_Cb cb, void *data)
52{
53 cb(data);
54}
55
56#include "callback.eo.c"
diff --git a/src/tests/eolian_cxx/callback.eo b/src/tests/eolian_cxx/callback.eo
index c05f64e293..9860281d6f 100644
--- a/src/tests/eolian_cxx/callback.eo
+++ b/src/tests/eolian_cxx/callback.eo
@@ -1,33 +1,19 @@
1import ecore_types; 1import ecore_types;
2 2
3struct Callback_Event
4{
5 field1: int;
6 field2: list<int*>;
7}
8
3class Callback (Eo.Base) 9class Callback (Eo.Base)
4{ 10{
5 data: Callback_Data; 11 data: Callback_Data;
6 methods {
7 onecallback {
8 params {
9 @in cb: Ecore_Cb;
10 @in data: void_ptr;
11 }
12 }
13 twocallback {
14 params {
15 @in cb: Ecore_Cb;
16 @in data: void_ptr;
17 @in cb2: Ecore_Cb;
18 }
19 }
20 test_global_callbacks @class {
21 params {
22 @in cb: Ecore_Cb;
23 @in data: void_ptr;
24 }
25 }
26 }
27 implements {
28 Eo.Base.constructor;
29 }
30 events { 12 events {
31 call_on_add; 13 prefix,event1;
14 prefix,event2: Callback;
15 prefix,event3: int;
16 prefix,event4: list<int*>;
17 prefix,event5: Callback_Event;
32 } 18 }
33} 19}
diff --git a/src/tests/eolian_cxx/complex.c b/src/tests/eolian_cxx/complex.c
index a61072bdc1..2eb381c045 100644
--- a/src/tests/eolian_cxx/complex.c
+++ b/src/tests/eolian_cxx/complex.c
@@ -1,4 +1,9 @@
1 1
2#ifdef HAVE_CONFIG_H
3#include "config.h"
4#endif
5
6#include <Eina.h>
2#include <Eo.h> 7#include <Eo.h>
3 8
4struct Complex_Data {}; 9struct Complex_Data {};
diff --git a/src/tests/eolian_cxx/complex.eo b/src/tests/eolian_cxx/complex.eo
index b84cd09964..d7672e7182 100644
--- a/src/tests/eolian_cxx/complex.eo
+++ b/src/tests/eolian_cxx/complex.eo
@@ -2,6 +2,68 @@ class Complex (Eo.Base)
2{ 2{
3 data: Complex_Data; 3 data: Complex_Data;
4 methods { 4 methods {
5 // container test
6 inptrcont {
7 params {
8 l: list<int*>;
9 }
10 }
11 inclasscont {
12 params {
13 l: list<Eo.Base>;
14 }
15 }
16 inptrptrcont {
17 params {
18 l: list<int**>;
19 }
20 }
21 inptrcontown {
22 params {
23 l: own(list<int*>);
24 }
25 }
26 inptrptrcontown {
27 params {
28 l: own(list<int**>);
29 }
30 }
31 incontcont {
32 params {
33 l: list<list<int*>>;
34 }
35 }
36 incontcontown {
37 params {
38 l: own(list<list<int*>>);
39 }
40 }
41 incontowncontown {
42 params {
43 l: own(list<own(list<int*>)>);
44 }
45 }
46 incontowncont {
47 params {
48 l: list<own(list<int*>)>;
49 }
50 }
51 instringcont {
52 params {
53 l: list<string>;
54 }
55 }
56 instringowncont {
57 params {
58 l: list<own(string)>;
59 }
60 }
61 instringcontown {
62 params {
63 l: own(list<string>);
64 }
65 }
66
5 foo { 67 foo {
6 params { 68 params {
7 l: list<int*>; 69 l: list<int*>;
@@ -28,6 +90,24 @@ class Complex (Eo.Base)
28 @out a1: Complex; 90 @out a1: Complex;
29 } 91 }
30 } 92 }
93 with_promise_r {
94 return: promise<int>;
95 }
96 with_promise_in {
97 params {
98 @in p: promise<int>;
99 }
100 }
101 with_promise_out {
102 params {
103 @out p: promise<int>;
104 }
105 }
106 with_promise_inout {
107 params {
108 @inout p: promise<int>;
109 }
110 }
31 } 111 }
32} 112}
33 113
diff --git a/src/tests/eolian_cxx/complex_cxx.cc b/src/tests/eolian_cxx/complex_cxx.cc
index b43e8be1ff..72f4608b7f 100644
--- a/src/tests/eolian_cxx/complex_cxx.cc
+++ b/src/tests/eolian_cxx/complex_cxx.cc
@@ -1,4 +1,9 @@
1 1
2#ifdef HAVE_CONFIG_H
3#include "config.h"
4#endif
5
6#include <Eina.h>
2#include <Eo.h> 7#include <Eo.h>
3 8
4#include "complex.eo.h" 9#include "complex.eo.h"
@@ -32,9 +37,22 @@ struct test_param_type<void(T::*)(P), U>
32 static_assert(std::is_same<P, U>::value, "Wrong type"); 37 static_assert(std::is_same<P, U>::value, "Wrong type");
33}; 38};
34 39
40test_param_type<typeof( & nonamespace::Complex::inptrcont ), efl::eina::range_list<int>> inptrcont;
41test_param_type<typeof( & nonamespace::Complex::inclasscont ), efl::eina::range_list<eo::Base>> inclasscont;
42test_param_type<typeof( & nonamespace::Complex::inptrptrcont ), efl::eina::range_list<int*>> inptrptrcont;
43test_param_type<typeof( & nonamespace::Complex::inptrcontown ), efl::eina::list<int>const&> inptrcontown;
44test_param_type<typeof( & nonamespace::Complex::inptrptrcontown ), efl::eina::list<int*>const&> inptrptrcontown;
45test_param_type<typeof( & nonamespace::Complex::incontcont ), efl::eina::range_list<efl::eina::range_list<int>>> incontont;
46test_param_type<typeof( & nonamespace::Complex::incontcontown ), efl::eina::list<efl::eina::range_list<int>>const&> incontcontown;
47test_param_type<typeof( & nonamespace::Complex::incontowncontown ), efl::eina::list<efl::eina::list<int>>const&> incontowncontown;
48test_param_type<typeof( & nonamespace::Complex::incontowncont ), efl::eina::range_list<efl::eina::list<int>>> incontowncont;
49test_param_type<typeof( & nonamespace::Complex::instringcont ), efl::eina::range_list<efl::eina::string_view>> instringcont;
50test_param_type<typeof( & nonamespace::Complex::instringowncont ), efl::eina::range_list<efl::eina::string_view>> instringowncont;
51test_param_type<typeof( & nonamespace::Complex::instringcontown ), efl::eina::list<efl::eina::string_view>const&> instringcontown;
52
35test_param_type<typeof( & nonamespace::Complex::foo ), efl::eina::range_list<int>> foo; 53test_param_type<typeof( & nonamespace::Complex::foo ), efl::eina::range_list<int>> foo;
36test_return_type<typeof( & nonamespace::Complex::bar ), efl::eina::range_array<int>> bar; 54test_return_type<typeof( & nonamespace::Complex::bar ), efl::eina::range_array<int>> bar;
37test_return_type<typeof( & nonamespace::Complex::wrapper_r ), nonamespace::Complex> wrapper_r; 55test_return_type<typeof( & nonamespace::Complex::wrapper_r ), nonamespace::Complex> wrapper_r;
38test_param_type<typeof( & nonamespace::Complex::wrapper_in ), nonamespace::Complex> wrapper_in; 56test_param_type<typeof( & nonamespace::Complex::wrapper_in ), nonamespace::Complex> wrapper_in;
39test_param_type<typeof( & nonamespace::Complex::wrapper_inout ), nonamespace::Complex*> wrapper_inout; 57test_param_type<typeof( & nonamespace::Complex::wrapper_inout ), nonamespace::Complex&> wrapper_inout;
40test_param_type<typeof( & nonamespace::Complex::wrapper_out ), nonamespace::Complex*> wrapper_out; 58test_param_type<typeof( & nonamespace::Complex::wrapper_out ), nonamespace::Complex&> wrapper_out;
diff --git a/src/tests/eolian_cxx/eolian_cxx_suite.cc b/src/tests/eolian_cxx/eolian_cxx_suite.cc
index f925b09edf..562eb82ebf 100644
--- a/src/tests/eolian_cxx/eolian_cxx_suite.cc
+++ b/src/tests/eolian_cxx/eolian_cxx_suite.cc
@@ -9,7 +9,6 @@ static const Efl_Test_Case etc[] = {
9 { "Eolian-Cxx Parsing", eolian_cxx_test_parse }, 9 { "Eolian-Cxx Parsing", eolian_cxx_test_parse },
10 { "Eolian-Cxx Wrapper", eolian_cxx_test_wrapper }, 10 { "Eolian-Cxx Wrapper", eolian_cxx_test_wrapper },
11 { "Eolian-Cxx Generation", eolian_cxx_test_generate }, 11 { "Eolian-Cxx Generation", eolian_cxx_test_generate },
12 { "Eolian-Cxx Callback", eolian_cxx_test_callback },
13 { "Eolian-Cxx Address_of", eolian_cxx_test_address_of }, 12 { "Eolian-Cxx Address_of", eolian_cxx_test_address_of },
14 { "Eolian-Cxx Inheritance", eolian_cxx_test_inheritance }, 13 { "Eolian-Cxx Inheritance", eolian_cxx_test_inheritance },
15 { "Eolian-Cxx Binding", eolian_cxx_test_binding }, 14 { "Eolian-Cxx Binding", eolian_cxx_test_binding },
diff --git a/src/tests/eolian_cxx/eolian_cxx_suite.h b/src/tests/eolian_cxx/eolian_cxx_suite.h
index 73e6dc2169..451154a325 100644
--- a/src/tests/eolian_cxx/eolian_cxx_suite.h
+++ b/src/tests/eolian_cxx/eolian_cxx_suite.h
@@ -6,7 +6,6 @@
6void eolian_cxx_test_parse(TCase* tc); 6void eolian_cxx_test_parse(TCase* tc);
7void eolian_cxx_test_wrapper(TCase* tc); 7void eolian_cxx_test_wrapper(TCase* tc);
8void eolian_cxx_test_generate(TCase* tc); 8void eolian_cxx_test_generate(TCase* tc);
9void eolian_cxx_test_callback(TCase* tc);
10void eolian_cxx_test_address_of(TCase* tc); 9void eolian_cxx_test_address_of(TCase* tc);
11void eolian_cxx_test_inheritance(TCase* tc); 10void eolian_cxx_test_inheritance(TCase* tc);
12void eolian_cxx_test_binding(TCase* tc); 11void eolian_cxx_test_binding(TCase* tc);
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_binding.cc b/src/tests/eolian_cxx/eolian_cxx_test_binding.cc
index b705e67732..83cb394658 100644
--- a/src/tests/eolian_cxx/eolian_cxx_test_binding.cc
+++ b/src/tests/eolian_cxx/eolian_cxx_test_binding.cc
@@ -2,7 +2,10 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include <Ecore.h>
6
5#include <generic.eo.hh> 7#include <generic.eo.hh>
8#include <name1_name2_type_generation.eo.hh>
6 9
7#include "eolian_cxx_suite.h" 10#include "eolian_cxx_suite.h"
8 11
@@ -10,18 +13,17 @@ START_TEST(eolian_cxx_test_binding_constructor_only_required)
10{ 13{
11 efl::eo::eo_init i; 14 efl::eo::eo_init i;
12 15
13 bool called1 = false; 16 nonamespace::Generic g
14 17 (
15 nonamespace::Generic g( 18 [&]
16 g.required_ctor_a(1), 19 {
17 g.required_ctor_b(std::bind([&called1] { called1 = true; })) 20 g.required_ctor_a(1);
18 ); 21 g.required_ctor_b(2);
22 }
23 );
19 24
20 g.call_req_ctor_b_callback();
21 g.call_opt_ctor_b_callback();
22
23 fail_if(!called1);
24 fail_if(1 != g.req_ctor_a_value_get()); 25 fail_if(1 != g.req_ctor_a_value_get());
26 fail_if(2 != g.req_ctor_b_value_get());
25} 27}
26END_TEST 28END_TEST
27 29
@@ -29,23 +31,142 @@ START_TEST(eolian_cxx_test_binding_constructor_all_optionals)
29{ 31{
30 efl::eo::eo_init i; 32 efl::eo::eo_init i;
31 33
32 bool called1 = false; 34 nonamespace::Generic g
33 bool called2 = false; 35 (
34 36 [&]
35 nonamespace::Generic g( 37 {
36 g.required_ctor_a(2), 38 g.required_ctor_a(2);
37 g.required_ctor_b(std::bind([&called1] { called1 = true; })), 39 g.required_ctor_b(4);
38 g.optional_ctor_a(3), 40 g.optional_ctor_a(3);
39 g.optional_ctor_b(std::bind([&called2] { called2 = true; })) 41 g.optional_ctor_b(5);
40 ); 42 }
43 );
41 44
42 g.call_req_ctor_b_callback();
43 g.call_opt_ctor_b_callback();
44
45 fail_if(!called1);
46 fail_if(!called2);
47 fail_if(2 != g.req_ctor_a_value_get()); 45 fail_if(2 != g.req_ctor_a_value_get());
48 fail_if(3 != g.opt_ctor_a_value_get()); 46 fail_if(3 != g.opt_ctor_a_value_get());
47 fail_if(4 != g.req_ctor_b_value_get());
48 fail_if(5 != g.opt_ctor_b_value_get());
49}
50END_TEST
51
52START_TEST(eolian_cxx_test_type_generation)
53{
54 efl::eo::eo_init eo_init;
55
56 name1::name2::Type_Generation g;
57
58 g.invoidptr(nullptr);
59 g.inint(42);
60 std::unique_ptr<int> i (new int(42));
61 g.inintptr(i.get());
62 {
63 int* p = (int*)malloc(sizeof(int));
64 *p = 42;
65 std::unique_ptr<int, void(*)(const void*)> inintptrown(p, (void(*)(const void*))&free);
66 g.inintptrown(std::move(inintptrown));
67 }
68 {
69 int** p = (int**)malloc(sizeof(int*));
70 *p = (int*)malloc(sizeof(int));
71 **p = 42;
72 std::unique_ptr<int*, void(*)(const void*)> inintptrownptr(p, (void(*)(const void*))&free);
73 g.inintptrownptr(std::move(inintptrownptr));
74 }
75 {
76 int*** p = (int***)malloc(sizeof(int**));
77 *p = (int**)malloc(sizeof(int*));
78 **p = (int*)malloc(sizeof(int));
79 ***p = 42;
80 std::unique_ptr<int**, void(*)(const void*)> inintptrownptrptr(p, (void(*)(const void*))&free);
81 g.inintptrownptrptr(std::move(inintptrownptrptr));
82 }
83 {
84 int*** p = (int***)malloc(sizeof(int**));
85 *p = (int**)malloc(sizeof(int*));
86 **p = (int*)malloc(sizeof(int));
87 ***p = 42;
88 std::unique_ptr<int**, void(*)(const void*)> inintptrptrownptr(p, (void(*)(const void*))&free);
89 g.inintptrptrownptr(std::move(inintptrptrownptr));
90 }
91 {
92 int* p = (int*)malloc(sizeof(int));
93 *p = 42;
94 std::unique_ptr<int, void(*)(const void*)> inintptrownfree(p, (void(*)(const void*))&free);
95 g.inintptrownfree(std::move(inintptrownfree));
96 }
97 g.instring("foobar");
98 // {
99 // efl::eina::string_view v("foobar");
100 // g.instringptr(&v);
101 // }
102 g.instringown("foobar");
103 // {
104 // std::string v("foobar");
105 // g.instringptrown(&v);
106 // }
107 // {
108 // std::unique_ptr<efl::eina::string_view, void(*)(const void*)> v
109 // ((efl::eina::string_view*)malloc(sizeof(string_view)), (void(*)(const void*))&free);
110 // g.instringptrown(v);
111 // }
112 // {
113 // std::string v("foobar");
114 // g.instringptrown(&v);
115 // }
116}
117END_TEST
118
119START_TEST(eolian_cxx_test_type_generation_in)
120{
121 efl::eo::eo_init i;
122
123 name1::name2::Type_Generation g;
124}
125END_TEST
126
127START_TEST(eolian_cxx_test_type_callback)
128{
129 efl::eo::eo_init i;
130
131 bool event1 = false, event2 = false, event3 = false, event4 = false
132 , event5 = false;
133
134 nonamespace::Generic g;
135 efl::eolian::event_add(g.prefix_event1_event, g, [&] (nonamespace::Generic)
136 {
137 event1 = true;
138 });
139 efl::eolian::event_add(g.prefix_event2_event, g, [&] (nonamespace::Generic, nonamespace::Generic)
140 {
141 event2 = true;
142 });
143 efl::eolian::event_add(g.prefix_event3_event, g, [&] (nonamespace::Generic, int v)
144 {
145 event3 = true;
146 ck_assert(v == 42);
147 });
148 efl::eolian::event_add(g.prefix_event4_event, g, [&] (nonamespace::Generic, efl::eina::range_list<int> e)
149 {
150 event4 = true;
151 ck_assert(e.size() == 1);
152 ck_assert(*e.begin() == 42);
153 });
154 efl::eolian::event_add(g.prefix_event5_event, g, [&] (nonamespace::Generic, Generic_Event)
155 {
156 event5 = true;
157 });
158
159 g.call_event1();
160 g.call_event2();
161 g.call_event3();
162 g.call_event4();
163 g.call_event5();
164
165 ck_assert(event1);
166 ck_assert(event2);
167 ck_assert(event3);
168 ck_assert(event4);
169 ck_assert(event5);
49} 170}
50END_TEST 171END_TEST
51 172
@@ -54,4 +175,7 @@ eolian_cxx_test_binding(TCase* tc)
54{ 175{
55 tcase_add_test(tc, eolian_cxx_test_binding_constructor_only_required); 176 tcase_add_test(tc, eolian_cxx_test_binding_constructor_only_required);
56 tcase_add_test(tc, eolian_cxx_test_binding_constructor_all_optionals); 177 tcase_add_test(tc, eolian_cxx_test_binding_constructor_all_optionals);
178 tcase_add_test(tc, eolian_cxx_test_type_generation);
179 tcase_add_test(tc, eolian_cxx_test_type_generation_in);
180 tcase_add_test(tc, eolian_cxx_test_type_callback);
57} 181}
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_callback.cc b/src/tests/eolian_cxx/eolian_cxx_test_callback.cc
deleted file mode 100644
index c22141307f..0000000000
--- a/src/tests/eolian_cxx/eolian_cxx_test_callback.cc
+++ /dev/null
@@ -1,184 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <iostream>
6#include <vector>
7#include <algorithm>
8#include <functional>
9
10#include <Eo.h>
11#include <Ecore.h>
12
13#include <callback.eo.hh>
14
15#include "eolian_cxx_suite.h"
16
17void foo(void*) {}
18
19START_TEST(eolian_cxx_test_callback_method)
20{
21 efl::eo::eo_init i;
22
23 nonamespace::Callback c;
24
25 bool called1 = false, called2 = false;
26
27 c.onecallback(std::bind([&called1] { called1 = true; }));
28 c.twocallback(std::bind([&called2] { called2 = true; }), &foo);
29
30 fail_if(!called1);
31 fail_if(!called2);
32}
33END_TEST
34
35START_TEST(eolian_cxx_test_callback_event_add)
36{
37 efl::eo::eo_init i;
38
39 nonamespace::Callback c;
40
41 bool called1 = false, called2 = false;
42
43
44 c.callback_call_on_add_add(std::bind([&called1] { called1 = true; }));
45 c.callback_call_on_add_add(std::bind([&called2] { called2 = true; }));
46
47 fail_if(!called1);
48 fail_if(!called2);
49}
50END_TEST
51
52START_TEST(eolian_cxx_test_callback_event_del)
53{
54 efl::eo::eo_init i;
55
56 nonamespace::Callback c;
57
58 int called1 = 0, called2 = 0, called3 = 0, called4 = 0;
59
60 efl::eo::signal_connection s1 = c.callback_call_on_add_add
61 (std::bind([&]
62 {
63 std::cerr << "called1 " << called1 << " called2 " << called2 << " called3 " << called3
64 << " called4 " << called4 << " 1" << std::endl;
65 fail_if(!( (called1 == 0 && called2 == 0 && called3 == 0 && called4 == 0)
66 || (called1 == 1 && called2 == 1 && called3 == 0 && called4 == 0)
67 ));
68 ++called1;
69 }));
70 efl::eo::signal_connection s2 = c.callback_call_on_add_add
71 (std::bind([&]
72 {
73 std::cerr << "called1 " << called1 << " called2 " << called2 << " called3 " << called3
74 << " called4 " << called4 << " 2" << std::endl;
75 fail_if(!( (called1 == 1 && called2 == 0 && called3 == 0 && called4 == 0)
76 || (called1 == 1 && called2 == 1 && called3 == 0 && called4 == 0)
77 || (called1 == 2 && called2 == 1 && called3 == 1 && called4 == 0)
78 ));
79 ++called2;
80 }));
81
82 s1.disconnect();
83
84 c.callback_call_on_add_add
85 (
86 std::bind([&]
87 {
88 std::cerr << "called1 " << called1 << " called2 " << called2 << " called3 " << called3
89 << " called4 " << called4 << " 3" << std::endl;
90 fail_if(!( (called1 == 2 && called2 == 1 && called3 == 0 && called4 == 0)
91 || (called1 == 2 && called2 == 2 && called3 == 1 && called4 == 1)
92 ));
93 ++called3;
94 }));
95
96 s2.disconnect();
97
98 c.callback_call_on_add_add
99 (
100 std::bind([&]
101 {
102 std::cerr << "called1 " << called1 << " called2 " << called2 << " called3 " << called3
103 << " called4 " << called4 << " 4" << std::endl;
104 fail_if(!( (called1 == 2 && called2 == 2 && called3 == 1 && called4 == 0)
105 ));
106 ++called4;
107 }));
108
109 fail_if(called1 != 2);
110 fail_if(called2 != 2);
111 fail_if(called3 != 2);
112 fail_if(called4 != 1);
113}
114END_TEST
115
116START_TEST(eolian_cxx_test_global_callback)
117{
118 efl::eo::eo_init i;
119
120 bool called = false;
121
122 nonamespace::Callback::test_global_callbacks(std::bind([&called] { called = true; }));
123
124 fail_if(!called);
125}
126END_TEST
127
128START_TEST(eolian_cxx_test_disconnect_inside_callback)
129{
130 efl::eo::eo_init i;
131 nonamespace::Callback c;
132
133 std::vector<long> capture_me;
134 int times_called = 0;
135
136 ::efl::eo::signal_connection sig(nullptr);
137 sig = c.callback_callback_add_add(
138 std::bind([&sig, &capture_me, &times_called](void *info)
139 {
140 ++times_called;
141 std::cout << "times_called: " << times_called << std::endl;
142 std::cout << "&sig: " << &sig << std::endl;
143 if (times_called <= 1)
144 return;
145
146 sig.disconnect();
147
148 long* info_l = static_cast<long*>(info);
149 std::cout << "info: " << info << std::endl;
150 std::cout << "*info_l: " << *info_l << std::endl;
151
152 fail_if(*info_l != 42);
153
154 capture_me = {9, 0, 8, 1, 7, 2, 6, 3, 5, 4};
155 std::sort(capture_me.begin(), capture_me.end());
156
157 capture_me[0] = capture_me[1] + +capture_me[2] + capture_me[9];
158
159 std::cout << "&capture_me: " << &capture_me << std::endl;
160 std::cout << "capture_me [0] [9]: [" << capture_me[0] << "] ["<< capture_me[9] << "]" << std::endl;
161
162 fail_if(capture_me.size() != 10);
163 fail_if(capture_me[0] != 12);
164 fail_if(times_called != 2);
165 }, std::placeholders::_3));
166
167 long n = 42;
168 c.callback_callback_add_call(&n);
169
170 fail_if(capture_me.size() != 10);
171 fail_if(capture_me[0] != 12);
172 fail_if(times_called != 2);
173}
174END_TEST
175
176void
177eolian_cxx_test_callback(TCase* tc)
178{
179 tcase_add_test(tc, eolian_cxx_test_callback_method);
180 tcase_add_test(tc, eolian_cxx_test_callback_event_add);
181 tcase_add_test(tc, eolian_cxx_test_callback_event_del);
182 tcase_add_test(tc, eolian_cxx_test_global_callback);
183 tcase_add_test(tc, eolian_cxx_test_disconnect_inside_callback);
184}
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_generate.cc b/src/tests/eolian_cxx/eolian_cxx_test_generate.cc
index acb32dd8e2..a6f0f110d3 100644
--- a/src/tests/eolian_cxx/eolian_cxx_test_generate.cc
+++ b/src/tests/eolian_cxx/eolian_cxx_test_generate.cc
@@ -2,15 +2,69 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include <iostream>
5#include <cassert> 6#include <cassert>
6 7#include <iterator>
7#include <Eolian_Cxx.hh>
8 8
9#include "eolian_cxx_suite.h" 9#include "eolian_cxx_suite.h"
10 10
11#include <grammar/header.hpp>
12
11START_TEST(eolian_cxx_test_generate_complex_types) 13START_TEST(eolian_cxx_test_generate_complex_types)
12{ 14{
13 // TODO implement 15 using efl::eolian::grammar::class_header;
16 using efl::eolian::grammar::attributes::unused_type;
17 using efl::eolian::grammar::attributes::regular_type_def;
18 using efl::eolian::grammar::attributes::klass_name;
19 using efl::eolian::grammar::attributes::complex_type_def;
20 using efl::eolian::grammar::attributes::parameter_direction;
21 using efl::eolian::grammar::attributes::qualifier_info;
22 using efl::eolian::grammar::context_null;;
23
24 // efl::eolian::grammar::attributes::klass_def my_class
25 // {
26 // "Class_Name", "Class_Name", {"Namespace1", "Namesapce2"}
27 // , {
28 // {{regular_type_def{"int", {qualifier_info::is_none, {}}, {}}}
29 // , "function_name"
30 // , {
31 // {parameter_direction::in, {regular_type_def{"unsigned", {qualifier_info::is_none, {}}, {}}}, "param1", ""}
32 // , {parameter_direction::out, {klass_name{{"Namespace1","Namesapce2"}, "Class_Name",
33 // {qualifier_info::is_none, {}}, {}, {}}}
34 // , "param2", ""}
35 // , {parameter_direction::inout, {complex_type_def
36 // {{
37 // {regular_type_def{"list", {qualifier_info::is_none, {}}, {}}}
38 // , {regular_type_def{"int", {qualifier_info::is_none, {}}, {}}}
39 // }}}
40 // , "param3", ""}
41 // }
42 // }
43 // }
44 // , {}
45 // , {}
46 // };
47
48 // std::tuple<std::string, std::vector<std::string>
49 // , std::vector<std::string>, std::vector<efl::eolian::grammar::attributes::klass_def>
50 // , std::vector<efl::eolian::grammar::attributes::klass_def>
51 // , std::vector<efl::eolian::grammar::attributes::klass_def>> attributes
52 // {"GUARD_HEADER_HH", {"abc.h", "def.h"}, {"abc.hh", "def.hh"}, {my_class}, {my_class}, {my_class}};
53 // std::vector<char> buffer;
54 // class_header.generate(std::back_inserter<std::vector<char>>(buffer), attributes, context_null());
55
56 // const char result[] =
57 // "#ifndef GUARD_HEADER_HH\n"
58 // "#define GUARD_HEADER_HH\n"
59 // "#endif\n"
60 // ;
61
62 // std::cout << "Beginning of generated file" << std::endl;
63 // std::copy(buffer.begin(), buffer.end(), std::ostream_iterator<char>(std::cout));
64 // std::cout << "\n End of generated file" << std::endl;
65
66 // ck_assert(buffer.size() == (sizeof(result) - 1));
67 // ck_assert(std::equal(buffer.begin(), buffer.end(), result));
14} 68}
15END_TEST 69END_TEST
16 70
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_inheritance.cc b/src/tests/eolian_cxx/eolian_cxx_test_inheritance.cc
index 8af557a2c5..5dc6b94773 100644
--- a/src/tests/eolian_cxx/eolian_cxx_test_inheritance.cc
+++ b/src/tests/eolian_cxx/eolian_cxx_test_inheritance.cc
@@ -9,35 +9,35 @@
9 9
10#include "eolian_cxx_suite.h" 10#include "eolian_cxx_suite.h"
11 11
12struct bar 12// struct bar
13: efl::eo::inherit<bar, nonamespace::Simple> 13// : efl::eo::inherit<bar, nonamespace::Simple>
14{ 14// {
15 bar() 15// bar()
16 : inherit_base(efl::eo::parent = nullptr) 16// : inherit_base(efl::eo::parent = nullptr)
17 {} 17// {}
18 18
19 bool simple_get() 19// bool simple_get()
20 { 20// {
21 printf("calling bar::%s\n", __FUNCTION__); 21// printf("calling bar::%s\n", __FUNCTION__);
22 return false; 22// return false;
23 } 23// }
24}; 24// };
25 25
26void foo(nonamespace::Simple is) 26// void foo(nonamespace::Simple is)
27{ 27// {
28 fail_if(is.simple_get()); 28// fail_if(is.simple_get());
29} 29// }
30 30
31START_TEST(eolian_cxx_test_inheritance_simple) 31// START_TEST(eolian_cxx_test_inheritance_simple)
32{ 32// {
33 efl::eo::eo_init i; 33// efl::eo::eo_init i;
34 bar b; 34// bar b;
35 foo(b); 35// foo(b);
36} 36// }
37END_TEST 37// END_TEST
38 38
39void 39void
40eolian_cxx_test_inheritance(TCase* tc) 40eolian_cxx_test_inheritance(TCase* /*tc*/)
41{ 41{
42 tcase_add_test(tc, eolian_cxx_test_inheritance_simple); 42 // tcase_add_test(tc, eolian_cxx_test_inheritance_simple);
43} 43}
diff --git a/src/tests/eolian_cxx/eolian_cxx_test_wrapper.cc b/src/tests/eolian_cxx/eolian_cxx_test_wrapper.cc
index 3441a8975b..971bb77886 100644
--- a/src/tests/eolian_cxx/eolian_cxx_test_wrapper.cc
+++ b/src/tests/eolian_cxx/eolian_cxx_test_wrapper.cc
@@ -5,7 +5,7 @@
5#include <Eo.h> 5#include <Eo.h>
6#include <Ecore.h> 6#include <Ecore.h>
7 7
8#include <callback.eo.hh> 8#include <a.eo.hh>
9 9
10#include "eolian_cxx_suite.h" 10#include "eolian_cxx_suite.h"
11 11
@@ -14,7 +14,7 @@ START_TEST(eolian_cxx_test_wrapper_size)
14 efl::eo::eo_init init; 14 efl::eo::eo_init init;
15 15
16 ::efl::eo::concrete b(nullptr); 16 ::efl::eo::concrete b(nullptr);
17 ::nonamespace::Callback c; 17 ::nonamespace::A c;
18 18
19 fail_if(sizeof(b) != sizeof(Eo*)); 19 fail_if(sizeof(b) != sizeof(Eo*));
20 fail_if(sizeof(b) != sizeof(c)); 20 fail_if(sizeof(b) != sizeof(c));
diff --git a/src/tests/eolian_cxx/generic.c b/src/tests/eolian_cxx/generic.c
index b0a32f6741..2ea56262c3 100644
--- a/src/tests/eolian_cxx/generic.c
+++ b/src/tests/eolian_cxx/generic.c
@@ -7,14 +7,14 @@
7 7
8#include "generic.eo.h" 8#include "generic.eo.h"
9 9
10#include <check.h>
11
10struct _Generic_Data 12struct _Generic_Data
11{ 13{
12 int req_ctor_a_val; 14 int req_ctor_a_val;
13 Ecore_Cb req_ctor_b_cb; 15 int req_ctor_b_val;
14 void *req_ctor_b_data;
15 int opt_ctor_a_val; 16 int opt_ctor_a_val;
16 Ecore_Cb opt_ctor_b_cb; 17 int opt_ctor_b_val;
17 void *opt_ctor_b_data;
18}; 18};
19typedef struct _Generic_Data Generic_Data; 19typedef struct _Generic_Data Generic_Data;
20 20
@@ -23,11 +23,7 @@ typedef struct _Generic_Data Generic_Data;
23static Eo *_generic_eo_base_constructor(Eo *obj, Generic_Data *pd) 23static Eo *_generic_eo_base_constructor(Eo *obj, Generic_Data *pd)
24{ 24{
25 pd->req_ctor_a_val = 0; 25 pd->req_ctor_a_val = 0;
26 pd->req_ctor_b_cb = NULL;
27 pd->req_ctor_b_data = NULL;
28 pd->opt_ctor_a_val = 0; 26 pd->opt_ctor_a_val = 0;
29 pd->opt_ctor_b_cb = NULL;
30 pd->opt_ctor_b_data = NULL;
31 return eo_constructor(eo_super(obj, MY_CLASS)); 27 return eo_constructor(eo_super(obj, MY_CLASS));
32} 28}
33 29
@@ -36,9 +32,9 @@ static void _generic_required_ctor_a(Eo *obj EINA_UNUSED, Generic_Data *pd, int
36 pd->req_ctor_a_val = value; 32 pd->req_ctor_a_val = value;
37} 33}
38 34
39static void _generic_required_ctor_b(Eo *obj EINA_UNUSED, Generic_Data *pd EINA_UNUSED, Ecore_Cb cb, void *data) 35static void _generic_required_ctor_b(Eo *obj EINA_UNUSED, Generic_Data *pd EINA_UNUSED, int value)
40{ 36{
41 cb(data); 37 pd->req_ctor_b_val = value;
42} 38}
43 39
44static void _generic_optional_ctor_a(Eo *obj EINA_UNUSED, Generic_Data *pd, int value) 40static void _generic_optional_ctor_a(Eo *obj EINA_UNUSED, Generic_Data *pd, int value)
@@ -46,9 +42,9 @@ static void _generic_optional_ctor_a(Eo *obj EINA_UNUSED, Generic_Data *pd, int
46 pd->opt_ctor_a_val = value; 42 pd->opt_ctor_a_val = value;
47} 43}
48 44
49static void _generic_optional_ctor_b(Eo *obj EINA_UNUSED, Generic_Data *pd EINA_UNUSED, Ecore_Cb cb, void *data) 45static void _generic_optional_ctor_b(Eo *obj EINA_UNUSED, Generic_Data *pd EINA_UNUSED, int value)
50{ 46{
51 cb(data); 47 pd->opt_ctor_b_val = value;
52} 48}
53 49
54static int _generic_req_ctor_a_value_get(Eo *obj EINA_UNUSED, Generic_Data *pd) 50static int _generic_req_ctor_a_value_get(Eo *obj EINA_UNUSED, Generic_Data *pd)
@@ -56,21 +52,78 @@ static int _generic_req_ctor_a_value_get(Eo *obj EINA_UNUSED, Generic_Data *pd)
56 return pd->req_ctor_a_val; 52 return pd->req_ctor_a_val;
57} 53}
58 54
55static int _generic_req_ctor_b_value_get(Eo *obj EINA_UNUSED, Generic_Data *pd)
56{
57 return pd->req_ctor_b_val;
58}
59
59static int _generic_opt_ctor_a_value_get(Eo *obj EINA_UNUSED, Generic_Data *pd) 60static int _generic_opt_ctor_a_value_get(Eo *obj EINA_UNUSED, Generic_Data *pd)
60{ 61{
61 return pd->opt_ctor_a_val; 62 return pd->opt_ctor_a_val;
62} 63}
63 64
64static void _generic_call_req_ctor_b_callback(Eo *obj EINA_UNUSED, Generic_Data *pd) 65static int _generic_opt_ctor_b_value_get(Eo *obj EINA_UNUSED, Generic_Data *pd)
66{
67 return pd->opt_ctor_b_val;
68}
69
70/* static void _generic_req_ctor_a_value_set(Eo *obj EINA_UNUSED, Generic_Data* pd EINA_UNUSED, int value EINA_UNUSED) */
71/* { */
72/* } */
73
74/* static void _generic_opt_ctor_a_value_set(Eo *obj EINA_UNUSED, Generic_Data* pd EINA_UNUSED, int value EINA_UNUSED) */
75/* { */
76/* } */
77
78static void _generic_out_required_ctor_a(Eo *obj EINA_UNUSED, Generic_Data* pd, int *value)
65{ 79{
66 if (pd->req_ctor_b_cb) 80 *value = pd->req_ctor_a_val;
67 pd->req_ctor_b_cb(pd->req_ctor_b_data);
68} 81}
69 82
70static void _generic_call_opt_ctor_b_callback(Eo *obj EINA_UNUSED, Generic_Data *pd) 83static void _generic_out_required_ctor_b(Eo *obj EINA_UNUSED, Generic_Data* pd, int *value)
71{ 84{
72 if (pd->opt_ctor_b_cb) 85 *value = pd->req_ctor_b_val;
73 pd->opt_ctor_b_cb(pd->opt_ctor_b_data); 86}
87
88static void _generic_out_optional_ctor_a(Eo *obj EINA_UNUSED, Generic_Data* pd, int *value)
89{
90 *value = pd->opt_ctor_a_val;
91}
92
93static void _generic_out_optional_ctor_b(Eo *obj EINA_UNUSED, Generic_Data* pd, int *value)
94{
95 *value = pd->opt_ctor_b_val;
96}
97
98static void _generic_call_event1(Eo *obj, Generic_Data* pd EINA_UNUSED)
99{
100 eo_event_callback_call(obj, GENERIC_EVENT_PREFIX_EVENT1, NULL);
101}
102static void _generic_call_event2(Eo *obj, Generic_Data* pd EINA_UNUSED)
103{
104 eo_event_callback_call(obj, GENERIC_EVENT_PREFIX_EVENT2, obj);
105}
106static void _generic_call_event3(Eo *obj, Generic_Data* pd EINA_UNUSED)
107{
108 int p = 42;
109 eo_event_callback_call(obj, GENERIC_EVENT_PREFIX_EVENT3, &p);
110}
111static void _generic_call_event4(Eo *obj, Generic_Data* pd EINA_UNUSED)
112{
113 int i = 42;
114 Eina_List* p = eina_list_append(NULL, &i);
115 ck_assert(p != NULL);
116 eo_event_callback_call(obj, GENERIC_EVENT_PREFIX_EVENT4, p);
117 eina_list_free(p);
118}
119static void _generic_call_event5(Eo *obj, Generic_Data* pd EINA_UNUSED)
120{
121 int i = 42;
122 Eina_List* p = eina_list_append(NULL, &i);
123
124 Generic_Event e = {.field1 = 42, .field2 = p};
125 eo_event_callback_call(obj, GENERIC_EVENT_PREFIX_EVENT5, &e);
126 eina_list_free(p);
74} 127}
75 128
76#include "generic.eo.c" 129#include "generic.eo.c"
diff --git a/src/tests/eolian_cxx/generic.eo b/src/tests/eolian_cxx/generic.eo
index cbff67aed5..20f471ba83 100644
--- a/src/tests/eolian_cxx/generic.eo
+++ b/src/tests/eolian_cxx/generic.eo
@@ -1,4 +1,9 @@
1import ecore_types; 1
2struct Generic.Event
3{
4 field1: int;
5 field2: list<int*>;
6}
2 7
3class Generic (Eo.Base) 8class Generic (Eo.Base)
4{ 9{
@@ -25,8 +30,7 @@ class Generic (Eo.Base)
25 } 30 }
26 required_ctor_b { 31 required_ctor_b {
27 params { 32 params {
28 @in cb: Ecore_Cb; 33 @in value: int;
29 @in data: void_ptr;
30 } 34 }
31 } 35 }
32 optional_ctor_a { 36 optional_ctor_a {
@@ -36,13 +40,52 @@ class Generic (Eo.Base)
36 } 40 }
37 optional_ctor_b { 41 optional_ctor_b {
38 params { 42 params {
39 @in cb: Ecore_Cb; 43 @in value: int;
40 @in data: void_ptr; 44 }
45 }
46
47 @property req_ctor_b_value {
48 get {}
49 values {
50 value: int;
41 } 51 }
42 } 52 }
43 call_req_ctor_b_callback { 53 @property opt_ctor_b_value {
54 get {}
55 values {
56 value: int;
57 }
44 } 58 }
45 call_opt_ctor_b_callback { 59 out_required_ctor_a {
60 params {
61 @out value: int;
62 }
63 }
64 out_required_ctor_b {
65 params {
66 @out value: int;
67 }
68 }
69 out_optional_ctor_a {
70 params {
71 @out value: int;
72 }
73 }
74 out_optional_ctor_b {
75 params {
76 @out value: int;
77 }
78 }
79
80 call_event1 {
81 }
82 call_event2 {
83 }
84 call_event3 {
85 }
86 call_event4 {
87 }
88 call_event5 {
46 } 89 }
47 } 90 }
48 constructors { 91 constructors {
@@ -54,4 +97,11 @@ class Generic (Eo.Base)
54 implements { 97 implements {
55 Eo.Base.constructor; 98 Eo.Base.constructor;
56 } 99 }
100 events {
101 prefix,event1;
102 prefix,event2: Generic;
103 prefix,event3: int;
104 prefix,event4: list<int*>;
105 prefix,event5: Generic.Event;
106 }
57} 107}
diff --git a/src/tests/eolian_cxx/name1_name2_type_generation.c b/src/tests/eolian_cxx/name1_name2_type_generation.c
new file mode 100644
index 0000000000..28b8c853ad
--- /dev/null
+++ b/src/tests/eolian_cxx/name1_name2_type_generation.c
@@ -0,0 +1,240 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Eo.h>
6#include <Ecore.h>
7
8#include <check.h>
9
10struct _Type_Generation_Data
11{
12};
13typedef struct _Type_Generation_Data Type_Generation_Data;
14
15#define MY_CLASS TYPE1_TYPE2_TYPE_GENERATION_CLASS
16
17#include "name1_name2_type_generation.eo.h"
18
19void _name1_name2_type_generation_invoidptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, void *v)
20{
21 ck_assert(v == NULL);
22}
23
24void _name1_name2_type_generation_inint(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int v EINA_UNUSED)
25{
26 ck_assert(v == 42);
27}
28
29void _name1_name2_type_generation_inintptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int *v EINA_UNUSED)
30{
31 ck_assert(*v == 42);
32}
33
34void _name1_name2_type_generation_inintptrown(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int *v EINA_UNUSED)
35{
36 ck_assert(*v == 42);
37}
38
39void _name1_name2_type_generation_inintptrownptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int **v EINA_UNUSED)
40{
41 ck_assert(**v == 42);
42}
43
44void _name1_name2_type_generation_inintptrownptrptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int ***v EINA_UNUSED)
45{
46 ck_assert(***v == 42);
47}
48
49void _name1_name2_type_generation_inintptrptrownptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int ***v EINA_UNUSED)
50{
51 ck_assert(***v == 42);
52}
53
54void _name1_name2_type_generation_inintptrownfree(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int *v EINA_UNUSED)
55{
56 ck_assert(*v == 42);
57}
58
59void * _name1_name2_type_generation_returnvoidptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED)
60{
61 return NULL;
62}
63
64void _name1_name2_type_generation_instring(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, const char *v EINA_UNUSED)
65{
66 ck_assert_str_eq(v, "foobar");
67}
68
69void _name1_name2_type_generation_instringptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, const char * *v EINA_UNUSED)
70{
71 ck_assert_str_eq(*v, "foobar");
72}
73
74void _name1_name2_type_generation_instringown(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, const char *v EINA_UNUSED)
75{
76 ck_assert_str_eq(v, "foobar");
77 free((void*)v);
78}
79
80void _name1_name2_type_generation_instringownptrown(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, const char **v EINA_UNUSED)
81{
82 ck_assert_str_eq(*v, "foobar");
83 free(v);
84}
85
86void _name1_name2_type_generation_instringownptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, const char * *v EINA_UNUSED)
87{
88 ck_assert_str_eq(*v, "foobar");
89 free(v);
90}
91
92int _name1_name2_type_generation_returnint(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED)
93{
94 return 42;
95}
96
97int * _name1_name2_type_generation_returnintptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED)
98{
99 return NULL;
100}
101
102int * _name1_name2_type_generation_returnintptrown(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED)
103{
104 return NULL;
105}
106
107int ** _name1_name2_type_generation_returnintptrownptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED)
108{
109 return NULL;
110}
111
112int *** _name1_name2_type_generation_returnintptrownptrptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED)
113{
114 return NULL;
115}
116
117int *** _name1_name2_type_generation_returnintptrptrownptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED)
118{
119 return NULL;
120}
121
122void _name1_name2_type_generation_returnintptrownfree(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int *v EINA_UNUSED)
123{
124}
125
126const char * _name1_name2_type_generation_returnstring(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED)
127{
128 return "foobar";
129}
130
131const char * * _name1_name2_type_generation_returnstringptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED)
132{
133 static const char* foobar = "foobar";
134 return &foobar;
135}
136
137const char * _name1_name2_type_generation_returnstringown(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED)
138{
139 const char foobar[] = "foobar";
140 char* p = malloc(sizeof(foobar));
141 memcpy(p, foobar, sizeof(foobar));
142 return p;
143}
144
145const char * * _name1_name2_type_generation_returnstringownptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED)
146{
147 const char foobar[] = "foobar";
148 char** p1 = malloc(sizeof(const char*));
149 char* p = malloc(sizeof(foobar));
150 memcpy(p, foobar, sizeof(foobar));
151
152 *p1 = p;
153 return (const char**)p1;
154}
155
156void _name1_name2_type_generation_outvoidptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, void **v EINA_UNUSED)
157{
158}
159
160void _name1_name2_type_generation_outint(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int *v EINA_UNUSED)
161{
162}
163
164void _name1_name2_type_generation_outintptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int **v EINA_UNUSED)
165{
166}
167
168void _name1_name2_type_generation_outintptrown(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int **v EINA_UNUSED)
169{
170}
171
172void _name1_name2_type_generation_outintptrownfree(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int **v EINA_UNUSED)
173{
174}
175
176void _name1_name2_type_generation_inclassname(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, Name1_Name2_Type_Generation *v EINA_UNUSED)
177{
178}
179
180void _name1_name2_type_generation_outclassname(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, Name1_Name2_Type_Generation **v EINA_UNUSED)
181{
182}
183
184void _name1_name2_type_generation_inoutclassname(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, Name1_Name2_Type_Generation **v EINA_UNUSED)
185{
186}
187
188void _name1_name2_type_generation_optionalinvoidptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, void *v EINA_UNUSED)
189{
190}
191
192void _name1_name2_type_generation_optionalinint(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int v EINA_UNUSED)
193{
194}
195
196void _name1_name2_type_generation_optionalinintptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int *v EINA_UNUSED)
197{
198}
199
200void _name1_name2_type_generation_optionalinintptrown(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int *v EINA_UNUSED)
201{
202}
203
204void _name1_name2_type_generation_optionalinintptrownfree(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int *v EINA_UNUSED)
205{
206}
207
208void _name1_name2_type_generation_optionaloutvoidptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, void **v EINA_UNUSED)
209{
210}
211
212void _name1_name2_type_generation_optionaloutint(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int *v EINA_UNUSED)
213{
214}
215
216void _name1_name2_type_generation_optionaloutintptr(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int **v EINA_UNUSED)
217{
218}
219
220void _name1_name2_type_generation_optionaloutintptrown(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int **v EINA_UNUSED)
221{
222}
223
224void _name1_name2_type_generation_optionaloutintptrownfree(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, int **v EINA_UNUSED)
225{
226}
227
228void _name1_name2_type_generation_optionalinclassname(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, Name1_Name2_Type_Generation *v EINA_UNUSED)
229{
230}
231
232void _name1_name2_type_generation_optionaloutclassname(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, Name1_Name2_Type_Generation **v EINA_UNUSED)
233{
234}
235
236void _name1_name2_type_generation_optionalinoutclassname(Eo *obj EINA_UNUSED, Type_Generation_Data *pd EINA_UNUSED, Name1_Name2_Type_Generation **v EINA_UNUSED)
237{
238}
239
240#include "name1_name2_type_generation.eo.c"
diff --git a/src/tests/eolian_cxx/name1_name2_type_generation.eo b/src/tests/eolian_cxx/name1_name2_type_generation.eo
new file mode 100644
index 0000000000..66b6461a81
--- /dev/null
+++ b/src/tests/eolian_cxx/name1_name2_type_generation.eo
@@ -0,0 +1,220 @@
1class Name1.Name2.Type_Generation (Eo.Base)
2{
3 data: Type_Generation_Data;
4 methods {
5 // in void ptr
6 invoidptr {
7 params {
8 @in v: void*;
9 }
10 }
11 inint {
12 params {
13 @in v: int;
14 }
15 }
16 inintptr {
17 params {
18 @in v: int*;
19 }
20 }
21 inintptrown {
22 params {
23 @in v: own(int*);
24 }
25 }
26 inintptrownptr {
27 params {
28 @in v: own(int*)*;
29 }
30 }
31 inintptrownptrptr {
32 params {
33 @in v: own(int*)**;
34 }
35 }
36 inintptrptrownptr {
37 params {
38 @in v: own(int**)*;
39 }
40 }
41 inintptrownfree {
42 params {
43 @in v: free(own(int*), free);
44 }
45 }
46 instring {
47 params {
48 @in v: string;
49 }
50 }
51 /*
52 instringptr {
53 params {
54 @in v: string*;
55 }
56 }*/
57 instringown {
58 params {
59 @in v: own(string);
60 }
61 }
62 /* no sense
63 instringptrown {
64 params {
65 @in v: own(string*);
66 }
67 }
68 instringownptrown {
69 params {
70 @in v: own(own(string)*);
71 }
72 }*/
73 // return
74 returnvoidptr {
75 return: void*;
76 }
77 returnint {
78 return: int;
79 }
80 returnintptr {
81 return: int*;
82 }
83 returnintptrown {
84 return: own(int*);
85 }
86 returnintptrownptr {
87 return: own(int*)*;
88 }
89 returnintptrownptrptr {
90 return: own(int*)**;
91 }
92 returnintptrptrownptr {
93 return: own(int**)*;
94 }
95 returnintptrownfree {
96 params {
97 @in v: free(own(int*), free);
98 }
99 }
100 returnstring {
101 return: string;
102 }
103 returnstringptr {
104 return: string*;
105 }
106 returnstringown {
107 return: own(string);
108 }
109 returnstringownptr {
110 return: own(string*);
111 }
112
113 // out
114 outvoidptr {
115 params {
116 @out v: void*;
117 }
118 }
119 outint {
120 params {
121 @out v: int;
122 }
123 }
124 outintptr {
125 params {
126 @out v: int*;
127 }
128 }
129 outintptrown {
130 params {
131 @out v: own(int*);
132 }
133 }
134 outintptrownfree {
135 params {
136 @out v: free(own(int*), free);
137 }
138 }
139 inclassname {
140 params {
141 @in v: Name1.Name2.Type_Generation;
142 }
143 }
144 outclassname {
145 params {
146 @out v: Name1.Name2.Type_Generation;
147 }
148 }
149 inoutclassname {
150 params {
151 @inout v: Name1.Name2.Type_Generation;
152 }
153 }
154 optionalinvoidptr {
155 params {
156 @in v: void* @optional;
157 }
158 }
159 optionalinint {
160 params {
161 @in v: int @optional;
162 }
163 }
164 optionalinintptr {
165 params {
166 @in v: int* @optional;
167 }
168 }
169 optionalinintptrown {
170 params {
171 @in v: own(int*) @optional;
172 }
173 }
174 optionalinintptrownfree {
175 params {
176 @in v: free(own(int*), free) @optional;
177 }
178 }
179 optionaloutvoidptr {
180 params {
181 @out v: void* @optional;
182 }
183 }
184 optionaloutint {
185 params {
186 @out v: int @optional;
187 }
188 }
189 optionaloutintptr {
190 params {
191 @out v: int* @optional;
192 }
193 }
194 optionaloutintptrown {
195 params {
196 @out v: own(int*) @optional;
197 }
198 }
199 optionaloutintptrownfree {
200 params {
201 @out v: free(own(int*), free) @optional;
202 }
203 }
204 optionalinclassname {
205 params {
206 @in v: Name1.Name2.Type_Generation @optional;
207 }
208 }
209 optionaloutclassname {
210 params {
211 @out v: Name1.Name2.Type_Generation @optional;
212 }
213 }
214 optionalinoutclassname {
215 params {
216 @inout v: Name1.Name2.Type_Generation @optional;
217 }
218 }
219 }
220}
diff --git a/src/tests/eolian_cxx/name_name_cxx.cc b/src/tests/eolian_cxx/name_name_cxx.cc
index d5669bc5f6..003b526529 100644
--- a/src/tests/eolian_cxx/name_name_cxx.cc
+++ b/src/tests/eolian_cxx/name_name_cxx.cc
@@ -1,4 +1,8 @@
1 1
2#ifdef HAVE_CONFIG_H
3#include "config.h"
4#endif
5
2#include <Eo.h> 6#include <Eo.h>
3 7
4#include "name_name.eo.h" 8#include "name_name.eo.h"