[retro-gtk] core: Port init() to C



commit 6a59ef5b625806da13e5d711a4e3f0dab49eda89
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu Jul 20 11:26:30 2017 +0200

    core: Port init() to C
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777489

 retro-gtk/core.vala    |   17 ++---------------
 retro-gtk/retro-core.c |   31 +++++++++++++++++++++++++++++--
 2 files changed, 31 insertions(+), 17 deletions(-)
---
diff --git a/retro-gtk/core.vala b/retro-gtk/core.vala
index 5a909c0..7699583 100644
--- a/retro-gtk/core.vala
+++ b/retro-gtk/core.vala
@@ -133,7 +133,7 @@ public class Core : Object {
        /**
         * Whether or not the a game is loaded.
         */
-       public bool is_initiated { private set; get; default = false; }
+       public bool is_initiated { internal set; get; default = false; }
 
        /**
         * Whether or not the a game is loaded.
@@ -255,25 +255,12 @@ public class Core : Object {
         *
         * Must be called before loading a game and running the core.
         */
-       public void init () throws Error {
-               set_environment_interface ();
-               push_cb_data ();
-               module.init ();
-               pop_cb_data ();
-
-               init_input ();
-
-               is_initiated = true;
-
-               load_medias ();
-       }
+       public extern void init () throws Error;
 
        public extern void set_medias ([CCode (array_null_terminated = true, array_length = false)] string[] 
uris);
 
        public extern void set_current_media (uint media_index) throws Error;
 
-       private extern void load_medias () throws Error;
-
        public extern void set_controller_port_device (uint port, DeviceType device);
 
        /**
diff --git a/retro-gtk/retro-core.c b/retro-gtk/retro-core.c
index e30d14b..3f0fc78 100644
--- a/retro-gtk/retro-core.c
+++ b/retro-gtk/retro-core.c
@@ -250,8 +250,7 @@ retro_core_prepare (RetroCore* self) {
   return game_loaded;
 }
 
-// FIXME Make static as soon as possible.
-void
+static void
 retro_core_load_medias (RetroCore* self,
                         GError** error)
 {
@@ -327,6 +326,34 @@ retro_core_load_medias (RetroCore* self,
 /* Public */
 
 void
+retro_core_init (RetroCore  *self,
+                 GError    **error)
+{
+  RetroInit init;
+  GError *tmp_error = NULL;
+
+  g_return_if_fail (self != NULL);
+
+  retro_core_set_environment_interface (self);
+
+  retro_core_push_cb_data (self);
+  init = retro_module_get_init (self->module);
+  init ();
+  retro_core_pop_cb_data ();
+
+  retro_core_init_input (self);
+
+  retro_core_set_is_initiated (self, TRUE);
+
+  retro_core_load_medias (self, &tmp_error);
+  if (G_UNLIKELY (tmp_error != NULL)) {
+    g_propagate_error (error, tmp_error);
+
+    return;
+  }
+}
+
+void
 retro_core_set_medias (RetroCore  *self,
                        gchar     **uris)
 {


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