summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2012-05-24 23:05:07 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2012-05-24 23:05:07 +0000
commit49b6c39d98967c5bad997bf1490deab0161b18a5 (patch)
tree6c77e48c65f9f4501846dd9c97e80e00579afecc
parent184519b6a6e967c57563e8a8a8a9a09e8214785b (diff)
downloadswig-49b6c39d98967c5bad997bf1490deab0161b18a5.tar.gz
Lua fix for -external-runtime
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13119 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--CHANGES.current3
-rw-r--r--Lib/lua/lua.swg24
-rw-r--r--Lib/lua/luarun.swg29
-rw-r--r--Source/Modules/lua.cxx21
4 files changed, 47 insertions, 30 deletions
diff --git a/CHANGES.current b/CHANGES.current
index b94133ac6..acbd8b642 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -4,6 +4,9 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.7 (in progress)
===========================
+2012-05-25: wsfulton
+ [Lua] Fixes for -external-runtime to work again.
+
2012-05-22: szager
[python] Disambiguate SWIG_From_unsigned_SS_int and SWIG_From_unsigned_SS_long.
diff --git a/Lib/lua/lua.swg b/Lib/lua/lua.swg
index 1cd7201c2..39ea1fea7 100644
--- a/Lib/lua/lua.swg
+++ b/Lib/lua/lua.swg
@@ -5,30 +5,6 @@
* This file is parsed by SWIG before reading any other interface file.
* ----------------------------------------------------------------------------- */
-%insert("runtime") %{
-/* Lua flavors */
-#define SWIG_LUA_FLAVOR_LUA 1
-#define SWIG_LUA_FLAVOR_ELUA 2
-#define SWIG_LUA_FLAVOR_ELUAC 3
-
-#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
-# define SWIG_LUA_CONSTTAB_INT(B, C) LSTRKEY(B), LNUMVAL(C)
-# define SWIG_LUA_CONSTTAB_FLOAT(B, C) LSTRKEY(B), LNUMVAL(C)
-# define SWIG_LUA_CONSTTAB_STRING(B, C) LSTRKEY(B), LSTRVAL(C)
-# define SWIG_LUA_CONSTTAB_CHAR(B, C) LSTRKEY(B), LNUMVAL(C)
-# else /* SWIG_LUA_FLAVOR_LUA */
-# define SWIG_LUA_CONSTTAB_INT(B, C) SWIG_LUA_INT, (char *)B, (long)C, 0, 0, 0
-# define SWIG_LUA_CONSTTAB_FLOAT(B, C) SWIG_LUA_FLOAT, (char *)B, 0, (double)C, 0, 0
-# define SWIG_LUA_CONSTTAB_STRING(B, C) SWIG_LUA_STRING, (char *)B, 0, 0, (void *)C, 0
-# define SWIG_LUA_CONSTTAB_CHAR(B, C) SWIG_LUA_CHAR, (char *)B, (long)C, 0, 0, 0
-#endif
-
-#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
-# define LRO_STRVAL(v) {{.p = (char *) v}, LUA_TSTRING}
-# define LSTRVAL LRO_STRVAL
-#endif
-%}
-
/* -----------------------------------------------------------------------------
* includes
* ----------------------------------------------------------------------------- */
diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg
index af3e7a3af..9b94e1efa 100644
--- a/Lib/lua/luarun.swg
+++ b/Lib/lua/luarun.swg
@@ -16,6 +16,35 @@ extern "C" {
#include <assert.h> /* for a few sanity tests */
/* -----------------------------------------------------------------------------
+ * Lua flavors
+ * ----------------------------------------------------------------------------- */
+
+#define SWIG_LUA_FLAVOR_LUA 1
+#define SWIG_LUA_FLAVOR_ELUA 2
+#define SWIG_LUA_FLAVOR_ELUAC 3
+
+#if !defined(SWIG_LUA_TARGET)
+# error SWIG_LUA_TARGET not defined
+#endif
+
+#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
+# define SWIG_LUA_CONSTTAB_INT(B, C) LSTRKEY(B), LNUMVAL(C)
+# define SWIG_LUA_CONSTTAB_FLOAT(B, C) LSTRKEY(B), LNUMVAL(C)
+# define SWIG_LUA_CONSTTAB_STRING(B, C) LSTRKEY(B), LSTRVAL(C)
+# define SWIG_LUA_CONSTTAB_CHAR(B, C) LSTRKEY(B), LNUMVAL(C)
+#else /* SWIG_LUA_FLAVOR_LUA */
+# define SWIG_LUA_CONSTTAB_INT(B, C) SWIG_LUA_INT, (char *)B, (long)C, 0, 0, 0
+# define SWIG_LUA_CONSTTAB_FLOAT(B, C) SWIG_LUA_FLOAT, (char *)B, 0, (double)C, 0, 0
+# define SWIG_LUA_CONSTTAB_STRING(B, C) SWIG_LUA_STRING, (char *)B, 0, 0, (void *)C, 0
+# define SWIG_LUA_CONSTTAB_CHAR(B, C) SWIG_LUA_CHAR, (char *)B, (long)C, 0, 0, 0
+#endif
+
+#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
+# define LRO_STRVAL(v) {{.p = (char *) v}, LUA_TSTRING}
+# define LSTRVAL LRO_STRVAL
+#endif
+
+/* -----------------------------------------------------------------------------
* compatibility defines
* ----------------------------------------------------------------------------- */
diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx
index ba121d28c..a6076a230 100644
--- a/Source/Modules/lua.cxx
+++ b/Source/Modules/lua.cxx
@@ -284,12 +284,7 @@ public:
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGLUA\n");
- if (elua_ltr)
- Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUA\n");
- else if (eluac_ltr)
- Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUAC\n");
- else
- Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_LUA\n");
+ emitLuaFlavor(f_runtime);
if (nomoduleglobal) {
Printf(f_runtime, "#define SWIG_LUA_NO_MODULE_GLOBAL\n");
@@ -1269,6 +1264,9 @@ public:
String *runtimeCode() {
String *s = NewString("");
const char *filenames[] = { "luarun.swg", 0 } ; // must be 0 terminated
+
+ emitLuaFlavor(s);
+
String *sfile;
for (int i = 0; filenames[i] != 0; i++) {
sfile = Swig_include_sys(filenames[i]);
@@ -1279,6 +1277,7 @@ public:
Delete(sfile);
}
}
+
return s;
}
@@ -1290,6 +1289,16 @@ public:
* helpers
* --------------------------------------------------------------------- */
+ void emitLuaFlavor(String *s) {
+ if (elua_ltr)
+ Printf(s, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUA\n");
+ else if (eluac_ltr)
+ Printf(s, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUAC\n");
+ else
+ Printf(s, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_LUA\n");
+ }
+
+
/* This is to convert the string of Lua code into a proper string, which can then be
emitted into the C/C++ code.
Basically is is a lot of search & replacing of odd sequences