grim/gplugin

Update to the develop branch
draft feature/gjs-cc
2020-02-15, Gary Kramlich
207be3b45350
Update to the develop branch
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/gplugin-gjs-core.cc Sat Feb 15 01:33:13 2020 -0600
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2011-2019 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gplugin.h>
+#include <gplugin-native.h>
+
+#include "gplugin-gjs-loader.h"
+#include "gplugin-gjs-plugin.h"
+
+extern "C" G_MODULE_EXPORT GPluginPluginInfo *
+gplugin_query(G_GNUC_UNUSED GError **error) {
+ const gchar * const authors[] = {
+ "Gary Kramlich <grim@reaperworld.com>",
+ NULL
+ };
+
+ return gplugin_plugin_info_new(
+ "gplugin/gjs-loader",
+ GPLUGIN_NATIVE_PLUGIN_ABI_VERSION,
+ "internal", TRUE,
+ "load-on-query", TRUE,
+ "name", "Gjs JavaScript Plugin Loader",
+ "version", GPLUGIN_VERSION,
+ "license-id", "GPL3",
+ "summary", "A plugin that can load Gjs JavaScript plugins",
+ "description", "This plugin allows the loading of plugins written in "
+ "Gjs JavaScript.",
+ "authors", authors,
+ "website", GPLUGIN_WEBSITE,
+ "category", "loaders",
+ NULL
+ );
+}
+
+extern "C" G_MODULE_EXPORT gboolean
+gplugin_load(GPluginNativePlugin *plugin,
+ G_GNUC_UNUSED GError **error)
+{
+ gplugin_gjs_loader_register(plugin);
+ gplugin_gjs_plugin_register(plugin);
+
+ gplugin_manager_register_loader(gplugin_gjs_loader_get_type());
+
+ return TRUE;
+}
+
+extern "C" G_MODULE_EXPORT gboolean
+gplugin_unload(G_GNUC_UNUSED GPluginNativePlugin *plugin,
+ G_GNUC_UNUSED GError **error)
+{
+ return FALSE;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/gplugin-gjs-loader.cc Sat Feb 15 01:33:13 2020 -0600
@@ -0,0 +1,192 @@
+/*
+ * Copyright (C) 2011-2019 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gplugin-gjs-loader.h"
+#include "gplugin-gjs-plugin.h"
+
+#include <glib/gi18n.h>
+
+#include <gjs/gjs.h>
+
+#include <jsapi.h>
+
+G_DEFINE_DYNAMIC_TYPE(GPluginGjsLoader, gplugin_gjs_loader, GPLUGIN_TYPE_LOADER);
+
+static GjsContext *global_ctx = NULL;
+
+/******************************************************************************
+ * Helpers
+ *****************************************************************************/
+static gboolean
+_gplugin_gjs_loader_eval_file(GjsContext *ctx,
+ const gchar *filename,
+ GError **error)
+{
+ gint exit_code = 0;
+
+ if(!gjs_context_eval_file(ctx, filename, &exit_code, error)) {
+ return FALSE;
+ }
+
+ return exit_code == 0;
+}
+
+/******************************************************************************
+ * GPluginLoaderInterface API
+ *****************************************************************************/
+static GSList *
+gplugin_gjs_loader_class_supported_extensions(G_GNUC_UNUSED const GPluginLoaderClass *klass) {
+ return g_slist_append(NULL, (gpointer)"js");
+}
+
+static GPluginPlugin *
+gplugin_gjs_loader_query(GPluginLoader *loader,
+ const gchar *filename,
+ GError **error)
+{
+ GObject *gobj = NULL;
+ GPluginPluginInfo *info = NULL;
+ GjsContext *context = NULL;
+ JSContext *cx = NULL;
+ JSObject *jsobj = NULL;
+
+ context = gjs_context_new();
+
+ g_message("context: %p", context);
+
+ if(!_gplugin_gjs_loader_eval_file(context, filename, error)) {
+ g_object_unref(G_OBJECT(context));
+
+ return NULL;
+ }
+
+ cx = (JSContext*)gjs_context_get_native_context(context);
+
+#if 0
+ /* now call the query function */
+ JS::RootedValue rval(cx);
+ JS::AutoValueArray<0> argv(cx);
+ if(!JS_CallFunctionName(cx, NULL, "gplugin_query", argv, &rval)) {
+ if(error) {
+ *error = g_error_new(GPLUGIN_DOMAIN, 0,
+ "Failed to call the query function");
+ }
+
+ g_object_unref(G_OBJECT(context));
+
+ return NULL;
+ }
+
+ /* now grab the plugin info */
+ if(!JS_ValueToObject(cx, rval, &jsobj)) {
+ if(error) {
+ *error = g_error_new(GPLUGIN_DOMAIN, 0,
+ "Query function did not return a GObject");
+ }
+
+ g_object_unref(G_OBJECT(context));
+
+ return NULL;
+ }
+
+ gobj = gjs_g_object_from_object(cx, jsobj);
+ if(!GPLUGIN_IS_PLUGIN_INFO(gobj)) {
+ if(error) {
+ *error = g_error_new(GPLUGIN_DOMAIN, 0,
+ "Query function did not return a "
+ "GPluginPluginInfo object");
+ }
+
+ g_object_unref(G_OBJECT(context));
+
+ return NULL;
+ }
+
+ info = GPLUGIN_PLUGIN_INFO(gobj);
+
+ return (GPluginPlugin *)g_object_new(GPLUGIN_TYPE_GJS_PLUGIN,
+ "filename", filename,
+ "loader", loader,
+ "info", info,
+ "context", context,
+ "global", scope,
+ NULL);
+#endif
+
+ return NULL;
+}
+
+static gboolean
+gplugin_gjs_loader_load_unload(G_GNUC_UNUSED GPluginLoader *loader,
+ GPluginPlugin *plugin,
+ gboolean load,
+ G_GNUC_UNUSED GError **error)
+{
+ g_set_error_literal(error, GPLUGIN_DOMAIN, 0, "unimplemented");
+
+ return FALSE;
+}
+
+static gboolean
+gplugin_gjs_loader_load(GPluginLoader *loader, GPluginPlugin *plugin,
+ GError **error)
+{
+ return gplugin_gjs_loader_load_unload(loader, plugin, TRUE, error);
+}
+
+static gboolean
+gplugin_gjs_loader_unload(GPluginLoader *loader, GPluginPlugin *plugin,
+ GError **error)
+{
+ return gplugin_gjs_loader_load_unload(loader, plugin, FALSE, error);
+}
+
+/******************************************************************************
+ * GObject Stuff
+ *****************************************************************************/
+static void
+gplugin_gjs_loader_init(G_GNUC_UNUSED GPluginGjsLoader *loader) {
+}
+
+static void
+gplugin_gjs_loader_class_init(G_GNUC_UNUSED GPluginGjsLoaderClass *klass) {
+ GPluginLoaderClass *loader_class = GPLUGIN_LOADER_CLASS(klass);
+
+ loader_class->supported_extensions =
+ gplugin_gjs_loader_class_supported_extensions;
+ loader_class->query = gplugin_gjs_loader_query;
+ loader_class->load = gplugin_gjs_loader_load;
+ loader_class->unload = gplugin_gjs_loader_unload;
+
+ g_warning("current-context: %p", gjs_context_get_current());
+
+ global_ctx = (GjsContext *)g_object_new(GJS_TYPE_CONTEXT, "program-name", "gplugin", NULL);
+}
+
+static void
+gplugin_gjs_loader_class_finalize(G_GNUC_UNUSED GPluginGjsLoaderClass *klass) {
+ g_clear_object(&global_ctx);
+}
+
+/******************************************************************************
+ * API
+ *****************************************************************************/
+void
+gplugin_gjs_loader_register(GPluginNativePlugin *plugin) {
+ gplugin_gjs_loader_register_type(G_TYPE_MODULE(plugin));
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/gplugin-gjs-loader.h Sat Feb 15 01:33:13 2020 -0600
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2011-2019 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GPLUGIN_GJS_LOADER_H
+#define GPLUGIN_GJS_LOADER_H
+
+#define GPLUGIN_TYPE_GJS_LOADER (gplugin_gjs_loader_get_type())
+#define GPLUGIN_GJS_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GPLUGIN_TYPE_GJS_LOADER, GPluginGjsLoader))
+#define GPLUGIN_GJS_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((obj), GPLUGIN_TYPE_GJS_LOADER, GPluginGjsLoaderClass))
+#define GPLUGIN_IS_GJS_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GPLUGIN_TYPE_GJS_LOADER))
+#define GPLUGIN_IS_GJS_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((obj), GPLUGIN_TYPE_GJS_LOADER))
+#define GPLUGIN_GJS_LOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GPLUGIN_TYPE_GJS_LOADER, GPluginGjsLoaderClass))
+
+typedef struct _GPluginGjsLoader GPluginGjsLoader;
+typedef struct _GPluginGjsLoaderClass GPluginGjsLoaderClass;
+
+#include <gplugin.h>
+#include <gplugin-native.h>
+
+struct _GPluginGjsLoader {
+ GPluginLoader parent;
+
+ void (*_gplugin_reserved_1)(void);
+ void (*_gplugin_reserved_2)(void);
+ void (*_gplugin_reserved_3)(void);
+ void (*_gplugin_reserved_4)(void);
+};
+
+struct _GPluginGjsLoaderClass {
+ GPluginLoaderClass parent;
+
+ void (*_gplugin_reserved_1)(void);
+ void (*_gplugin_reserved_2)(void);
+ void (*_gplugin_reserved_3)(void);
+ void (*_gplugin_reserved_4)(void);
+};
+
+G_BEGIN_DECLS
+
+void gplugin_gjs_loader_register(GPluginNativePlugin *plugin);
+GType gplugin_gjs_loader_get_type(void);
+
+G_END_DECLS
+
+#endif /* GPLUGIN_GJS_LOADER_H */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/gplugin-gjs-plugin.cc Sat Feb 15 01:33:13 2020 -0600
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2011-2014 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gplugin-gjs-plugin.h"
+
+#define GPLUGIN_GJS_PLUGIN_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GPLUGIN_TYPE_GJS_PLUGIN, GPluginGjsPluginPrivate))
+
+/******************************************************************************
+ * Typedefs
+ *****************************************************************************/
+typedef struct {
+ GjsContext *context;
+} GPluginGjsPluginPrivate;
+
+/******************************************************************************
+ * Enums
+ *****************************************************************************/
+enum {
+ PROP_ZERO,
+ PROP_CONTEXT,
+ N_PROPERTIES,
+};
+static GParamSpec *properties[N_PROPERTIES] = {NULL, };
+
+static void gplugin_gjs_plugin_iface_init(GPluginPluginInterface *iface);
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED(
+ GPluginGjsPlugin,
+ gplugin_gjs_plugin,
+ G_TYPE_OBJECT,
+ 0,
+ G_ADD_PRIVATE_DYNAMIC(GPluginGjsPlugin)
+ G_IMPLEMENT_INTERFACE(GPLUGIN_TYPE_PLUGIN, gplugin_gjs_plugin_iface_init)
+);
+
+/******************************************************************************
+ * GPluginPlugin Implementation
+ *****************************************************************************/
+static void
+gplugin_gjs_plugin_iface_init(G_GNUC_UNUSED GPluginPluginInterface *iface) {
+}
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+static void
+gplugin_gjs_plugin_set_context(GPluginGjsPlugin *plugin, GjsContext *context) {
+ GPluginGjsPluginPrivate *priv = GPLUGIN_GJS_PLUGIN_GET_PRIVATE(plugin);
+
+ if(priv->context)
+ g_object_unref(G_OBJECT(priv->context));
+
+ if(GJS_IS_CONTEXT(context)) {
+ priv->context = (GjsContext*)g_object_ref(G_OBJECT(context));
+ } else {
+ priv->context = NULL;
+ }
+}
+
+static void
+gplugin_gjs_plugin_get_property(GObject *obj, guint param_id, GValue *value,
+ GParamSpec *pspec)
+{
+ GPluginGjsPlugin *plugin = GPLUGIN_GJS_PLUGIN(obj);
+
+ switch(param_id) {
+ case PROP_CONTEXT:
+ g_value_set_object(value, gplugin_gjs_plugin_get_context(plugin));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+ break;
+ }
+}
+
+static void
+gplugin_gjs_plugin_set_property(GObject *obj, guint param_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ GPluginGjsPlugin *plugin = GPLUGIN_GJS_PLUGIN(obj);
+
+ switch(param_id) {
+ case PROP_CONTEXT:
+ gplugin_gjs_plugin_set_context(plugin, (GjsContext*)g_value_get_object(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+ break;
+ }
+}
+
+static void
+gplugin_gjs_plugin_init(G_GNUC_UNUSED GPluginGjsPlugin *plugin) {
+}
+
+static void
+gplugin_gjs_plugin_finalize(GObject *obj) {
+ GPluginGjsPluginPrivate *priv = GPLUGIN_GJS_PLUGIN_GET_PRIVATE(obj);
+
+ g_clear_object(&priv->context);
+
+ G_OBJECT_CLASS(gplugin_gjs_plugin_parent_class)->finalize(obj);
+}
+
+static void
+gplugin_gjs_plugin_class_init(GPluginGjsPluginClass *klass) {
+ GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+
+ obj_class->get_property = gplugin_gjs_plugin_get_property;
+ obj_class->set_property = gplugin_gjs_plugin_set_property;
+ obj_class->finalize = gplugin_gjs_plugin_finalize;
+
+ properties[PROP_CONTEXT] = g_param_spec_object(
+ "context", "context",
+ "The Gjs Context for this plugin",
+ GJS_TYPE_CONTEXT,
+ (GParamFlags)(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)
+ );
+
+ g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
+}
+
+static void
+gplugin_gjs_plugin_class_finalize(G_GNUC_UNUSED GPluginGjsPluginClass *klass) {
+}
+
+/******************************************************************************
+ * API
+ *****************************************************************************/
+void
+gplugin_gjs_plugin_register(GPluginNativePlugin *plugin) {
+ gplugin_gjs_plugin_register_type(G_TYPE_MODULE(plugin));
+}
+
+GjsContext *
+gplugin_gjs_plugin_get_context(const GPluginGjsPlugin *plugin) {
+ GPluginGjsPluginPrivate *priv = NULL;
+
+ g_return_val_if_fail(GPLUGIN_IS_GJS_PLUGIN(plugin), NULL);
+
+ priv = GPLUGIN_GJS_PLUGIN_GET_PRIVATE(plugin);
+
+ return priv->context;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/gplugin-gjs-plugin.h Sat Feb 15 01:33:13 2020 -0600
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011-2019 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GPLUGIN_GJS_PLUGIN_H
+#define GPLUGIN_GJS_PLUGIN_H
+
+#define GPLUGIN_TYPE_GJS_PLUGIN (gplugin_gjs_plugin_get_type())
+#define GPLUGIN_GJS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GPLUGIN_TYPE_GJS_PLUGIN, GPluginGjsPlugin))
+#define GPLUGIN_GJS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((obj), GPLUGIN_TYPE_GJS_PLUGIN, GPluginGjsPluginClass))
+#define GPLUGIN_IS_GJS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GPLUGIN_TYPE_GJS_PLUGIN))
+#define GPLUGIN_IS_GJS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((obj), GPLUGIN_TYPE_GJS_PLUGIN))
+#define GPLUGIN_GJS_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GPLUGIN_TYPE_GJS_PLUGIN, GPluginGjsPluginClass))
+
+typedef struct _GPluginGjsPlugin GPluginGjsPlugin;
+typedef struct _GPluginGjsPluginClass GPluginGjsPluginClass;
+
+#include <gplugin.h>
+#include <gplugin-native.h>
+
+#include <gjs/gjs.h>
+
+struct _GPluginGjsPlugin {
+ GObject parent;
+};
+
+struct _GPluginGjsPluginClass {
+ GObjectClass parent;
+};
+
+G_BEGIN_DECLS
+
+void gplugin_gjs_plugin_register(GPluginNativePlugin *plugin);
+GType gplugin_gjs_plugin_get_type(void);
+
+GjsContext *gplugin_gjs_plugin_get_context(const GPluginGjsPlugin *plugin);
+
+G_END_DECLS
+
+#endif /* GPLUGIN_GJS_PLUGIN_H */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/meson.build Sat Feb 15 01:33:13 2020 -0600
@@ -0,0 +1,39 @@
+if get_option('gjs')
+ if not get_option('gobject-introspection')
+ error('gnome-javascript plugin requires GObject Introspection.')
+ endif
+
+ GPLUGIN_GJS_SOURCES = [
+ 'gplugin-gjs-core.cc',
+ 'gplugin-gjs-loader.cc',
+ 'gplugin-gjs-plugin.cc',
+ ]
+
+ GPLUGIN_GJS_HEADERS = [
+ 'gplugin-gjs-loader.h',
+ 'gplugin-gjs-plugin.h',
+ ]
+
+ GJS = dependency('gjs-1.0', version: '>=1.32.0')
+
+ # tell meson we need cpp since we have gjs
+ add_languages('cpp')
+
+ gjs_args = [
+# '-DPREFIX="@0@"'.format(get_option('prefix')),
+# '-DLIBDIR="@0@"'.format(get_option('libdir')),
+ '-DGPLUGIN_WEBSITE="http://bitbucket.org/gplugin/main"',
+ ]
+
+ shared_library('gplugin-gjs',
+ GPLUGIN_GJS_SOURCES,
+ GPLUGIN_GJS_HEADERS,
+ name_prefix : '',
+ dependencies : [GIO, GJS, gplugin_dep],
+ install : true,
+ install_dir : join_paths(get_option('libdir'), 'gplugin'),
+ cpp_args: gjs_args,
+ )
+endif # gjs
+
+subdir('tests')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/tests/meson.build Sat Feb 15 01:33:13 2020 -0600
@@ -0,0 +1,13 @@
+if get_option('gjs')
+
+e = executable('test-gjs-loader', 'test-gjs-loader.c',
+ include_directories : include_directories('.'),
+ c_args : [
+ '-DGJS_LOADER_DIR="@0@/gjs"'.format(meson.build_root()),
+ '-DGJS_PLUGIN_DIR="@0@/plugins"'.format(meson.current_source_dir()),
+ ],
+ link_with : gplugin_loader_tests,
+ dependencies : [GLIB, GOBJECT, GJS, gplugin_dep])
+test('GNOME JavaScript loader', e)
+
+endif # gjs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/tests/plugins/basic.js Sat Feb 15 01:33:13 2020 -0600
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2011-2014 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+const GPlugin = imports.gi.GPlugin;
+
+function gplugin_query() {
+ return new GPlugin.PluginInfo({
+ id: "gplugin/gjs-basic-plugin",
+ abi_version: 0x01020304,
+ name: "basic plugin",
+ authors: ['author1'],
+ category: 'test',
+ version: 'version',
+ license_id: 'license',
+ summary: 'summary',
+ website: 'website',
+ description: 'description'
+ });
+};
+
+function gplugin_load(plugin) {
+ return true;
+};
+
+function gplugin_unload(plugin) {
+ return true;
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/tests/plugins/dependent.js Sat Feb 15 01:33:13 2020 -0600
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011-2014 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+const GPlugin = imports.gi.GPlugin;
+
+function gplugin_query() {
+ return new GPlugin.PluginInfo({
+ id: "gplugin/gjs-dependent-plugin",
+ dependencies: ["dependency1", "dependency2"],
+ });
+};
+
+function gplugin_load(plugin) {
+ return false;
+};
+
+function gplugin_unload(plugin) {
+ return false;
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/tests/plugins/load-exception.js Sat Feb 15 01:33:13 2020 -0600
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011-2014 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+const GPlugin = imports.gi.GPlugin;
+
+function gplugin_query() {
+ return new GPlugin.PluginInfo({
+ id: "gplugin/gjs-load-exception"
+ });
+};
+
+function gplugin_load(plugin) {
+ throw "boom!";
+};
+
+function gplugin_unload(plugin) {
+ return true;
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/tests/plugins/load-failed.js Sat Feb 15 01:33:13 2020 -0600
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011-2014 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+const GPlugin = imports.gi.GPlugin;
+
+var gplugin_query = function() {
+ return new GPlugin.PluginInfo({
+ id: "gplugin/gjs-load-failed"
+ });
+};
+
+var gplugin_load = function(plugin) {
+ return false;
+};
+
+var gplugin_unload = function(plugin) {
+ return true;
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/tests/plugins/unload-failed.js Sat Feb 15 01:33:13 2020 -0600
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011-2014 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+const GPlugin = imports.gi.GPlugin;
+
+function gplugin_query() {
+ return new GPlugin.PluginInfo({
+ id: "gplugin/gjs-unload-failed"
+ });
+};
+
+function gplugin_load(plugin) {
+ return true;
+};
+
+function gplugin_unload(plugin) {
+ return false;
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/tests/test-gjs-loader.c Sat Feb 15 01:33:13 2020 -0600
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2011-2017 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <gplugin.h>
+
+#include <gplugin/gplugin-loader-tests.h>
+
+gint
+main(gint argc, gchar **argv) {
+ g_test_init(&argc, &argv, NULL);
+
+ gplugin_loader_tests_main(GJS_LOADER_DIR, GJS_PLUGIN_DIR, "gjs");
+
+ return g_test_run();
+}
+
--- a/meson.build Tue Aug 03 03:42:48 2021 -0500
+++ b/meson.build Sat Feb 15 01:33:13 2020 -0600
@@ -5,7 +5,7 @@
license : 'LGPL-2.0-or-later',
version : '0.33.1-dev',
meson_version : '>=0.56.0',
- default_options : ['c_std=c99'])
+ default_options : ['c_std=c99', 'cpp_std=c++11'])
parts = meson.project_version().split('-')
if parts.length() > 1
@@ -36,6 +36,7 @@
GLIB = dependency('glib-2.0', version : '>=2.40.0')
GOBJECT = dependency('gobject-2.0')
+GIO = dependency('gio-2.0')
# we separate gmodule out so our test aren't linked to it
GMODULE = dependency('gmodule-2.0')
@@ -90,6 +91,7 @@
subdir('packaging')
subdir('po')
+subdir('gjs')
subdir('lua')
subdir('perl5')
subdir('python3')
--- a/meson_options.txt Tue Aug 03 03:42:48 2021 -0500
+++ b/meson_options.txt Sat Feb 15 01:33:13 2020 -0600
@@ -17,6 +17,12 @@
)
option(
+ 'gjs',
+ type : 'boolean', value : true,
+ description : 'Whether or not to build the GNOME JavaScript plugin loader'
+)
+
+option(
'help2man',
type : 'boolean', value : true,
description : 'Whether or not to build man pages from --help output'