[Lua] Added a patch by Torsten Landschoff to fix the unary minus issue

Ran 'astyle --style=kr -2' across lua.cxx to neaten it up

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10246 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Mark Gossage 2008-02-11 03:11:18 +00:00
commit 9441b672cd
3 changed files with 271 additions and 246 deletions

View file

@ -1,6 +1,10 @@
Version 1.3.34 (in progress) Version 1.3.34 (in progress)
============================ ============================
02/11/2008: mgossage
[Lua] Added a patch by Torsten Landschoff to fix the unary minus issue
Ran 'astyle --style=kr -2' across lua.cxx to neaten it up
02/10/2007: wsfulton 02/10/2007: wsfulton
Bump SWIG_RUNTIME_VERSION to 4. This is because of the recently introduced API Bump SWIG_RUNTIME_VERSION to 4. This is because of the recently introduced API
change in the conversion functions, ie change in definition of swig_converter_func. change in the conversion functions, ie change in definition of swig_converter_func.

View file

@ -53,8 +53,8 @@ assert(f/g==Op(1))
--and will complain if too many args are provided --and will complain if too many args are provided
--therefore disabling these tests for now --therefore disabling these tests for now
-- (solution will to be not to check args for this test case) -- (solution will to be not to check args for this test case)
--assert(-a==a) assert(-a==a)
--assert(-b==Op(-5)) assert(-b==Op(-5))
-- test [] -- test []
h=Op(3) h=Op(3)

View file

@ -339,8 +339,7 @@ NEW LANGUAGE NOTE:END ************************************************/
if (Getattr(n, "sym:overloaded")) { if (Getattr(n, "sym:overloaded")) {
overname = Getattr(n, "sym:overname"); overname = Getattr(n, "sym:overname");
} else { } else {
if (!addSymbol(iname, n)) if (!addSymbol(iname, n)) {
{
Printf(stderr,"addSymbol(%s) failed\n",iname); Printf(stderr,"addSymbol(%s) failed\n",iname);
return SWIG_ERROR; return SWIG_ERROR;
} }
@ -386,6 +385,16 @@ NEW LANGUAGE NOTE:END ************************************************/
int num_required = emit_num_required(l); int num_required = emit_num_required(l);
int varargs = emit_isvarargs(l); int varargs = emit_isvarargs(l);
// Check if we have to ignore arguments that are passed by LUA.
// Needed for unary minus, where lua passes two arguments and
// we have to ignore the second.
int args_to_ignore = 0;
if (Getattr(n, "lua:ignore_args")) {
args_to_ignore = GetInt(n, "lua:ignore_args");
}
/* Which input argument to start with? */ /* Which input argument to start with? */
// int start = (current == MEMBER_FUNC || current == MEMBER_VAR || current == DESTRUCTOR) ? 1 : 0; // int start = (current == MEMBER_FUNC || current == MEMBER_VAR || current == DESTRUCTOR) ? 1 : 0;
@ -411,8 +420,9 @@ NEW LANGUAGE NOTE:END ************************************************/
String *checkfn = NULL; String *checkfn = NULL;
// String *numoutputs=NULL; // String *numoutputs=NULL;
char source[64]; char source[64];
//Printf(argument_check, "//args must be %d..%d\n",num_required,num_arguments); //Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",name,num_required,num_arguments);
Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",name,num_required,num_arguments); Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",name,num_required+args_to_ignore,num_arguments+args_to_ignore);
for (i = 0, p = l; i < num_arguments; i++) { for (i = 0, p = l; i < num_arguments; i++) {
while (checkAttribute(p, "tmap:in:numinputs", "0")) { while (checkAttribute(p, "tmap:in:numinputs", "0")) {
@ -963,6 +973,15 @@ NEW LANGUAGE NOTE:END ************************************************/
String *iname = GetChar(n, "sym:name"); String *iname = GetChar(n, "sym:name");
//Printf(stdout,"memberfunctionHandler %s %s\n",name,iname); //Printf(stdout,"memberfunctionHandler %s %s\n",name,iname);
// Special case unary minus: LUA passes two parameters for the
// wrapper function while we want only one. Tell our
// functionWrapper to ignore a parameter.
if (Cmp(Getattr(n, "sym:name"), "__unm") == 0) {
//Printf(stdout, "unary minus: ignore one argument\n");
SetInt(n, "lua:ignore_args", 1);
}
String *realname, *rname; String *realname, *rname;
current = MEMBER_FUNC; current = MEMBER_FUNC;
@ -1081,7 +1100,9 @@ NEW LANGUAGE NOTE:END ************************************************/
*/ */
String *runtimeCode() { String *runtimeCode() {
String *s = NewString(""); String *s = NewString("");
const char *filenames[] = { "luarun.swg", 0 }; // must be 0 termiated const char *filenames[] = { "luarun.swg", 0
}
; // must be 0 termiated
String *sfile; String *sfile;
for (int i = 0; filenames[i] != 0; i++) { for (int i = 0; filenames[i] != 0; i++) {
sfile = Swig_include_sys(filenames[i]); sfile = Swig_include_sys(filenames[i]);