From 24c0eced7724f435cec0e5b81e45f1485d08c64e Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Wed, 18 Oct 2017 18:12:13 +0900 Subject: [PATCH] config: Simplify EO API This is: - using a property (but terribly ugly due to the ownership on the returned value) - removing an unused function Note: This interface Efl.Config covers only elm_config for now. But it's very generic and could be used in the future for application specific configuration. --- src/lib/efl/interfaces/efl_config.eo | 43 ++++++++++++------------- src/lib/elementary/efl_config_global.eo | 4 +-- src/lib/elementary/elm_config.c | 13 ++------ 3 files changed, 24 insertions(+), 36 deletions(-) diff --git a/src/lib/efl/interfaces/efl_config.eo b/src/lib/efl/interfaces/efl_config.eo index 7dec728efd..aa19dfad48 100644 --- a/src/lib/efl/interfaces/efl_config.eo +++ b/src/lib/efl/interfaces/efl_config.eo @@ -2,30 +2,29 @@ interface Efl.Config () { [[A generic configuration interface, that holds key-value pairs.]] methods { - /* FIXME: make this a property -- @own is a problem */ - config_set { - [[Set configuration]] - params { - name: string; [[Configuration option name]] - val: const(any_value_ptr); [[Configuration option value]] + @property config { + [[A generic configuration value, refered to by name.]] + get { + keys { + name: string; [[Configuration option name.]] + } + values { + value: any_value_ptr @owned; + [[The value. It will be empty if it doesn't exist. The caller + must free it after use (using $eina_value_free() in C).]] + } } - return: bool; [[$false in case of error: value type was invalid, the - config can't be changed, config does not exist...]] - } - config_get @const { - [[Get configuration]] - params { - name: string; [[Configuration option name]] + set { + keys { + name: string; [[Configuration option name.]] + } + values { + value: const(any_value_ptr); + [[Configuration option value. May be $null if not found.]] + } + return: bool; [[$false in case of error: value type was invalid, the + config can't be changed, config does not exist...]] } - return: any_value_ptr @owned; [[Configuration option value]] - } - config_list_get @const { - [[Returns a list of generic values under a given key.]] - params { - @in name: string; [[Configuration option name]] - } - return: iterator @owned; [[ - List of configuration option values]] } } } diff --git a/src/lib/elementary/efl_config_global.eo b/src/lib/elementary/efl_config_global.eo index 99ba68eb2b..2114036039 100644 --- a/src/lib/elementary/efl_config_global.eo +++ b/src/lib/elementary/efl_config_global.eo @@ -106,8 +106,6 @@ class Efl.Config.Global (Efl.Object, Efl.Config) } } implements { - Efl.Config.config_set; - Efl.Config.config_get; - Efl.Config.config_list_get; + Efl.Config.config { get; set; } } } diff --git a/src/lib/elementary/elm_config.c b/src/lib/elementary/elm_config.c index cfbfc0f871..9f6df2b6f8 100644 --- a/src/lib/elementary/elm_config.c +++ b/src/lib/elementary/elm_config.c @@ -4639,8 +4639,8 @@ _efl_config_global_efl_config_config_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNU } EOLIAN static Eina_Value * -_efl_config_global_efl_config_config_get(const Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, - const char *name) +_efl_config_global_efl_config_config_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, + const char *name) { Eina_Value *val = NULL; @@ -4766,15 +4766,6 @@ _efl_config_global_efl_config_config_get(const Eo *obj EINA_UNUSED, void *_pd EI return NULL; } -EOLIAN static Eina_Iterator * -_efl_config_global_efl_config_config_list_get(const Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, - const char *name) -{ - // Not implemented: none of the elm_config functions returns a list of primitive types - (void) name; - return NULL; -} - EOLIAN static void _efl_config_global_profile_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, const char *profile) {