[retro-gtk/wip/aplazas/options] core: Add option accessors



commit 7cf0260731fc8cf5a6a7defc7fae4537b532d1a1
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Wed Sep 20 13:32:40 2017 +0200

    core: Add option accessors

 retro-gtk/core.vala       |    8 ++++
 retro-gtk/retro-core.c    |   84 +++++++++++++++++++++++++++++++++++++++++++++
 retro-gtk/retro-option.c  |    2 +-
 retro-gtk/retro-option.h  |    2 +-
 retro-gtk/retro-options.c |    2 +-
 retro-gtk/retro-options.h |    2 +-
 6 files changed, 96 insertions(+), 4 deletions(-)
---
diff --git a/retro-gtk/core.vala b/retro-gtk/core.vala
index 3778337..7b3d8c4 100644
--- a/retro-gtk/core.vala
+++ b/retro-gtk/core.vala
@@ -224,6 +224,14 @@ public class Core : Object {
         */
        public extern void set_memory (MemoryType id, uint8[] data);
 
+       public extern bool contains_option (string key);
+       public extern unowned string get_option_value (string key);
+       public extern void set_option_value (string key, string value);
+       public extern unowned string get_option_description (string key);
+       [CCode (type="const gchar * const *", array_length=false, array_null_terminated=true)]
+       public extern unowned string[] get_option_values (string key);
+       public extern List<weak string> get_option_keys ();
+
        private extern void init_input ();
        private extern void on_input_controller_connected (uint port, InputDevice device);
        private extern void on_input_controller_disconnected (uint port);
diff --git a/retro-gtk/retro-core.c b/retro-gtk/retro-core.c
index 5ff2763..68097f7 100644
--- a/retro-gtk/retro-core.c
+++ b/retro-gtk/retro-core.c
@@ -1057,3 +1057,87 @@ retro_core_set_memory (RetroCore       *self,
   memcpy (memory_region, data, length);
   memset (memory_region + length, 0, memory_region_size - length);
 }
+
+gboolean
+retro_core_contains_option (RetroCore   *self,
+                            const gchar *key)
+{
+  RetroCoreEnvironmentInternal *internal;
+
+  g_return_val_if_fail (RETRO_IS_CORE (self), FALSE);
+  g_return_val_if_fail (key != NULL, FALSE);
+
+  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+  return retro_options_contains (internal->options, key);
+}
+
+const gchar *
+retro_core_get_option_value (RetroCore   *self,
+                             const gchar *key)
+{
+  RetroCoreEnvironmentInternal *internal;
+
+  g_return_val_if_fail (RETRO_IS_CORE (self), NULL);
+  g_return_val_if_fail (key != NULL, NULL);
+
+  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+  return retro_options_get_option_value (internal->options, key);
+}
+
+void
+retro_core_set_option_value (RetroCore   *self,
+                             const gchar *key,
+                             const gchar *value)
+{
+  RetroCoreEnvironmentInternal *internal;
+
+  g_return_if_fail (RETRO_IS_CORE (self));
+  g_return_if_fail (key != NULL);
+  g_return_if_fail (value != NULL);
+
+  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+  retro_options_set_option_value(internal->options, key, value);
+}
+
+const gchar *
+retro_core_get_option_description (RetroCore   *self,
+                                   const gchar *key)
+{
+  RetroCoreEnvironmentInternal *internal;
+
+  g_return_val_if_fail (RETRO_IS_CORE (self), NULL);
+  g_return_val_if_fail (key != NULL, NULL);
+
+  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+  return retro_options_get_option_description (internal->options, key);
+}
+
+const gchar * const *
+retro_core_get_option_values (RetroCore   *self,
+                              const gchar *key)
+{
+  RetroCoreEnvironmentInternal *internal;
+
+  g_return_val_if_fail (RETRO_IS_CORE (self), NULL);
+  g_return_val_if_fail (key != NULL, NULL);
+
+  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+  return retro_options_get_option_values (internal->options, key);
+}
+
+GList *
+retro_core_get_option_keys (RetroCore *self)
+{
+  RetroCoreEnvironmentInternal *internal;
+
+  g_return_val_if_fail (RETRO_IS_CORE (self), NULL);
+
+  internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+  return retro_options_get_keys (internal->options);
+}
diff --git a/retro-gtk/retro-option.c b/retro-gtk/retro-option.c
index 2368293..fb058e7 100644
--- a/retro-gtk/retro-option.c
+++ b/retro-gtk/retro-option.c
@@ -73,7 +73,7 @@ retro_option_get_description (RetroOption *self)
   return self->description;
 }
 
-const gchar **
+const gchar * const *
 retro_option_get_values (RetroOption *self)
 {
   g_return_val_if_fail (RETRO_IS_OPTION (self), NULL);
diff --git a/retro-gtk/retro-option.h b/retro-gtk/retro-option.h
index b49ca09..8d7e8ea 100644
--- a/retro-gtk/retro-option.h
+++ b/retro-gtk/retro-option.h
@@ -16,7 +16,7 @@ RetroOption *retro_option_new (const RetroVariable  *variable,
                                GError              **error);
 const gchar *retro_option_get_key (RetroOption *self);
 const gchar *retro_option_get_description (RetroOption *self);
-const gchar **retro_option_get_values (RetroOption *self);
+const gchar * const *retro_option_get_values (RetroOption *self);
 const gchar *retro_option_get_current (RetroOption *self);
 void retro_option_set_current (RetroOption  *self,
                                const gchar  *current,
diff --git a/retro-gtk/retro-options.c b/retro-gtk/retro-options.c
index f6a12c0..4619f3d 100644
--- a/retro-gtk/retro-options.c
+++ b/retro-gtk/retro-options.c
@@ -124,7 +124,7 @@ retro_options_get_option_description (RetroOptions *self,
   return retro_option_get_description (option);
 }
 
-const gchar **
+const gchar * const *
 retro_options_get_option_values (RetroOptions *self,
                                  const gchar  *key)
 {
diff --git a/retro-gtk/retro-options.h b/retro-gtk/retro-options.h
index e4c1d2e..d20440a 100644
--- a/retro-gtk/retro-options.h
+++ b/retro-gtk/retro-options.h
@@ -23,7 +23,7 @@ void retro_options_set_option_value (RetroOptions *self,
                                      const gchar  *value);
 const gchar *retro_options_get_option_description (RetroOptions *self,
                                                    const gchar  *key);
-const gchar **retro_options_get_option_values (RetroOptions *self,
+const gchar * const *retro_options_get_option_values (RetroOptions *self,
                                                const gchar  *key);
 GList *retro_options_get_keys (RetroOptions *self);
 void retro_options_insert_variable (RetroOptions        *self,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]