mirror of https://github.com/rusefi/lua.git
"call" returns separate results, instead of a table.
This commit is contained in:
parent
6d383202dc
commit
e5ec547eb3
17
inout.c
17
inout.c
|
@ -5,7 +5,7 @@
|
||||||
** Also provides some predefined lua functions.
|
** Also provides some predefined lua functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *rcs_inout="$Id: inout.c,v 2.40 1996/09/11 21:53:02 roberto Exp roberto $";
|
char *rcs_inout="$Id: inout.c,v 2.41 1996/09/24 17:30:28 roberto Exp roberto $";
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -281,15 +281,13 @@ void luaI_call (void)
|
||||||
temp = lua_getsubscript();
|
temp = lua_getsubscript();
|
||||||
narg = lua_isnumber(temp) ? lua_getnumber(temp) : MAXPARAMS+1;
|
narg = lua_isnumber(temp) ? lua_getnumber(temp) : MAXPARAMS+1;
|
||||||
/* read arg[1...n] */
|
/* read arg[1...n] */
|
||||||
for (i=0; i<narg; i++)
|
for (i=0; i<narg; i++) {
|
||||||
{
|
|
||||||
if (i>=MAXPARAMS)
|
if (i>=MAXPARAMS)
|
||||||
lua_error("argument list too long in function `call'");
|
lua_error("argument list too long in function `call'");
|
||||||
lua_pushobject(arg);
|
lua_pushobject(arg);
|
||||||
lua_pushnumber(i+1);
|
lua_pushnumber(i+1);
|
||||||
params[i] = lua_getsubscript();
|
params[i] = lua_getsubscript();
|
||||||
if (narg == MAXPARAMS+1 && lua_isnil(params[i]))
|
if (narg == MAXPARAMS+1 && lua_isnil(params[i])) {
|
||||||
{
|
|
||||||
narg = i;
|
narg = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -298,14 +296,7 @@ void luaI_call (void)
|
||||||
for (i=0; i<narg; i++)
|
for (i=0; i<narg; i++)
|
||||||
lua_pushobject(params[i]);
|
lua_pushobject(params[i]);
|
||||||
if (lua_callfunction(f))
|
if (lua_callfunction(f))
|
||||||
{ /* error */
|
|
||||||
lua_error(NULL);
|
lua_error(NULL);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{ /* push results */
|
passresults();
|
||||||
Object r;
|
|
||||||
arg = lua_getresult(1);
|
|
||||||
luaI_packarg((arg == LUA_NOOBJECT)?NULL:luaI_Address(arg), &r);
|
|
||||||
luaI_pushobject(&r);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
30
opcode.c
30
opcode.c
|
@ -3,7 +3,7 @@
|
||||||
** TecCGraf - PUC-Rio
|
** TecCGraf - PUC-Rio
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *rcs_opcode="$Id: opcode.c,v 3.74 1996/09/20 12:51:16 roberto Exp roberto $";
|
char *rcs_opcode="$Id: opcode.c,v 3.75 1996/09/24 17:30:28 roberto Exp roberto $";
|
||||||
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -897,41 +897,35 @@ static void comparison (lua_Type tag_less, lua_Type tag_equal,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void luaI_packarg (Object *firstelem, Object *arg)
|
static void adjust_varargs (StkId first_extra_arg)
|
||||||
{
|
{
|
||||||
int nvararg = (firstelem != NULL) ? top-firstelem : 0;
|
Object arg;
|
||||||
|
Object *firstelem = stack+first_extra_arg;
|
||||||
|
int nvararg = top-firstelem;
|
||||||
int i;
|
int i;
|
||||||
if (nvararg < 0) nvararg = 0;
|
if (nvararg < 0) nvararg = 0;
|
||||||
avalue(arg) = lua_createarray(nvararg+1); /* +1 for field 'n' */
|
avalue(&arg) = lua_createarray(nvararg+1); /* +1 for field 'n' */
|
||||||
tag(arg) = LUA_T_ARRAY;
|
tag(&arg) = LUA_T_ARRAY;
|
||||||
for (i=0; i<nvararg; i++)
|
for (i=0; i<nvararg; i++) {
|
||||||
{
|
|
||||||
Object index;
|
Object index;
|
||||||
tag(&index) = LUA_T_NUMBER;
|
tag(&index) = LUA_T_NUMBER;
|
||||||
nvalue(&index) = i+1;
|
nvalue(&index) = i+1;
|
||||||
*(lua_hashdefine(avalue(arg), &index)) = *(firstelem+i);
|
*(lua_hashdefine(avalue(&arg), &index)) = *(firstelem+i);
|
||||||
}
|
}
|
||||||
/* store counter in field "n" */
|
/* store counter in field "n" */ {
|
||||||
{
|
|
||||||
Object index, extra;
|
Object index, extra;
|
||||||
tag(&index) = LUA_T_STRING;
|
tag(&index) = LUA_T_STRING;
|
||||||
tsvalue(&index) = lua_createstring("n");
|
tsvalue(&index) = lua_createstring("n");
|
||||||
tag(&extra) = LUA_T_NUMBER;
|
tag(&extra) = LUA_T_NUMBER;
|
||||||
nvalue(&extra) = nvararg;
|
nvalue(&extra) = nvararg;
|
||||||
*(lua_hashdefine(avalue(arg), &index)) = extra;
|
*(lua_hashdefine(avalue(&arg), &index)) = extra;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void adjust_varargs (StkId first_extra_arg)
|
|
||||||
{
|
|
||||||
Object arg;
|
|
||||||
luaI_packarg(stack+first_extra_arg, &arg);
|
|
||||||
adjust_top(first_extra_arg);
|
adjust_top(first_extra_arg);
|
||||||
*top = arg; incr_top;
|
*top = arg; incr_top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Execute the given opcode, until a RET. Parameters are between
|
** Execute the given opcode, until a RET. Parameters are between
|
||||||
** [stack+base,top). Returns n such that the the results are between
|
** [stack+base,top). Returns n such that the the results are between
|
||||||
|
|
3
opcode.h
3
opcode.h
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
** TeCGraf - PUC-Rio
|
** TeCGraf - PUC-Rio
|
||||||
** $Id: opcode.h,v 3.20 1996/03/15 13:13:13 roberto Exp roberto $
|
** $Id: opcode.h,v 3.21 1996/05/28 21:07:32 roberto Exp roberto $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef opcode_h
|
#ifndef opcode_h
|
||||||
|
@ -122,6 +122,5 @@ Object *luaI_Address (lua_Object o);
|
||||||
void luaI_pushobject (Object *o);
|
void luaI_pushobject (Object *o);
|
||||||
void luaI_gcFB (Object *o);
|
void luaI_gcFB (Object *o);
|
||||||
int luaI_dorun (TFunc *tf);
|
int luaI_dorun (TFunc *tf);
|
||||||
void luaI_packarg (Object *firstelem, Object *arg);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue