From 078ccd1ca9d53421f0a378e77957abd0d11f3704 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Thu, 21 Feb 2019 15:33:55 +0100 Subject: [PATCH] efl_loop / efl_app: make efl_app / efl_loop abstract this is done inorder to ensure that noone ever thinks of creating theire own app/loop object. Reviewed-by: Cedric BAIL Differential Revision: https://phab.enlightenment.org/D7982 --- src/lib/ecore/efl_app.c | 5 ++++- src/lib/ecore/efl_app.eo | 2 +- src/lib/ecore/efl_loop.eo | 2 +- src/lib/eo/eo_internal.h | 9 +++++++++ src/tests/ecore/efl_app_test_loop.c | 5 ++++- src/tests/efl_mono/Events.cs | 2 +- src/tests/elementary/suite_helpers.c | 5 ++++- 7 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/lib/ecore/efl_app.c b/src/lib/ecore/efl_app.c index 6bfa80088b..01ae3447e9 100644 --- a/src/lib/ecore/efl_app.c +++ b/src/lib/ecore/efl_app.c @@ -5,6 +5,7 @@ #include #include "ecore_private.h" +#include "eo_internal.h" #ifndef _WIN32 # include @@ -12,13 +13,15 @@ #define MY_CLASS EFL_APP_CLASS +EFL_CLASS_SIMPLE_CLASS(efl_app, "Efl.App", EFL_APP_CLASS) + Efl_Version _app_efl_version = { 0, 0, 0, 0, NULL, NULL }; EOLIAN static Efl_App* _efl_app_app_main_get(void) { if (_mainloop_singleton) return _mainloop_singleton; - _mainloop_singleton = efl_add_ref(EFL_APP_CLASS, NULL); + _mainloop_singleton = efl_add_ref(efl_app_realized_class_get(), NULL); _mainloop_singleton_data = efl_data_scope_get(_mainloop_singleton, EFL_LOOP_CLASS); return _mainloop_singleton; } diff --git a/src/lib/ecore/efl_app.eo b/src/lib/ecore/efl_app.eo index 05893997d9..5d5cddd551 100644 --- a/src/lib/ecore/efl_app.eo +++ b/src/lib/ecore/efl_app.eo @@ -1,6 +1,6 @@ import efl_types; -class @beta Efl.App extends Efl.Loop implements Efl.Core.Command_Line +abstract @beta Efl.App extends Efl.Loop implements Efl.Core.Command_Line { [[Object representing the application itself]] data: null; diff --git a/src/lib/ecore/efl_loop.eo b/src/lib/ecore/efl_loop.eo index 50e0abfba2..4d08a6ab7b 100644 --- a/src/lib/ecore/efl_loop.eo +++ b/src/lib/ecore/efl_loop.eo @@ -4,7 +4,7 @@ struct Efl.Loop_Arguments { initialization: bool; [[Set to $true when the program should initialize its internal state. This happen once per process instance.]] } -class @beta Efl.Loop extends Efl.Task +abstract @beta Efl.Loop extends Efl.Task { [[The Efl Main Loop diff --git a/src/lib/eo/eo_internal.h b/src/lib/eo/eo_internal.h index f57d2698d5..0eecdf2eb2 100644 --- a/src/lib/eo/eo_internal.h +++ b/src/lib/eo/eo_internal.h @@ -35,6 +35,15 @@ EAPI void ___efl_auto_unref_set(Eo *obj_id, Eina_Bool enable); EAPI int ___efl_ref2_count(const Eo *obj_id); EAPI void ___efl_ref2_reset(const Eo *obj_id); +#define EFL_CLASS_SIMPLE_CLASS(FUNC, NAME, ABSTRACT_CLASS) \ +static const Efl_Class_Description FUNC ##_realized_class_desc = { \ + EO_VERSION, \ + #NAME"_Realized", \ + EFL_CLASS_TYPE_REGULAR, \ + 0, NULL, NULL, NULL \ +}; \ +EFL_DEFINE_CLASS(FUNC ##_realized_class_get, &FUNC ##_realized_class_desc, ABSTRACT_CLASS, NULL) + #undef EAPI #define EAPI diff --git a/src/tests/ecore/efl_app_test_loop.c b/src/tests/ecore/efl_app_test_loop.c index 0ab7bb6bdb..4325be2a9e 100644 --- a/src/tests/ecore/efl_app_test_loop.c +++ b/src/tests/ecore/efl_app_test_loop.c @@ -4,6 +4,7 @@ #include #include +#include "eo_internal.h" #define EFL_NOLEGACY_API_SUPPORT #include #include "efl_app_suite.h" @@ -65,13 +66,15 @@ loop_timer_tick(void *data, const Efl_Event *ev EINA_UNUSED) efl_loop_iterate(data); } +EFL_CLASS_SIMPLE_CLASS(efl_loop, "Efl.Loop", EFL_LOOP_CLASS) + EFL_START_TEST(efl_app_test_efl_loop_concentric) { Eo *loop, *loop2, *timer, *timer2; int exitcode; loop = efl_main_loop_get(); - loop2 = efl_add(EFL_LOOP_CLASS, loop); + loop2 = efl_add(efl_loop_realized_class_get(), loop); efl_event_callback_add(loop, EFL_LOOP_EVENT_IDLE, loop_idle, loop2); efl_event_callback_add(loop, EFL_LOOP_EVENT_IDLE_ENTER, loop_idle_enter, NULL); timer = efl_add(EFL_LOOP_TIMER_CLASS, loop2, diff --git a/src/tests/efl_mono/Events.cs b/src/tests/efl_mono/Events.cs index 78568782dc..c3c034166d 100644 --- a/src/tests/efl_mono/Events.cs +++ b/src/tests/efl_mono/Events.cs @@ -25,7 +25,7 @@ class TestEoEvents public static void idle_event() { - Efl.Loop loop = new Efl.Loop(); + Efl.Loop loop = Efl.App.AppMain; loop.SetName("loop"); TestEoEvents listener = new TestEoEvents(); listener.loop = loop; diff --git a/src/tests/elementary/suite_helpers.c b/src/tests/elementary/suite_helpers.c index 4352b65408..fe2976e48b 100644 --- a/src/tests/elementary/suite_helpers.c +++ b/src/tests/elementary/suite_helpers.c @@ -4,6 +4,7 @@ #include #include #include +#include "eo_internal.h" #include "../efl_check.h" #include "elm_widget.h" @@ -170,6 +171,8 @@ _ui_win_hide(void *data EINA_UNUSED, const Efl_Event *ev) efl_key_data_set(ev->object, "timer", NULL); } +EFL_CLASS_SIMPLE_CLASS(efl_loop, "Efl.Loop", EFL_LOOP_CLASS) + static Evas_Object * _elm_suite_win_create() { @@ -181,7 +184,7 @@ _elm_suite_win_create() else win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(), efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC)); if (!buffer) return win; - loop = efl_add(EFL_LOOP_CLASS, win); + loop = efl_add(efl_loop_realized_class_get(), win); timer = efl_add(EFL_LOOP_TIMER_CLASS, loop, efl_loop_timer_interval_set(efl_added, BUFFER_RENDER_INTERVAL), efl_event_freeze(efl_added),