diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2014-10-05 21:59:17 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2014-10-05 21:59:17 +0200 |
commit | cc6e599a52b3a062e62eb1a225c603f105e95f04 (patch) | |
tree | 468c13628ef77c1bd5194eaba142db90c54ea0f7 /tests | |
parent | b577b7119aa1f57c4db7fd254c2b5b197e7451d2 (diff) | |
download | crawler-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 'tests')
-rw-r--r-- | tests/modules/test4.MUST | 2 | ||||
-rwxr-xr-x | tests/modules/testmod4/TestMod4.cpp | 10 | ||||
-rwxr-xr-x | tests/tolua/libtest1/TestMod.cpp | 5 | ||||
-rwxr-xr-x | tests/tolua/test1.cpp | 7 |
4 files changed, 14 insertions, 10 deletions
diff --git a/tests/modules/test4.MUST b/tests/modules/test4.MUST index 1d14a0c..9ef1168 100644 --- a/tests/modules/test4.MUST +++ b/tests/modules/test4.MUST @@ -2,5 +2,5 @@ Created common object test4: Module 4 initModule called with user data: 47 hello there test4: hello from main test4: hello world from module -test4: Module 4 destroyModule called +test4: Module 4 destroyModule called with user data: 47 hello there Destroyed common object diff --git a/tests/modules/testmod4/TestMod4.cpp b/tests/modules/testmod4/TestMod4.cpp index de8b1b6..f2d0ecd 100755 --- a/tests/modules/testmod4/TestMod4.cpp +++ b/tests/modules/testmod4/TestMod4.cpp @@ -34,9 +34,15 @@ static void initModule( void *user_data ) Common::instance( ).print( ss.str( ) ); } -static void destroyModule( ) +static void destroyModule( void *user_data ) { - Common::instance( ).print( "Module 4 destroyModule called" ); + UserData *data = (UserData *)user_data; + ostringstream ss; + + ss << "Module 4 destroyModule called with user data: " + << data->version << " " << data->text; + + Common::instance( ).print( ss.str( ) ); } REGISTER_MODULE( "testmod4", &initModule, &destroyModule, Base, Derived ) diff --git a/tests/tolua/libtest1/TestMod.cpp b/tests/tolua/libtest1/TestMod.cpp index 912d652..b06644e 100755 --- a/tests/tolua/libtest1/TestMod.cpp +++ b/tests/tolua/libtest1/TestMod.cpp @@ -19,8 +19,11 @@ static void initModule( void *user_data ) tolua_TestMod_open( luaVm->handle( ) ); } -static void destroyModule( ) +static void destroyModule( void *user_data ) { + LuaVM *luaVm = (LuaVM *)user_data; + + luaVm->fullGarbageCollect( ); } REGISTER_MODULE( "testmod", &initModule, &destroyModule, Base, Derived ) diff --git a/tests/tolua/test1.cpp b/tests/tolua/test1.cpp index 902b278..271544e 100755 --- a/tests/tolua/test1.cpp +++ b/tests/tolua/test1.cpp @@ -23,13 +23,8 @@ int main( int /* argc */, char *argv[] ) luaVm.loadSource( argv[1] ); luaVm.executeMain( ); - //luaVm.dumpState( ); - - //Base *obj = loader.create( "testmod" ); - //obj->hello( ); - //loader.destroy( obj ); - return 0; + } catch( exception &e ) { LOG( logFATAL ) << "ERROR: " << e.what( ); return 1; |