summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno da Silva Belo <brunodasilvabelo@gmail.com>2019-11-20 19:07:21 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-11-20 19:22:53 -0300
commit53af539f2781deb08f4d8e5bc983e743e92abb36 (patch)
tree683c21229e60ecf264e4fabd7afc6b3f366d19f1
parent4b13be6d15e24c64c5350bd10ec41c0ad0f1119b (diff)
downloadefl-53af539f2781deb08f4d8e5bc983e743e92abb36.tar.gz
csharp: Components enum are flags now.
Reviewers: lauromoura, felipealmeida, YOhoho Reviewed By: lauromoura Subscribers: segfaultxavi, cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8411 Differential Revision: https://phab.enlightenment.org/D10541
-rw-r--r--src/bindings/mono/efl_mono/efl_all.cs63
-rw-r--r--src/bindings/mono/efl_mono/efl_csharp_application.cs93
2 files changed, 107 insertions, 49 deletions
diff --git a/src/bindings/mono/efl_mono/efl_all.cs b/src/bindings/mono/efl_mono/efl_all.cs
index 66c7de2fb5..c49ec4dfd4 100644
--- a/src/bindings/mono/efl_mono/efl_all.cs
+++ b/src/bindings/mono/efl_mono/efl_all.cs
@@ -59,7 +59,7 @@ static class UnsafeNativeMethods
/// </summary>
public static class All
{
- private static bool InitializedUi = false;
+ private static Efl.Csharp.Components initComponents = Efl.Csharp.Components.Basic;
/// <summary>
/// If the main loop was initialized.
@@ -79,17 +79,28 @@ public static class All
/// <param name="components">The <see cref="Efl.Csharp.Components" /> that initialize the Efl.</param>
public static void Init(Efl.Csharp.Components components = Efl.Csharp.Components.Basic)
{
- Eina.Config.Init();
- Efl.Eo.Config.Init();
- ecore_init();
- ecore_init_ex(0, IntPtr.Zero);
- evas_init();
- eldbus.Config.Init();
-
- if (components == Efl.Csharp.Components.Ui)
+ if (components == Efl.Csharp.Components.None)
+ {
+ return;
+ }
+
+ initComponents = components;
+
+ if ((initComponents & Efl.Csharp.Components.Basic)
+ == Efl.Csharp.Components.Basic)
+ {
+ Eina.Config.Init();
+ Efl.Eo.Config.Init();
+ ecore_init();
+ ecore_init_ex(0, IntPtr.Zero);
+ evas_init();
+ eldbus.Config.Init();
+ }
+
+ if ((initComponents & Efl.Csharp.Components.Ui)
+ == Efl.Csharp.Components.Ui)
{
Efl.Ui.Config.Init();
- InitializedUi = true;
}
Monitor.Enter(InitLock);
MainLoopInitialized = true;
@@ -114,22 +125,32 @@ public static class All
MainLoopInitialized = false;
Monitor.Exit(InitLock);
- if (InitializedUi)
+ if (initComponents == Efl.Csharp.Components.None)
+ {
+ return;
+ }
+
+ if ((initComponents & Efl.Csharp.Components.Ui)
+ == Efl.Csharp.Components.Ui)
{
Eina.Log.Debug("Shutting down Elementary");
Efl.Ui.Config.Shutdown();
}
- Eina.Log.Debug("Shutting down Eldbus");
- eldbus.Config.Shutdown();
- Eina.Log.Debug("Shutting down Evas");
- evas_shutdown();
- Eina.Log.Debug("Shutting down Ecore");
- ecore_shutdown();
- Eina.Log.Debug("Shutting down Eo");
- Efl.Eo.Config.Shutdown();
- Eina.Log.Debug("Shutting down Eina");
- Eina.Config.Shutdown();
+ if ((initComponents & Efl.Csharp.Components.Basic)
+ == Efl.Csharp.Components.Basic)
+ {
+ Eina.Log.Debug("Shutting down Eldbus");
+ eldbus.Config.Shutdown();
+ Eina.Log.Debug("Shutting down Evas");
+ evas_shutdown();
+ Eina.Log.Debug("Shutting down Ecore");
+ ecore_shutdown();
+ Eina.Log.Debug("Shutting down Eo");
+ Efl.Eo.Config.Shutdown();
+ Eina.Log.Debug("Shutting down Eina");
+ Eina.Config.Shutdown();
+ }
}
}
diff --git a/src/bindings/mono/efl_mono/efl_csharp_application.cs b/src/bindings/mono/efl_mono/efl_csharp_application.cs
index 4a936338cd..63d9aacae8 100644
--- a/src/bindings/mono/efl_mono/efl_csharp_application.cs
+++ b/src/bindings/mono/efl_mono/efl_csharp_application.cs
@@ -16,6 +16,9 @@
using System;
using System.Runtime.InteropServices;
using System.Threading;
+using System.Diagnostics.CodeAnalysis;
+using System.Collections.Generic;
+
using static Efl.UnsafeNativeMethods;
namespace Efl.Csharp
@@ -24,17 +27,32 @@ namespace Efl.Csharp
/// <summary>The components to be initialized.
/// <para>Since EFL 1.23.</para>
/// </summary>
-public enum Components
+[Flags]
+public enum Components : Int32
{
+ // Base flags.
+ /// <summary>
+ /// Initialize nothing.
+ /// <para>Since EFL 1.24.</para>
+ /// </summary>
+ None = 0x0,
///<summary>Basic components: Eina, Eo, Ecore, Evas and DBus.
- /// <para>Since EFL 1.23.</para>
+ /// <para>Since EFL 1.24.</para>
/// </summary>
- Basic,
- ///<summary>The same components of <see cref="Efl.Csharp.Components.Basic"/>
- /// and the Elementary widget toolkit.
- /// <para>Since EFL 1.23.</para>
+ Basic = 0x1,
+ /// <summary>
+ /// Elementary Widget toolkit: Elm.
+ /// <para>it's depend of <see cref="Efl.Csharp.Components.Basic" />.</para>
+ /// <para>Since EFL 1.24</para>
/// </summary>
- Ui,
+ Ui = Basic | 0x2,
+
+ // Combined flags.
+ /// <summary>
+ /// Enable all components, equals to <see cref="Efl.Csharp.Components.Ui" />.
+ /// <para>Since EFL 1.24.</para>
+ /// </summary>
+ All = int.MaxValue,
}
/// <summary>
@@ -60,23 +78,36 @@ public enum Components
public abstract class Application
{
//the initializied components
- private static Components initComponent;
+ private static Components initComponents = Components.All;
+
//what follows are 3 private functions to boot up the internals of efl
- private static void Init(Efl.Csharp.Components component)
+ private static void Init(Efl.Csharp.Components components = Components.All)
{
- Eina.Config.Init();
- Efl.Eo.Config.Init();
- ecore_init();
- ecore_init_ex(0, IntPtr.Zero);
- evas_init();
- eldbus.Config.Init();
-
- if (component == Components.Ui)
+ if (components == Components.None)
{
+ return;
+ }
+
+ initComponents = components;
+
+ if ((initComponents & Components.Basic) == Components.Basic)
+ {
+ Eina.Config.Init();
+ Efl.Eo.Config.Init();
+ ecore_init();
+ ecore_init_ex(0, IntPtr.Zero);
+ evas_init();
+ eldbus.Config.Init();
+ }
+
+ if ((initComponents & Components.Ui) == Components.Ui)
+ {
+#if WIN32
// TODO Support elm command line arguments
-#if WIN32 // Not a native define, we define it in our build system
+ // Not a native define, we define it in our build system
// Ecore_Win32 uses OleInitialize, which requires single thread apartments
- if (System.Threading.Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
+ if (System.Threading.Thread.CurrentThread.GetApartmentState()
+ != ApartmentState.STA)
{
throw new InvalidOperationException("UI Applications require STAThreadAttribute in Main()");
}
@@ -85,8 +116,6 @@ public abstract class Application
Efl.Ui.Win.ExitOnAllWindowsClosed = new Eina.Value(0);
}
-
- initComponent = component;
}
private static void Shutdown()
@@ -95,16 +124,24 @@ public abstract class Application
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
- if (initComponent == Components.Ui)
+ if (initComponents == Components.None)
+ {
+ return;
+ }
+
+ if ((initComponents & Components.Ui) == Components.Ui)
{
elm_shutdown();
}
- eldbus.Config.Shutdown();
- evas_shutdown();
- ecore_shutdown();
- Efl.Eo.Config.Shutdown();
- Eina.Config.Shutdown();
+ if ((initComponents & Components.Basic) == Components.Basic)
+ {
+ eldbus.Config.Shutdown();
+ evas_shutdown();
+ ecore_shutdown();
+ Efl.Eo.Config.Shutdown();
+ Eina.Config.Shutdown();
+ }
}
/// <summary>
@@ -157,7 +194,7 @@ public abstract class Application
/// <para>Since EFL 1.23.</para>
/// </summary>
/// <param name="components">The <see cref="Efl.Csharp.Components" /> to run the application.</param>
- public void Launch(Efl.Csharp.Components components = Components.Ui)
+ public void Launch(Efl.Csharp.Components components = Components.All)
{
Init(components);
Efl.App app = Efl.App.AppMain;