diff --git a/Examples/lua/dual/dual.cpp b/Examples/lua/dual/dual.cpp index d2a9ecaa9..ad7897953 100644 --- a/Examples/lua/dual/dual.cpp +++ b/Examples/lua/dual/dual.cpp @@ -36,6 +36,10 @@ extern "C" int luaopen_example2(lua_State*L); #define DEBUG2(X,Y) {printf(X,Y);fflush(stdout);} #define DEBUG3(X,Y,Z) {printf(X,Y,Z);fflush(stdout);} +#if LUA_VERSION_NUM > 501 +#define lua_open luaL_newstate +#endif + void testModule(lua_State *L) { swig_type_info *pTypeInfo=0,*pTypeInfo2=0; diff --git a/Examples/lua/embed/Makefile b/Examples/lua/embed/Makefile index df1f8fa04..57979c061 100644 --- a/Examples/lua/embed/Makefile +++ b/Examples/lua/embed/Makefile @@ -4,6 +4,7 @@ TARGET = embed SRCS = example.c INTERFACE = example.i LUA_INTERP = embed.c +LIBS = -lm # this is a little different to normal as we have our own special interpreter # which we want to static link @@ -12,7 +13,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' LIBS='$(LIBS)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static clean: $(MAKE) -f $(TOP)/Makefile lua_clean diff --git a/Examples/lua/embed/embed.c b/Examples/lua/embed/embed.c index 9df168f94..f21c933a5 100644 --- a/Examples/lua/embed/embed.c +++ b/Examples/lua/embed/embed.c @@ -18,6 +18,10 @@ We will be using the luaL_dostring()/lua_dostring() function to call into lua #include #include +#if LUA_VERSION_NUM > 501 +#define lua_open luaL_newstate +#endif + /* the SWIG wrappered library */ extern int luaopen_example(lua_State*L); diff --git a/Examples/lua/embed2/Makefile b/Examples/lua/embed2/Makefile index fc309ac7e..ec22bdcae 100644 --- a/Examples/lua/embed2/Makefile +++ b/Examples/lua/embed2/Makefile @@ -4,6 +4,7 @@ TARGET = embed2 SRCS = example.c INTERFACE = example.i LUA_INTERP = embed2.c +LIBS = -lm # this is a little different to normal as we have our own special interpreter # which we want to static link @@ -12,7 +13,7 @@ check: build build: $(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' LIBS='$(LIBS)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static clean: $(MAKE) -f $(TOP)/Makefile lua_clean diff --git a/Examples/test-suite/keyword_rename.i b/Examples/test-suite/keyword_rename.i index 46c3338b3..a9f58ebef 100644 --- a/Examples/test-suite/keyword_rename.i +++ b/Examples/test-suite/keyword_rename.i @@ -32,8 +32,10 @@ KW(go, defer) KW(chan, fallthrough) /* Lua keywords */ +#ifdef SWIGLUA KW(end, function) KW(nil,local) +#endif %} diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index ff807a785..5ae08f5d0 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -357,6 +357,9 @@ SWIGINTERN int SWIG_Lua_namespace_set(lua_State *L) lua_pop(L,1); /* remove the value */ } lua_pop(L,1); /* remove the value .set table */ + lua_pop(L,1); /* remote metatable */ + assert(lua_gettop(L) == 3); // TODO: REMOVE + lua_rawset(L,-3); return 0; } @@ -505,7 +508,7 @@ SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname); typedef int (*swig_lua_base_iterator_func)(lua_State*,swig_type_info*, int, int *ret); -int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info *swig_type, int first_arg, swig_lua_base_iterator_func func, int *const ret) +SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info *swig_type, int first_arg, swig_lua_base_iterator_func func, int *const ret) { // first_arg - position of the object in stack. Everything that is above are arguments // and is passed to every evocation of the func