[retro-gtk/wip/aplazas/c-port: 19/36] Port ModuleQuery to C
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk/wip/aplazas/c-port: 19/36] Port ModuleQuery to C
- Date: Thu, 5 Oct 2017 07:36:22 +0000 (UTC)
commit 93a4c1a1561d46350228d6642160a66cbd5e5a40
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 | 27 +++++++++++
retro-gtk/retro-module-query.vala | 27 -----------
4 files changed, 121 insertions(+), 28 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index 41d3384..6f90946 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -43,6 +43,7 @@ retro_gtk_public_h_sources = \
retro-lightgun-id.h \
retro-log.h \
retro-memory-type.h \
+ retro-module-query.h \
retro-mouse-id.h \
retro-pa-player.h \
retro-pixel-format.h \
@@ -87,7 +88,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 \
@@ -115,6 +116,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 =
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..1c6e445
--- /dev/null
+++ b/retro-gtk/retro-module-query.h
@@ -0,0 +1,27 @@
+// This file is part of retro-gtk. License: GPL-3.0+.
+
+#ifndef RETRO_MODULE_QUERY_H
+#define RETRO_MODULE_QUERY_H
+
+#if !defined(__RETRO_GTK_INSIDE__) && !defined(RETRO_GTK_COMPILATION)
+# error "Only <retro-gtk.h> can be included directly."
+#endif
+
+#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]