-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
530 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
# Makefile | ||
|
||
ROOTDIR = ../.. | ||
include $(ROOTDIR)/config.mk | ||
|
||
SUBDIRS = $(filter-out Interface/, $(sort $(dir $(wildcard */)))) | ||
CLEANSUBDIRS = $(addsuffix .clean, $(SUBDIRS)) | ||
|
||
.PHONY: Modules | ||
|
||
Modules: | ||
@echo | ||
@echo Making all in subdirectory $@... | ||
$(MAKE) -C Modules | ||
|
||
clean: $(CLEANSUBDIRS) | ||
|
||
$(CLEANSUBDIRS): | ||
@cd $(basename $@) ; $(MAKE) clean | ||
|
||
|
||
ROOTDIR = ../../../.. | ||
include $(ROOTDIR)/config.mk | ||
|
||
CFLAGS_SO += -I$(INCLUDE_DIR)/pkg_Core/Interface | ||
CFLAGS_SO += -I$(INCLUDE_DIR)/pkg_Platform/Interface | ||
|
||
all: | ||
$(CC) $(CFLAGS_SO) -c Cx_Example.cpp | ||
$(CC) $(CFLAGS_SO) -c Plugin.cpp | ||
$(CC) $(CFLAGS_SO) -c Module.cpp | ||
$(CC) $(C_FLAGS_SO) -o $(PLUGINS_DIR)/libx3c_swig.so *.o | ||
clean: | ||
rm -rf *.so | ||
rm -rf *.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#include <UtilFunc/PluginInc.h> | ||
#include <PluginManager/PluginManager.h> | ||
#include <PluginManager/XComCreator.h> | ||
#include <UtilFunc/ConvStr.h> | ||
#include <PluginManager/Ix_PluginLoader2.h> | ||
|
||
#ifdef _MSC_VER // hide warnings | ||
#pragma warning(disable:4505) // unreferenced local function has been removed | ||
#pragma warning (push, 2) | ||
#pragma warning(disable:4701) // potentially uninitialized local variable used | ||
#pragma warning(disable:4706) // assignment within conditional expression | ||
#endif | ||
#include "x3core_wrap.cxx" | ||
#ifdef _MSC_VER // hide warnings | ||
#pragma warning (pop) | ||
#endif | ||
|
||
static CPluginManager s_loader; | ||
static HMODULE s_hmod = NULL; | ||
|
||
#ifdef APIENTRY | ||
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID) | ||
{ | ||
if (dwReason == DLL_PROCESS_ATTACH) | ||
{ | ||
s_hmod = (HMODULE)hModule; | ||
} | ||
return TRUE; | ||
} | ||
#endif | ||
|
||
bool LoadCorePlugins() | ||
{ | ||
return s_loader.LoadCorePlugins(L"../plugins", s_hmod); | ||
} | ||
|
||
bool LoadAllPlugins() | ||
{ | ||
if (!s_loader.LoadCorePlugins(L"../plugins", s_hmod)) | ||
return false; | ||
|
||
Ix_PluginLoader* loader = s_loader.GetPluginLoader(); | ||
long n; | ||
|
||
n = loader->LoadPlugins(L"../plugins"); | ||
n = loader->LoadPlugins(L"../plugins", L".pyd"); | ||
n = loader->InitializePlugins(); | ||
|
||
return n >= 0; | ||
} | ||
|
||
bool LoadPluginFiles(const char* files) | ||
{ | ||
if (!s_loader.Handle()) | ||
{ | ||
s_loader.LoadPluginManager(L"../plugins", s_hmod); | ||
} | ||
|
||
Ix_PluginLoader* loader = s_loader.GetPluginLoader(); | ||
|
||
return loader->LoadPluginFiles(L"../plugins", x3::a2w(files).c_str(), s_hmod) > 0 | ||
&& loader->InitializePlugins() > 0; | ||
} | ||
|
||
void UnloadPlugins() | ||
{ | ||
s_loader.Unload(); | ||
} | ||
|
||
std::vector<std::wstring> GetPluginFiles() | ||
{ | ||
Cx_Interface<Ix_PluginLoader2> loader(s_loader.GetPluginLoader()); | ||
ASSERT(loader.IsNotNull()); | ||
|
||
std::vector<std::wstring> filenames; | ||
HMODULE hdll; | ||
std::wstring filename; | ||
|
||
for (int i = 0; loader->GetPluginFileName(i, hdll, filename); i++) | ||
{ | ||
filenames.push_back(filename); | ||
} | ||
|
||
return filenames; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Version.rc2 - resources Microsoft Visual C++ does not edit directly | ||
// | ||
// TODO: Change values of FILEVERSION and FileVersion | ||
// | ||
|
||
VS_VERSION_INFO VERSIONINFO | ||
FILEVERSION 1,0,0,1 | ||
FILEFLAGSMASK 0x3fL | ||
#ifdef _DEBUG | ||
FILEFLAGS 0x1L | ||
#else | ||
FILEFLAGS 0x0L | ||
#endif | ||
FILEOS 0x4L | ||
FILETYPE 0x2L | ||
FILESUBTYPE 0x0L | ||
BEGIN | ||
BLOCK "StringFileInfo" | ||
BEGIN | ||
BLOCK "000004b0" | ||
BEGIN | ||
VALUE "FileDescription", "Adaptor module for python.\0" | ||
VALUE "FileVersion", "1.0.0.1\0" | ||
VALUE "LegalCopyright", "(C) 2008-2011, X3 C++ PluginFramework\0" | ||
VALUE "OriginalFilename", "_x3core.pyd\0" | ||
VALUE "ProductName", "X3 C++ PluginFramework\0" | ||
END | ||
END | ||
BLOCK "VarFileInfo" | ||
BEGIN | ||
VALUE "Translation", 0x0, 1200 | ||
END | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import x3core as C | ||
|
||
assert(C.LoadPluginFiles("ChangeManager")) | ||
files = C.GetPluginFiles() | ||
print(files) | ||
|
||
C.UnloadPlugins() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
%module x3core | ||
|
||
%{ | ||
#include <UtilFunc/vecfunc.h> | ||
using namespace std; | ||
typedef vector<wstring> WStrVector; | ||
|
||
bool LoadCorePlugins(); | ||
bool LoadAllPlugins(); | ||
bool LoadPluginFiles(const char* files); | ||
void UnloadPlugins(); | ||
std::vector<std::wstring> GetPluginFiles(); | ||
%} | ||
|
||
%include stl.i | ||
using namespace std; | ||
|
||
%template(WStrVector) vector<wstring>; | ||
|
||
bool LoadCorePlugins(); | ||
bool LoadAllPlugins(); | ||
bool LoadPluginFiles(const char* files); | ||
void UnloadPlugins(); | ||
WStrVector GetPluginFiles(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# This file was automatically generated by SWIG (http://www.swig.org). | ||
# Version 2.0.4 | ||
# | ||
# Do not make changes to this file unless you know what you are doing--modify | ||
# the SWIG interface file instead. | ||
|
||
|
||
|
||
from sys import version_info | ||
if version_info >= (2,6,0): | ||
def swig_import_helper(): | ||
from os.path import dirname | ||
import imp | ||
fp = None | ||
try: | ||
fp, pathname, description = imp.find_module('_x3core', [dirname(__file__)]) | ||
except ImportError: | ||
import _x3core | ||
return _x3core | ||
if fp is not None: | ||
try: | ||
_mod = imp.load_module('_x3core', fp, pathname, description) | ||
finally: | ||
fp.close() | ||
return _mod | ||
_x3core = swig_import_helper() | ||
del swig_import_helper | ||
else: | ||
import _x3core | ||
del version_info | ||
try: | ||
_swig_property = property | ||
except NameError: | ||
pass # Python < 2.2 doesn't have 'property'. | ||
def _swig_setattr_nondynamic(self,class_type,name,value,static=1): | ||
if (name == "thisown"): return self.this.own(value) | ||
if (name == "this"): | ||
if type(value).__name__ == 'SwigPyObject': | ||
self.__dict__[name] = value | ||
return | ||
method = class_type.__swig_setmethods__.get(name,None) | ||
if method: return method(self,value) | ||
if (not static): | ||
self.__dict__[name] = value | ||
else: | ||
raise AttributeError("You cannot add attributes to %s" % self) | ||
|
||
def _swig_setattr(self,class_type,name,value): | ||
return _swig_setattr_nondynamic(self,class_type,name,value,0) | ||
|
||
def _swig_getattr(self,class_type,name): | ||
if (name == "thisown"): return self.this.own() | ||
method = class_type.__swig_getmethods__.get(name,None) | ||
if method: return method(self) | ||
raise AttributeError(name) | ||
|
||
def _swig_repr(self): | ||
try: strthis = "proxy of " + self.this.__repr__() | ||
except: strthis = "" | ||
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) | ||
|
||
try: | ||
_object = object | ||
_newclass = 1 | ||
except AttributeError: | ||
class _object : pass | ||
_newclass = 0 | ||
|
||
|
||
|
||
def LoadPlugins(): | ||
return _x3core.LoadPlugins() | ||
LoadPlugins = _x3core.LoadPlugins | ||
# This file is compatible with both classic and new-style classes. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifdef _WIN32 | ||
#include <winver.h> | ||
LANGUAGE 0, 0 // LANG_NEUTRAL, SUBLANG_NEUTRAL | ||
#pragma code_page(1252) | ||
#include "Version.rc2" | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.