diff options
author | pixel <pixel> | 2008-07-04 12:01:52 +0000 |
---|---|---|
committer | pixel <pixel> | 2008-07-04 12:01:52 +0000 |
commit | cee868801b55aa4302c91a46df8daf38388163e7 (patch) | |
tree | 1bd77d5167f0a18ff7beb603b1b359c7b8c459b1 /src |
Adding project files.
Diffstat (limited to 'src')
-rw-r--r-- | src/lua-plugin.cc | 43 | ||||
-rw-r--r-- | src/lua-plugin.h | 9 | ||||
-rw-r--r-- | src/plugin-luaconfigfiles.cc | 9 | ||||
-rw-r--r-- | src/plugin-luaftgl.cc | 9 | ||||
-rw-r--r-- | src/plugin-luagl.cc | 10 | ||||
-rw-r--r-- | src/plugin-luahandle.cc | 12 | ||||
-rw-r--r-- | src/plugin-luahttp.cc | 9 | ||||
-rw-r--r-- | src/plugin-lualibs.cc | 9 | ||||
-rw-r--r-- | src/plugin-luaocci.cc | 9 | ||||
-rw-r--r-- | src/plugin-luaregex.cc | 9 | ||||
-rw-r--r-- | src/plugin-luasql.cc | 9 | ||||
-rw-r--r-- | src/plugin-luatask.cc | 9 | ||||
-rw-r--r-- | src/plugin-luaxml.cc | 10 |
13 files changed, 156 insertions, 0 deletions
diff --git a/src/lua-plugin.cc b/src/lua-plugin.cc new file mode 100644 index 0000000..79968a6 --- /dev/null +++ b/src/lua-plugin.cc @@ -0,0 +1,43 @@ +#include <lua-plugin.h> + +typedef void(*init_ptr_t)(Lua *); + +#ifdef _WIN32 +#include <windows.h> + +void LuaLoadPlugin(const String & _fname, Lua * L) throw (GeneralException) { + HMODULE handle; + String fname = _fname + ".dll"; + + if (!(handle = LoadLibraryEx(fname.to_charp(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH)) && + !(handle = LoadLibraryEx(fname.to_charp(), NULL, NULL))) { + throw GeneralException("File not found or error loading shared object file: " + fname + "; Error #" + String((int) GetLastError())); + } + + init_ptr_t init_ptr = (init_ptr_t) GetProcAddress(handle, "init_plugin"); + + if (!init_ptr) { + throw GeneralException("No init pointer on plugin " + fname); + } + + init_ptr(L); +} +#else +#include <dlfcn.h> + +void LuaLoadPlugin(const String & fname, Lua * L) throw (GeneralException) { + void * handle = dlopen(("./" + fname + ".so").to_charp(), RTLD_NOW | RTLD_GLOBAL); + + if (!handle) { + throw GeneralException("File not found or error loading shared object file: " + fname + "; " + dlerror()); + } + + init_ptr_t init_ptr = (init_ptr_t) dlsym(handle, "init_plugin"); + + if (!init_ptr) { + throw GeneralException("No init pointer on plugin " + fname); + } + + init_ptr(L); +} +#endif diff --git a/src/lua-plugin.h b/src/lua-plugin.h new file mode 100644 index 0000000..dba8518 --- /dev/null +++ b/src/lua-plugin.h @@ -0,0 +1,9 @@ +#ifndef __LUA_PLUGIN_H__ +#define __LUA_PLUGIN_H__ + +#include <BLua.h> +#include <Exceptions.h> + +void LuaLoadPlugin(const String & fname, Lua * L) throw (GeneralException); + +#endif diff --git a/src/plugin-luaconfigfiles.cc b/src/plugin-luaconfigfiles.cc new file mode 100644 index 0000000..a174f6a --- /dev/null +++ b/src/plugin-luaconfigfiles.cc @@ -0,0 +1,9 @@ +#include <LuaConfigFile.h> + +extern "C" { + +void init_plugin(Lua * L) { + LuaConfigFile::pushstatics(L); +} + +} diff --git a/src/plugin-luaftgl.cc b/src/plugin-luaftgl.cc new file mode 100644 index 0000000..cd577b6 --- /dev/null +++ b/src/plugin-luaftgl.cc @@ -0,0 +1,9 @@ +#include <LuaFTGL.h> + +extern "C" { + +void init_plugin(Lua * L) { + LuaFTFont::pushstatics(L); +} + +} diff --git a/src/plugin-luagl.cc b/src/plugin-luagl.cc new file mode 100644 index 0000000..2f0b55c --- /dev/null +++ b/src/plugin-luagl.cc @@ -0,0 +1,10 @@ +#include <LuaGL.h> + +extern "C" { + +void init_plugin(Lua * L) { + luaopen_opengl(L); + L->pop(); +} + +} diff --git a/src/plugin-luahandle.cc b/src/plugin-luahandle.cc new file mode 100644 index 0000000..d2002af --- /dev/null +++ b/src/plugin-luahandle.cc @@ -0,0 +1,12 @@ +#include <LuaHandle.h> + +extern "C" { + +void init_plugin(Lua * L) { + LuaInput::pushconstruct(L); + LuaOutput::pushconstruct(L); + LuaBuffer::pushconstruct(L); + LuaHandle::pushconstruct(L); +} + +} diff --git a/src/plugin-luahttp.cc b/src/plugin-luahttp.cc new file mode 100644 index 0000000..819a2f3 --- /dev/null +++ b/src/plugin-luahttp.cc @@ -0,0 +1,9 @@ +#include <LuaHttp.h> + +extern "C" { + +void init_plugin(Lua * L) { + LuaHttpResponse::pushstatics(L); +} + +} diff --git a/src/plugin-lualibs.cc b/src/plugin-lualibs.cc new file mode 100644 index 0000000..e364d9b --- /dev/null +++ b/src/plugin-lualibs.cc @@ -0,0 +1,9 @@ +#include <loadlualibs.h> + +extern "C" { + +void init_plugin(Lua * L) { + LoadLuaLibs(L); +} + +} diff --git a/src/plugin-luaocci.cc b/src/plugin-luaocci.cc new file mode 100644 index 0000000..8d9377e --- /dev/null +++ b/src/plugin-luaocci.cc @@ -0,0 +1,9 @@ +#include <LuaOCCI.h> + +extern "C" { + +void init_plugin(Lua * L) { + LuaOCCI_pushstatics(L); +} + +} diff --git a/src/plugin-luaregex.cc b/src/plugin-luaregex.cc new file mode 100644 index 0000000..694738c --- /dev/null +++ b/src/plugin-luaregex.cc @@ -0,0 +1,9 @@ +#include <LuaRegex.h> + +extern "C" { + +void init_plugin(Lua * L) { + LuaRegex::pushstatics(L); +} + +} diff --git a/src/plugin-luasql.cc b/src/plugin-luasql.cc new file mode 100644 index 0000000..c891942 --- /dev/null +++ b/src/plugin-luasql.cc @@ -0,0 +1,9 @@ +#include <LuaSQL.h> + +extern "C" { + +void init_plugin(Lua * L) { + LuaSQLConnection::pushstatics(L); +} + +} diff --git a/src/plugin-luatask.cc b/src/plugin-luatask.cc new file mode 100644 index 0000000..b97e273 --- /dev/null +++ b/src/plugin-luatask.cc @@ -0,0 +1,9 @@ +#include <LuaTask.h> + +extern "C" { + +void init_plugin(Lua * L) { + LuaTaskMan::pushstatics(L); +} + +} diff --git a/src/plugin-luaxml.cc b/src/plugin-luaxml.cc new file mode 100644 index 0000000..2cec871 --- /dev/null +++ b/src/plugin-luaxml.cc @@ -0,0 +1,10 @@ +#include <LuaXML.h> + +extern "C" { + +void init_plugin(Lua * L) { + luaopen_xml(L); + L->pop(); +} + +} |