[retro-gtk/wip/aplazas/port-module-query: 23/24] Port ModuleQuery to C
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk/wip/aplazas/port-module-query: 23/24] Port ModuleQuery to C
- Date: Sun, 17 Sep 2017 10:17:49 +0000 (UTC)
commit e5b4e62fb821a9167338908c52c855db60bd47b5
Author: Adrien Plazas <kekun plazas laposte net>
Date: Fri Sep 15 07:37:18 2017 +0200
Port ModuleQuery to C
retro-gtk/Makefile.am | 5 ++-
retro-gtk/retro-module-query.c | 90 +++++++++++++++++++++++++++++++++++++
retro-gtk/retro-module-query.h | 23 +++++++++
retro-gtk/retro-module-query.vala | 27 -----------
4 files changed, 117 insertions(+), 28 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index 73a993c..0af09a4 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -48,7 +48,7 @@ libretro_gtk_la_SOURCES = \
retro-input-device.c \
retro-log.c \
retro-module.c \
- retro-module-query.vala \
+ retro-module-query.c \
retro-module-iterator.vala \
retro-option.c \
retro-options.c \
@@ -77,6 +77,8 @@ retro-log.c: retro-gtk-internal.h
retro-module.c: retro-gtk-internal.h
+retro-module-query.c: retro-gtk-internal.h
+
retro-pa-player.c: retro-gtk-internal.h
libretro_gtk_la_LDFLAGS =
@@ -118,6 +120,7 @@ retro_gtkinclude_HEADERS = \
retro-lightgun-id.h \
retro-log.h \
retro-memory-type.h \
+ retro-module-query.h \
retro-mouse-id.h \
retro-option.h \
retro-options.h \
diff --git a/retro-gtk/retro-module-query.c b/retro-gtk/retro-module-query.c
new file mode 100644
index 0000000..659f9c9
--- /dev/null
+++ b/retro-gtk/retro-module-query.c
@@ -0,0 +1,90 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#include "retro-module-query.h"
+
+#include "retro-gtk-internal.h"
+
+struct _RetroModuleQuery
+{
+ GObject parent_instance;
+ gboolean recursive;
+};
+
+G_DEFINE_TYPE (RetroModuleQuery, retro_module_query, G_TYPE_OBJECT)
+
+#define RETRO_MODULE_QUERY_ENV_PLUGIN_PATH "LIBRETRO_PLUGIN_PATH"
+
+/* Private */
+
+static void
+retro_module_query_finalize (GObject *object)
+{
+ RetroModuleQuery *self = RETRO_MODULE_QUERY (object);
+
+ G_OBJECT_CLASS (retro_module_query_parent_class)->finalize (object);
+}
+
+static void
+retro_module_query_class_init (RetroModuleQueryClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = retro_module_query_finalize;
+}
+
+static void
+retro_module_query_init (RetroModuleQuery *self)
+{
+}
+
+static gchar **
+retro_module_query_get_plugin_lookup_paths ()
+{
+ gchar **envp;
+ gchar *env_plugin_path;
+ gchar *full_plugin_path;
+ gchar **result;
+
+ envp = g_get_environ ();
+ env_plugin_path = g_environ_getenv (envp, RETRO_MODULE_QUERY_ENV_PLUGIN_PATH);
+ if (env_plugin_path == NULL) {
+ g_strfreev (envp);
+
+ return g_strsplit (RETRO_PLUGIN_PATH, ":", 0);
+ }
+
+ full_plugin_path = g_strconcat (env_plugin_path, ":", RETRO_PLUGIN_PATH, NULL);
+ g_strfreev (envp);
+ result = g_strsplit (full_plugin_path, ":", 0);
+ g_free (full_plugin_path);
+
+ return result;
+}
+
+/* Public */
+
+RetroModuleIterator *
+retro_module_query_iterator (RetroModuleQuery *self)
+{
+ RetroModuleIterator *result;
+ gchar **paths;
+
+ g_return_val_if_fail (RETRO_IS_MODULE_ITERATOR (self), NULL);
+
+ paths = retro_module_query_get_plugin_lookup_paths ();
+ result = retro_module_iterator_new (paths, g_strv_length (paths), self->recursive);
+ g_strfreev (paths);
+
+ return result;
+}
+
+RetroModuleQuery *
+retro_module_query_new (gboolean recursive)
+{
+ RetroModuleQuery *self;
+
+ self = g_object_new (RETRO_TYPE_MODULE_QUERY, NULL);
+ self->recursive = recursive;
+
+ return self;
+}
diff --git a/retro-gtk/retro-module-query.h b/retro-gtk/retro-module-query.h
new file mode 100644
index 0000000..ac62705
--- /dev/null
+++ b/retro-gtk/retro-module-query.h
@@ -0,0 +1,23 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_MODULE_QUERY_H
+#define RETRO_MODULE_QUERY_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+// FIXME Remove as soon as possible.
+typedef struct _RetroModuleIterator RetroModuleIterator;
+
+#define RETRO_TYPE_MODULE_QUERY (retro_module_query_get_type())
+
+G_DECLARE_FINAL_TYPE (RetroModuleQuery, retro_module_query, RETRO, MODULE_QUERY, GObject)
+
+RetroModuleQuery *retro_module_query_new (gboolean recursive);
+RetroModuleIterator *retro_module_query_iterator (RetroModuleQuery *self);
+
+G_END_DECLS
+
+#endif /* RETRO_MODULE_QUERY_H */
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]