gplugin/gplugin

merging
feature/tcc-loader
2015-02-22, Gary Kramlich
d96c503ef371
merging
--- a/tcc/CMakeLists.txt Thu Feb 12 10:03:50 2015 -0800
+++ b/tcc/CMakeLists.txt Sun Feb 22 13:51:11 2015 -0600
@@ -7,12 +7,12 @@
if(BUILD_TCC)
set(GPLUGIN_TCC_SOURCES
gplugin-tcc-core.c
- gplugin-tcc-loader.c
+# gplugin-tcc-loader.c
gplugin-tcc-plugin.c
)
set(GPLUGIN_TCC_HEADERS
- gplugin-tcc-loader.h
+# gplugin-tcc-loader.h
gplugin-tcc-plugin.h
)
--- a/tcc/gplugin-tcc-core.c Thu Feb 12 10:03:50 2015 -0800
+++ b/tcc/gplugin-tcc-core.c Sun Feb 22 13:51:11 2015 -0600
@@ -23,7 +23,7 @@
G_MODULE_EXPORT GPluginPluginInfo *
-gplugin_query(GError **error) {
+gplugin_query(GPLUGIN_UNUSED GError **error) {
const gchar * const authors[] = {
"Eion Robb <eion@robbmob.com>",
NULL
@@ -34,10 +34,10 @@
GPLUGIN_NATIVE_PLUGIN_ABI_VERSION,
"internal", TRUE,
"load-on-query", TRUE,
- "name", "C Plugin Loader",
+ "name", "C source plugin loader",
"version", GPLUGIN_VERSION,
"license-id", "LGPL2",
- "summary", "A plugin that can load C script plugins",
+ "summary", "A plugin that can load C source plugins",
"description", "This plugin allows the loading of plugins written in C.",
"authors", authors,
"website", GPLUGIN_WEBSITE,
@@ -47,17 +47,21 @@
}
G_MODULE_EXPORT gboolean
-gplugin_load(GPluginNativePlugin *plugin, GError **error) {
- gplugin_tcc_loader_register(plugin);
- gplugin_tcc_plugin_register(plugin);
+gplugin_load(GPluginNativePlugin *plugin,
+ GPLUGIN_UNUSED GError **error)
+{
+// gplugin_tcc_loader_register(plugin);
+// gplugin_tcc_plugin_register(plugin);
- gplugin_manager_register_loader(gplugin_tcc_loader_get_type());
+// gplugin_manager_register_loader(gplugin_tcc_loader_get_type());
return TRUE;
}
G_MODULE_EXPORT gboolean
-gplugin_unload(GPluginNativePlugin *plugin, GError **error) {
+gplugin_unload(GPLUGIN_UNUSED GPluginNativePlugin *plugin,
+ GPLUGIN_UNUSED GError **error)
+{
return FALSE;
}
--- a/tcc/gplugin-tcc-loader.c Thu Feb 12 10:03:50 2015 -0800
+++ b/tcc/gplugin-tcc-loader.c Sun Feb 22 13:51:11 2015 -0600
@@ -33,15 +33,10 @@
* GPluginLoaderInterface API
*****************************************************************************/
static GSList *
-gplugin_tcc_loader_class_supported_extensions(const GPluginLoaderClass *klass) {
+gplugin_tcc_loader_class_supported_extensions(GPLUGIN_UNUSED const GPluginLoaderClass *klass) {
GSList *exts = NULL;
exts = g_slist_append(exts, "c");
- //exts = g_slist_append(exts, "so");
- //exts = g_slist_append(exts, "dll");
- //exts = g_slist_append(exts, "a");
- //exts = g_slist_append(exts, "exe");
- //exts = g_slist_append(exts, "obj");
return exts;
}
@@ -55,16 +50,17 @@
TCCState *s = NULL;
gpointer memneeded = NULL;
int memsize = -1;
-
+
GPluginTccPluginQueryFunc gplugin_query = NULL;
s = tcc_new();
-
+
if(tcc_add_file(s, filename) == -1) {
if(error)
*error = g_error_new(GPLUGIN_DOMAIN, 0, "couldn't load file %s", filename);
-
+
tcc_delete(s);
+
return NULL;
}
@@ -76,33 +72,34 @@
tcc_delete(s);
return NULL;
}
+
memneeded = g_malloc0(memsize);
if(tcc_relocate(s, memneeded) < 0) {
if(error)
*error = g_error_new(GPLUGIN_DOMAIN, 0, "could not relocate plugin into memory");
-
+
tcc_delete(s);
g_free(memneeded);
return NULL;
}
-
+
gplugin_query = (GPluginTccPluginQueryFunc) tcc_get_symbol(s, "gplugin_query");
if (gplugin_query == NULL) {
if(error)
*error = g_error_new(GPLUGIN_DOMAIN, 0, "no gplugin_query function found");
-
+
tcc_delete(s);
g_free(memneeded);
return NULL;
}
-
+
info = gplugin_query(error);
if(info == NULL) {
tcc_delete(s);
g_free(memneeded);
return NULL;
}
-
+
plugin = g_object_new(GPLUGIN_TYPE_TCC_PLUGIN,
"filename", filename,
"loader", loader,
@@ -115,38 +112,40 @@
}
static gboolean
-gplugin_tcc_loader_load(GPluginLoader *loader, GPluginPlugin *plugin,
+gplugin_tcc_loader_load(GPLUGIN_UNUSED GPluginLoader *loader,
+ GPluginPlugin *plugin,
GError **error)
{
GPluginTccPluginLoadFunc gplugin_load = NULL;
TCCState *s = gplugin_tcc_plugin_get_state(GPLUGIN_TCC_PLUGIN(plugin));
-
+
gplugin_load = (GPluginTccPluginLoadFunc) tcc_get_symbol(s, "gplugin_load");
if (gplugin_load == NULL) {
if(error)
*error = g_error_new(GPLUGIN_DOMAIN, 0, "no gplugin_load function found");
-
+
return FALSE;
}
-
+
return gplugin_load(GPLUGIN_NATIVE_PLUGIN(plugin), error);
}
static gboolean
-gplugin_tcc_loader_unload(GPluginLoader *loader, GPluginPlugin *plugin,
+gplugin_tcc_loader_unload(GPLUGIN_UNUSED GPluginLoader *loader,
+ GPluginPlugin *plugin,
GError **error)
{
GPluginTccPluginLoadFunc gplugin_unload = NULL;
TCCState *s = gplugin_tcc_plugin_get_state(GPLUGIN_TCC_PLUGIN(plugin));
-
+
gplugin_unload = (GPluginTccPluginUnloadFunc) tcc_get_symbol(s, "gplugin_unload");
if (gplugin_unload == NULL) {
if(error)
*error = g_error_new(GPLUGIN_DOMAIN, 0, "no gplugin_unload function found");
-
+
return FALSE;
}
-
+
return gplugin_unload(GPLUGIN_NATIVE_PLUGIN(plugin), error);
}
--- a/tcc/gplugin-tcc-plugin.c Thu Feb 12 10:03:50 2015 -0800
+++ b/tcc/gplugin-tcc-plugin.c Sun Feb 22 13:51:11 2015 -0600
@@ -52,14 +52,14 @@
static void
gplugin_tcc_plugin_set_state(GPluginTccPlugin *plugin, TCCState *s) {
GPluginTccPluginPrivate *priv = GPLUGIN_TCC_PLUGIN_GET_PRIVATE(plugin);
-
+
priv->s = s;
}
static void
gplugin_tcc_plugin_set_memory(GPluginTccPlugin *plugin, gpointer mem) {
GPluginTccPluginPrivate *priv = GPLUGIN_TCC_PLUGIN_GET_PRIVATE(plugin);
-
+
priv->mem = mem;
}
@@ -107,10 +107,10 @@
static void
gplugin_tcc_plugin_finalize(GObject *obj) {
GPluginTccPluginPrivate *priv = GPLUGIN_TCC_PLUGIN_GET_PRIVATE(obj);
-
+
if(priv->s)
tcc_delete(priv->s);
-
+
if(priv->mem)
g_free(priv->mem);
--- a/tcc/gplugin-tcc-plugin.h Thu Feb 12 10:03:50 2015 -0800
+++ b/tcc/gplugin-tcc-plugin.h Sun Feb 22 13:51:11 2015 -0600
@@ -58,5 +58,5 @@
G_END_DECLS
-#endif /* GPLUGIN_LUA_PLUGIN_H */
+#endif /* GPLUGIN_TCC_PLUGIN_H */
--- a/tcc/tests/CMakeLists.txt Thu Feb 12 10:03:50 2015 -0800
+++ b/tcc/tests/CMakeLists.txt Sun Feb 22 13:51:11 2015 -0600
@@ -20,8 +20,8 @@
-DTCC_PLUGIN_DIR="${CMAKE_CURRENT_SOURCE_DIR}/plugins"
)
-add_tcc_gtest(test-tcc-c-loader)
-target_link_libraries(test-tcc-c-loader gplugin-loader-tests)
+add_tcc_gtest(test-tcc-loader)
+target_link_libraries(test-tcc-loader gplugin-loader-tests)
set(GTESTER_TCC_TESTS "${TCC_TESTS}")
set(GTESTER_TCC_LOG "test-gplugin-tcc.xml")
--- a/tcc/tests/test-tcc-c-loader.c Thu Feb 12 10:03:50 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011-2013 Gary Kramlich <grim@reaperworld.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. 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(TCC_LOADER_DIR, TCC_PLUGIN_DIR, "c");
-
- return g_test_run();
-}
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tcc/tests/test-tcc-loader.c Sun Feb 22 13:51:11 2015 -0600
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2011-2013 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. 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(TCC_LOADER_DIR, TCC_PLUGIN_DIR, "c");
+
+ return g_test_run();
+}
+