efl_loop / efl_app: make efl_app / efl_loop abstract
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Thu, 21 Feb 2019 14:33:55 +0000 (15:33 +0100)
committerWonki Kim <wonki_.kim@samsung.com>
Fri, 8 Mar 2019 11:49:35 +0000 (20:49 +0900)
this is done inorder to ensure that noone ever thinks of creating theire
own app/loop object.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D7982

src/lib/ecore/efl_app.c
src/lib/ecore/efl_app.eo
src/lib/ecore/efl_loop.eo
src/lib/eo/eo_internal.h
src/tests/ecore/efl_app_test_loop.c
src/tests/efl_mono/Events.cs
src/tests/elementary/suite_helpers.c

index 6bfa800..01ae344 100644 (file)
@@ -5,6 +5,7 @@
 #include <Ecore.h>
 
 #include "ecore_private.h"
+#include "eo_internal.h"
 
 #ifndef _WIN32
 # include <sys/resource.h>
 
 #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;
 }
index 0589399..5d5cddd 100644 (file)
@@ -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;
index 50e0abf..4d08a6a 100644 (file)
@@ -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
 
index f57d269..0eecdf2 100644 (file)
@@ -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
 
index 0ab7bb6..4325be2 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <unistd.h>
+#include "eo_internal.h"
 #define EFL_NOLEGACY_API_SUPPORT
 #include <Efl_Core.h>
 #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,
index 7856878..c3c0341 100644 (file)
@@ -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;
index 4352b65..fe2976e 100644 (file)
@@ -4,6 +4,7 @@
 #include <Elementary.h>
 #include <Efl_Ui.h>
 #include <check.h>
+#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),