Add experimental plugin system

Plugins define the interface specified in plugin.h and have
full access to any functions exposed in mkxp.
Specify plugins to be loaded in the config file via
'plugin=/path/to/plugin.so' lines.

A sample plugin for the MRI binding is provided.
This commit is contained in:
Jonas Kulla 2014-01-03 07:35:25 +01:00
parent 3daf805350
commit 94c2f2b60e
8 changed files with 290 additions and 3 deletions

41
sample-plugin/main.cpp Normal file
View file

@ -0,0 +1,41 @@
#include "plugin.h"
#include "debugwriter.h"
#include "exception.h"
#include "binding-util.h"
static void pluginInit();
static void pluginFini();
Plugin plugin =
{
pluginInit,
pluginFini,
PLUGIN_MRI
};
/* Callable from ruby scripts as 'plugin_function' */
RB_METHOD(pluginFunction)
{
RB_UNUSED_PARAM;
const char *str = 0;
rb_get_args(argc, argv, "|z", &str RB_ARG_END);
Debug() << "Sample plugin function:" << str;
return Qnil;
}
void pluginInit()
{
_rb_define_module_function(rb_mKernel, "plugin_function", pluginFunction);
Debug() << "Sample plugin inited!";
}
void pluginFini()
{
Debug() << "Sample plugin finited!";
}

View file

@ -0,0 +1,18 @@
######################################################################
# Automatically generated by qmake (2.01a) Fri Jan 3 01:40:45 2014
######################################################################
TEMPLATE = lib
QT =
TARGET = sample-plugin
DEPENDPATH += . ../src ../binding-mri
INCLUDEPATH += . ../src ../binding-mri
CONFIG += plugin
unix {
CONFIG += link_pkgconfig
PKGCONFIG += ruby-2.1
}
# Input
SOURCES += main.cpp