summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2017-06-27 18:49:37 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-07-13 19:00:53 -0300
commitda6c685b8cfb6b95d38ac87c17913c4b98ed4e45 (patch)
tree2623a574de2027cf88ef66b75180fb7a27d4f915
parent64cefd6e372bdcc77777e6f3cf16e28b5c24867a (diff)
efl_mono: Use a common efl.All.Init()
Use efl.All.Init/Shutdown as a convenience around call each init function separately.
-rw-r--r--src/Makefile_Efl_Mono.am1
-rw-r--r--src/bindings/mono/efl_mono/efl_all.cs36
-rw-r--r--src/bindings/mono/eo_mono/iwrapper.cs6
-rw-r--r--src/examples/ecore/efl_loop_callback_add_event.cs8
-rw-r--r--src/examples/ecore/efl_loop_timer_example.cs8
-rw-r--r--src/examples/evas/evas_mono_box.cs10
-rw-r--r--src/examples/evas/evas_mono_image.cs11
-rw-r--r--src/examples/evas/evas_mono_image2.cs8
-rw-r--r--src/examples/evas/evas_mono_rectangle.cs13
-rw-r--r--src/examples/evas/evas_mono_table.cs10
-rw-r--r--src/examples/evas/evas_mono_text.cs13
-rw-r--r--src/tests/efl_mono/Main.cs9
12 files changed, 66 insertions, 67 deletions
diff --git a/src/Makefile_Efl_Mono.am b/src/Makefile_Efl_Mono.am
index 674cee11c0..ba1b138aaa 100644
--- a/src/Makefile_Efl_Mono.am
+++ b/src/Makefile_Efl_Mono.am
@@ -144,6 +144,7 @@ efl_eina_mono_files = \
144 bindings/mono/eina_mono/eina_error.cs 144 bindings/mono/eina_mono/eina_error.cs
145 145
146lib_efl_mono_libefl_mono_dll_SOURCES = \ 146lib_efl_mono_libefl_mono_dll_SOURCES = \
147 bindings/mono/efl_mono/efl_all.cs \
147 $(efl_eo_mono_files) \ 148 $(efl_eo_mono_files) \
148 $(efl_eina_mono_files) 149 $(efl_eina_mono_files)
149 150
diff --git a/src/bindings/mono/efl_mono/efl_all.cs b/src/bindings/mono/efl_mono/efl_all.cs
new file mode 100644
index 0000000000..bd9fe55b98
--- /dev/null
+++ b/src/bindings/mono/efl_mono/efl_all.cs
@@ -0,0 +1,36 @@
1using System;
2using System.Runtime.InteropServices;
3
4using static efl.UnsafeNativeMethods;
5
6namespace efl {
7
8static class UnsafeNativeMethods {
9 [DllImport("ecore")] public static extern void ecore_init();
10 [DllImport("ecore")] public static extern void ecore_shutdown();
11 [DllImport("evas")] public static extern void evas_init();
12 [DllImport("evas")] public static extern void evas_shutdown();
13}
14
15public static class All {
16 public static void Init() {
17 eina.Config.Init();
18 efl.eo.Config.Init();
19 ecore_init();
20 evas_init();
21 }
22
23 /// <summary>Shutdowns all EFL subsystems.</summary>
24 public static void Shutdown() {
25 // Try to cleanup everything before actually shutting down.
26 System.GC.Collect();
27 System.GC.WaitForPendingFinalizers();
28
29 evas_shutdown();
30 ecore_shutdown();
31 efl.eo.Config.Shutdown();
32 eina.Config.Shutdown();
33 }
34}
35
36}
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs
index 476055d1dd..d6ff1cf9b0 100644
--- a/src/bindings/mono/eo_mono/iwrapper.cs
+++ b/src/bindings/mono/eo_mono/iwrapper.cs
@@ -7,6 +7,7 @@ namespace efl { namespace eo {
7 7
8public class Globals { 8public class Globals {
9 [DllImport("eo")] public static extern void efl_object_init(); 9 [DllImport("eo")] public static extern void efl_object_init();
10 [DllImport("eo")] public static extern void efl_object_shutdown();
10 [DllImport("eo")] public static extern IntPtr 11 [DllImport("eo")] public static extern IntPtr
11 _efl_add_internal_start([MarshalAs(UnmanagedType.LPStr)] String file, int line, 12 _efl_add_internal_start([MarshalAs(UnmanagedType.LPStr)] String file, int line,
12 IntPtr klass, IntPtr parent, byte is_ref, byte is_fallback); 13 IntPtr klass, IntPtr parent, byte is_ref, byte is_fallback);
@@ -171,6 +172,11 @@ public static class Config
171 { 172 {
172 Globals.efl_object_init(); 173 Globals.efl_object_init();
173 } 174 }
175
176 public static void Shutdown()
177 {
178 Globals.efl_object_shutdown();
179 }
174} 180}
175 181
176public interface IWrapper 182public interface IWrapper
diff --git a/src/examples/ecore/efl_loop_callback_add_event.cs b/src/examples/ecore/efl_loop_callback_add_event.cs
index 56ea898c9c..fe81bfd9ad 100644
--- a/src/examples/ecore/efl_loop_callback_add_event.cs
+++ b/src/examples/ecore/efl_loop_callback_add_event.cs
@@ -4,9 +4,6 @@ using System.Runtime.CompilerServices;
4 4
5class TestMain 5class TestMain
6{ 6{
7 [DllImport("eo")] static extern void efl_object_init();
8 [DllImport("ecore")] static extern void ecore_init();
9
10 /* private efl.Loop loop; */ 7 /* private efl.Loop loop; */
11 8
12 public TestMain(efl.Loop loop) 9 public TestMain(efl.Loop loop)
@@ -16,8 +13,7 @@ class TestMain
16 13
17 static void Main(string[] args) 14 static void Main(string[] args)
18 { 15 {
19 efl_object_init(); 16 efl.All.Init();
20 ecore_init();
21 17
22 efl.Loop loop = new efl.LoopConcrete(); 18 efl.Loop loop = new efl.LoopConcrete();
23 19
@@ -29,6 +25,8 @@ class TestMain
29 loop.CALLBACK_ADD -= listener.on_idle_enter; 25 loop.CALLBACK_ADD -= listener.on_idle_enter;
30 26
31 loop.IDLE += listener.on_idle_enter; // Will trigger CALLBACK_ADD 27 loop.IDLE += listener.on_idle_enter; // Will trigger CALLBACK_ADD
28
29 efl.All.Shutdown();
32 } 30 }
33 31
34 public void on_idle_enter(object sender, EventArgs e) 32 public void on_idle_enter(object sender, EventArgs e)
diff --git a/src/examples/ecore/efl_loop_timer_example.cs b/src/examples/ecore/efl_loop_timer_example.cs
index 47f55c3ca8..dd6b2b8606 100644
--- a/src/examples/ecore/efl_loop_timer_example.cs
+++ b/src/examples/ecore/efl_loop_timer_example.cs
@@ -4,9 +4,6 @@ using System.Runtime.CompilerServices;
4 4
5class TestMain 5class TestMain
6{ 6{
7 [DllImport("eo")] static extern void efl_object_init();
8 [DllImport("ecore")] static extern void ecore_init();
9
10 private efl.Loop loop; 7 private efl.Loop loop;
11 private int count; 8 private int count;
12 9
@@ -18,8 +15,7 @@ class TestMain
18 15
19 static void Main(string[] args) 16 static void Main(string[] args)
20 { 17 {
21 efl_object_init(); 18 efl.All.Init();
22 ecore_init();
23 19
24 efl.Loop loop = new efl.LoopConcrete(); 20 efl.Loop loop = new efl.LoopConcrete();
25 efl.loop.Timer timer = new efl.loop.TimerConcrete(loop); 21 efl.loop.Timer timer = new efl.loop.TimerConcrete(loop);
@@ -35,6 +31,8 @@ class TestMain
35 timer.TICK -= listener.another_callback; 31 timer.TICK -= listener.another_callback;
36 32
37 loop.begin(); 33 loop.begin();
34
35 efl.All.Shutdown();
38 } 36 }
39 37
40 public void on_tick(object sender, EventArgs e) 38 public void on_tick(object sender, EventArgs e)
diff --git a/src/examples/evas/evas_mono_box.cs b/src/examples/evas/evas_mono_box.cs
index 009385d2ac..32794e7381 100644
--- a/src/examples/evas/evas_mono_box.cs
+++ b/src/examples/evas/evas_mono_box.cs
@@ -28,15 +28,9 @@ public class MyBox : evas.BoxInherit
28 28
29class TestMain 29class TestMain
30{ 30{
31 [DllImport("eo")] static extern void efl_object_init();
32 [DllImport("ecore")] static extern void ecore_init();
33 [DllImport("evas")] static extern void evas_init();
34
35 static void Main(string[] args) 31 static void Main(string[] args)
36 { 32 {
37 efl_object_init(); 33 efl.All.Init();
38 ecore_init();
39 evas_init();
40 34
41 efl.Loop loop = new efl.LoopConcrete(); 35 efl.Loop loop = new efl.LoopConcrete();
42 36
@@ -66,5 +60,7 @@ class TestMain
66 box.append(rect2); 60 box.append(rect2);
67 61
68 loop.begin(); 62 loop.begin();
63
64 efl.All.Shutdown();
69 } 65 }
70} 66}
diff --git a/src/examples/evas/evas_mono_image.cs b/src/examples/evas/evas_mono_image.cs
index 8fc71e8a97..794f24bba6 100644
--- a/src/examples/evas/evas_mono_image.cs
+++ b/src/examples/evas/evas_mono_image.cs
@@ -1,13 +1,8 @@
1using System; 1using System;
2using System.Runtime.InteropServices;
3using System.Runtime.CompilerServices; 2using System.Runtime.CompilerServices;
4 3
5class TestMain 4class TestMain
6{ 5{
7 [DllImport("eo")] static extern void efl_object_init();
8 [DllImport("ecore")] static extern void ecore_init();
9 [DllImport("evas")] static extern void evas_init();
10
11 static int WIDTH = 320; 6 static int WIDTH = 320;
12 static int HEIGHT = 240; 7 static int HEIGHT = 240;
13 8
@@ -26,9 +21,7 @@ class TestMain
26 21
27 static void Main(string[] args) 22 static void Main(string[] args)
28 { 23 {
29 efl_object_init(); 24 efl.All.Init();
30 ecore_init();
31 evas_init();
32 25
33 efl.Loop loop = new efl.LoopConcrete(); 26 efl.Loop loop = new efl.LoopConcrete();
34 27
@@ -76,6 +69,8 @@ class TestMain
76 /* callback, null); */ 69 /* callback, null); */
77 70
78 loop.begin(); 71 loop.begin();
72
73 efl.All.Shutdown();
79 } 74 }
80 75
81 public void on_key_down(object sender, EventArgs e) 76 public void on_key_down(object sender, EventArgs e)
diff --git a/src/examples/evas/evas_mono_image2.cs b/src/examples/evas/evas_mono_image2.cs
index ca2179621a..c9535d7e4b 100644
--- a/src/examples/evas/evas_mono_image2.cs
+++ b/src/examples/evas/evas_mono_image2.cs
@@ -4,19 +4,13 @@ using System.Runtime.CompilerServices;
4 4
5class TestMain 5class TestMain
6{ 6{
7 [DllImport("eo")] static extern void efl_object_init();
8 [DllImport("ecore")] static extern void ecore_init();
9 [DllImport("evas")] static extern void evas_init();
10
11 static int WIDTH = 320; 7 static int WIDTH = 320;
12 static int HEIGHT = 240; 8 static int HEIGHT = 240;
13 9
14 10
15 static void Main(string[] args) 11 static void Main(string[] args)
16 { 12 {
17 efl_object_init(); 13 efl.All.Init();
18 ecore_init();
19 evas_init();
20 14
21 efl.Loop loop = new efl.LoopConcrete(); 15 efl.Loop loop = new efl.LoopConcrete();
22 16
diff --git a/src/examples/evas/evas_mono_rectangle.cs b/src/examples/evas/evas_mono_rectangle.cs
index a096240b4e..0a719e8e1f 100644
--- a/src/examples/evas/evas_mono_rectangle.cs
+++ b/src/examples/evas/evas_mono_rectangle.cs
@@ -1,13 +1,7 @@
1using System; 1using System;
2using System.Runtime.InteropServices;
3using System.Runtime.CompilerServices;
4 2
5class TestMain 3class TestMain
6{ 4{
7 [DllImport("eo")] static extern void efl_object_init();
8 [DllImport("ecore")] static extern void ecore_init();
9 [DllImport("evas")] static extern void evas_init();
10
11 private static int[,] colors = new int[,] { 5 private static int[,] colors = new int[,] {
12 {255, 0, 0}, 6 {255, 0, 0},
13 {0, 255, 0}, 7 {0, 255, 0},
@@ -18,10 +12,7 @@ class TestMain
18 { 12 {
19 int color_index = 0; 13 int color_index = 0;
20 14
21 eina.Log.Init(); 15 efl.All.Init();
22 efl_object_init();
23 ecore_init();
24 evas_init();
25 16
26 efl.Loop loop = new efl.LoopConcrete(); 17 efl.Loop loop = new efl.LoopConcrete();
27 EcoreEvas ecore_evas = new EcoreEvas(); 18 EcoreEvas ecore_evas = new EcoreEvas();
@@ -47,5 +38,7 @@ class TestMain
47 }; 38 };
48 39
49 loop.begin(); 40 loop.begin();
41
42 efl.All.Shutdown();
50 } 43 }
51} 44}
diff --git a/src/examples/evas/evas_mono_table.cs b/src/examples/evas/evas_mono_table.cs
index 36d02ea9c0..6e103e6137 100644
--- a/src/examples/evas/evas_mono_table.cs
+++ b/src/examples/evas/evas_mono_table.cs
@@ -4,18 +4,12 @@ using System.Runtime.CompilerServices;
4 4
5class TestMain 5class TestMain
6{ 6{
7 [DllImport("eo")] static extern void efl_object_init();
8 [DllImport("ecore")] static extern void ecore_init();
9 [DllImport("evas")] static extern void evas_init();
10
11 static int WIDTH = 100; 7 static int WIDTH = 100;
12 static int HEIGHT = 150; 8 static int HEIGHT = 150;
13 9
14 static void Main(string[] args) 10 static void Main(string[] args)
15 { 11 {
16 efl_object_init(); 12 efl.All.Init();
17 ecore_init();
18 evas_init();
19 13
20 efl.Loop loop = new efl.LoopConcrete(); 14 efl.Loop loop = new efl.LoopConcrete();
21 15
@@ -64,6 +58,8 @@ class TestMain
64 table.pack(rect, 2, 3, 1, 1); 58 table.pack(rect, 2, 3, 1, 1);
65 59
66 loop.begin(); 60 loop.begin();
61
62 efl.All.Shutdown();
67 } 63 }
68} 64}
69 65
diff --git a/src/examples/evas/evas_mono_text.cs b/src/examples/evas/evas_mono_text.cs
index c7da9b8be7..3ccd5ea064 100644
--- a/src/examples/evas/evas_mono_text.cs
+++ b/src/examples/evas/evas_mono_text.cs
@@ -1,7 +1,5 @@
1using System; 1using System;
2using System.Linq; 2using System.Linq;
3using System.Runtime.InteropServices;
4using System.Runtime.CompilerServices;
5using System.Collections.Generic; 3using System.Collections.Generic;
6 4
7static class Extensions 5static class Extensions
@@ -20,10 +18,6 @@ static class Extensions
20 18
21class TestMain 19class TestMain
22{ 20{
23 [DllImport("eo")] static extern void efl_object_init();
24 [DllImport("ecore")] static extern void ecore_init();
25 [DllImport("evas")] static extern void evas_init();
26
27 static int WIDTH = 320; 21 static int WIDTH = 320;
28 static int HEIGHT = 240; 22 static int HEIGHT = 240;
29 23
@@ -100,10 +94,7 @@ class TestMain
100 94
101 static void Main(string[] args) 95 static void Main(string[] args)
102 { 96 {
103 eina.Log.Init(); 97 efl.All.Init();
104 efl_object_init();
105 ecore_init();
106 evas_init();
107 98
108 String border_path = "./src/examples/evas/resources/images/red.png"; 99 String border_path = "./src/examples/evas/resources/images/red.png";
109 100
@@ -114,6 +105,8 @@ class TestMain
114 TestMain t = new TestMain(border_path); 105 TestMain t = new TestMain(border_path);
115 106
116 loop.begin(); 107 loop.begin();
108
109 efl.All.Shutdown();
117 } 110 }
118} 111}
119 112
diff --git a/src/tests/efl_mono/Main.cs b/src/tests/efl_mono/Main.cs
index 07b64cfd14..71ef39ecc1 100644
--- a/src/tests/efl_mono/Main.cs
+++ b/src/tests/efl_mono/Main.cs
@@ -57,10 +57,6 @@ public class Test
57 57
58class TestMain 58class TestMain
59{ 59{
60 [DllImport("eo")] static extern void efl_object_init();
61 [DllImport("ecore")] static extern void ecore_init();
62 [DllImport("evas")] static extern void evas_init();
63
64 static Type[] GetTestCases(String name="") 60 static Type[] GetTestCases(String name="")
65 { 61 {
66 return Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "TestSuite", StringComparison.Ordinal) && 62 return Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace, "TestSuite", StringComparison.Ordinal) &&
@@ -70,10 +66,7 @@ class TestMain
70 66
71 static int Main(string[] args) 67 static int Main(string[] args)
72 { 68 {
73 eina.Config.Init(); 69 efl.All.Init();
74 efl_object_init();
75 ecore_init();
76 evas_init();
77 70
78 bool pass = true; 71 bool pass = true;
79 72