Lots of tweaking and stuff
--- a/CMakeLists.txt Tue Jul 14 18:46:53 2015 -0500
+++ b/CMakeLists.txt Tue Sep 29 22:45:21 2015 -0500
@@ -22,7 +22,7 @@
###############################################################################
###############################################################################
set(GPLUGIN_MAJOR_VERSION 0)
set(GPLUGIN_MINOR_VERSION 0)
@@ -192,6 +192,7 @@
add_subdirectory(plugins)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/CMakeLists.txt Tue Sep 29 22:45:21 2015 -0500
@@ -0,0 +1,43 @@
+ "Whether or not to build the GJS JavaScript plugin loader" + set(GPLUGIN_GJS_SOURCES + set(GPLUGIN_GJS_HEADERS + pkg_check_modules(GJS REQUIRED gjs-1.0>=1.32.0) + add_library(gplugin-gjs MODULE + set_target_properties(gplugin-gjs PROPERTIES PREFIX "") + include_directories(${GJS_INCLUDE_DIRS}) + target_link_libraries(gplugin-gjs + install(TARGETS gplugin-gjs DESTINATION lib/gplugin) + add_subdirectory(tests) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/gplugin-gjs-core.cc Tue Sep 29 22:45:21 2015 -0500
@@ -0,0 +1,67 @@
+ * 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-native.h> +#include "gplugin-gjs-loader.h" +#include "gplugin-gjs-plugin.h" +extern "C" G_MODULE_EXPORT GPluginPluginInfo * +gplugin_query(GPLUGIN_UNUSED GError **error) { + const gchar * const authors[] = { + "Gary Kramlich <grim@reaperworld.com>", + return gplugin_plugin_info_new( + GPLUGIN_NATIVE_PLUGIN_ABI_VERSION, + "name", "Gjs JavaScript Plugin Loader", + "version", GPLUGIN_VERSION, + "summary", "A plugin that can load Gjs JavaScript plugins", + "description", "This plugin allows the loading of plugins written in " + "website", GPLUGIN_WEBSITE, +extern "C" G_MODULE_EXPORT gboolean +gplugin_load(GPluginNativePlugin *plugin, + GPLUGIN_UNUSED GError **error) + gplugin_gjs_loader_register(plugin); + gplugin_gjs_plugin_register(plugin); + gplugin_manager_register_loader(gplugin_gjs_loader_get_type()); +extern "C" G_MODULE_EXPORT gboolean +gplugin_unload(GPLUGIN_UNUSED GPluginNativePlugin *plugin, + GPLUGIN_UNUSED GError **error) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/gplugin-gjs-loader.cc Tue Sep 29 22:45:21 2015 -0500
@@ -0,0 +1,371 @@
+ * 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-loader.h" +#include "gplugin-gjs-plugin.h" +#include <gjs/gjs-module.h> +/****************************************************************************** + *****************************************************************************/ +static GObjectClass *parent_class = NULL; +static GType type_real = 0; +/****************************************************************************** + *****************************************************************************/ +gplugin_gjs_loader_find_function(JSContext *jsctx, JSObject *parent, + const gchar *name, GError **error) + jsval value = JSVAL_VOID; + g_message("ctx: %p", jsctx); + g_message("parent: %p", parent); + g_message("name: %s", name); + if(!JS_GetProperty(jsctx, parent, name, &value)) { + *error = g_error_new(GPLUGIN_DOMAIN, 0, + "Failed to find the function '%s'", name); + if(JSVAL_IS_VOID(value)) { + *error = g_error_new(GPLUGIN_DOMAIN, 0, "failed to find %s", name); + if(JSVAL_IS_OBJECT(value) && !JSVAL_IS_NULL(value)) { + return JS_ValueToFunction(jsctx, value); + *error = g_error_new(GPLUGIN_DOMAIN, 0, + "'%s' is not a function", name); +_gplugin_gjs_loader_eval(GjsContext *ctx, JSObject **scope, + const gchar *content, gsize content_length, + const gchar *filename, gint *exit_code, + JSContext *jsctx = NULL; + JSObject *global = NULL; + jsctx = (JSContext *)gjs_context_get_native_context(ctx); + global = gjs_get_global_object(jsctx); + JSAutoCompartment ac(jsctx, global); + JSAutoRequest ar(jsctx); + *scope = JS_NewObject(jsctx, NULL, NULL, NULL); + if(!gjs_eval_with_scope(jsctx, *scope, content, content_length, + gjs_log_exception(jsctx); + g_set_error(error, GPLUGIN_DOMAIN, 0, + "JS_EvaluateScript() failed"); + if(JSVAL_IS_INT(retval)) { + if(JS_ValueToInt32(jsctx, retval, &ret_code)) { +_gplugin_gjs_loader_eval_file(GjsContext *ctx, JSObject **scope, + const char *filename, GError **error) + gchar *contents = NULL; + file = g_file_new_for_commandline_arg(filename); + if(!g_file_query_exists(file, NULL)) { + g_object_unref(G_OBJECT(file)); + if(!g_file_load_contents(file, NULL, &contents, &content_length, NULL, error)) { + g_object_unref(G_OBJECT(file)); + ret = _gplugin_gjs_loader_eval(ctx, scope, contents, content_length, + filename, NULL, error); + g_object_unref(G_OBJECT(file)); +/****************************************************************************** + * GPluginLoaderInterface API + *****************************************************************************/ +gplugin_gjs_loader_class_supported_extensions(GPLUGIN_UNUSED const GPluginLoaderClass *klass) { + return g_slist_append(NULL, (gpointer)"js"); +gplugin_gjs_loader_query(GPluginLoader *loader, + GPluginPluginInfo *info = NULL; + GjsContext *context = NULL; + JSContext *jsctx = NULL; + JSObject *scope = NULL, *jsobj = NULL; + JSFunction *query = NULL; + context = gjs_context_new(); + g_message("Scope: %p", scope); + if(!_gplugin_gjs_loader_eval_file(context, &scope, filename, error)) { + g_object_unref(G_OBJECT(context)); + /* grab our context since we're going to pass it to find_function */ + jsctx = (JSContext *)gjs_context_get_native_context(context); + /* find the query function */ + query = gplugin_gjs_loader_find_function(jsctx, scope, "gplugin_query", + g_message("query: %p", query); + g_object_unref(G_OBJECT(context)); + /* now call the query function */ + if(!JS_CallFunction(jsctx, scope, query, 0, NULL, &value)) { + *error = g_error_new(GPLUGIN_DOMAIN, 0, + "Failed to call the query function"); + g_object_unref(G_OBJECT(context)); + /* now grab the plugin info */ + if(!JS_ValueToObject(jsctx, value, &jsobj)) { + *error = g_error_new(GPLUGIN_DOMAIN, 0, + "Query function did not return a GObject"); + g_object_unref(G_OBJECT(context)); + gobj = gjs_g_object_from_object(jsctx, jsobj); + if(!GPLUGIN_IS_PLUGIN_INFO(gobj)) { + *error = g_error_new(GPLUGIN_DOMAIN, 0, + "Query function did not return a " + "GPluginPluginInfo object"); + g_object_unref(G_OBJECT(context)); + info = GPLUGIN_PLUGIN_INFO(gobj); + return (GPluginPlugin *)g_object_new(GPLUGIN_TYPE_GJS_PLUGIN, +gplugin_gjs_loader_load_unload(GPLUGIN_UNUSED GPluginLoader *loader, + GPLUGIN_UNUSED GError **error) + JSContext *jsctx = NULL; + JSFunction *func = NULL; + JSObject *global = NULL, *js_plugin = NULL; + const gchar *func_name = (load) ? "gplugin_load" : "gplugin_unload"; + gchar *filename = NULL; + g_object_get(G_OBJECT(plugin), + func = gplugin_gjs_loader_find_function(jsctx, global, func_name, error); + js_plugin = gjs_object_from_g_object(jsctx, G_OBJECT(plugin)); + args[0] = OBJECT_TO_JSVAL(js_plugin); + if(!JS_CallFunction(jsctx, global, func, 1, args, &rval)) { + *error = g_error_new(GPLUGIN_DOMAIN, 0, + (load) ? "load" : "unload", filename); + ret = JSVAL_TO_BOOLEAN(rval); + *error = g_error_new(GPLUGIN_DOMAIN, 0, + (load) ? "load" : "unload", filename); +gplugin_gjs_loader_load(GPluginLoader *loader, GPluginPlugin *plugin, + return gplugin_gjs_loader_load_unload(loader, plugin, TRUE, error); +gplugin_gjs_loader_unload(GPluginLoader *loader, GPluginPlugin *plugin, + return gplugin_gjs_loader_load_unload(loader, plugin, FALSE, error); +/****************************************************************************** + *****************************************************************************/ +gplugin_gjs_loader_class_init(GPluginGjsLoaderClass *klass) { + GPluginLoaderClass *loader_class = GPLUGIN_LOADER_CLASS(klass); + parent_class = (GObjectClass*)g_type_class_peek_parent(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; +/****************************************************************************** + *****************************************************************************/ +gplugin_gjs_loader_register(GPluginNativePlugin *plugin) { + if(g_once_init_enter(&type_real)) { + info.class_size = sizeof(GPluginGjsLoaderClass); + info.class_init = (GClassInitFunc)gplugin_gjs_loader_class_init; + info.instance_size = sizeof(GPluginGjsLoader); + type = gplugin_native_plugin_register_type(plugin, + g_once_init_leave(&type_real, type); +gplugin_gjs_loader_get_type(void) { + if(G_UNLIKELY(type_real == 0)) { + g_warning("gplugin_gjs_loader_get_type was called before " + "the type was registered!\n"); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/gplugin-gjs-loader.h Tue Sep 29 22:45:21 2015 -0500
@@ -0,0 +1,60 @@
+ * 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/>. +#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-native.h> +struct _GPluginGjsLoader { + 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); +void gplugin_gjs_loader_register(GPluginNativePlugin *plugin); +GType gplugin_gjs_loader_get_type(void); +#endif /* GPLUGIN_GJS_LOADER_H */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/gplugin-gjs-plugin.cc Tue Sep 29 22:45:21 2015 -0500
@@ -0,0 +1,238 @@
+ * 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)) +/****************************************************************************** + *****************************************************************************/ +} GPluginGjsPluginPrivate; +/****************************************************************************** + *****************************************************************************/ +/****************************************************************************** + *****************************************************************************/ +static GObjectClass *parent_class = NULL; +static GType type_real = 0; +/****************************************************************************** + *****************************************************************************/ +gplugin_gjs_plugin_set_context(GPluginGjsPlugin *plugin, GjsContext *context) { + GPluginGjsPluginPrivate *priv = GPLUGIN_GJS_PLUGIN_GET_PRIVATE(plugin); + g_object_unref(G_OBJECT(priv->context)); + if(GJS_IS_CONTEXT(context)) { + priv->context = (GjsContext*)g_object_ref(G_OBJECT(context)); +gplugin_gjs_plugin_set_global_scope(GPluginGjsPlugin *plugin, JSObject *global) { + GPluginGjsPluginPrivate *priv = GPLUGIN_GJS_PLUGIN_GET_PRIVATE(plugin); +gplugin_gjs_plugin_set_js_context(GPluginGjsPlugin *plugin, JSContext *jsctx) { + GPluginGjsPluginPrivate *priv = GPLUGIN_GJS_PLUGIN_GET_PRIVATE(plugin); + priv->js_context = jsctx; +/****************************************************************************** + *****************************************************************************/ +gplugin_gjs_plugin_get_property(GObject *obj, guint param_id, GValue *value, + GPluginGjsPlugin *plugin = GPLUGIN_GJS_PLUGIN(obj); + g_value_set_object(value, gplugin_gjs_plugin_get_context(plugin)); + g_value_set_pointer(value, + gplugin_gjs_plugin_get_global_scope(plugin)); + g_value_set_pointer(value, + gplugin_gjs_plugin_get_js_context(plugin)); + G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); +gplugin_gjs_plugin_set_property(GObject *obj, guint param_id, + const GValue *value, GParamSpec *pspec) + GPluginGjsPlugin *plugin = GPLUGIN_GJS_PLUGIN(obj); + gplugin_gjs_plugin_set_context(plugin, (GjsContext*)g_value_get_object(value)); + gplugin_gjs_plugin_set_global_scope(plugin, + (JSObject*)g_value_get_pointer(value)); + gplugin_gjs_plugin_set_js_context(plugin, + (JSContext*)g_value_get_pointer(value)); + G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); +gplugin_gjs_plugin_finalize(GObject *obj) { + GPluginGjsPluginPrivate *priv = GPLUGIN_GJS_PLUGIN_GET_PRIVATE(obj); + g_object_unref(G_OBJECT(priv->context)); + G_OBJECT_CLASS(parent_class)->finalize(obj); +gplugin_gjs_plugin_class_init(GPluginGjsPluginClass *klass) { + GObjectClass *obj_class = G_OBJECT_CLASS(klass); + parent_class = (GObjectClass*)g_type_class_peek_parent(klass); + g_type_class_add_private(klass, sizeof(GPluginGjsPluginPrivate)); + 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; + g_object_class_install_property(obj_class, PROP_CONTEXT, + g_param_spec_object("context", "context", + "The Gjs Context for this plugin", + (GParamFlags)(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS))); + g_object_class_install_property(obj_class, PROP_GLOBAL, + g_param_spec_pointer("global", "global", + "The global scope for this plugin", + (GParamFlags)(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS))); + g_object_class_install_property(obj_class, PROP_JS_CONTEXT, + g_param_spec_pointer("js-context", "js-context", + "The JSContext function for this plugin", + (GParamFlags)(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS))); +/****************************************************************************** + *****************************************************************************/ +gplugin_gjs_plugin_register(GPluginNativePlugin *plugin) { + if(g_once_init_enter(&type_real)) { + info.class_size = sizeof(GPluginGjsPluginClass); + info.class_init = (GClassInitFunc)gplugin_gjs_plugin_class_init; + info.instance_size = sizeof(GPluginGjsPlugin); + type = gplugin_native_plugin_register_type(plugin, + g_once_init_leave(&type_real, type); +gplugin_gjs_plugin_get_type(void) { + if(G_UNLIKELY(type_real == 0)) { + g_warning("gplugin_gjs_plugin_get_type was called before " + "the type was registered!\n"); +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); +gplugin_gjs_plugin_get_global_scope(const GPluginGjsPlugin *plugin) { + GPluginGjsPluginPrivate *priv = NULL; + g_return_val_if_fail(GPLUGIN_IS_GJS_PLUGIN(plugin), NULL); + priv = GPLUGIN_GJS_PLUGIN_GET_PRIVATE(plugin); +gplugin_gjs_plugin_get_js_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->js_context; --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/gplugin-gjs-plugin.h Tue Sep 29 22:45:21 2015 -0500
@@ -0,0 +1,61 @@
+ * 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/>. +#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-native.h> +#include <gjs/gjs-module.h> +struct _GPluginGjsPlugin { +struct _GPluginGjsPluginClass { + GPluginPluginClass parent; + void (*_gplugin_reserved_1)(void); + void (*_gplugin_reserved_2)(void); + void (*_gplugin_reserved_3)(void); + void (*_gplugin_reserved_4)(void); +void gplugin_gjs_plugin_register(GPluginNativePlugin *plugin); +GType gplugin_gjs_plugin_get_type(void); +GjsContext *gplugin_gjs_plugin_get_context(const GPluginGjsPlugin *plugin); +JSObject *gplugin_gjs_plugin_get_global_scope(const GPluginGjsPlugin *plugin); +JSContext *gplugin_gjs_plugin_get_js_context(const GPluginGjsPlugin *plugin); +#endif /* GPLUGIN_GJS_PLUGIN_H */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/tests/CMakeLists.txt Tue Sep 29 22:45:21 2015 -0500
@@ -0,0 +1,52 @@
+macro(add_gjs_gtest target) + add_executable(${target} ${target}.c) + target_link_libraries(${target} + ${GLIB_LIBRARIES} ${GJS_LIBRARIES} gplugin + add_dependencies(${target} gplugin-gjs) + get_target_property(_output_name ${target} RUNTIME_OUTPUT_NAME) + if(NOT ${_output_name}) + get_target_property(_output_name ${target} LOCATION) + endif(NOT ${_output_name}) + list(APPEND GJS_TESTS ${_output_name}) + -DGJS_LOADER_DIR="${CMAKE_BINARY_DIR}/gjs" + -DGJS_PLUGIN_DIR="${CMAKE_CURRENT_SOURCE_DIR}/plugins" +add_gjs_gtest(test-gjs-loader) +target_link_libraries(test-gjs-loader gplugin-loader-tests) +set(GTESTER_GJS_TESTS "${GJS_TESTS}") +set(GTESTER_GJS_LOG "test-gplugin-gjs.xml") +set(GTESTER_GJS_JUNIT "test-gplugin-gjs-junit.xml") + COMMAND ${GTESTER} -k --verbose -o ${GTESTER_GJS_LOG} ${GJS_TESTS} + OUTPUT ${GTESTER_GJS_LOG} + DEPENDS gplugin gplugin-gjs + ${GJS_TESTS} ${CMAKE_CURRENT_SOURCE_DIR}/plugins + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${XSLTPROC} -o ${GTESTER_GJS_JUNIT} --nonet + ${CMAKE_SOURCE_DIR}/xsl/gtester-junit.xsl + OUTPUT ${GTESTER_GJS_JUNIT} + DEPENDS ${GTESTER_GJS_LOG} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +add_custom_target(gjs-tests ALL + DEPENDS ${GTESTER_GJS_LOG} ${GTESTER_GJS_JUNIT} ${GJS_TESTS} --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/tests/plugins/basic.js Tue Sep 29 22:45:21 2015 -0500
@@ -0,0 +1,43 @@
+ * 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, + description: 'description' +function gplugin_load(plugin) { +function gplugin_unload(plugin) { --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/tests/plugins/dependent.js Tue Sep 29 22:45:21 2015 -0500
@@ -0,0 +1,34 @@
+ * 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) { +function gplugin_unload(plugin) { --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/tests/plugins/load-exception.js Tue Sep 29 22:45:21 2015 -0500
@@ -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-load-exception" +function gplugin_load(plugin) { +function gplugin_unload(plugin) { --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/tests/plugins/load-failed.js Tue Sep 29 22:45:21 2015 -0500
@@ -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; +var gplugin_query = function() { + return new GPlugin.PluginInfo({ + id: "gplugin/gjs-load-failed" +var gplugin_load = function(plugin) { +var gplugin_unload = function(plugin) { --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/tests/plugins/unload-failed.js Tue Sep 29 22:45:21 2015 -0500
@@ -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-unload-failed" +function gplugin_load(plugin) { +function gplugin_unload(plugin) { --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gjs/tests/test-gjs-loader.c Tue Sep 29 22:45:21 2015 -0500
@@ -0,0 +1,31 @@
+ * 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/gplugin-loader-tests.h> +main(gint argc, gchar **argv) { + g_test_init(&argc, &argv, NULL); + gplugin_loader_tests_main(GJS_LOADER_DIR, GJS_PLUGIN_DIR, "gjs");