gplugin/gplugin

248adf7fa170
flow: Promoted 'trunk' (f36cec1b6b4a) to 'feature/tcc-loader'.
--- a/CMakeLists.txt Thu Jan 28 23:15:55 2016 -0600
+++ b/CMakeLists.txt Sun Aug 21 23:56:03 2016 -0500
@@ -17,6 +17,9 @@
# don't force target names to match a pattern
cmake_policy(SET CMP0037 OLD)
+
+ # enable MACOSX_RPATH
+ cmake_policy(SET CMP0042 NEW)
endif(${CMAKE_VERSION} VERSION_GREATER "3.0.0")
###############################################################################
@@ -25,9 +28,9 @@
project(gplugin C)
set(GPLUGIN_MAJOR_VERSION 0)
-set(GPLUGIN_MINOR_VERSION 24)
-set(GPLUGIN_MICRO_VERSION 1)
-set(GPLUGIN_EXTRA_VERSION)
+set(GPLUGIN_MINOR_VERSION 28)
+set(GPLUGIN_MICRO_VERSION 0)
+set(GPLUGIN_EXTRA_VERSION dev)
set(GPLUGIN_VERSION ${GPLUGIN_MAJOR_VERSION}.${GPLUGIN_MINOR_VERSION}.${GPLUGIN_MICRO_VERSION}${GPLUGIN_EXTRA_VERSION})
@@ -106,27 +109,13 @@
include(help2man)
endif(BUILD_HELP2MAN)
-set(REQ_GLIB_VER 2.20.0)
-
-pkg_check_modules(GLIB REQUIRED
- glib-2.0>=${REQ_GLIB_VER}
- gobject-2.0>=${REQ_GLIB_VER}
-)
+pkg_check_modules(GLIB REQUIRED glib-2.0>=2.34.0 gobject-2.0)
# we separate gmodule out so our test aren't linked to it
-pkg_check_modules(GMODULE REQUIRED
- gmodule-2.0>=${REQ_GLIB_VER}
-)
+pkg_check_modules(GMODULE REQUIRED gmodule-2.0)
pkg_config_variable(glib-2.0 glib_genmarshal GLIB_GENMARSHAL)
-
-if(${GLIB_gobject-2.0_VERSION} LESS 2.32.0)
- set(GLIB_MKENUMS ${CMAKE_SOURCE_DIR}/tools/glib-mkenums
- CACHE FILEPATH "glib-mkenums executable"
- )
-else(${GLIB_gobject-2.0_VERSION} LESS 2.32.0)
- pkg_config_variable(glib-2.0 glib_mkenums GLIB_MKENUMS)
-endif(${GLIB_gobject-2.0_VERSION} LESS 2.32.0)
+pkg_config_variable(glib-2.0 glib_mkenums GLIB_MKENUMS)
if(TESTING_ENABLED)
find_program(GTESTER
@@ -159,6 +148,7 @@
add_definitions(
-std=c99
-g -g3
+ -O2
-DPREFIX="${CMAKE_INSTALL_PREFIX}"
-DLIBDIR="${CMAKE_INSTALL_LIBDIR}"
-DGPLUGIN_WEBSITE="http://bitbucket.org/gplugin/main"
@@ -169,16 +159,16 @@
)
# check if we're using gcc
-if(CMAKE_COMPILER_IS_GNUCC)
+if(CMAKE_COMPILER_IS_GNUCC OR APPLE)
add_definitions(
-DGPLUGIN_UNUSED=__attribute__\(\(unused\)\)
-ggdb
)
-else(CMAKE_COMPILER_IS_GNUCC)
+else(CMAKE_COMPILER_IS_GNUCC OR APPLE)
add_definitions(
-DGPLUGIN_UNUSED=
)
-endif(CMAKE_COMPILER_IS_GNUCC)
+endif(CMAKE_COMPILER_IS_GNUCC OR APPLE)
include_directories(
${CMAKE_SOURCE_DIR}
@@ -198,6 +188,7 @@
###############################################################################
add_subdirectory(gplugin)
add_subdirectory(gplugin-gtk)
+add_subdirectory(packaging)
add_subdirectory(plugins)
add_subdirectory(po)
--- a/ChangeLog Thu Jan 28 23:15:55 2016 -0600
+++ b/ChangeLog Sun Aug 21 23:56:03 2016 -0500
@@ -1,3 +1,17 @@
+0.28.0:
+
+0.27.0: 2016/04/18
+ * Bumped the glib requirement to 2.34.0
+ * Fix some error reporting with the native loader
+
+0.26.0: 2016/03/03
+ * Added a load-failed signal which is emitted when a plugin fails to load
+ * Removed pre glib 2.32.0 code
+
+0.25.0: 2016/02/06
+ * Fix a regression where the GIR file did not have a predictable name.
+ * Fix the glib requirement. It was set at 2.20, but we require 2.32.
+
0.24.1: 2016/01/28
* Fixed the version numbering finally
* Updated the version in CMakeLists.txt
--- a/Debian.md Thu Jan 28 23:15:55 2016 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-Installing from Packages
-========================
-
-There are packages available (more to come) via our debian mirror. You can
-access it with the following commands.
-
- sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 75FE259AA8AC8032
- echo "deb http://gplug.in/debian jessie main" | sudo tee /etc/apt/sources.list.d/gplugin.list
- sudo apt-get update
- sudo apt-get install libgplugin0 libgplugin-loaders
-
-You can use `apt-cache search gplugin` to see the other packages that are available
-
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/HACKING.OSX Sun Aug 21 23:56:03 2016 -0500
@@ -0,0 +1,28 @@
+There are a few notes about building on OSX.
+
+First off, building has *ONLY* been tested against homebrew. If you want to
+support fink or macports, please let me know and I will merge your pull
+request.
+
+Lua
+===
+
+For the Lua loader to work, you need to install lgi from luarocks either
+systemwide or to a virtual environment created by LuaDist, vert, or something
+along those lines.
+
+When you're building lgi against homebrew you'll have to set the
+PKG_CONFIG_PATH environment variable since homebrew does not install libffi
+systemwide. This is easily done via:
+
+ export PKG_CONFIG_PATH=$(brew --prefix libffi)/lib/pkgconfig
+
+and then running "luarocks install lgi"
+
+PYTHON
+======
+
+If you're using homebrew, you need to install pygobject3 with
+
+ brew install pygobject3 --with-python3
+
--- a/gplugin/CMakeLists.txt Thu Jan 28 23:15:55 2016 -0600
+++ b/gplugin/CMakeLists.txt Sun Aug 21 23:56:03 2016 -0500
@@ -222,30 +222,25 @@
# GObject Introspection
###############################################################################
if(BUILD_GIR)
- if(APPLE)
- message("The GObject Introspection build always fails on OS X, "
- "skipping")
- else(APPLE)
- include(GObjectIntrospection)
+ include(GObjectIntrospection)
- set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${CMAKE_BINARY_DIR}")
+ set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${CMAKE_BINARY_DIR}")
- gobject_introspection(
- FILENAME GPlugin-${GPLUGIN_MAJOR_VERSION}.${GPLUGIN_MINOR_VERSION}.gir
- PACKAGES glib-2.0 gmodule-2.0 gobject-2.0
- LIBRARY gplugin
- QUIET
- SCANNER_ARGS --add-include-path=${CMAKE_CURRENT_SOURCE_DIR}
- --include=GModule-2.0 --include=GObject-2.0
- COMPILER_ARGS --includedir=${CMAKE_CURRENT_SOURCE_DIR}
- SYMBOL_PREFIXES gplugin
- SOURCES ${GPLUGIN_SOURCES} ${GPLUGIN_HEADERS}
- BUILT_SOURCES ${GPLUGIN_PUBLIC_BUILT_SOURCES}
- ${GPLUGIN_PUBLIC_BUILT_HEADERS}
- )
- # For loader plugin tests dependencies
- set(GPLUGIN_GIR_TARGETS ${GPLUGIN_GIR_TARGETS} PARENT_SCOPE)
- endif(APPLE)
+ gobject_introspection(
+ FILENAME GPlugin-${GPLUGIN_MAJOR_VERSION}.${GPLUGIN_MINOR_VERSION}.gir
+ PACKAGES glib-2.0 gmodule-2.0 gobject-2.0
+ LIBRARY gplugin
+ QUIET
+ SCANNER_ARGS --add-include-path=${CMAKE_CURRENT_SOURCE_DIR}
+ --include=GModule-2.0 --include=GObject-2.0
+ COMPILER_ARGS --includedir=${CMAKE_CURRENT_SOURCE_DIR}
+ SYMBOL_PREFIXES gplugin
+ SOURCES ${GPLUGIN_SOURCES} ${GPLUGIN_HEADERS}
+ BUILT_SOURCES ${GPLUGIN_PUBLIC_BUILT_SOURCES}
+ ${GPLUGIN_PUBLIC_BUILT_HEADERS}
+ )
+ # For loader plugin tests dependencies
+ set(GPLUGIN_GIR_TARGETS ${GPLUGIN_GIR_TARGETS} PARENT_SCOPE)
endif(BUILD_GIR)
###############################################################################
--- a/gplugin/gplugin-manager.c Thu Jan 28 23:15:55 2016 -0600
+++ b/gplugin/gplugin-manager.c Sun Aug 21 23:56:03 2016 -0500
@@ -37,6 +37,7 @@
enum {
SIG_LOADING,
SIG_LOADED,
+ SIG_LOAD_FAILED,
SIG_UNLOADING,
SIG_UNLOADED,
N_SIGNALS,
@@ -89,6 +90,7 @@
GError **error);
void (*loaded_plugin)(GObject *manager,
GPluginPlugin *plugin);
+ void (*load_failed)(GObject *manager, GPluginPlugin *plugin);
gboolean (*unloading_plugin)(GObject *manager,
GPluginPlugin *plugin,
GError **error);
@@ -149,7 +151,7 @@
*****************************************************************************/
static void
gplugin_manager_real_append_path(GPluginManager *manager,
- const gchar *path)
+ const gchar *path)
{
GList *l = NULL;
@@ -165,7 +167,7 @@
static void
gplugin_manager_real_prepend_path(GPluginManager *manager,
- const gchar *path)
+ const gchar *path)
{
GList *l = NULL;
@@ -181,7 +183,7 @@
static void
gplugin_manager_real_remove_path(GPluginManager *manager,
- const gchar *path)
+ const gchar *path)
{
GList *l = NULL, *link = NULL;
@@ -209,7 +211,7 @@
static void
gplugin_manager_real_register_loader(GPluginManager *manager,
- GType type)
+ GType type)
{
GPluginLoader *loader = NULL;
GPluginLoaderClass *lo_class = NULL;
@@ -273,7 +275,7 @@
static void
gplugin_manager_real_unregister_loader(GPluginManager *manager,
- GType type)
+ GType type)
{
GPluginLoaderClass *klass = NULL;
GSList *exts = NULL;
@@ -550,7 +552,7 @@
static GSList *
gplugin_manager_real_find_plugins(GPluginManager *manager,
- const gchar *id)
+ const gchar *id)
{
GSList *plugins_list = NULL, *l;
@@ -767,15 +769,18 @@
gplugin_plugin_set_state(plugin, (ret) ? GPLUGIN_PLUGIN_STATE_LOADED :
GPLUGIN_PLUGIN_STATE_LOAD_FAILED);
- g_signal_emit(manager, signals[SIG_LOADED], 0, plugin);
+ if(ret)
+ g_signal_emit(manager, signals[SIG_LOADED], 0, plugin);
+ else
+ g_signal_emit(manager, signals[SIG_LOAD_FAILED], 0, plugin);
return ret;
}
static gboolean
gplugin_manager_real_unload_plugin(GPluginManager *manager,
- GPluginPlugin *plugin,
- GError **error)
+ GPluginPlugin *plugin,
+ GError **error)
{
GPluginLoader *loader = NULL;
gboolean ret = TRUE;
@@ -832,16 +837,7 @@
gplugin_manager_finalize(GObject *obj) {
GPluginManager *manager = GPLUGIN_MANAGER(obj);
-#if GLIB_CHECK_VERSION(2,32,0)
g_queue_free_full(manager->paths, g_free);
-#else
- GList *iter = NULL;
- GSList *l = NULL;
-
- for(iter = manager->paths->head; iter; iter = iter->next)
- g_free(iter->data);
- g_queue_free(manager->paths);
-#endif /* GLIB_CHECK_VERSION(2,32,0) */
/* free all the data in the plugins hash table and destroy it */
g_hash_table_foreach_remove(manager->plugins,
@@ -937,10 +933,28 @@
GPLUGIN_TYPE_PLUGIN);
/**
+ * GPluginManager::load-failed:
+ * @manager: The #GPluginPluginManager instance.
+ * @plugin: The #GPluginPlugin that failed to load.
+ *
+ * emitted after a plugin fails to load.
+ */
+ signals[SIG_LOAD_FAILED] =
+ g_signal_new("load-failed",
+ G_OBJECT_CLASS_TYPE(manager_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(GPluginManagerClass, load_failed),
+ NULL,
+ NULL,
+ gplugin_marshal_VOID__OBJECT,
+ G_TYPE_NONE,
+ 1,
+ GPLUGIN_TYPE_PLUGIN);
+
+ /**
* GPluginManager::unloading-plugin:
- * @manager: the #gpluginpluginmanager instance. treat as a #gobject.
- * @plugin: the #gpluginplugin that's about to be loaded.
- * @error: return address for a #gerror.
+ * @manager: the #GPluginPluginManager instance. treat as a #GObject.
+ * @plugin: the #GPluginPlugin that's about to be loaded.
*
* emitted before a plugin is unloaded.
*
--- a/gplugin/gplugin-native-loader.c Thu Jan 28 23:15:55 2016 -0600
+++ b/gplugin/gplugin-native-loader.c Sun Aug 21 23:56:03 2016 -0500
@@ -132,7 +132,7 @@
if(module)
g_module_close(module);
- if(error) {
+ if(error && !*error) {
*error = g_error_new(GPLUGIN_DOMAIN, 0,
_("the query function did not return a "
"GPluginPluginInfo instance"));
@@ -151,7 +151,7 @@
if(!GPLUGIN_IS_PLUGIN_INFO(info)) {
g_module_close(module);
- if(error) {
+ if(error && !*error) {
*error = g_error_new(GPLUGIN_DOMAIN, 0,
_("the query function did not return a "
"GPluginPluginInfo instance"));
--- a/gplugin/tests/CMakeLists.txt Thu Jan 28 23:15:55 2016 -0600
+++ b/gplugin/tests/CMakeLists.txt Sun Aug 21 23:56:03 2016 -0500
@@ -3,7 +3,15 @@
###############################################################################
macro(add_test_plugin plugin)
add_library(${plugin} MODULE ${plugin}.c)
- set_target_properties(${plugin} PROPERTIES PREFIX "")
+
+ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+ set(LINK_FLAGS "-undefined dynamic_lookup")
+ endif(CMAKE_C_COMPILER_ID MATCHES "Clang")
+
+ set_target_properties(${plugin} PROPERTIES
+ PREFIX ""
+ LINK_FLAGS "${LINK_FLAGS}"
+ )
target_link_libraries(${plugin} ${GLIB_LIBRARIES} gplugin)
endmacro(add_test_plugin)
@@ -31,6 +39,7 @@
add_subdirectory(load-on-query-fail)
add_subdirectory(versioned-dependencies)
add_subdirectory(bind-local)
+add_subdirectory(unresolved-symbol)
###############################################################################
# Tests
@@ -116,6 +125,15 @@
add_dependencies(test-bind-local bind-local)
add_definitions(-DTEST_BIND_LOCAL_DIR="${CMAKE_CURRENT_BINARY_DIR}/bind-local/")
+#######################################
+# Unresolved Symbol
+#######################################
+add_gtest(test-unresolved-symbol)
+add_dependencies(test-unresolved-symbol unresolved-symbol)
+add_definitions(
+ -DPLUGIN_DIR="${CMAKE_CURRENT_BINARY_DIR}/unresolved-symbol"
+)
+
###############################################################################
# GTester Stuff
###############################################################################
--- a/gplugin/tests/test-signals.c Thu Jan 28 23:15:55 2016 -0600
+++ b/gplugin/tests/test-signals.c Sun Aug 21 23:56:03 2016 -0500
@@ -24,6 +24,7 @@
gboolean loaded;
gboolean unloading;
gboolean unloaded;
+ gboolean load_failed;
} TestGPluginManagerSignalsData;
/******************************************************************************
@@ -105,6 +106,16 @@
return FALSE;
}
+static void
+test_gplugin_manager_signals_load_failed(GPLUGIN_UNUSED GObject *manager,
+ GPLUGIN_UNUSED GPluginPlugin *plugin,
+ gpointer d)
+{
+ TestGPluginManagerSignalsData *data = (TestGPluginManagerSignalsData *)d;
+
+ data->load_failed = TRUE;
+}
+
/******************************************************************************
* Tests
*****************************************************************************/
@@ -113,7 +124,7 @@
GPluginPlugin *plugin = NULL;
GObject *manager = gplugin_manager_get_instance();
GError *error = NULL;
- TestGPluginManagerSignalsData data = { FALSE, FALSE, FALSE, FALSE };
+ TestGPluginManagerSignalsData data = { FALSE, FALSE, FALSE, FALSE, FALSE };
gulong signals[] = { 0, 0, 0, 0};
signals[0] =
@@ -158,7 +169,7 @@
GPluginPlugin *plugin = NULL;
GObject *manager = gplugin_manager_get_instance();
GError *error = NULL;
- TestGPluginManagerSignalsData data = { FALSE, FALSE, FALSE, FALSE };
+ TestGPluginManagerSignalsData data = { FALSE, FALSE, FALSE, FALSE, FALSE };
gulong signals[] = { 0, 0, 0, 0};
signals[0] =
@@ -200,7 +211,7 @@
GPluginPlugin *plugin = NULL;
GObject *manager = gplugin_manager_get_instance();
GError *error = NULL;
- TestGPluginManagerSignalsData data = { FALSE, FALSE, FALSE, FALSE };
+ TestGPluginManagerSignalsData data = { FALSE, FALSE, FALSE, FALSE, FALSE };
gulong signals[] = { 0, 0, 0, 0};
signals[0] =
@@ -240,6 +251,36 @@
g_signal_handler_disconnect(manager, signals[3]);
}
+static void
+test_gplugin_manager_signals_load_failure(void) {
+ GPluginPlugin *plugin = NULL;
+ GObject *manager = gplugin_manager_get_instance();
+ GError *error = NULL;
+ TestGPluginManagerSignalsData data = { FALSE, FALSE, FALSE, FALSE, FALSE };
+ gulong signals[] = { 0, 0, 0, 0, 0};
+
+ signals[0] =
+ g_signal_connect(manager, "loading-plugin",
+ G_CALLBACK(test_gplugin_manager_signals_normal_loading),
+ &data);
+ signals[1] =
+ g_signal_connect(manager, "load-failed",
+ G_CALLBACK(test_gplugin_manager_signals_load_failed),
+ &data);
+
+ gplugin_manager_append_path(TEST_DIR);
+ gplugin_manager_refresh();
+
+ plugin = gplugin_manager_find_plugin("gplugin/native-load-failed");
+ gplugin_manager_load_plugin(plugin, &error);
+ g_assert_error(error, GPLUGIN_DOMAIN, 0);
+ g_assert(data.loading);
+ g_assert(data.load_failed);
+
+ g_signal_handler_disconnect(manager, signals[0]);
+ g_signal_handler_disconnect(manager, signals[1]);
+}
+
/******************************************************************************
* Main
*****************************************************************************/
@@ -256,6 +297,8 @@
test_gplugin_manager_signals_loading_stopped);
g_test_add_func("/manager/signals/unloading-stopped",
test_gplugin_manager_signals_unloading_stopped);
+ g_test_add_func("/manager/signals/load-failed",
+ test_gplugin_manager_signals_load_failure);
return g_test_run();
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/test-unresolved-symbol.c Sun Aug 21 23:56:03 2016 -0500
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2011-2016 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 <stdlib.h>
+
+#include <gplugin.h>
+#include <gplugin-native.h>
+
+#include <glib.h>
+
+/******************************************************************************
+ * Tests
+ *****************************************************************************/
+
+static void
+test_unresolved_symbol(void) {
+ g_test_expect_message(
+ G_LOG_DOMAIN,
+ G_LOG_LEVEL_WARNING,
+ "*some_unresolved_symbol*"
+ );
+
+ gplugin_manager_remove_paths();
+ gplugin_manager_append_path(PLUGIN_DIR);
+ gplugin_manager_refresh();
+
+ g_test_assert_expected_messages();
+}
+
+/******************************************************************************
+ * Main
+ *****************************************************************************/
+gint
+main(gint argc, gchar **argv) {
+
+ g_test_init(&argc, &argv, NULL);
+
+ gplugin_init();
+
+ /* test the load on query flag */
+ g_test_add_func("/loaders/native/unresolved-symbol",
+ test_unresolved_symbol);
+
+ return g_test_run();
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/unresolved-symbol/CMakeLists.txt Sun Aug 21 23:56:03 2016 -0500
@@ -0,0 +1,1 @@
+add_test_plugin(unresolved-symbol)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/unresolved-symbol/unresolved-symbol.c Sun Aug 21 23:56:03 2016 -0500
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2011-2016 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>
+
+G_MODULE_EXPORT GPluginPluginInfo *
+gplugin_query(GPLUGIN_UNUSED GError **error) {
+ some_unresolved_symbol();
+
+ return NULL;
+}
+
+G_MODULE_EXPORT gboolean
+gplugin_load(GPLUGIN_UNUSED GPluginNativePlugin *plugin,
+ GPLUGIN_UNUSED GError **error)
+{
+ return TRUE;
+}
+
+G_MODULE_EXPORT gboolean
+gplugin_unload(GPLUGIN_UNUSED GPluginNativePlugin *plugin,
+ GPLUGIN_UNUSED GError **error)
+{
+ return TRUE;
+}
+
--- a/lua/CMakeLists.txt Thu Jan 28 23:15:55 2016 -0600
+++ b/lua/CMakeLists.txt Sun Aug 21 23:56:03 2016 -0500
@@ -33,6 +33,8 @@
include_directories(${LUA_INCLUDE_DIRS})
+ link_directories(${LUA_LIBRARY_DIRS})
+
message(STATUS "checking for lua module 'lgi'")
# compile our lua-lgi test program
@@ -42,6 +44,7 @@
CMAKE_FLAGS
-DINCLUDE_DIRECTORIES:STRING=${LUA_INCLUDE_DIRS}
-DLINK_LIBRARIES:STRING=${LUA_LIBRARIES}
+ -DLINK_DIRECTORIES:STRING=${LUA_LIBRARY_DIRS}
OUTPUT_VARIABLE OUTPUT
COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/gplugin-lua-test-lgi
)
--- a/lua/gplugin-lua-test-lgi.c Thu Jan 28 23:15:55 2016 -0600
+++ b/lua/gplugin-lua-test-lgi.c Sun Aug 21 23:56:03 2016 -0500
@@ -16,18 +16,46 @@
*/
#include <stdio.h>
+#include <string.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
+static void
+_add_require_path(lua_State *L, const char *path) {
+ const char *pkg_path = NULL;
+ char buff[255];
+
+ lua_getglobal(L, "package");
+ lua_getfield(L, -1, "path"); // get field "path" from table at top of stack (-1)
+ pkg_path = lua_tostring(L, -1); // grab path string from top of stack
+
+ memset(buff, 0, sizeof(buff));
+ snprintf(buff, sizeof(buff), "%s;%s", pkg_path, path);
+
+ lua_pop(L, 1); // pop off the path field
+ lua_pushstring(L, buff); // push the new one
+ lua_setfield(L, -2, "path"); // set the field "path" in table at -2 with value at top of stack
+ lua_pop( L, 1 ); // get rid of package table from top of stack
+}
+
int
main(int argc, char *argv[]) {
- lua_State *L = luaL_newstate();
+ lua_State *L = NULL;
int ret = 0;
+ L = luaL_newstate();
+ if(L == NULL) {
+ return 134;
+ }
+
luaL_openlibs(L);
+ /* add some additional paths to package.path */
+ //_add_require_path(L, "/usr/local/lib/luarocks/rocks");
+
+ /* now try to do the require */
lua_getglobal(L, "require");
lua_pushstring(L, "lgi");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/packaging/CMakeLists.txt Sun Aug 21 23:56:03 2016 -0500
@@ -0,0 +1,1 @@
+configure_file(gplugin.spec.in gplugin.spec @ONLY)
--- a/packaging/debian/changelog Thu Jan 28 23:15:55 2016 -0600
+++ b/packaging/debian/changelog Sun Aug 21 23:56:03 2016 -0500
@@ -1,8 +1,26 @@
+gplugin (0.27) unstable; urgency=medium
+
+ * New upstream release, see official changelog
+
+ -- Gary Kramlich <grim@reaperworld.com> Mon, 18 Apr 2016 22:31:45 -0500
+
+gplugin (0.26) unstable; urgency=medium
+
+ * New upstream release, see official changelog
+
+ -- Gary Kramlich <grim@reaperworld.com> Mon, 18 Apr 2016 22:31:30 -0500
+
+gplugin (0.25) unstable; urgency=medium
+
+ * New upstream release, see official changelog
+
+ -- Gary Kramlich <grim@reaperworld.com> Sat, 06 Feb 2016 20:28:53 -0600
+
gplugin (0.24.1) unstable; urgency=medium
* New upstream release, see official changelog
- -- Gary Kramlich <grim@reaperworld.com> Thu, 28 Jan 2016 22:49:30 -0600
+ -- Gary Kramlich <grim@reaperworld.com> Sat, 06 Feb 2016 20:28:47 -0600
gplugin (0.0.24) unstable; urgency=medium
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/packaging/gplugin.spec.in Sun Aug 21 23:56:03 2016 -0500
@@ -0,0 +1,245 @@
+Name: gplugin
+Version: @GPLUGIN_VERSION@
+Release: %{?build_number}%{?!build_number:1}
+License: LGPL-2.0+
+Summary: A GObject based library that implements a reusable plugin system
+Url: https://bitbucket.org/rw_grim/gplugin/overview
+Group: Development/Libraries
+
+BuildRequires: cmake >= 2.8
+BuildRequires: glib2-devel >= 2.20.0
+BuildRequires: gobject-introspection-devel
+BuildRequires: gettext
+BuildRequires: gtk3-devel
+BuildRequires: help2man
+BuildRequires: libxslt
+BuildRequires: lua-devel
+BuildRequires: lua-lgi
+BuildRequires: python3-devel
+BuildRequires: python3-gobject
+BuildRequires: /usr/lib64/pkgconfig/pygobject-3.0.pc
+
+%if 0%{?suse_version} > 0
+# avoid "directories not owned by a package" error
+%define notownedhack 1
+%else
+%define notownedhack 0
+%endif
+
+
+%package -n libgplugin0
+Summary: A GObject based library that implements a reusable plugin system
+Group: Development/Libraries
+
+%package devel
+Summary: A GObject based library that implements a reusable plugin system
+Group: Development/Libraries
+Requires: %{name}%{?_isa} = %{version}-%{release}
+
+%package gtk3
+Summary: A GObject based library that implements a reusable plugin system
+Group: Development/Libraries
+
+%package gtk3-devel
+Summary: A GObject based library that implements a reusable plugin system
+Group: Development/Libraries
+Requires: %{name}-gtk3%{?_isa} = %{version}-%{release}
+Requires: %{name}-devel%{?_isa} = %{version}-%{release}
+
+%package lua
+Summary: A GObject based library that implements a reusable plugin system
+Group: Development/Libraries
+
+%package python3
+Summary: A GObject based library that implements a reusable plugin system
+Group: Development/Libraries
+
+
+%description
+GPlugin is a GObject based library that implements a reusable plugin system
+that supports loading plugins in other languages via loaders. GPlugin also
+implements dependencies among the plugins.
+
+It was started due to the infamous "Plugin Problem" for Guifications 3, which
+was that I needed plugins that could depend on each other, be able to be
+written in other languages, have plugins that are loaded before the main load
+phase, and allow plugins to register types into the GObject type system.
+
+%description -n libgplugin0
+GPlugin is a GObject based library that implements a reusable plugin system
+that supports loading plugins in other languages via loaders. GPlugin also
+implements dependencies among the plugins.
+
+It was started due to the infamous "Plugin Problem" for Guifications 3, which
+was that I needed plugins that could depend on each other, be able to be
+written in other languages, have plugins that are loaded before the main load
+phase, and allow plugins to register types into the GObject type system.
+
+%description devel
+GPlugin is a GObject based library that implements a reusable plugin system
+that supports loading plugins in other languages via loaders. GPlugin also
+implements dependencies among the plugins.
+
+It was started due to the infamous "Plugin Problem" for Guifications 3, which
+was that I needed plugins that could depend on each other, be able to be
+written in other languages, have plugins that are loaded before the main load
+phase, and allow plugins to register types into the GObject type system.
+
+This package contains all necessary include files and libraries needed
+to develop applications that require these.
+
+%description gtk3
+GPlugin is a GObject based library that implements a reusable plugin system
+that supports loading plugins in other languages via loaders. GPlugin also
+implements dependencies among the plugins.
+
+It was started due to the infamous "Plugin Problem" for Guifications 3, which
+was that I needed plugins that could depend on each other, be able to be
+written in other languages, have plugins that are loaded before the main load
+phase, and allow plugins to register types into the GObject type system.
+
+This package contains additional GTK3 dependencies for %{name} library.
+
+%description gtk3-devel
+GPlugin is a GObject based library that implements a reusable plugin system
+that supports loading plugins in other languages via loaders. GPlugin also
+implements dependencies among the plugins.
+
+It was started due to the infamous "Plugin Problem" for Guifications 3, which
+was that I needed plugins that could depend on each other, be able to be
+written in other languages, have plugins that are loaded before the main load
+phase, and allow plugins to register types into the GObject type system.
+
+This package contains all necessary include files and libraries needed
+to develop GTK3 applications that require these.
+
+%description lua
+GPlugin is a GObject based library that implements a reusable plugin system
+that supports loading plugins in other languages via loaders. GPlugin also
+implements dependencies among the plugins.
+
+It was started due to the infamous "Plugin Problem" for Guifications 3, which
+was that I needed plugins that could depend on each other, be able to be
+written in other languages, have plugins that are loaded before the main load
+phase, and allow plugins to register types into the GObject type system.
+
+This package contains the Lua Loader for %{name} library.
+
+%description python3
+GPlugin is a GObject based library that implements a reusable plugin system
+that supports loading plugins in other languages via loaders. GPlugin also
+implements dependencies among the plugins.
+
+It was started due to the infamous "Plugin Problem" for Guifications 3, which
+was that I needed plugins that could depend on each other, be able to be
+written in other languages, have plugins that are loaded before the main load
+phase, and allow plugins to register types into the GObject type system.
+
+This package contains Python 3 loader for %{name} library.
+
+
+%build
+mkdir -p build
+pushd build
+
+CFLAGS="%{optflags}" cmake \
+ -Wno-dev \
+ -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+ -DBUILD_LUA=On \
+ -DBUILD_PYTHON=On \
+ ..
+
+make %{?_smp_mflags}
+
+
+%install
+pushd build
+
+make install DESTDIR=%{buildroot}
+
+# Unneeded files
+rm -rf %{buildroot}%{_datadir}/doc/gplugin/
+%if %{notownedhack} == 1
+rm -rf %{buildroot}%{_datadir}/gplugin/
+%endif
+
+%post -n libgplugin0 -p /sbin/ldconfig
+
+%postun -n libgplugin0 -p /sbin/ldconfig
+
+%post -n gplugin-gtk3 -p /sbin/ldconfig
+
+%postun -n gplugin-gtk3 -p /sbin/ldconfig
+
+
+%files
+%defattr(-,root,root)
+%doc README ChangeLog
+%if %{notownedhack} == 0
+%license COPYING
+%endif
+%{_bindir}/gplugin-query
+%{_libdir}/gplugin/
+%{_mandir}/man1/gplugin-query.1*
+
+%files -n libgplugin0
+%defattr(-,root,root)
+%{_libdir}/libgplugin.so.0.1.0
+
+%files devel
+%defattr(-,root,root)
+%doc README HACKING
+%if %{notownedhack} == 0
+%license COPYING
+%endif
+%{_includedir}/gplugin-1.0/
+%{_libdir}/libgplugin.so
+%{_libdir}/libgplugin.so.0
+%{_libdir}/pkgconfig/gplugin.pc
+%{_libdir}/pkgconfig/gplugin-gtk.pc
+%{_libdir}/girepository-1.0/GPlugin-0.0.typelib
+%{_datadir}/gir-1.0/GPlugin-0.0.gir
+
+%files gtk3
+%defattr(-,root,root)
+%doc README
+%if %{notownedhack} == 0
+%license COPYING
+%endif
+%{_bindir}/gplugin-gtk-viewer
+%{_libdir}/libgplugin-gtk.so.0.1.0
+%if %{notownedhack} == 0
+%{_datadir}/gplugin/gplugin-gtk/
+%endif
+%{_mandir}/man1/gplugin-gtk-viewer.1*
+
+%files gtk3-devel
+%defattr(-,root,root)
+%doc README
+%if %{notownedhack} == 0
+%license COPYING
+%endif
+%{_libdir}/libgplugin-gtk.so
+%{_libdir}/libgplugin-gtk.so.0
+
+%files lua
+%defattr(-,root,root)
+%doc README
+%license COPYING
+%{_libdir}/gplugin/gplugin-lua.so
+
+%files python3
+%defattr(-,root,root)
+%doc README
+%if %{notownedhack} == 0
+%license COPYING
+%endif
+%{_libdir}/gplugin/gplugin-python.so
+
+
+%changelog
+* Sun May 15 2016 Gary Kramlich <grim@reaperworld.com>
+- Updates and pulled upstream
+
+* Mon May 4 2015 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.0.18-1
+- Initial package release
--- a/python/CMakeLists.txt Thu Jan 28 23:15:55 2016 -0600
+++ b/python/CMakeLists.txt Sun Aug 21 23:56:03 2016 -0500
@@ -32,6 +32,8 @@
${PYGOBJECT_INCLUDE_DIRS}
)
+ link_directories(${PYTHON3_LIBRARY_DIRS})
+
message(STATUS "checking if pygobject works with python3")
set(GPLUGIN_PYTHON_TEST_PYGOBJECT_INCLUDES)
--- a/tools/glib-mkenums Thu Jan 28 23:15:55 2016 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,565 +0,0 @@
-#! /usr/bin/perl
-
-use warnings;
-use File::Basename;
-use Safe;
-
-# glib-mkenums.pl
-# Information about the current enumeration
-my $flags; # Is enumeration a bitmask?
-my $option_underscore_name; # Overriden underscore variant of the enum name
- # for example to fix the cases we don't get the
- # mixed-case -> underscorized transform right.
-my $option_lowercase_name; # DEPRECATED. A lower case name to use as part
- # of the *_get_type() function, instead of the
- # one that we guess. For instance, when an enum
- # uses abnormal capitalization and we can not
- # guess where to put the underscores.
-my $seenbitshift; # Have we seen bitshift operators?
-my $enum_prefix; # Prefix for this enumeration
-my $enumname; # Name for this enumeration
-my $enumshort; # $enumname without prefix
-my $enumname_prefix; # prefix of $enumname
-my $enumindex = 0; # Global enum counter
-my $firstenum = 1; # Is this the first enumeration per file?
-my @entries; # [ $name, $val ] for each entry
-my $sandbox = Safe->new; # sandbox for safe evaluation of expressions
-
-sub parse_trigraph {
- my $opts = shift;
- my @opts;
-
- for $opt (split /\s*,\s*/, $opts) {
- $opt =~ s/^\s*//;
- $opt =~ s/\s*$//;
- my ($key,$val) = $opt =~ /(\w+)(?:=(.+))?/;
- defined $val or $val = 1;
- push @opts, $key, $val;
- }
- @opts;
-}
-sub parse_entries {
- my $file = shift;
- my $file_name = shift;
- my $looking_for_name = 0;
-
- while (<$file>) {
- # read lines until we have no open comments
- while (m@/\*([^*]|\*(?!/))*$@) {
- my $new;
- defined ($new = <$file>) || die "Unmatched comment in $ARGV";
- $_ .= $new;
- }
- # strip comments w/o options
- s@/\*(?!<)
- ([^*]+|\*(?!/))*
- \*/@@gx;
-
- # strip newlines
- s@\n@ @;
-
- # skip empty lines
- next if m@^\s*$@;
-
- if ($looking_for_name) {
- if (/^\s*(\w+)/) {
- $enumname = $1;
- return 1;
- }
- }
-
- # Handle include files
- if (/^\#include\s*<([^>]*)>/ ) {
- my $file= "../$1";
- open NEWFILE, $file or die "Cannot open include file $file: $!\n";
-
- if (parse_entries (\*NEWFILE, $NEWFILE)) {
- return 1;
- } else {
- next;
- }
- }
-
- if (/^\s*\}\s*(\w+)/) {
- $enumname = $1;
- $enumindex++;
- return 1;
- }
-
- if (/^\s*\}/) {
- $enumindex++;
- $looking_for_name = 1;
- next;
- }
-
- if (m@^\s*
- (\w+)\s* # name
- (?:=( # value
- \s*\w+\s*\(.*\)\s* # macro with multiple args
- | # OR
- (?:[^,/]|/(?!\*))* # anything but a comma or comment
- ))?,?\s*
- (?:/\*< # options
- (([^*]|\*(?!/))*)
- >\s*\*/)?,?
- \s*$
- @x) {
- my ($name, $value, $options) = ($1,$2,$3);
-
- if (!defined $flags && defined $value && $value =~ /<</) {
- $seenbitshift = 1;
- }
-
- if (defined $options) {
- my %options = parse_trigraph($options);
- if (!defined $options{skip}) {
- push @entries, [ $name, $value, $options{nick} ];
- }
- } else {
- push @entries, [ $name, $value ];
- }
- } elsif (m@^\s*\#@) {
- # ignore preprocessor directives
- } else {
- print STDERR "$0: $file_name:$.: Failed to parse `$_'\n";
- }
- }
-
- return 0;
-}
-
-sub version {
- print "glib-mkenums version glib-2.36.3\n";
- print "glib-mkenums comes with ABSOLUTELY NO WARRANTY.\n";
- print "You may redistribute copies of glib-mkenums under the terms of\n";
- print "the GNU General Public License which can be found in the\n";
- print "GLib source package. Sources, examples and contact\n";
- print "information are available at http://www.gtk.org\n";
- exit 0;
-}
-sub usage {
- print "Usage:\n";
- print " glib-mkenums [OPTION...] [FILES...]\n\n";
- print "Help Options:\n";
- print " -h, --help Show this help message\n\n";
- print "Utility Options:\n";
- print " --identifier-prefix <text> Identifier prefix\n";
- print " --symbol-prefix <text> Symbol prefix\n";
- print " --fhead <text> Output file header\n";
- print " --fprod <text> Per input file production\n";
- print " --ftail <text> Output file trailer\n";
- print " --eprod <text> Per enum text (produced prior to value itarations)\n";
- print " --vhead <text> Value header, produced before iterating over enum values\n";
- print " --vprod <text> Value text, produced for each enum value\n";
- print " --vtail <text> Value tail, produced after iterating over enum values\n";
- print " --comments <text> Comment structure\n";
- print " --template file Template file\n";
- print " -v, --version Print version informations\n\n";
- print "Production text substitutions:\n";
- print " \@EnumName\@ PrefixTheXEnum\n";
- print " \@enum_name\@ prefix_the_xenum\n";
- print " \@ENUMNAME\@ PREFIX_THE_XENUM\n";
- print " \@ENUMSHORT\@ THE_XENUM\n";
- print " \@ENUMPREFIX\@ PREFIX\n";
- print " \@VALUENAME\@ PREFIX_THE_XVALUE\n";
- print " \@valuenick\@ the-xvalue\n";
- print " \@valuenum\@ the integer value (limited support, Since: 2.26)\n";
- print " \@type\@ either enum or flags\n";
- print " \@Type\@ either Enum or Flags\n";
- print " \@TYPE\@ either ENUM or FLAGS\n";
- print " \@filename\@ name of current input file\n";
- print " \@basename\@ base name of the current input file (Since: 2.22)\n";
- exit 0;
-}
-
-# production variables:
-my $idprefix = ""; # "G", "Gtk", etc
-my $symprefix = ""; # "g", "gtk", etc, if not just lc($idprefix)
-my $fhead = ""; # output file header
-my $fprod = ""; # per input file production
-my $ftail = ""; # output file trailer
-my $eprod = ""; # per enum text (produced prior to value itarations)
-my $vhead = ""; # value header, produced before iterating over enum values
-my $vprod = ""; # value text, produced for each enum value
-my $vtail = ""; # value tail, produced after iterating over enum values
-my $comment_tmpl = ""; # comment template
-
-sub read_template_file {
- my ($file) = @_;
- my %tmpl = ('file-header', $fhead,
- 'file-production', $fprod,
- 'file-tail', $ftail,
- 'enumeration-production', $eprod,
- 'value-header', $vhead,
- 'value-production', $vprod,
- 'value-tail', $vtail,
- 'comment', $comment_tmpl);
- my $in = 'junk';
- open (FILE, $file) || die "Can't open $file: $!\n";
- while (<FILE>) {
- if (/^\/\*\*\*\s+(BEGIN|END)\s+([\w-]+)\s+\*\*\*\//) {
- if (($in eq 'junk') && ($1 eq 'BEGIN') && (exists($tmpl{$2}))) {
- $in = $2;
- next;
- }
- elsif (($in eq $2) && ($1 eq 'END') && (exists($tmpl{$2}))) {
- $in = 'junk';
- next;
- } else {
- die "Malformed template file $file\n";
- }
- }
- if (!($in eq 'junk')) {
- $tmpl{$in} .= $_;
- }
- }
- close (FILE);
- if (!($in eq 'junk')) {
- die "Malformed template file $file\n";
- }
- $fhead = $tmpl{'file-header'};
- $fprod = $tmpl{'file-production'};
- $ftail = $tmpl{'file-tail'};
- $eprod = $tmpl{'enumeration-production'};
- $vhead = $tmpl{'value-header'};
- $vprod = $tmpl{'value-production'};
- $vtail = $tmpl{'value-tail'};
- $comment_tmpl = $tmpl{'comment'};
-
- # default to C-style comments
- $comment_tmpl = "/* \@comment\@ */" if $comment_tmpl eq "";
-}
-
-if (!defined $ARGV[0]) {
- usage;
-}
-while ($_=$ARGV[0],/^-/) {
- shift;
- last if /^--$/;
- if (/^--template$/) { read_template_file (shift); }
- elsif (/^--identifier-prefix$/) { $idprefix = shift }
- elsif (/^--symbol-prefix$/) { $symprefix = shift }
- elsif (/^--fhead$/) { $fhead = $fhead . shift }
- elsif (/^--fprod$/) { $fprod = $fprod . shift }
- elsif (/^--ftail$/) { $ftail = $ftail . shift }
- elsif (/^--eprod$/) { $eprod = $eprod . shift }
- elsif (/^--vhead$/) { $vhead = $vhead . shift }
- elsif (/^--vprod$/) { $vprod = $vprod . shift }
- elsif (/^--vtail$/) { $vtail = $vtail . shift }
- elsif (/^--comments$/) { $comment_tmpl = shift }
- elsif (/^--help$/ || /^-h$/ || /^-\?$/) { usage; }
- elsif (/^--version$/ || /^-v$/) { version; }
- else { usage; }
- last if not defined($ARGV[0]);
-}
-
-# put auto-generation comment
-{
- my $comment = $comment_tmpl;
- $comment =~ s/\@comment\@/Generated data (by glib-mkenums)/;
- print "\n" . $comment . "\n\n";
-}
-
-if (length($fhead)) {
- my $prod = $fhead;
- my $base = basename ($ARGV[0]);
-
- $prod =~ s/\@filename\@/$ARGV[0]/g;
- $prod =~ s/\@basename\@/$base/g;
- $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
- $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
- chomp ($prod);
-
- print "$prod\n";
-}
-
-while (<>) {
- if (eof) {
- close (ARGV); # reset line numbering
- $firstenum = 1; # Flag to print filename at next enum
- }
-
- # read lines until we have no open comments
- while (m@/\*([^*]|\*(?!/))*$@) {
- my $new;
- defined ($new = <>) || die "Unmatched comment in $ARGV";
- $_ .= $new;
- }
- # strip comments w/o options
- s@/\*(?!<)
- ([^*]+|\*(?!/))*
- \*/@@gx;
-
- # ignore forward declarations
- next if /^\s*typedef\s+enum.*;/;
-
- if (m@^\s*typedef\s+enum\s*
- ({)?\s*
- (?:/\*<
- (([^*]|\*(?!/))*)
- >\s*\*/)?
- \s*({)?
- @x) {
- if (defined $2) {
- my %options = parse_trigraph ($2);
- next if defined $options{skip};
- $enum_prefix = $options{prefix};
- $flags = $options{flags};
- $option_lowercase_name = $options{lowercase_name};
- $option_underscore_name = $options{underscore_name};
- } else {
- $enum_prefix = undef;
- $flags = undef;
- $option_lowercase_name = undef;
- $option_underscore_name = undef;
- }
- if (defined $option_lowercase_name) {
- if (defined $option_underscore_name) {
- print STDERR "$0: $ARGV:$.: lowercase_name overriden with underscore_name\n";
- $option_lowercase_name = undef;
- } else {
- print STDERR "$0: $ARGV:$.: lowercase_name is deprecated, use underscore_name\n";
- }
- }
- # Didn't have trailing '{' look on next lines
- if (!defined $1 && !defined $4) {
- while (<>) {
- if (eof) {
- die "Hit end of file while parsing enum in $ARGV";
- }
- if (s/^\s*\{//) {
- last;
- }
- }
- }
-
- $seenbitshift = 0;
- @entries = ();
-
- # Now parse the entries
- parse_entries (\*ARGV, $ARGV);
-
- # figure out if this was a flags or enums enumeration
- if (!defined $flags) {
- $flags = $seenbitshift;
- }
-
- # Autogenerate a prefix
- if (!defined $enum_prefix) {
- for (@entries) {
- my $nick = $_->[2];
- if (!defined $nick) {
- my $name = $_->[0];
- if (defined $enum_prefix) {
- my $tmp = ~ ($name ^ $enum_prefix);
- ($tmp) = $tmp =~ /(^\xff*)/;
- $enum_prefix = $enum_prefix & $tmp;
- } else {
- $enum_prefix = $name;
- }
- }
- }
- if (!defined $enum_prefix) {
- $enum_prefix = "";
- } else {
- # Trim so that it ends in an underscore
- $enum_prefix =~ s/_[^_]*$/_/;
- }
- } else {
- # canonicalize user defined prefixes
- $enum_prefix = uc($enum_prefix);
- $enum_prefix =~ s/-/_/g;
- $enum_prefix =~ s/(.*)([^_])$/$1$2_/;
- }
-
- for $entry (@entries) {
- my ($name,$num,$nick) = @{$entry};
- if (!defined $nick) {
- ($nick = $name) =~ s/^$enum_prefix//;
- $nick =~ tr/_/-/;
- $nick = lc($nick);
- @{$entry} = ($name, $num, $nick);
- }
- }
-
-
- # Spit out the output
- if (defined $option_underscore_name) {
- $enumlong = uc $option_underscore_name;
- $enumsym = lc $option_underscore_name;
- $enumshort = $enumlong;
- $enumshort =~ s/^[A-Z][A-Z0-9]*_//;
-
- $enumname_prefix = $enumlong;
- $enumname_prefix =~ s/_$enumshort$//;
- } elsif (!$symprefix && !$idprefix) {
- # enumname is e.g. GMatchType
- $enspace = $enumname;
- $enspace =~ s/^([A-Z][a-z]*).*$/$1/;
-
- $enumshort = $enumname;
- $enumshort =~ s/^[A-Z][a-z]*//;
- $enumshort =~ s/([^A-Z])([A-Z])/$1_$2/g;
- $enumshort =~ s/([A-Z][A-Z])([A-Z][0-9a-z])/$1_$2/g;
- $enumshort = uc($enumshort);
-
- $enumname_prefix = $enumname;
- $enumname_prefix =~ s/^([A-Z][a-z]*).*$/$1/;
- $enumname_prefix = uc($enumname_prefix);
-
- $enumlong = uc($enspace) . "_" . $enumshort;
- $enumsym = lc($enspace) . "_" . lc($enumshort);
-
- if (defined($option_lowercase_name)) {
- $enumsym = $option_lowercase_name;
- }
- } else {
- $enumshort = $enumname;
- if ($idprefix) {
- $enumshort =~ s/^${idprefix}//;
- } else {
- $enumshort =~ s/^[A-Z][a-z]*//;
- }
- $enumshort =~ s/([^A-Z])([A-Z])/$1_$2/g;
- $enumshort =~ s/([A-Z][A-Z])([A-Z][0-9a-z])/$1_$2/g;
- $enumshort = uc($enumshort);
-
- $enumname_prefix = $symprefix && uc($symprefix) || uc($idprefix);
-
- $enumlong = $enumname_prefix . "_" . $enumshort;
- $enumsym = lc($enumlong);
- }
-
- if ($firstenum) {
- $firstenum = 0;
-
- if (length($fprod)) {
- my $prod = $fprod;
- my $base = basename ($ARGV);
-
- $prod =~ s/\@filename\@/$ARGV/g;
- $prod =~ s/\@basename\@/$base/g;
- $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
- $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
- chomp ($prod);
-
- print "$prod\n";
- }
- }
-
- if (length($eprod)) {
- my $prod = $eprod;
-
- $prod =~ s/\@enum_name\@/$enumsym/g;
- $prod =~ s/\@EnumName\@/$enumname/g;
- $prod =~ s/\@ENUMSHORT\@/$enumshort/g;
- $prod =~ s/\@ENUMNAME\@/$enumlong/g;
- $prod =~ s/\@ENUMPREFIX\@/$enumname_prefix/g;
- if ($flags) { $prod =~ s/\@type\@/flags/g; } else { $prod =~ s/\@type\@/enum/g; }
- if ($flags) { $prod =~ s/\@Type\@/Flags/g; } else { $prod =~ s/\@Type\@/Enum/g; }
- if ($flags) { $prod =~ s/\@TYPE\@/FLAGS/g; } else { $prod =~ s/\@TYPE\@/ENUM/g; }
- $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
- $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
- chomp ($prod);
-
- print "$prod\n";
- }
-
- if (length($vhead)) {
- my $prod = $vhead;
-
- $prod =~ s/\@enum_name\@/$enumsym/g;
- $prod =~ s/\@EnumName\@/$enumname/g;
- $prod =~ s/\@ENUMSHORT\@/$enumshort/g;
- $prod =~ s/\@ENUMNAME\@/$enumlong/g;
- $prod =~ s/\@ENUMPREFIX\@/$enumname_prefix/g;
- if ($flags) { $prod =~ s/\@type\@/flags/g; } else { $prod =~ s/\@type\@/enum/g; }
- if ($flags) { $prod =~ s/\@Type\@/Flags/g; } else { $prod =~ s/\@Type\@/Enum/g; }
- if ($flags) { $prod =~ s/\@TYPE\@/FLAGS/g; } else { $prod =~ s/\@TYPE\@/ENUM/g; }
- $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
- $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
- chomp ($prod);
-
- print "$prod\n";
- }
-
- if (length($vprod)) {
- my $prod = $vprod;
- my $next_num = 0;
-
- $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
- $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
- for (@entries) {
- my ($name,$num,$nick) = @{$_};
- my $tmp_prod = $prod;
-
- if ($prod =~ /\@valuenum\@/) {
- # only attempt to eval the value if it is requested
- # this prevents us from throwing errors otherwise
- if (defined $num) {
- # use sandboxed perl evaluation as a reasonable
- # approximation to C constant folding
- $num = $sandbox->reval ($num);
-
- # make sure it parsed to an integer
- if (!defined $num or $num !~ /^-?\d+$/) {
- die "Unable to parse enum value '$num'";
- }
- } else {
- $num = $next_num;
- }
-
- $tmp_prod =~ s/\@valuenum\@/$num/g;
- $next_num = $num + 1;
- }
-
- $tmp_prod =~ s/\@VALUENAME\@/$name/g;
- $tmp_prod =~ s/\@valuenick\@/$nick/g;
- if ($flags) { $tmp_prod =~ s/\@type\@/flags/g; } else { $tmp_prod =~ s/\@type\@/enum/g; }
- if ($flags) { $tmp_prod =~ s/\@Type\@/Flags/g; } else { $tmp_prod =~ s/\@Type\@/Enum/g; }
- if ($flags) { $tmp_prod =~ s/\@TYPE\@/FLAGS/g; } else { $tmp_prod =~ s/\@TYPE\@/ENUM/g; }
- chomp ($tmp_prod);
-
- print "$tmp_prod\n";
- }
- }
-
- if (length($vtail)) {
- my $prod = $vtail;
-
- $prod =~ s/\@enum_name\@/$enumsym/g;
- $prod =~ s/\@EnumName\@/$enumname/g;
- $prod =~ s/\@ENUMSHORT\@/$enumshort/g;
- $prod =~ s/\@ENUMNAME\@/$enumlong/g;
- $prod =~ s/\@ENUMPREFIX\@/$enumname_prefix/g;
- if ($flags) { $prod =~ s/\@type\@/flags/g; } else { $prod =~ s/\@type\@/enum/g; }
- if ($flags) { $prod =~ s/\@Type\@/Flags/g; } else { $prod =~ s/\@Type\@/Enum/g; }
- if ($flags) { $prod =~ s/\@TYPE\@/FLAGS/g; } else { $prod =~ s/\@TYPE\@/ENUM/g; }
- $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
- $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
- chomp ($prod);
-
- print "$prod\n";
- }
- }
-}
-
-if (length($ftail)) {
- my $prod = $ftail;
- my $base = basename ($ARGV);
-
- $prod =~ s/\@filename\@/$ARGV/g;
- $prod =~ s/\@basename\@/$base/g;
- $prod =~ s/\\a/\a/g; $prod =~ s/\\b/\b/g; $prod =~ s/\\t/\t/g; $prod =~ s/\\n/\n/g;
- $prod =~ s/\\f/\f/g; $prod =~ s/\\r/\r/g;
- chomp ($prod);
-
- print "$prod\n";
-}
-
-# put auto-generation comment
-{
- my $comment = $comment_tmpl;
- $comment =~ s/\@comment\@/Generated data ends here/;
- print "\n" . $comment . "\n\n";
-}