summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2014-10-05 12:39:48 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2014-10-05 12:39:48 +0200
commit08be1164cbaa7ec69bd229e138d3ad86b169f68f (patch)
tree26b212498a9bafe5251bc5e53a506abc3f0d46e5
parent4174158dc75b5ed892b293b18b7dd5c85aa36f2f (diff)
downloadcrawler-08be1164cbaa7ec69bd229e138d3ad86b169f68f.tar.gz
crawler-08be1164cbaa7ec69bd229e138d3ad86b169f68f.tar.bz2
trying to initialize tolua glue code in test module, segfaulting still
-rwxr-xr-xinclude/luaglue/LuaVM.hpp2
-rw-r--r--src/libluaglue/LuaVM.cpp5
-rwxr-xr-xtests/tolua/libtest1/GNUmakefile3
-rwxr-xr-xtests/tolua/libtest1/TestMod.cpp7
-rwxr-xr-xtests/tolua/test1.cpp4
5 files changed, 15 insertions, 6 deletions
diff --git a/include/luaglue/LuaVM.hpp b/include/luaglue/LuaVM.hpp
index a8a6524..f25cc3e 100755
--- a/include/luaglue/LuaVM.hpp
+++ b/include/luaglue/LuaVM.hpp
@@ -14,6 +14,8 @@ class LuaVM
void loadSource( const char *sourceFilename );
void executeMain( );
void dumpState( );
+
+ lua_State *handle( );
private:
void initialize( );
diff --git a/src/libluaglue/LuaVM.cpp b/src/libluaglue/LuaVM.cpp
index 7c1ce51..cf8935f 100644
--- a/src/libluaglue/LuaVM.cpp
+++ b/src/libluaglue/LuaVM.cpp
@@ -16,6 +16,11 @@ LuaVM::~LuaVM( )
lua_close( m_lua );
}
+lua_State *LuaVM::handle( )
+{
+ return m_lua;
+}
+
void LuaVM::initialize( )
{
m_lua = luaL_newstate( );
diff --git a/tests/tolua/libtest1/GNUmakefile b/tests/tolua/libtest1/GNUmakefile
index 9393a93..b53a1b2 100755
--- a/tests/tolua/libtest1/GNUmakefile
+++ b/tests/tolua/libtest1/GNUmakefile
@@ -7,7 +7,8 @@ SUBDIRS =
INCLUDE_DIRS = \
-I. -I$(TOPDIR)/src -I.. \
-I$(TOPDIR)/include/module \
- -I$(TOPDIR)/include/util
+ -I$(TOPDIR)/include/util \
+ -I$(TOPDIR)/include/luaglue
INCLUDE_CXXFLAGS = \
diff --git a/tests/tolua/libtest1/TestMod.cpp b/tests/tolua/libtest1/TestMod.cpp
index 491001c..912d652 100755
--- a/tests/tolua/libtest1/TestMod.cpp
+++ b/tests/tolua/libtest1/TestMod.cpp
@@ -1,6 +1,7 @@
#include "TestMod.hpp"
#include "tolua.h"
#include "TestModLua.hpp"
+#include "LuaVM.hpp"
#include <iostream>
@@ -11,9 +12,11 @@ void Derived::hello( )
cout << "hello" << endl;
}
-static void initModule( )
+static void initModule( void *user_data )
{
-// tolua_TestMod_open( 0 /* m_lua, where from? */ );
+ LuaVM *luaVm = (LuaVM *)user_data;
+
+ tolua_TestMod_open( luaVm->handle( ) );
}
static void destroyModule( )
diff --git a/tests/tolua/test1.cpp b/tests/tolua/test1.cpp
index a2e91cb..fe2801a 100755
--- a/tests/tolua/test1.cpp
+++ b/tests/tolua/test1.cpp
@@ -17,9 +17,7 @@ int main( int /* argc */, char *argv[] )
vector<string> modules;
modules.push_back( "./libtest1/mod_test.so" );
- ModuleLoader<Base> loader( modules );
-
- Logger::instance( ).openConsoleLog( logDEBUG );
+ ModuleLoader<Base> loader( modules, (void *)&luaVm );
luaVm.loadSource( argv[1] );
luaVm.executeMain( );