summaryrefslogtreecommitdiff
path: root/libmodman
diff options
context:
space:
mode:
Diffstat (limited to 'libmodman')
-rw-r--r--libmodman/CMakeLists.txt19
-rw-r--r--libmodman/module.hpp113
-rw-r--r--libmodman/module_manager.cpp330
-rw-r--r--libmodman/module_manager.hpp86
-rw-r--r--libmodman/test/CMakeLists.txt79
-rw-r--r--libmodman/test/builtin.cpp28
-rw-r--r--libmodman/test/main.cpp72
-rw-r--r--libmodman/test/main.hpp43
-rw-r--r--libmodman/test/module.cpp.in24
9 files changed, 0 insertions, 794 deletions
diff --git a/libmodman/CMakeLists.txt b/libmodman/CMakeLists.txt
deleted file mode 100644
index 8264b33..0000000
--- a/libmodman/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-### Main library
-# Flags / Definitions / Environment
-if (WIN32)
- add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
-else(WIN32)
- set(CMAKE_CXX_FLAGS "-fvisibility=hidden -fPIC ${CMAKE_CXX_FLAGS}")
-endif(WIN32)
-include_directories(${CMAKE_SOURCE_DIR})
-
-add_library(modman STATIC
- module.hpp
- module_manager.hpp
- module_manager.cpp)
-if(NOT WIN32)
- target_link_libraries(modman ${CMAKE_DL_LIBS})
-endif()
-
-### Tests
-add_testdirectory(test)
diff --git a/libmodman/module.hpp b/libmodman/module.hpp
deleted file mode 100644
index 2d974aa..0000000
--- a/libmodman/module.hpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * libmodman - A library for extending applications
- * Copyright (C) 2009 Nathaniel McCallum <nathaniel@natemccallum.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.1 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- ******************************************************************************/
-
-#ifndef MODULE_HPP_
-#define MODULE_HPP_
-
-#include <cstdlib> // For NULL
-
-#ifndef MM_MODULE_BUILTIN
-#define MM_MODULE_BUILTIN
-#endif
-
-#ifdef _MSC_VER
-#define __MM_DLL_EXPORT __declspec(dllexport)
-#else
-#define __MM_DLL_EXPORT __attribute__ ((visibility("default")))
-#endif
-
-#define __MM_MODULE_VERSION 2
-#define __MM_MODULE_VARNAME__(suffix, name) mm_ ## name ## _ ## suffix
-#define __MM_MODULE_VARNAME_(suffix, name) __MM_MODULE_VARNAME__(suffix, name)
-#define __MM_MODULE_VARNAME(name) __MM_MODULE_VARNAME_(MM_MODULE_BUILTIN, name)
-
-#define MM_MODULE_INIT(mtype, minit, mtest, msymb, msmod) \
- extern "C" __MM_DLL_EXPORT struct mm_module __MM_MODULE_VARNAME(info); \
- struct mm_module __MM_MODULE_VARNAME(info) = { \
- __MM_MODULE_VERSION, \
- # mtype, \
- mtype::base_type, \
- minit, mtest, msymb, msmod \
- }
-
-#define MM_MODULE_INIT_EZ(clsname, mtest, msymb, msmod) \
- static libmodman::base_extension** clsname ## _init() { \
- libmodman::base_extension** retval = new libmodman::base_extension*[2]; \
- retval[0] = new clsname(); \
- retval[1] = NULL; \
- return retval; \
- } \
- static bool clsname ## _test() { return mtest; } \
- MM_MODULE_INIT(clsname, clsname ## _init, clsname ## _test, msymb, msmod)
-
-/* Helper macro for loading builtins */
-
-#define MM_DEF_BUILTIN(modname) \
- extern "C" struct mm_module __MM_MODULE_VARNAME_(modname,info)
-
-#define MM_BUILTIN(modname) __MM_MODULE_VARNAME_(modname,info)
-
-
-namespace libmodman {
-
-class __MM_DLL_EXPORT base_extension {
-public:
- static const char* base_type() { return NULL; }
- static bool singleton() { return false; }
- virtual ~base_extension() {}
- virtual const char* get_base_type() const =0;
- virtual bool operator<(const base_extension&) const =0;
-};
-
-template <class basetype, bool sngl=false>
-class __MM_DLL_EXPORT extension : public base_extension {
-public:
-#ifdef _MSC_VER
- static const char* base_type() { return __FUNCSIG__; }
-#else
- static const char* base_type() { return __PRETTY_FUNCTION__; }
-#endif
-
- static bool singleton() { return sngl; }
- virtual const char* get_base_type() const { return basetype::base_type(); }
- virtual bool operator<(const base_extension&) const { return false; };
-};
-
-}
-
-extern "C" {
-
-struct __MM_DLL_EXPORT mm_module
-{
-/* For some unknown reason, when vers is const VC++ (win32) NULLs out the whole struct.
- * This obviously breaks module loading. I'd love to know the reason for this, so if
- * anyone knows, please tell me. In the meantime, vers not being const is by design,
- * so don't change it. */
- unsigned int vers;
- const char* name;
- const char* (*type)();
- libmodman::base_extension** (*init)();
- bool (*test)();
- const char* symb;
- const char* smod;
-};
-
-}
-
-#endif /* MODULE_HPP_ */
diff --git a/libmodman/module_manager.cpp b/libmodman/module_manager.cpp
deleted file mode 100644
index 88e6198..0000000
--- a/libmodman/module_manager.cpp
+++ /dev/null
@@ -1,330 +0,0 @@
-/*******************************************************************************
- * libmodman - A library for extending applications
- * Copyright (C) 2009 Nathaniel McCallum <nathaniel@natemccallum.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.1 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- ******************************************************************************/
-
-#include <algorithm> // For sort()
-#include <sys/stat.h> // For stat()
-#include <iostream>
-#include <typeinfo>
-
-#ifdef WIN32
-#include <windows.h>
-#else
-#include <dlfcn.h> // For dlopen(), etc...
-#include <dirent.h> // For opendir(), readdir(), closedir()
-#endif
-
-#include "module_manager.hpp"
-using namespace libmodman;
-
-#include <cstdio>
-
-#define _LOAD_FAIL -1
-#define _LOAD_LAZY 0
-#define _LOAD_SUCC 1
-
-#ifdef WIN32
-#define pdlmtype HMODULE
-#define pdlopenl(filename) LoadLibraryEx(filename, NULL, DONT_RESOLVE_DLL_REFERENCES)
-#define pdlclose(module) FreeLibrary((pdlmtype) module)
-static void* pdlsym(pdlmtype mod, const string &sym) {
- return (void *) GetProcAddress(mod, sym.c_str());
-}
-
-static pdlmtype pdlreopen(const char* filename, pdlmtype module) {
- pdlclose(module);
- return LoadLibrary(filename);
-}
-
-static string pdlerror() {
- std::string e;
- LPTSTR msg;
-
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &msg,
- 0,
- NULL);
- e = std::string((const char*) msg);
- LocalFree(msg);
- return e;
-}
-
-static bool pdlsymlinked(const char* modn, const char* symb) {
- return (GetProcAddress(GetModuleHandle(modn), symb) != NULL || \
- GetProcAddress(GetModuleHandle(NULL), symb) != NULL);
-}
-
-static string prep_type_name(string name) {
- string prefix = "<class ";
- string suffix = ",";
- if (name.find(prefix) != name.npos)
- name = name.substr(name.find(prefix) + prefix.size());
- if (name.find(suffix) != name.npos)
- name = name.substr(0, name.find(suffix));
- return name;
-}
-#else
-#define pdlmtype void*
-#define pdlopenl(filename) dlopen(filename, RTLD_LAZY | RTLD_LOCAL)
-#define pdlclose(module) dlclose((pdlmtype) module)
-#define pdlreopen(filename, module) module
-static void* pdlsym(pdlmtype mod, const string &sym) {
- return dlsym(mod, sym.c_str());
-}
-
-static string pdlerror() {
- return dlerror();
-}
-
-bool pdlsymlinked(const char* modn, const char* symb) {
- void* mod = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL);
- if (mod) {
- void* sym = dlsym(mod, symb);
- dlclose(mod);
- return sym != NULL;
- }
- return false;
-}
-
-#define prep_type_name(name) name
-#endif
-
-#define _str(s) #s
-#define __str(s) _str(s)
-
-#ifndef _MOD_SUFFIX
-#ifdef WIN32
-#define _MOD_SUFFIX "dll"
-#define CR ""
-#else
-#define _MOD_SUFFIX "so"
-#define CR "\r"
-#endif
-#endif
-
-module_manager::~module_manager() {
- // Free all extensions
- for (map<string, vector<base_extension*> >::iterator i=this->extensions.begin() ; i != this->extensions.end() ; i++) {
- for (vector<base_extension*>::iterator j=i->second.begin() ; j != i->second.end() ; j++)
- delete *j;
- i->second.clear();
- }
- this->extensions.clear();
-
- // Free all modules
- for (set<void*>::iterator i=this->modules.begin() ; i != this->modules.end() ; i++)
- pdlclose(*i);
- this->modules.clear();
-}
-
-static int load(map<string, vector<base_extension*> >& extensions,
- set<string>& singletons,
- mm_module *mod,
- bool lazy,
- bool symbreq) {
- const char* debug = getenv("_MM_DEBUG");
-
- if (!mod || mod->vers != __MM_MODULE_VERSION || !mod->type || !mod->init) {
- if (debug)
- cerr << "failed!" << endl
- << "\tUnable to find basic module info!" << endl;
- return _LOAD_FAIL;
- }
-
- // Get the module type
- string types = mod->type();
-
- // Make sure the type is registered
- if (extensions.find(types) == extensions.end()) {
- if (debug)
- cerr << "failed!" << endl
- << "\tUnknown extension type: " << prep_type_name(types) << endl;
- return _LOAD_FAIL;
- }
-
- // If this is a singleton and we already have an instance, don't instantiate
- if (singletons.find(types) != singletons.end() &&
- extensions[types].size() > 0) {
- if (debug)
- cerr << "failed!" << endl
- << "\tNot loading subsequent singleton for: " << prep_type_name(types) << endl;
- return _LOAD_FAIL;
- }
-
- // If a symbol is defined, we'll search for it in the main process
- if (mod->symb && mod->smod && !pdlsymlinked(mod->smod, mod->symb)) {
- // If the symbol is not found and the symbol is required, error
- if (symbreq) {
- if (debug)
- cerr << "failed!" << endl
- << "\tUnable to find required symbol: "
- << mod->symb << endl;
- return _LOAD_FAIL;
- }
-
- // If the symbol is not found and not required, we'll load only
- // if there are no other modules of this type
- else if (extensions[types].size() > 0) {
- if (debug)
- cerr << "failed!" << endl
- << "\tUnable to find required symbol: "
- << mod->symb << endl;
- return _LOAD_FAIL;
- }
- }
-
- // We've passed all the tests this far, do it again in non-lazy mode
- if (lazy) return _LOAD_LAZY;
-
- // If our execution test succeeds, call init()
- if ((mod->test && mod->test()) || !mod->test) {
- base_extension** exts = mod->init();
- if (!exts) {
- if (debug)
- cerr << "failed!" << endl
- << "\tinit() returned no extensions!" << endl;
- return _LOAD_FAIL;
- }
-
- if (debug)
- cerr << "success" << endl;
-
- // init() returned extensions we need to register
- for (unsigned int i=0 ; exts[i] ; i++) {
- if (debug)
- cerr << "\tRegistering "
- << typeid(*exts[i]).name() << "("
- << prep_type_name(exts[i]->get_base_type()) << ")" << endl;
- extensions[exts[i]->get_base_type()].push_back(exts[i]);
- }
- delete[] exts;
- return _LOAD_SUCC;
- }
-
- if (debug)
- cerr << "failed!" << endl
- << "\tTest execution failed." << endl;
- return _LOAD_FAIL;
-}
-
-bool module_manager::load_builtin(mm_module *mod) {
- const char* debug = getenv("_MM_DEBUG");
- if (debug)
- cerr << "loading : builtin module " << mod->name << CR;
-
- // Do the load with the specified prefix
- int status = load(this->extensions, this->singletons, mod, false, false);
- return status == _LOAD_SUCC;
-}
-
-bool module_manager::load_file(const string &filename, bool symbreq) {
- const char* debug = getenv("_MM_DEBUG");
-
- // Stat the file to make sure it is a file
- struct stat st;
- if (stat(filename.c_str(), &st) != 0) return false;
- if ((st.st_mode & S_IFMT) != S_IFREG) return false;
-
- if (debug)
- cerr << "loading : " << filename << CR;
-
- // Open the module
- pdlmtype dlobj = pdlopenl(filename.c_str());
- if (!dlobj) {
- if (debug)
- cerr << "failed!" << endl
- << "\t" << pdlerror() << endl;
- return false;
- }
-
- // If we have already loaded this module, return true
- if (this->modules.find((void*) dlobj) != this->modules.end()) {
- if (debug)
- cerr << "preload" << endl;
- pdlclose(dlobj);
- return true;
- }
-
- // Try and finish the load
- struct mm_module *mod_info = (mm_module*) pdlsym(dlobj, __str(__MM_MODULE_VARNAME(info)));
- int status = load(this->extensions, this->singletons, mod_info, true, symbreq);
- if (status == _LOAD_LAZY) { // Reload the module in non-lazy mode
- dlobj = pdlreopen(filename.c_str(), dlobj);
- if (!dlobj) {
- if (debug)
- cerr << "failed!" << endl
- << "\tUnable to reload module: " << pdlerror() << endl;
- return false;
- }
- mod_info = (mm_module*) pdlsym(dlobj, __str(__MM_MODULE_VARNAME(info)));
- status = load(this->extensions, this->singletons, mod_info, false, symbreq);
- }
- if (status == _LOAD_FAIL) {
- pdlclose(dlobj);
- return false;
- }
-
- // Add the dlobject to our known modules
- this->modules.insert((void*) dlobj);
-
- // Yay, we did it!
- return true;
-}
-
-bool module_manager::load_dir(const string &dirname, bool symbreq) {
- vector<string> files;
-
-#ifdef WIN32
- WIN32_FIND_DATA fd;
- HANDLE search;
-
- string srch = dirname + "\\*." + _MOD_SUFFIX;
- search = FindFirstFile(srch.c_str(), &fd);
- if (search != INVALID_HANDLE_VALUE) {
- do {
- files.push_back(dirname + "\\" + fd.cFileName);
- } while (FindNextFile(search, &fd));
- FindClose(search);
- }
-#else
- struct dirent *ent;
-
- DIR *moduledir = opendir(dirname.c_str());
- if (moduledir) {
- while((ent = readdir(moduledir))) {
- string tmp = ent->d_name;
- if (tmp.find(_MOD_SUFFIX, tmp.size() - string(_MOD_SUFFIX).size()) != tmp.npos)
- files.push_back(dirname + "/" + tmp);
- }
- closedir(moduledir);
- }
-#endif
-
- // Perform our load alphabetically
- sort(files.begin(), files.end());
-
- // Try to do the load
- bool loaded = false;
- for (vector<string>::iterator it = files.begin() ; it != files.end() ; it++)
- loaded = this->load_file(*it, symbreq) || loaded;
- return loaded;
-}
diff --git a/libmodman/module_manager.hpp b/libmodman/module_manager.hpp
deleted file mode 100644
index 7820575..0000000
--- a/libmodman/module_manager.hpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * libmodman - A library for extending applications
- * Copyright (C) 2009 Nathaniel McCallum <nathaniel@natemccallum.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.1 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- ******************************************************************************/
-
-#ifndef MODULE_MANAGER_HPP_
-#define MODULE_MANAGER_HPP_
-
-#include <algorithm>
-#include <map>
-#include <set>
-#include <string>
-#include <vector>
-#include <cassert>
-
-#include "module.hpp"
-
-namespace libmodman {
-using namespace std;
-
-class __MM_DLL_EXPORT module_manager {
-public:
- ~module_manager();
- bool load_builtin(mm_module *mod);
- bool load_file(const string &filename, bool symbreq=true);
- bool load_dir(const string &dirname, bool symbreq=true);
-
- template <class T> vector<T*> get_extensions() const {
- struct pcmp {
- static bool cmp(T* x, T* y) { return *x < *y; }
- };
-
- map<string, vector<base_extension*> >::const_iterator it = this->extensions.find(T::base_type());
- vector<T*> retlist;
-
- if (it != this->extensions.end()) {
- vector<base_extension*> extlist = it->second;
-
- for (size_t i=0 ; i < extlist.size() ; i++) {
- T* obj = dynamic_cast<T*>(extlist[i]);
- if (obj)
- retlist.push_back(obj);
- else
- assert (obj != NULL);
- }
-
- sort(retlist.begin(), retlist.end(), &pcmp::cmp);
- }
-
- return retlist;
- }
-
- template <class T> bool register_type() {
- if (T::singleton()) {
- if (!this->singletons.insert(T::base_type()).second)
- return false;
- }
- else
- this->singletons.erase(T::base_type());
- this->extensions[T::base_type()];
- return true;
- }
-
-private:
- set<void*> modules;
- set<string> singletons;
- map<string, vector<base_extension*> > extensions;
-};
-
-}
-
-#endif /* MODULE_MANAGER_HPP_ */
diff --git a/libmodman/test/CMakeLists.txt b/libmodman/test/CMakeLists.txt
deleted file mode 100644
index 168b130..0000000
--- a/libmodman/test/CMakeLists.txt
+++ /dev/null
@@ -1,79 +0,0 @@
-#####
-## LibModMan Tests
-####
-
-# Functions
-function(mm_create_module MODTYPE MODNAME MODCOND MODSYMB MODSMOD)
- configure_file(module.cpp.in
- ${CMAKE_CURRENT_BINARY_DIR}/${MODTYPE}_${MODNAME}.cpp
- @ONLY)
- add_library(${MODTYPE}_${MODNAME}
- MODULE
- ${CMAKE_CURRENT_BINARY_DIR}/${MODTYPE}_${MODNAME}.cpp)
- set_target_properties(${MODTYPE}_${MODNAME}
- PROPERTIES PREFIX ""
- LIBRARY_OUTPUT_DIRECTORY
- ${CMAKE_CURRENT_BINARY_DIR}/modules/${MODTYPE})
- target_link_libraries(${MODTYPE}_${MODNAME} modman)
-endfunction(mm_create_module)
-
-function(mm_create_program name EXTTYPE)
- add_executable(${name} main.cpp)
- target_link_libraries(${name} modman)
- set_property(TARGET ${name} PROPERTY
- COMPILE_DEFINITIONS
- EXTTYPE=${EXTTYPE}_extension)
- if(${ARGC} GREATER 2)
- target_link_libraries(${name} ${ARGN};modman)
- set_property(TARGET ${name} PROPERTY
- COMPILE_DEFINITIONS
- EXTTYPE=${EXTTYPE}_extension;SYMB=1)
- if(NOT WIN32 AND NOT APPLE)
- set_property(TARGET ${name} PROPERTY
- LINK_FLAGS -Wl,--no-as-needed)
- endif()
- endif()
-endfunction(mm_create_program)
-
-# Modules
-mm_create_module(condition one false NULL NULL)
-mm_create_module(condition two true NULL NULL)
-mm_create_module(singleton one true NULL NULL)
-mm_create_module(singleton two true NULL NULL)
-mm_create_module(sorted one true NULL NULL)
-mm_create_module(sorted two true NULL NULL)
-mm_create_module(builtin one true NULL NULL)
-if (WIN32)
- mm_create_module(symbol one true \"asdfoia\" \"ws2_32\")
- mm_create_module(symbol two true \"recv\" \"ws2_32\")
-else()
- mm_create_module(symbol one true \"asdfoia\" \"z\")
- mm_create_module(symbol two true \"deflate\" \"z\")
-endif()
-
-# Programs
-mm_create_program(condition condition)
-mm_create_program(singleton singleton)
-mm_create_program(sorted sorted)
-mm_create_program(symbol symbol)
-if (WIN32)
- mm_create_program(symbollnk symbol ws2_32)
-else()
- mm_create_program(symbollnk symbol z)
-endif()
-add_executable(builtin
- builtin.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/builtin_one.cpp)
-target_link_libraries(builtin modman)
-set_property(TARGET builtin PROPERTY COMPILE_DEFINITIONS
- EXTTYPE=builtin_extension;BUILTIN_MODULE=extension;MM_MODULE_BUILTIN=extension)
-
-# Tests
-add_test(NAME condition COMMAND condition $<TARGET_FILE_DIR:condition_one> two)
-add_test(NAME singleton COMMAND singleton $<TARGET_FILE_DIR:singleton_one> one)
-add_test(NAME sorted COMMAND sorted $<TARGET_FILE_DIR:sorted_one> two one)
-add_test(NAME symbol COMMAND symbollnk $<TARGET_FILE_DIR:symbol_one> two)
-add_test(NAME nosymbol COMMAND symbol $<TARGET_FILE_DIR:symbol_one>)
-add_test(NAME nosymreq COMMAND symbol $<TARGET_FILE_DIR:symbol_one> one)
-add_test(NAME builtin COMMAND builtin)
-
diff --git a/libmodman/test/builtin.cpp b/libmodman/test/builtin.cpp
deleted file mode 100644
index 8a3f328..0000000
--- a/libmodman/test/builtin.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * libmodman - A library for extending applications
- * Copyright (C) 2009 Nathaniel McCallum <nathaniel@natemccallum.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.1 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- ******************************************************************************/
-
-#include "main.hpp"
-
-MM_DEF_BUILTIN(BUILTIN_MODULE);
-
-int main() {
- module_manager mm;
- mm.register_type<EXTTYPE>();
- return !mm.load_builtin(& MM_BUILTIN(BUILTIN_MODULE));
-}
diff --git a/libmodman/test/main.cpp b/libmodman/test/main.cpp
deleted file mode 100644
index cf930c1..0000000
--- a/libmodman/test/main.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * libmodman - A library for extending applications
- * Copyright (C) 2009 Nathaniel McCallum <nathaniel@natemccallum.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.1 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- ******************************************************************************/
-
-#include <iostream>
-#include <vector>
-#include <cstring>
-#ifdef WIN32
-#ifdef SYMB
-#include <winsock2.h>
-#endif
-#endif
-
-#include "main.hpp"
-
-int main(int argc, const char** argv) {
- module_manager mm;
-#ifdef WIN32
-#ifdef SYMB
- void* symb = recv;
-#endif
-#endif
-
- if (argc < 2) {
- cout << "Usage: " << argv[0] << " MODULEDIR MODNAME ..." << endl;
- return 1;
- }
-
- if (!mm.register_type<EXTTYPE>()) {
- cout << "Unable to register type!" << endl;
- return 2;
- }
-
- if (!mm.load_dir(argv[1]) && argc > 2) {
- if (!mm.load_dir(argv[1], false)) {
- cout << "Unable to load modules!" << endl;
- return 3;
- }
- }
-
- vector<EXTTYPE*> exts = mm.get_extensions<EXTTYPE>();
- if (exts.size() != (unsigned int) argc - 2) {
- cout << "Wrong number of extensions found!" << endl;
- return 4;
- }
-
- for (unsigned int i=0 ; i < exts.size() ; i++) {
- if (!strstr(typeid(*(exts[i])).name(), argv[i+2])) {
- cout << "Unable to find extension! Here's the list:" << endl;
- for (unsigned int j=0 ; j < exts.size() ; j++)
- cout << "\t" << typeid(*(exts[j])).name() << endl;
- return 5;
- }
- }
-
- return 0;
-}
diff --git a/libmodman/test/main.hpp b/libmodman/test/main.hpp
deleted file mode 100644
index 0a08c63..0000000
--- a/libmodman/test/main.hpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * libmodman - A library for extending applications
- * Copyright (C) 2009 Nathaniel McCallum <nathaniel@natemccallum.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.1 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- ******************************************************************************/
-
-#ifndef MAIN_HPP_
-#define MAIN_HPP_
-
-#include <typeinfo>
-
-#include "../module_manager.hpp"
-
-using namespace std;
-using namespace libmodman;
-
-class __MM_DLL_EXPORT singleton_extension : public extension<singleton_extension, true> {};
-
-class __MM_DLL_EXPORT sorted_extension : public extension<sorted_extension> {
-public:
- virtual bool operator<(const base_extension& other) const {
- return string(typeid(*this).name()) > string(typeid(other).name());
- }
-};
-
-class __MM_DLL_EXPORT symbol_extension : public extension<symbol_extension> {};
-class __MM_DLL_EXPORT condition_extension : public extension<condition_extension> {};
-class __MM_DLL_EXPORT builtin_extension : public extension<builtin_extension> {};
-
-#endif /* MAIN_HPP_ */
diff --git a/libmodman/test/module.cpp.in b/libmodman/test/module.cpp.in
deleted file mode 100644
index 3390ead..0000000
--- a/libmodman/test/module.cpp.in
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * libmodman - A library for extending applications
- * Copyright (C) 2009 Nathaniel McCallum <nathaniel@natemccallum.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.1 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- ******************************************************************************/
-
-#include <libmodman/module.hpp>
-#include <libmodman/test/main.hpp>
-
-class @MODNAME@ : public @MODTYPE@_extension {};
-MM_MODULE_INIT_EZ(@MODNAME@, @MODCOND@, @MODSYMB@, @MODSMOD@);