summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2014-10-05 21:59:17 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2014-10-05 21:59:17 +0200
commitcc6e599a52b3a062e62eb1a225c603f105e95f04 (patch)
tree468c13628ef77c1bd5194eaba142db90c54ea0f7 /include
parentb577b7119aa1f57c4db7fd254c2b5b197e7451d2 (diff)
downloadcrawler-cc6e599a52b3a062e62eb1a225c603f105e95f04.tar.gz
crawler-cc6e599a52b3a062e62eb1a225c603f105e95f04.tar.bz2
added userdata to destroy function, remembering userdata on module
initialization and passing it to destroy function in principle the system works, a dlopen of the lua module removes necessary functions needed during lua VM shutdown, this is due to stack unwinding and the order objects are destroyed (should be fixable)
Diffstat (limited to 'include')
-rwxr-xr-xinclude/luaglue/LuaVM.hpp1
-rwxr-xr-xinclude/module/ModuleLoader.hpp7
-rwxr-xr-xinclude/module/ModuleRegistry.hpp20
3 files changed, 16 insertions, 12 deletions
diff --git a/include/luaglue/LuaVM.hpp b/include/luaglue/LuaVM.hpp
index f25cc3e..baa5bca 100755
--- a/include/luaglue/LuaVM.hpp
+++ b/include/luaglue/LuaVM.hpp
@@ -14,6 +14,7 @@ class LuaVM
void loadSource( const char *sourceFilename );
void executeMain( );
void dumpState( );
+ void fullGarbageCollect( );
lua_State *handle( );
diff --git a/include/module/ModuleLoader.hpp b/include/module/ModuleLoader.hpp
index 21905ec..045383f 100755
--- a/include/module/ModuleLoader.hpp
+++ b/include/module/ModuleLoader.hpp
@@ -28,6 +28,7 @@ struct Module {
#else
HMODULE handle;
#endif
+ void *user_data;
ModuleRegistry< Interface, CtorParams > *registry;
};
@@ -81,9 +82,11 @@ class BaseModuleLoader {
}
if( m.registry->initModule != 0 ) {
- m.registry->initModule( user_data );
+ m.registry->initModule( user_data );
}
+ m.user_data = user_data;
+
m_modules.insert( std::make_pair( m.registry->name, m ) );
}
}
@@ -96,7 +99,7 @@ class BaseModuleLoader {
typename mapType::iterator it = m_modules.begin( );
if( (*it).second.registry ) {
if( (*it).second.registry->destroyModule != 0 ) {
- (*it).second.registry->destroyModule( );
+ (*it).second.registry->destroyModule( (*it).second.user_data );
}
}
if( (*it).second.handle ) {
diff --git a/include/module/ModuleRegistry.hpp b/include/module/ModuleRegistry.hpp
index d98c9ba..058aa24 100755
--- a/include/module/ModuleRegistry.hpp
+++ b/include/module/ModuleRegistry.hpp
@@ -12,13 +12,13 @@ template< typename Interface>
struct ModuleRegistry< Interface > {
std::string name;
void (*initModule)( void *user_data );
- void (*destroyModule)( );
+ void (*destroyModule)( void *user_data );
Interface *(*create)( );
void (*destroy)( Interface *obj );
ModuleRegistry( std::string _name,
void (*_initModule)( void *user_data ),
- void (*_destroyModule)( ),
+ void (*_destroyModule)( void *user_data ),
Interface *(*_create)( ),
void (*_destroy)( Interface *obj ) )
: name( _name ),
@@ -32,13 +32,13 @@ template< typename Interface, typename P1 >
struct ModuleRegistry< Interface, TYPELIST_1( P1 ) > {
std::string name;
void (*initModule)( void *user_data );
- void (*destroyModule)( );
+ void (*destroyModule)( void *user_data );
Interface *(*create)( P1 );
void (*destroy)( Interface *obj );
ModuleRegistry( std::string _name,
void (*_initModule)( void *user_data ),
- void (*_destroyModule)( ),
+ void (*_destroyModule)( void *user_data ),
Interface *(*_create)( P1 ),
void (*_destroy)( Interface *obj ) )
: name( _name ),
@@ -52,13 +52,13 @@ template< typename Interface, typename P1, typename P2 >
struct ModuleRegistry< Interface, TYPELIST_2( P1, P2 ) > {
std::string name;
void (*initModule)( void *user_data );
- void (*destroyModule)( );
+ void (*destroyModule)( void *user_data );
Interface *(*create)( P1, P2 );
void (*destroy)( Interface *obj );
ModuleRegistry( std::string _name,
void (*_initModule)( void *user_data ),
- void (*_destroyModule)( ),
+ void (*_destroyModule)( void *user_data ),
Interface *(*_create)( P1, P2 ),
void (*_destroy)( Interface *obj ) )
: name( _name ),
@@ -72,13 +72,13 @@ template< typename Interface, typename P1, typename P2, typename P3 >
struct ModuleRegistry< Interface, TYPELIST_3( P1, P2, P3 ) > {
std::string name;
void (*initModule)( void *user_data );
- void (*destroyModule)( );
+ void (*destroyModule)( void *user_data );
Interface *(*create)( P1, P2, P3 );
void (*destroy)( Interface *obj );
ModuleRegistry( std::string _name,
void (*_initModule)( void *user_data ),
- void (*_destroyModule)( ),
+ void (*_destroyModule)( void *user_data ),
Interface *(*_create)( P1, P2, P3 ),
void (*_destroy)( Interface *obj ) )
: name( _name ),
@@ -92,13 +92,13 @@ template< typename Interface, typename P1, typename P2, typename P3, typename P4
struct ModuleRegistry< Interface, TYPELIST_4( P1, P2, P3, P4 ) > {
std::string name;
void (*initModule)( void *user_data );
- void (*destroyModule)( );
+ void (*destroyModule)( void *user_data );
Interface *(*create)( P1, P2, P3, P4 );
void (*destroy)( Interface *obj );
ModuleRegistry( std::string _name,
void (*_initModule)( void *user_data ),
- void (*_destroyModule)( ),
+ void (*_destroyModule)( void *user_data ),
Interface *(*_create)( P1, P2, P3, P4 ),
void (*_destroy)( Interface *obj ) )
: name( _name ),